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/core/image/flat_image.hh>
00030 #include <mln/core/image/dmorph/image_if.hh>
00031 #include <mln/core/image/dmorph/sub_image.hh>
00032 #include <mln/core/image/dmorph/extension_val.hh>
00033 #include <mln/core/routine/duplicate.hh>
00034
00035 #include <mln/fun/v2v/inc.hh>
00036 #include <mln/fun/v2v/dec.hh>
00037 #include <mln/fun/p2b/chess.hh>
00038
00039 #include <mln/debug/iota.hh>
00040
00041 #include <mln/data/transform_inplace.hh>
00042 #include <mln/data/compare.hh>
00043
00044
00045
00046 int main()
00047 {
00048 using namespace mln;
00049 const unsigned size = 50;
00050
00051
00052
00053 {
00054 typedef int T;
00055 image2d<T> ref(size, size);
00056 debug::iota(ref);
00057
00058 image2d<T> ima = duplicate(ref);
00059 data::transform_inplace(ima, fun::v2v::inc<T>());
00060 data::transform_inplace(ima, fun::v2v::dec<T>());
00061
00062 mln_assertion(ima == ref);
00063 }
00064
00066 {
00067 typedef unsigned short T;
00068 image1d<T> ref(size);
00069 debug::iota(ref);
00070
00071 image1d<T> ima = duplicate(ref);
00072 data::transform_inplace(ima, fun::v2v::inc<T>());
00073 data::transform_inplace(ima, fun::v2v::dec<T>());
00074
00075 mln_assertion(ima == ref);
00076 }
00077
00078
00080 {
00081 typedef unsigned short T;
00082 image3d<T> ref(size, size, size);
00083 debug::iota(ref);
00084
00085 image3d<T> ima = duplicate(ref);
00086 data::transform_inplace(ima, fun::v2v::inc<T>());
00087 data::transform_inplace(ima, fun::v2v::dec<T>());
00088
00089 mln_assertion(ima == ref);
00090 }
00091
00092
00093 {
00094 typedef short T;
00095 flat_image<T, box2d>
00096 ref(5, make::box2d(size, size)),
00097 ima(5, make::box2d(size, size));
00098
00099 data::transform_inplace(ima, fun::v2v::inc<T>());
00100 data::transform_inplace(ima, fun::v2v::dec<T>());
00101
00102 mln_assertion(ima == ref);
00103 }
00104
00105
00106 {
00107 typedef unsigned short T;
00108 typedef image2d<T> I;
00109 typedef image_if<I, fun::p2b::chess> II;
00110
00111 I ref(size, size);
00112 debug::iota(ref);
00113 II ref_if = ref | fun::p2b::chess();
00114
00115 I ima = duplicate(ref);
00116 II ima_if = ima | fun::p2b::chess();
00117
00118 data::transform_inplace(ima_if, fun::v2v::inc<T>());
00119 data::transform_inplace(ima_if, fun::v2v::dec<T>());
00120
00121 mln_assertion(ima_if == ref_if);
00122 }
00123
00124
00125 {
00126 typedef image2d<int> I;
00127 typedef sub_image< image2d<int>, box2d > II;
00128 typedef image2d<unsigned short> III;
00129
00130 I ref(size, size);
00131 debug::iota(ref);
00132 II sub_ref(ref, make::box2d(4,4, 10,10));
00133
00134 I ima = duplicate(ref);
00135 II sub_ima(ima, make::box2d(4,4, 10,10));
00136
00137 data::transform_inplace(sub_ima, fun::v2v::inc<int>());
00138 data::transform_inplace(sub_ima, fun::v2v::dec<int>());
00139
00140 mln_assertion(sub_ima == sub_ref);
00141 }
00142
00143
00144 {
00145 typedef int T;
00146 typedef image2d<T> I;
00147 typedef extension_val< image2d<T> > II;
00148
00149 I ref(size, size);
00150
00151 I ima = duplicate(ref);
00152 II extend_ima(ima, 5);
00153
00154 data::transform_inplace(extend_ima, fun::v2v::inc<T>());
00155 data::transform_inplace(extend_ima, fun::v2v::dec<T>());
00156
00157 mln_assertion(extend_ima == ref);
00158
00159 }
00160 }