Milena (Olena)
User documentation 2.0a Id
|
00001 #include <mln/core/image/image2d.hh> 00002 #include <mln/core/image/dmorph/image_if.hh> 00003 #include <mln/core/var.hh> 00004 #include <mln/core/alias/neighb2d.hh> 00005 00006 #include <mln/make/image.hh> 00007 00008 #include <mln/value/rgb8.hh> 00009 #include <mln/value/label_8.hh> 00010 #include <mln/literal/colors.hh> 00011 00012 #include <mln/pw/all.hh> 00013 00014 #include <mln/labeling/blobs.hh> 00015 #include <mln/labeling/colorize.hh> 00016 00017 #include <mln/data/fill.hh> 00018 00019 #include <doc/tools/sample_utils.hh> 00020 00021 int main() 00022 { 00023 using namespace mln; 00024 using value::rgb8; 00025 using value::label_8; 00026 00027 00028 // \{ 00029 bool vals[6][5] = { 00030 {0, 1, 1, 0, 0}, 00031 {0, 1, 1, 0, 0}, 00032 {0, 0, 0, 0, 0}, 00033 {1, 1, 0, 1, 0}, 00034 {1, 0, 1, 1, 1}, 00035 {1, 0, 0, 0, 0} 00036 }; 00037 image2d<bool> ima = make::image(vals); 00038 // \} 00039 00040 doc::pbmsave(ima, "fill-subdomain"); 00041 00042 // Find and label the different components. 00043 // \{ 00044 label_8 nlabels; 00045 image2d<label_8> lbl = labeling::blobs(ima, c4(), nlabels); 00046 // \} 00047 00048 doc::ppmsave(labeling::colorize(rgb8(), lbl, nlabels), "fill-subdomain"); 00049 00050 // Create a new image from lbl's sites being part of component 2. 00051 // \{ 00052 mln_VAR(lbl_2, lbl | (pw::value(lbl) == pw::cst(2u))); 00053 // \} 00054 00055 image2d<label_8> tmp; 00056 initialize(tmp, lbl); 00057 data::fill(tmp, 0); 00058 data::fill((tmp | lbl_2.domain()).rw(), 1); 00059 doc::ppmsave(labeling::colorize(rgb8(), tmp, 1), "fill-subdomain"); 00060 00061 // Create a black image from ima. 00062 // Fill sites being part of component 2 with red. 00063 // \{ 00064 image2d<rgb8> ima2; 00065 initialize(ima2, ima); 00066 data::fill(ima2, literal::black); 00067 00068 data::fill((ima2 | lbl_2.domain()).rw(), literal::red); 00069 // \} 00070 00071 doc::ppmsave(ima2, "fill-subdomain"); 00072 }