$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
get_full.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/dmorph/sub_image.hh>
28 #include <mln/core/image/dmorph/image_if.hh>
29 #include <mln/fun/p2b/chess.hh>
30 
31 #include <mln/border/get.hh>
32 #include <mln/literal/origin.hh>
33 #include <mln/value/int_u8.hh>
34 #include <mln/value/rgb8.hh>
35 
36 
37 struct f_box2d_t : mln::Function_v2b< f_box2d_t >
38 {
39  f_box2d_t(const mln::box2d& b)
40  : b_(b)
41  {
42  }
43  mln::box2d b_;
44  bool operator()(const mln::point2d& p) const
45  {
46  return b_.has(p);
47  }
48 };
49 
50 
51 
52 int main()
53 {
54  using namespace mln;
55 
56  box2d b(literal::origin, point2d(1,1));
57  f_box2d_t f_b(b);
59 
60  {
61  typedef image2d<int> I;
62  (std::cerr << "Tests border::get on int ... ").flush ();
63  I ima(3,3, 51);
64 
65  mln_assertion(border::get(ima) == 51);
66  sub_image<I, box2d> sub(ima, b);
67  mln_assertion(border::get(sub) == 0);
68 
69  image_if<I, f_box2d_t> imaif(ima, f_b);
70  mln_assertion(border::get(imaif) == 51);
71  mln_assertion(border::get( (ima | b) ) == 0);
72  mln_assertion(border::get( (ima | b) | f_b ) == 0);
73  std::cerr << "OK" << std::endl;
74  }
75 
76 
77  {
78  typedef image2d<value::int_u8> I;
79  (std::cerr << "Tests border::get on int_u8 ... ").flush ();
80  I ima(10, 10, 42);
81  mln_assertion(border::get(ima) == 42);
82  mln_assertion( ima.has(point2d(2,2)) == true );
83  sub_image<I, box2d> sub(ima, b);
84  mln_assertion(border::get(sub) == 0);
85 
86  image_if<I, mln::fun::p2b::chess > imaif(ima, c_b);
87  mln_assertion(border::get(imaif) == 42);
88  mln_assertion(border::get( (ima | b) ) == 0);
89  mln_assertion(border::get( (ima | b) | c_b ) == 0);
90  std::cerr << "OK" << std::endl;
91  }
92 
93  {
94  typedef image2d<value::rgb8> I;
95  (std::cerr << "Tests border::get on rgb8 ... ").flush ();
96  I ima(10, 10, 36);
97  mln_assertion(border::get(ima) == 36);
98  mln_assertion( ima.has(point2d(2,2)) == true );
99  sub_image<I, box2d> sub(ima, b);
100  mln_assertion(border::get(sub) == 0);
101 
102  image_if<I, mln::fun::p2b::chess > imaif(ima, c_b);
103  mln_assertion(border::get(imaif) == 36);
104  mln_assertion(border::get( (ima | b) ) == 0);
105  mln_assertion(border::get( (ima | b) | c_b ) == 0);
106  std::cerr << "OK" << std::endl;
107  }
108 
109 }