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
00030 #include <mln/value/int_u8.hh>
00031 #include <mln/value/int_s8.hh>
00032 #include <mln/value/int_u16.hh>
00033 #include <mln/value/int_s16.hh>
00034
00035 #include <mln/debug/iota.hh>
00036 #include <mln/data/saturate.hh>
00037 #include <mln/data/stretch.hh>
00038
00039
00040
00041 namespace mln
00042 {
00043 template <typename I, typename J>
00044 void
00045 chck(Image<I>& input_, Image<J>& output_)
00046 {
00047 I& input = exact(input_);
00048 J& output = exact(output_);
00049 output = data::stretch(mln_value(J)(), input);
00050 }
00051
00052 template <typename I, typename J>
00053 void
00054 chk1d(unsigned cols)
00055 {
00056 {
00057 image1d<I> input(cols);
00058 debug::iota(input);
00059 image1d<J> output(cols);
00060 chck(input, output);
00061 }
00062
00063 }
00064
00065 template <typename I, typename J>
00066 void
00067 chk2d(unsigned rows, unsigned cols)
00068 {
00069
00070 {
00071 image2d<I> input(rows, cols);
00072 debug::iota(input);
00073 image2d<J> output(rows, cols);
00074 chck(input, output);
00075 }
00076
00077 }
00078
00079 template <typename I, typename J>
00080 void
00081 chk3d(unsigned slis, unsigned rows, unsigned cols)
00082 {
00083
00084 {
00085 image3d<I> input(slis, rows, cols);
00086 debug::iota(input);
00087 image3d<J> output(slis, rows, cols);
00088 chck(input, output);
00089 }
00090
00091 }
00092
00093
00094 template <typename I, typename J>
00095 void
00096 chk(unsigned slis, unsigned rows, unsigned cols)
00097 {
00098 (std::cerr << " in 1d ... ").flush ();
00099 {
00100 for (unsigned i = 2; i < cols; ++i)
00101 chk1d<I, J>(i);
00102 }
00103 std::cerr << "OK" << std::endl;
00104
00105 (std::cerr << " in 2d ... ").flush ();
00106 {
00107 for (unsigned j = 2; j < rows; ++j)
00108 for (unsigned i = 2; i < cols; ++i)
00109 chk2d<I, J>(j, i);
00110 }
00111 std::cerr << "OK" << std::endl;
00112
00113 (std::cerr << " in 3d ... ").flush ();
00114 {
00115 for (unsigned k = 2; k < slis; ++k)
00116 for (unsigned j = 2; j < rows; ++j)
00117 for (unsigned i = 2; i < cols; ++i)
00118 chk3d<I, J>(k, j, i);
00119 }
00120 std::cerr << "OK" << std::endl;
00121 }
00122
00123 template <typename I>
00124 void
00125 ch(unsigned slis, unsigned rows, unsigned cols)
00126 {
00127 std::cerr << " into int_u8:" << std::endl;
00128 chk<I, value::int_u8>(slis, rows, cols);
00129 std::cerr << " into int_u16:" << std::endl;
00130 chk<I, value::int_u16>(slis, rows, cols);
00131 }
00132 }
00133
00134
00135 int main()
00136 {
00137 using namespace mln;
00138
00139 unsigned slis = 4;
00140 unsigned rows = 4;
00141 unsigned cols = 16;
00142
00143 std::cerr << "Tests data::stretch:" << std::endl;
00144 std::cerr << "on int:" << std::endl;
00145 ch<int>(slis, rows, cols);
00146 std::cerr << "on unsigned:" << std::endl;
00147 ch<unsigned>(slis, rows, cols);
00148 std::cerr << "on int_u8:" << std::endl;
00149 ch<value::int_u8>(slis, rows, cols);
00150 std::cerr << "on int_u16:" << std::endl;
00151 ch<value::int_u16>(slis, rows, cols);
00152 std::cerr << "on int_s8:" << std::endl;
00153 ch<value::int_s8>(slis, rows, cols);
00154 std::cerr << "on int_s16:" << std::endl;
00155 ch<value::int_s16>(slis, rows, cols);
00156 }