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

plain.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/image2d.hh>
00027 #include <mln/core/image/imorph/plain.hh>
00028 
00029 #include <mln/value/int_u8.hh>
00030 #include <mln/data/compare.hh>
00031 #include <mln/data/fill.hh>
00032 
00033 
00034 #include <mln/debug/println.hh>
00035 
00036 #include <mln/io/pgm/load.hh>
00037 #include <mln/io/pgm/save.hh>
00038 
00039 #include "tests/data.hh"
00040 
00041 
00042 int main()
00043 {
00044   using namespace mln;
00045   using value::int_u8;
00046 
00047   {
00048     plain< image2d<int_u8> > lena
00049       = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm");
00050 
00051     image2d<int_u8> ima;
00052     image2d<int_u8> ima2;
00053 
00054     ima = lena;
00055 
00056     ima(point2d(0,0)) = 124;
00057 
00058     mln_assertion(exact(ima).is_valid());
00059     mln_assertion(exact(lena).is_valid());
00060     mln_assertion(ima != lena);
00061 
00062     ima2 = lena;
00063     ima = lena;
00064 
00065     mln_assertion(ima == ima2);
00066 
00067     ima(point2d(0,0)) = 124;
00068     mln_assertion(ima != ima2);
00069 
00070     ima = ima2;
00071 
00072     ima(point2d(0,0)) = 124;
00073     mln_assertion(ima == ima2);
00074 
00075   }
00076 
00077   {
00078     image2d<int_u8> lena(12,12);
00079     data::fill(lena, 42);
00080 
00081     point2d p1(0,0);
00082     point2d p2(5,4);
00083 
00084     image2d< image2d<int_u8> > ima(2,2);
00085     data::fill(ima, lena);
00086     // The 4 pixels of ima share the same data (holded by lena).
00087     // Then this update will affect the 4 pixels of ima.
00088     ima(p1)(p2) = 0;
00089     // ima(0,0)(p2) == ima(0,1)(p2) == ima(1,0)(p2) == ima(1,1)(p2) == 0
00090 
00091     image2d< plain< image2d<int_u8> > > ima_plain(2,2);
00092     data::fill(ima_plain, plain< image2d<int_u8> >(lena));
00093     // The 4 pixels of ima_plain are instances of plain<
00094     // image2d<int_u8> >.  So each of them hold their own data. Then
00095     // this update will affect just one pixel at the coordinate 0,0 of
00096     // ima_plain.
00097     ima_plain(p1)(p2) = 0;
00098     // ima_plain(0,0)(p2) == 0
00099     // ima_plain(0,1)(p2) == 0
00100     // ima_plain(1,0)(p2) == 0
00101     // ima_plain(1,1)(p2) == 0
00102 
00103   }
00104 
00105 }

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