8 #include <oln/basics1d.hh>
9 #include <oln/basics2d.hh>
16 #include <oln/morpho/erosion.hh>
17 #include <oln/morpho/dilation.hh>
18 #include <oln/morpho/opening.hh>
19 #include <oln/morpho/closing.hh>
20 #include <oln/morpho/watershed.hh>
22 #include <oln/utils/stat.hh>
25 #include <oln/convert/basics.hh>
68 std::cout <<
"ntg_max_val(int_u8) = "
69 << ntg_max_val(int_u8) << std::endl;
75 std::cout <<
"a + b = " << a + b << std::endl;
83 std::cout << typename_of<int_u8>()
86 <<
" = " << typename_of_var(a + b) << std::endl;
108 std::cout <<
"c = " << c << std::endl;
125 image1d<int_u8> img1a;
126 image1d<int_u8> img1b(20);
140 std::cout <<
"img1b(10) ="
141 << img1b(10) << std::endl;
146 img1a = img1b.clone ();
148 std::cout <<
"img1b(10) ="
149 << img1b(10) << std::endl;
156 for (coord col = 0; col < img1a.ncols(); ++col)
157 img1a(col) = col % 5;
159 std::cout <<
"img1a:" << std::endl;
160 std::cout << img1a << std::endl;
165 image2d<bin> img2a(10, 10);
166 for (coord row = 0; row < img2a.nrows(); ++row)
167 for (coord col = 0; col < img2a.ncols(); ++col)
168 img2a(row, col) = (row >= 3 && col >= 3 && row < 7 && col < 7);
169 std::cout <<
"img2a:" << std::endl;
170 std::cout << img2a << std::endl;
194 std::cout <<
"img1b[p1]" << img1b[p1] << std::endl;
197 std::cout <<
"img2a:" << std::endl;
198 std::cout << img2a << std::endl;
218 std::cout <<
"p1 + dp1 = " << p1 + dp1 << std::endl;
220 img2a[p2 + dp2] =
false;
221 std::cout <<
"img2a:" << std::endl;
222 std::cout << img2a << std::endl;
241 std::cout <<
"win_c4p() = " <<
win_c4p() << std::endl;
243 std::cout <<
"win_c4_only() = " << win_c4_only() << std::endl;
249 for (
unsigned i = 0; i < w2.card(); ++i)
250 std::cout <<
"img2a[p2 + w2[" << i <<
"]] = "
251 <<
"img2a[" << p2 + w2.dp(i) <<
"] = "
252 << img2a[p2 + w2.dp(i)] << std::endl;
261 w1.add(-1).add(0).add(1);
262 std::cout <<
"w1 = " << w1 << std::endl;
274 std::cout <<
"n1 = " << n1 << std::endl;
284 std::cout <<
"erosion" << std::endl;
285 std::cout << morpho::erosion(img1a, w1) << std::endl;
287 std::cout <<
"dilation" << std::endl;
288 std::cout << morpho::dilation(img1a, w1) << std::endl;
290 std::cout <<
"opening" << std::endl;
291 std::cout << morpho::opening(img1a, w1) << std::endl;
293 std::cout <<
"closing" << std::endl;
294 std::cout << morpho::closing(img1a, w1) << std::endl;
303 std::cout << morpho::closing(img2a,
win_c4p()) << std::endl;
322 std::cout <<
"watershed" << std::endl;
323 std::cout << morpho::watershed_seg<int_u8>(img1a, n1) << std::endl;
332 image2d<int_u8> lena =
load(IMGDIR
"/lena.pgm");
333 if (!lena.has_impl())
335 std::cerr <<
"Could not load " << IMGDIR
"/lena.pgm" << std::endl;
338 std::cout <<
"watershedling lena..." << std::endl;
339 save(morpho::watershed_seg<int_u8>(lena, neighb_c4()),
"output.pgm");
355 utils::f_moments<int_u8> f;
357 std::cout <<
"f.mean() = " << f.mean() << std::endl;
358 std::cout <<
"f.variance() = " << f.variance() << std::endl;
386 std::cout << apply(convert::bound<int_u<2> >(), img1a) << std::endl;