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/image1d.hh>
00027 #include <mln/core/image/image2d.hh>
00028 #include <mln/core/image/image3d.hh>
00029 #include <mln/pw/image.hh>
00030 #include <mln/core/image/flat_image.hh>
00031 #include <mln/core/image/vmorph/cast_image.hh>
00032 #include <mln/core/image/dmorph/image_if.hh>
00033 #include <mln/core/image/dmorph/sub_image.hh>
00034 #include <mln/core/image/dmorph/extension_val.hh>
00035
00036 #include <mln/data/fill.hh>
00037 #include <mln/data/paste.hh>
00038 #include <mln/data/compare.hh>
00039
00040 #include <mln/fun/p2b/chess.hh>
00041 #include <mln/fun/p2v/iota.hh>
00042
00043 #include <mln/debug/iota.hh>
00044 #include <mln/debug/println.hh>
00045 #include <mln/trace/all.hh>
00046
00047
00048 int main()
00049 {
00050 using namespace mln;
00051 const unsigned size = 50;
00052
00053
00054 {
00055 box2d b(point2d(1,2), point2d(2,4));
00056 image2d<int> ima(b, 2);
00057 debug::iota(ima);
00058
00059 box2d b2(point2d(-1,-2), point2d(3,6));
00060 image2d<int> ima2(b2, 0);
00061 debug::iota(ima2);
00062
00063 image2d<int> ima3(b, 2);
00064
00065 data::paste(ima, ima2);
00066 mln_assertion(ima == (ima2 | b));
00067
00068 data::paste(ima, ima3);
00069 mln_assertion(ima == ima3);
00070 }
00071
00072
00073 {
00074 box3d b(point3d(1,2, 1), point3d(2,4, 3));
00075 image3d<int> ima(b, 2);
00076 debug::iota(ima);
00077
00078 box3d b2(point3d(-1,-2, -1), point3d(3,6, 3));
00079 image3d<int> ima2(b2, 2);
00080 debug::iota(ima2);
00081
00082 image3d<int> ima3(b, 2);
00083
00084 data::paste(ima, ima2);
00085 mln_assertion(ima == (ima2 | b));
00086
00087 data::paste(ima, ima3);
00088 mln_assertion(ima == ima3);
00089 }
00090
00092 {
00093 image1d<unsigned short> ima(size);
00094 image1d<unsigned short> out(size);
00095
00096 debug::iota(ima);
00097 data::paste(ima, out);
00098
00099 mln_assertion(ima == out);
00100 }
00101
00102
00104 {
00105 fun::p2v::iota f;
00106 const pw::image<fun::p2v::iota, box2d> ima(f, make::box2d(2,2, 5,5));
00107 image2d<short unsigned int> out(8, 8);
00108
00109 data::fill(out, (short unsigned int)0);
00110 data::paste(ima, out);
00111 }
00112
00113
00114 {
00115 flat_image<short, box2d> ima(5, make::box2d(size, size));
00116 image2d<unsigned short> out(size, size);
00117
00118 data::fill_with_value(ima, 51);
00119 data::paste(ima, out);
00120
00121 mln_assertion(ima == out);
00122 }
00123
00124
00125 {
00126 typedef image2d<unsigned short> I;
00127 typedef fun::p2b::chess F;
00128 F f;
00129 typedef image_if<I, F> II;
00130
00131 I ima(size, size);
00132 I out(size, size);
00133 II ima_if = ima | f;
00134
00135 data::fill_with_value(ima, 0);
00136 debug::iota(ima);
00137 data::paste(ima_if, out);
00138
00139 mln_assertion(ima_if == (out | f));
00140 }
00141
00142
00143 {
00144 typedef image2d<unsigned short> I;
00145 typedef cast_image_<int, I> II;
00146 typedef image2d<unsigned short> III;
00147
00148 I in(size, size);
00149 II cast(in);
00150 III out(size, size);
00151
00152 data::fill(in, (unsigned short)51);
00153 data::fill(out, (unsigned short)42);
00154
00155 data::paste(cast, out);
00156
00157 mln_assertion(cast == out);
00158 }
00159
00160
00161 {
00162 typedef image2d<int> I;
00163 typedef sub_image< image2d<int>, box2d > II;
00164 typedef image2d<unsigned short> III;
00165
00166 I ima(size, size);
00167 II sub_ima(ima, make::box2d(4,4, 10,10));
00168 III out(size, size);
00169
00170 data::fill(ima, 51);
00171 data::paste(sub_ima, out);
00172
00173 II::piter p(sub_ima.domain());
00174 for_all(p)
00175 mln_assertion(sub_ima(p) == out(p));
00176 }
00177
00178
00179 {
00180 typedef image2d<int> I;
00181 typedef extension_val< image2d<int> > II;
00182 typedef image2d<unsigned short> III;
00183
00184 I ima(size, size);
00185 II extend_ima(ima, 5);
00186 III out(size, size);
00187
00188 data::fill(ima, 51);
00189 data::paste(extend_ima, out);
00190
00191 II::piter p(extend_ima.domain());
00192 for_all(p)
00193 mln_assertion(extend_ima(p) == out(p));
00194 }
00195 }