$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plain.cc
1 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #include <mln/core/image/image2d.hh>
27 #include <mln/core/image/imorph/plain.hh>
28 
29 #include <mln/value/int_u8.hh>
30 #include <mln/data/compare.hh>
31 #include <mln/data/fill.hh>
32 
33 
34 #include <mln/debug/println.hh>
35 
36 #include <mln/io/pgm/load.hh>
37 #include <mln/io/pgm/save.hh>
38 
39 #include "tests/data.hh"
40 
41 
42 int main()
43 {
44  using namespace mln;
45  using value::int_u8;
46 
47  {
49  = io::pgm::load<int_u8>(MLN_IMG_DIR "/lena.pgm");
50 
51  image2d<int_u8> ima;
52  image2d<int_u8> ima2;
53 
54  ima = lena;
55 
56  ima(point2d(0,0)) = 124;
57 
58  mln_assertion(exact(ima).is_valid());
59  mln_assertion(exact(lena).is_valid());
60  mln_assertion(ima != lena);
61 
62  ima2 = lena;
63  ima = lena;
64 
65  mln_assertion(ima == ima2);
66 
67  ima(point2d(0,0)) = 124;
68  mln_assertion(ima != ima2);
69 
70  ima = ima2;
71 
72  ima(point2d(0,0)) = 124;
73  mln_assertion(ima == ima2);
74 
75  }
76 
77  {
78  image2d<int_u8> lena(12,12);
79  data::fill(lena, 42);
80 
81  point2d p1(0,0);
82  point2d p2(5,4);
83 
84  image2d< image2d<int_u8> > ima(2,2);
85  data::fill(ima, lena);
86  // The 4 pixels of ima share the same data (holded by lena).
87  // Then this update will affect the 4 pixels of ima.
88  ima(p1)(p2) = 0;
89  // ima(0,0)(p2) == ima(0,1)(p2) == ima(1,0)(p2) == ima(1,1)(p2) == 0
90 
91  image2d< plain< image2d<int_u8> > > ima_plain(2,2);
92  data::fill(ima_plain, plain< image2d<int_u8> >(lena));
93  // The 4 pixels of ima_plain are instances of plain<
94  // image2d<int_u8> >. So each of them hold their own data. Then
95  // this update will affect just one pixel at the coordinate 0,0 of
96  // ima_plain.
97  ima_plain(p1)(p2) = 0;
98  // ima_plain(0,0)(p2) == 0
99  // ima_plain(0,1)(p2) == 0
100  // ima_plain(1,0)(p2) == 0
101  // ima_plain(1,1)(p2) == 0
102 
103  }
104 
105 }