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

at.cc

00001 // Copyright (C) 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/dmorph/sub_image.hh>
00028 #include <mln/core/image/vmorph/cast_image.hh>
00029 
00030 /*#include <mln/core/image/image2d.hh>
00031 #include <mln/core/image/image3d.hh>
00032 #include <mln/pw/image.hh>
00033 #include <mln/core/image/flat_image.hh>
00034 #include <mln/core/image/dmorph/image_if.hh>
00035 #include <mln/core/image/dmorph/extension_val.hh>*/
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     // FIXME
00091     //opt::at(cast, 5) = 12;
00092     //mln_assertion(cast(p) == 12);
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     // FIXME
00133     //opt::at(cast, 5) = 12;
00134     //mln_assertion(cast(p) == 12);
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 }

Generated on Tue Oct 4 2011 15:23:25 for Milena (Olena) by  doxygen 1.7.1