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/image/image2d.hh>
00027 #include <mln/value/int_u8.hh>
00028
00029 #include <mln/win/rectangle2d.hh>
00030 #include <mln/core/alias/window2d.hh>
00031
00032 #include <mln/win/shift.hh>
00033 #include <mln/win/diff.hh>
00034
00035 #include <mln/io/pbm/load.hh>
00036 #include <mln/io/pbm/save.hh>
00037 #include <mln/data/fill.hh>
00038
00039 #include <mln/morpho/hit_or_miss.hh>
00040
00041 # include <mln/convert/to.hh>
00042
00043 #include "tests/data.hh"
00044
00045
00046 int main()
00047 {
00048 using namespace mln;
00049 using value::int_u8;
00050
00051 window2d win_hit = win::shift(win::rectangle2d(3, 3),
00052 dpoint2d(+1, +1));
00053 window2d win_miss = win::rectangle2d(5, 5) - win_hit;
00054
00055 {
00056 bool hit[] = { 0, 0, 0, 0, 0,
00057 0, 0, 0, 0, 0,
00058 0, 0, 1, 1, 1,
00059 0, 0, 1, 1, 1,
00060 0, 0, 1, 1, 1 };
00061 window2d win_hit_ = convert::to<window2d>(hit);
00062 mln_assertion(win_hit_ == win_hit);
00063
00064 bool miss[] = { 1, 1, 1, 1, 1,
00065 1, 1, 1, 1, 1,
00066 1, 1, 0, 0, 0,
00067 1, 1, 0, 0, 0,
00068 1, 1, 0, 0, 0 };
00069 window2d win_miss_ = convert::to<window2d>(miss);
00070 mln_assertion(win_miss_ == win_miss);
00071 }
00072
00073 border::thickness = 2;
00074
00075 image2d<bool> pic;
00076 io::pbm::load(pic, MLN_IMG_DIR "/picasso.pbm");
00077 image2d<bool> out = morpho::hit_or_miss(pic, win_hit, win_miss);
00078
00079
00080
00081
00082
00083 io::pbm::save(out, "out.pbm");
00084
00085 mln_postcondition(morpho::hit_or_miss(morpho::complementation(pic),
00086 win_miss, win_hit) == out);
00087
00088
00089 }