• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

labeling-compute.cc

00001 #include <mln/core/image/image2d.hh>
00002 #include <mln/core/alias/neighb2d.hh>
00003 
00004 #include <mln/make/image.hh>
00005 
00006 #include <mln/labeling/blobs.hh>
00007 #include <mln/labeling/colorize.hh>
00008 #include <mln/labeling/compute.hh>
00009 
00010 #include <mln/util/array.hh>
00011 
00012 #include <mln/accu/shape/bbox.hh>
00013 
00014 #include <mln/value/label_8.hh>
00015 
00016 #include <doc/tools/sample_utils.hh>
00017 
00018 int main()
00019 {
00020   using namespace mln;
00021   using value::rgb8;
00022   using value::label_8;
00023 
00024 
00025   // \{
00026   bool vals[6][5] = {
00027       {0, 1, 1, 0, 0},
00028       {0, 1, 1, 0, 0},
00029       {0, 0, 0, 0, 0},
00030       {1, 1, 0, 1, 0},
00031       {1, 0, 1, 1, 1},
00032       {1, 0, 0, 0, 0}
00033   };
00034   image2d<bool> ima = make::image(vals);
00035   // \}
00036   doc::pbmsave(ima, "labeling-compute");
00037 
00038   // \{
00039   label_8 nlabels;
00040   image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels);
00041   // \}
00042   doc::ppmsave(labeling::colorize(rgb8(), lbl, nlabels), "labeling-compute");
00043 
00044 
00045   // \{
00046   util::array<box2d> boxes =
00047       labeling::compute(accu::meta::shape::bbox(),
00048                         lbl,
00049                         nlabels);
00050   // \}
00051 
00052 
00053   // \{
00054   for (unsigned i = 1; i <= nlabels; ++i)
00055     std::cout << boxes[i] << std::endl;
00056   // \}
00057 }

Generated on Tue Oct 4 2011 15:24:01 for Milena (Olena) by  doxygen 1.7.1