00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <mln/core/image/image2d.hh>
00028 #include <mln/value/int_u8.hh>
00029 #include <mln/io/pgm/load.hh>
00030 #include <mln/core/alias/neighb2d.hh>
00031 #include <mln/labeling/flat_zones.hh>
00032
00033 #include <mln/labeling/blobs.hh>
00034 #include <mln/pw/all.hh>
00035 #include <mln/data/compare.hh>
00036
00037 #include "tests/data.hh"
00038
00039
00040 int main()
00041 {
00042 using namespace mln;
00043 using value::int_u8;
00044
00045 image2d<int_u8> lena = io::pgm::load<int_u8>(MLN_IMG_DIR "/tiny.pgm");
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 unsigned n;
00063 image2d<unsigned> labels = labeling::flat_zones(lena, c4(), n);
00064 mln_assertion(n == 247);
00065
00066 {
00067 typedef image2d<int_u8> I;
00068 labeling::impl::flat_zones_functor<I> f(lena);
00069
00070 unsigned nlabels_generic, nlabels_fastest;
00071 mln_assertion(canvas::labeling::impl::generic::labeling(lena,
00072 c4(),
00073 nlabels_generic,
00074 lena.domain(),
00075 f)
00076 ==
00077 canvas::labeling::impl::video_fastest(lena,
00078 c4(),
00079 nlabels_fastest,
00080 f));
00081 mln_assertion(nlabels_generic == nlabels_fastest);
00082 }
00083
00084 {
00085 unsigned n_ = 0;
00086 for (unsigned i = 0; i <= 255; ++i)
00087 {
00088 unsigned n_i;
00089 labeling::blobs((pw::value(lena) == pw::cst(i)) | lena.domain(),
00090 c4(), n_i);
00091 n_ += n_i;
00092 }
00093 mln_assertion(n_ == n);
00094 }
00095
00096 }