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

fill_with_value.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/data/fill_with_value.hh>
00027 
00028 #include <mln/core/image/image1d.hh>
00029 #include <mln/core/image/image2d.hh>
00030 #include <mln/core/image/image3d.hh>
00031 #include <mln/core/image/flat_image.hh>
00032 #include <mln/core/image/dmorph/image_if.hh>
00033 #include <mln/core/image/dmorph/sub_image.hh>
00034 #include <mln/core/image/dmorph/extension_val.hh>
00035 
00036 #include <mln/value/rgb8.hh>
00037 #include <mln/fun/p2b/chess.hh>
00038 
00039 #include <mln/make/box2d.hh>
00040 
00041 int main()
00042 {
00043   using namespace mln;
00044   const unsigned size = 50;
00045 
00046   {
00047     typedef image1d<unsigned char> I;
00048     I ima(size);
00049     data::fill_with_value(ima, 51);
00050     mln_piter_(I) p(ima.domain());
00051     for_all(p)
00052       mln_assertion(ima(p) == 51);
00053   }
00054 
00055 
00056   {
00057     typedef image2d<unsigned char> I;
00058     I ima(size, size);
00059     data::fill_with_value(ima, 51);
00060     mln_piter_(I) p(ima.domain());
00061     for_all(p)
00062       mln_assertion(ima(p) == 51);
00063   }
00064 
00065   {
00066     typedef image3d<value::rgb8> I;
00067     I ima(size, size, size);
00068     data::fill_with_value(ima, value::rgb8(255, 0, 255));
00069     mln_piter_(I) p(ima.domain());
00070     for_all(p)
00071       mln_assertion(ima(p) == value::rgb8(255, 0, 255));
00072   }
00073 
00074 
00075   {
00076     flat_image<short, box2d> ima(5, make::box2d(2, 3));
00077     data::fill_with_value(ima, 51);
00078     box2d::piter p(ima.domain());
00079     for_all(p)
00080       mln_assertion(ima(p) == 51);
00081   }
00082 
00083 
00084   {
00085     typedef image2d<unsigned char> I;
00086     typedef image_if<I, fun::p2b::chess> II;
00087 
00088     I ima(size, size);
00089     data::fill_with_value(ima, 51);
00090 
00091     II ima_if = ima | fun::p2b::chess();
00092     data::fill_with_value(ima_if, 42);
00093 
00094     II::piter p(ima_if.domain());
00095     for_all(p)
00096       mln_assertion(ima_if(p) == 42);
00097   }
00098 
00099   {
00100     typedef image2d<int> I;
00101     typedef sub_image< image2d<int>, box2d > II;
00102     I ima(size, size);
00103     II sub_ima(ima, make::box2d(4,4, 10,10));
00104 
00105     data::fill_with_value(sub_ima,  5);
00106 
00107     II::piter p(sub_ima.domain());
00108     for_all(p)
00109       mln_assertion(sub_ima(p) == 5);
00110   }
00111 
00112   {
00113     typedef image2d<int> I;
00114     typedef extension_val< image2d<int> > II;
00115     I ima(size, size);
00116     II extend_ima(ima, 5);
00117 
00118     data::fill_with_value(extend_ima,  51);
00119 
00120     II::piter p(extend_ima.domain());
00121     for_all(p)
00122       mln_assertion(extend_ima(p) == 51);
00123   }
00124 
00125 }

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