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 #include <iostream>
00027
00028 #include <mln/core/image/image2d.hh>
00029
00030 #include <mln/make/image2d.hh>
00031
00032 #include <mln/value/label_8.hh>
00033 #include <mln/value/int_u8.hh>
00034
00035 #include <mln/morpho/watershed/superpose.hh>
00036 #include <mln/data/compare.hh>
00037
00038 #include "tests/data.hh"
00039
00040 #include <mln/debug/println.hh>
00041 #include <mln/debug/iota.hh>
00042
00043 namespace mln
00044 {
00045
00046 struct ref_data : Function_v2v<ref_data>
00047 {
00048 typedef value::rgb8 result;
00049
00050 value::rgb8 operator()(const point2d& p) const
00051 {
00052 if (p.row() == 2 || p.col() == 2)
00053 return literal::red;
00054 unsigned val = p.col() + 1 + p.row() * 4;
00055 return value::rgb8(val, val, val);
00056 }
00057
00058 };
00059
00060 }
00061
00062 int main()
00063 {
00064 using namespace mln;
00065
00066 image2d<value::int_u8> ima(4,4);
00067 debug::iota(ima);
00068
00069 value::label_8 data_ws[16] = { 1, 1, 0, 2,
00070 1, 1, 0, 2,
00071 0, 0, 0, 0,
00072 5, 5, 0, 4 };
00073
00074 image2d<value::label_8> ima_ws = make::image2d(data_ws);
00075
00076 image2d<value::rgb8> sup = morpho::watershed::superpose(ima, ima_ws);
00077 mln_assertion(sup == (ref_data() | sup.domain()));
00078 }