• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

stretch_full.cc

00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
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 }

Generated on Fri Sep 16 2011 16:34:03 for Milena (Olena) by  doxygen 1.7.1