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 #include <mln/io/pgm/load.hh>
00029 #include <mln/io/pbm/load.hh>
00030
00031 #include <mln/win/all.hh>
00032 #include <mln/morpho/erosion.hh>
00033 #include <mln/morpho/dilation.hh>
00034
00035 #include "tests/data.hh"
00036
00037
00038 int main()
00039 {
00040 using namespace mln;
00041 using value::int_u8;
00042
00043
00044
00045 win::rectangle2d rec(5, 5);
00046 win::hline2d hline(7);
00047 win::vline2d vline(7);
00048 win::diag2d diag2d(7);
00049 win::backdiag2d backdiag2d(7);
00050 win::octagon2d oct(2 * 3 + 1);
00051
00052 morpho::erosion_op ero;
00053 morpho::dilation_op dil;
00054
00055 {
00056 image2d<int_u8> lena, out, ref;
00057 io::pgm::load(lena, MLN_IMG_DIR "/small.pgm");
00058
00059
00060
00061
00062 ref = morpho::impl::generic::general_on_function(ero, lena, rec);
00063
00064 out = morpho::impl::general_rectangle2d(ero, lena, rec);
00065 mln_assertion(out == ref);
00066
00067 out = morpho::impl::general_arbitrary_2d(ero, lena, rec);
00068 mln_assertion(out == ref);
00069
00070 out = morpho::impl::general_directional(ero, lena, rec, 0);
00071 mln_assertion(out == ref);
00072
00073 out = morpho::impl::general_directional(ero, lena, rec, 1);
00074 mln_assertion(out == ref);
00075
00076
00077
00078
00079 ref = morpho::impl::generic::general_on_function(dil, lena, rec);
00080
00081 out = morpho::impl::general_rectangle2d(dil, lena, rec);
00082 mln_assertion(out == ref);
00083
00084 out = morpho::impl::general_arbitrary_2d(dil, lena, rec);
00085 mln_assertion(out == ref);
00086
00087 out = morpho::impl::general_directional(dil, lena, rec, 0);
00088 mln_assertion(out == ref);
00089
00090 out = morpho::impl::general_directional(dil, lena, rec, 1);
00091 mln_assertion(out == ref);
00092
00093
00094
00095 ref = morpho::impl::generic::general_on_function(ero, lena, hline);
00096
00097 out = morpho::impl::general_directional(ero, lena, hline, 1);
00098 mln_assertion(out == ref);
00099
00100 out = morpho::impl::general_line(ero, lena, hline);
00101 mln_assertion(out == ref);
00102
00103
00104
00105 ref = morpho::impl::generic::general_on_function(ero, lena, vline);
00106
00107 out = morpho::impl::general_directional(ero, lena, vline, 0);
00108 mln_assertion(out == ref);
00109
00110 out = morpho::impl::general_line(ero, lena, vline);
00111 mln_assertion(out == ref);
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 }
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 {
00148 image2d<bool> pic, out, ref;
00149 io::pbm::load(pic, MLN_IMG_DIR "/small.pbm");
00150
00151
00152
00153 ref = morpho::impl::generic::general_on_set(ero, pic, rec);
00154
00155 out = morpho::impl::general_on_set_centered(ero, pic, rec);
00156 mln_assertion(out == ref);
00157
00158 out = morpho::impl::general_on_set_centered_fastest(ero, pic, rec);
00159 mln_assertion(out == ref);
00160
00161 out = morpho::impl::general_rectangle2d(ero, pic, rec);
00162 mln_assertion(out == ref);
00163
00164 out = morpho::impl::general_arbitrary_2d(ero, pic, rec);
00165 mln_assertion(out == ref);
00166
00167 out = morpho::impl::general_directional(ero, pic, rec, 0);
00168 mln_assertion(out == ref);
00169
00170 out = morpho::impl::general_directional(ero, pic, rec, 1);
00171 mln_assertion(out == ref);
00172
00173
00174
00175
00176 ref = morpho::impl::generic::general_on_set(dil, pic, rec);
00177
00178 out = morpho::impl::general_on_set_centered(dil, pic, rec);
00179 mln_assertion(out == ref);
00180
00181 out = morpho::impl::general_on_set_centered_fastest(dil, pic, rec);
00182 mln_assertion(out == ref);
00183
00184 out = morpho::impl::general_rectangle2d(dil, pic, rec);
00185 mln_assertion(out == ref);
00186
00187 out = morpho::impl::general_arbitrary_2d(dil, pic, rec);
00188 mln_assertion(out == ref);
00189
00190 out = morpho::impl::general_directional(dil, pic, rec, 0);
00191 mln_assertion(out == ref);
00192
00193 out = morpho::impl::general_directional(dil, pic, rec, 1);
00194 mln_assertion(out == ref);
00195 }
00196
00197 }