DGtal 1.4.2
Loading...
Searching...
No Matches
exampleRigidtransformation2d.cpp
Go to the documentation of this file.
1
39#include <iostream>
40#include <cmath>
41#include "DGtal/images/ImageSelector.h"
42#include "DGtal/images/ImageContainerBySTLVector.h"
43#include "DGtal/images/ConstImageAdapter.h"
44#include "ConfigExamples.h"
45#include "DGtal/helpers/StdDefs.h"
46#include "DGtal/base/Common.h"
47#include "DGtal/io/readers/PGMReader.h"
48#include "DGtal/io/writers/GenericWriter.h"
50#include "DGtal/images/RigidTransformation2D.h"
53
54using namespace std;
55using namespace DGtal;
56using namespace functors;
57using namespace Z2i;
58
60
61int main( int , char** )
62{
65 typedef ForwardRigidTransformation2D < Space > ForwardTrans;
66 typedef BackwardRigidTransformation2D < Space > BackwardTrans;
68 typedef DomainRigidTransformation2D < Domain, ForwardTrans > MyDomainTransformer;
69 typedef MyDomainTransformer::Bounds Bounds;
71 trace.beginBlock ( "Example rigidtransformation2d" );
73 ForwardTrans forwardTrans( RealPoint ( 5, 5 ), M_PI_4, RealVector( 3, -3 ) );
74 BackwardTrans backwardTrans( RealPoint ( 5, 5 ), M_PI_4, RealVector( 3, -3 ) );
77 MyDomainTransformer domainTransformer ( forwardTrans );
79 Identity idD;
80
81 Image image = PGMReader<Image>::importPGM ( examplesPath + "samples/church.pgm" );
83 Bounds bounds = domainTransformer ( image.domain() );
84 Domain transformedDomain ( bounds.first, bounds.second );
86
87 trace.beginBlock ( "Backward - Eulerian model" );
89 MyImageBackwardAdapter backwardImageAdapter ( image, transformedDomain , backwardTrans, idD );
91 backwardImageAdapter >> "backward_transform.pgm";
93
94 trace.beginBlock( "Forward - Lagrangian model" );
95 Image forwardTransformedImage ( transformedDomain );
97 for ( Domain::ConstIterator it = image.domain().begin(); it != image.domain().end(); ++it )
98 {
99 forwardTransformedImage.setValue ( forwardTrans ( *it ), image ( *it ) );
100 }
102 forwardTransformedImage >> "forward_transform.pgm";
103 trace.endBlock();
104 trace.endBlock();
105 return 0;
106}
107// //
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Aim: implements association bewteen points lying in a digital domain and values.
Definition Image.h:70
void setValue(const Point &aPoint, const Value &aValue)
Definition Image.h:247
Aim: Implements basic operations that will be used in Point and Vector classes.
void beginBlock(const std::string &keyword="")
double endBlock()
Space::RealVector RealVector
Definition StdDefs.h:98
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
STL namespace.
static ImageContainer importPGM(const std::string &aFilename, const Functor &aFunctor=Functor(), bool topbotomOrder=true)
Aim: Define a simple default functor that just returns its argument.
int main()
Definition testBits.cpp:56
ImageContainerBySTLVector< Domain, Value > Image