A test file for ConstImageAdapter.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
- Author
- Tristan Roussillon (
trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
- Date
- 2012/02/13
- Author
- Martial Tola (
marti.nosp@m.al.t.nosp@m.ola@l.nosp@m.iris.nosp@m..cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
- Date
- 2012/10/12
This file is part of the DGtal library.
Definition in file testConstImageAdapter.cpp.
| int main |
( |
int | argc, |
|
|
char ** | argv ) |
[ConstImageAdapterConstruction]
[ConstImageAdapterConstruction]
[ConstImageAdapterRange]
[ConstImageAdapterRange]
Definition at line 64 of file testConstImageAdapter.cpp.
65{
66 unsigned int nbok = 0;
67 unsigned int nb = 0;
68
69 trace.beginBlock (
"Test for ConstImageAdapter" );
70 trace.info() <<
"Args:";
71 for ( int i = 0; i < argc; ++i )
72 trace.info() <<
" " << argv[ i ];
74
76
77 trace.beginBlock(
"Image creation");
78
79
81 Point p = Point::diagonal(0);
82 Point q = Point::diagonal(size-1);
84
85
88
89
90 const int maximalValue = size*size;
92 for (int i = 0; i < maximalValue; ++i)
93 *it++ = i;
94
95
97 std::copy( r.
begin(), r.
end(), std::ostream_iterator<int>(cout,
", ") );
98 cout << endl;
100
101
102 const int thresholdValue = maximalValue/2;
103 trace.beginBlock(
"Implicit thresholding");
104
110 MyConstImageAdapter a(img, d,
g, t);
112
113
116 ra = a.constRange();
117 std::copy( ra.begin(), ra.end(), std::ostream_iterator<int>(cout,", ") );
118 cout << endl;
119
120 std::vector<int> to_vector(25);
121 std::copy(ra.begin(), ra.end(), to_vector.begin());
122 for (int i = 0; i < 25; i++)
123 {
124 if (i<=12)
125 {
126 if (to_vector[i]==1)
127 {
128 cout << "ok, ";
129 nbok += 1 ; nb++;
130 }
131 else
132 {
133 cout << "!ok, ";
134 nb++;
135 }
136 }
137 else
138 {
139 if (to_vector[i]==0)
140 {
141 cout << "ok, ";
142 nbok += 1 ; nb++;
143 }
144 else
145 {
146 cout << "!ok, ";
147 nb++;
148 }
149 }
150 }
152
153 cout << endl;
154
156
157 bool res = (nbok == nb);
158
159 trace.emphase() << ( res ?
"Passed." :
"Error." ) << endl;
161 return res ? 0 : 1;
162}
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
std::vector< Value >::iterator OutputIterator
SimpleRandomAccessConstRangeFromPoint< ConstIterator, DistanceFunctorFromPoint< Self > > ConstRange
Aim: implements association bewteen points lying in a digital domain and values.
ConstIterator begin() const
ConstIterator end() const
Aim: A small functor with an operator () that compares one value to a threshold value according to tw...
Point::Coordinate Integer
Z2i this namespace gathers the standard of types for 2D imagery.
ImageContainerBySTLVector< Domain, Value > Type
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Aim: Define a simple default functor that just returns its argument.
Image::ConstRange ConstRange
References DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::begin(), DGtal::Image< TImageContainer >::constRange(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::end(), g(), DGtal::SimpleRandomAccessRangeFromPoint< TConstIterator, TIterator, DistanceFunctor >::outputIterator(), DGtal::Image< TImageContainer >::range(), and DGtal::trace.