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/dmorph/sub_image.hh>
00028 #include <mln/core/image/vmorph/cast_image.hh>
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <mln/data/fill.hh>
00038 #include <mln/data/paste.hh>
00039 #include <mln/data/compare.hh>
00040
00041 #include <mln/opt/at.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
00054 {
00055 image1d<short> ima(size);
00056 debug::iota(ima);
00057 const image1d<short> cima = ima;
00058
00059 point1d p(5);
00060 mln_assertion(cima(p) == opt::at(cima, 5));
00061
00062 opt::at(ima, 5) = 12;
00063 mln_assertion(cima(p) == 12);
00064 }
00065 {
00066 typedef image1d<short> I;
00067 typedef sub_image< image1d<short>, box1d > II;
00068
00069 I ima(size);
00070 II sub_ima(ima, make::box1d(4, 10));
00071 const II csub_ima(ima, make::box1d(4, 10));
00072 point1d p(5);
00073
00074 data::fill(ima, short(51));
00075 mln_assertion(csub_ima(p) == opt::at(csub_ima, 5));
00076 opt::at(sub_ima, 5) = 12;
00077 mln_assertion(sub_ima(p) == 12);
00078 }
00079 {
00080 typedef image1d<unsigned short> I;
00081 typedef cast_image_<int, I> II;
00082
00083 I in(size, size);
00084 II cast(in);
00085 const II ccast(in);
00086 point1d p(5);
00087
00088 data::fill(in, (unsigned short)51);
00089 mln_assertion(ccast(p) == opt::at(ccast, 5));
00090
00091
00092
00093 }
00094
00096 {
00097 image2d<short> ima(size, size);
00098 debug::iota(ima);
00099 const image2d<short> cima = ima;
00100
00101 point2d p(5, 5);
00102 mln_assertion(cima(p) == opt::at(cima, 5, 5));
00103
00104 opt::at(ima, 5, 5) = 12;
00105 mln_assertion(cima(p) == 12);
00106 }
00107 {
00108 typedef image2d<short> I;
00109 typedef sub_image< image2d<short>, box2d > II;
00110
00111 I ima(size, size);
00112 II sub_ima(ima, make::box2d(4,4, 10, 10));
00113 const II csub_ima(ima, make::box2d(4, 4, 10, 10));
00114 point2d p(5, 5);
00115
00116 data::fill(ima, short(51));
00117 mln_assertion(csub_ima(p) == opt::at(csub_ima, 5, 5));
00118 opt::at(sub_ima, 5, 5) = 12;
00119 mln_assertion(sub_ima(p) == 12);
00120 }
00121 {
00122 typedef image2d<unsigned short> I;
00123 typedef cast_image_<int, I> II;
00124
00125 I in(size, size);
00126 II cast(in);
00127 const II ccast(in);
00128 point2d p(5,5);
00129
00130 data::fill(in, (unsigned short)51);
00131 mln_assertion(ccast(p) == opt::at(ccast, 5, 5));
00132
00133
00134
00135 }
00136
00137
00139 {
00140 image3d<short> ima(size, size, size);
00141 debug::iota(ima);
00142 const image3d<short> cima = ima;
00143
00144 point3d p(5, 5, 5);
00145 mln_assertion(cima(p) == opt::at(cima, 5, 5, 5));
00146
00147 opt::at(ima, 5, 5, 5) = 12;
00148 mln_assertion(cima(p) == 12);
00149 }
00150 }