33#include <DGtal/images/ImageSelector.h>
34#include <DGtal/images/ImageContainerBySTLVector.h>
35#include "DGtal/images/ConstImageAdapter.h"
36#include "DGtal/base/Common.h"
37#include "ConfigTest.h"
38#include "DGtal/helpers/StdDefs.h"
39#include "DGtal/images/RigidTransformation2D.h"
40#include "DGtal/io/readers/PGMReader.h"
41#include "DGtal/io/writers/GenericWriter.h"
47using namespace functors;
58class testRigidTransformation2D
61 typedef ForwardRigidTransformation2D < Space > ForwardTrans;
62 typedef BackwardRigidTransformation2D < Space > BackwardTrans;
64 typedef DomainRigidTransformation2D < Domain, ForwardTrans > DomainTrans;
69 ForwardTrans forwardTrans;
70 BackwardTrans backwardTrans;
72 DomainTrans domainForwardTrans;
75 testRigidTransformation2D() :
77 gray (
PGMReader<
Image>::importPGM ( testPath +
"samples/church-small.pgm" ) ),
80 domainForwardTrans ( forwardTrans )
83 binary.setValue (
Point ( 3,4 ), 255 );
84 binary.setValue (
Point ( 4,3 ), 255 );
85 binary.setValue (
Point ( 4,4 ), 255 );
87 binary >>
"binary.pgm";
91 bool forwardTransformationBinary ()
93 Bounds bounds = domainForwardTrans ( binary.domain() );
94 Domain d ( bounds.first, bounds.second );
95 Image transformed ( d );
98 transformed.setValue ( forwardTrans ( *it ), binary ( *it ) );
100 transformed >>
"binary_after_forward.pgm";
104 bool backwardTransformationBinary ()
106 Bounds bounds = domainForwardTrans ( binary.domain() );
107 Domain d ( bounds.first, bounds.second );
108 MyImageBackwardAdapter adapter ( binary, d, backwardTrans, idD );
109 adapter >>
"binary_after_backward.pgm";
113 bool backwardTransformationGray ()
115 Bounds bounds = domainForwardTrans ( gray.
domain() );
116 Domain d ( bounds.first, bounds.second );
117 MyImageBackwardAdapter adapter ( gray, d, backwardTrans, idD );
118 adapter >>
"gray_after_backward.pgm";
122 bool forwardTransformationGray ()
124 Bounds bounds = domainForwardTrans ( gray.
domain() );
125 Domain d ( bounds.first, bounds.second );
126 Image transformed ( d );
129 transformed.setValue ( forwardTrans ( *it ), gray ( *it ) );
131 transformed >>
"gray_after_forward.pgm";
142 testRigidTransformation2D rigidTest;
144 res &= rigidTest.forwardTransformationBinary();
145 res &= rigidTest.backwardTransformationBinary();
146 res &= rigidTest.backwardTransformationGray();
147 res &= rigidTest.forwardTransformationGray();
148 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Iterator for HyperRectDomain.
Aim: implements association bewteen points lying in a digital domain and values.
const Domain & domain() const
void setValue(const Point &aPoint, const Value &aValue)
void beginBlock(const std::string &keyword="")
std::pair< typename Domain::Space::Point, typename Domain::Space::Point > Bounds
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Import a 2D or 3D using the Netpbm formats (ASCII mode).
Aim: Define a simple default functor that just returns its argument.