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