DGtal  1.5.beta
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 
54 using namespace std;
55 using namespace DGtal;
56 using namespace functors;
57 using namespace Z2i;
58 
60 
61 int 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";
92  trace.endBlock();
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...
Iterator for HyperRectDomain.
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.
Definition: PointVector.h:593
void beginBlock(const std::string &keyword="")
double endBlock()
Space::RealVector RealVector
int main(int, char **)
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
Aim: Automatically defines an adequate image type according to the hints given by the user.
Definition: ImageSelector.h:70
Aim: Import a 2D or 3D using the Netpbm formats (ASCII mode).
Definition: PGMReader.h:98
Aim: Define a simple default functor that just returns its argument.
ImageContainerBySTLVector< Domain, Value > Image