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 <mln/core/alias/dpoint2d.hh>
00027 #include <mln/core/image/image2d.hh>
00028 #include <mln/core/image/dmorph/sub_image.hh>
00029 #include <mln/core/alias/window2d.hh>
00030 #include <mln/core/alias/box2d.hh>
00031 #include <mln/core/alias/neighb2d.hh>
00032
00033
00034 #include <mln/data/fill.hh>
00035
00036 #include <mln/convert/to_window.hh>
00037 #include <mln/convert/to_p_set.hh>
00038
00039 #include <mln/util/ord.hh>
00040
00041 using namespace mln;
00042
00043 void test(window2d ref, window2d cmp)
00044 {
00045 mln_assertion(ref.size() == cmp.size());
00046 for (unsigned i = 0; i < ref.size(); ++i)
00047 mln_assertion(ref.dp(i) == cmp.dp(i));
00048 }
00049
00050 int main()
00051 {
00052 dpoint2d
00053 a(1, 0),
00054 b(0, 1),
00055 c(-1,0),
00056 d(0,-1);
00057
00058 window2d ref;
00059 ref.insert(a);
00060 ref.insert(b);
00061 ref.insert(c);
00062 ref.insert(d);
00063
00064
00065
00066 neighb2d nbh = c4();
00067 window2d test_nbh = convert::to_window(nbh);
00068 test(ref, test_nbh);
00069
00070
00071 image2d<bool> ima(make::box2d(-6, -6, 6, 6));
00072 data::fill(ima, false);
00073 data::fill((ima | convert::to_p_set(ref)).rw(), true);
00074 window2d test_ima = convert::to_window(ima);
00075 test(ref, test_ima);
00076
00077
00078 p_set<point2d> setp;
00079 setp.insert(point2d::origin + a);
00080 setp.insert(point2d::origin + b);
00081 setp.insert(point2d::origin + c);
00082 setp.insert(point2d::origin + d);
00083 window2d test_setp = convert::to_window(setp);
00084 test(ref, test_setp);
00085
00086
00087 std::set<dpoint2d, util::ord<dpoint2d> > set;
00088 set.insert(a);
00089 set.insert(b);
00090 set.insert(c);
00091 set.insert(d);
00092 window2d test_set = convert::to_window(set);
00093 test(ref, test_set);
00094
00095
00096 }