DGtal  1.5.beta
exampleRigidtransformation3d.cpp
Go to the documentation of this file.
1 
40 #include <iostream>
41 #include <cmath>
42 #include "DGtal/images/ImageSelector.h"
43 #include "DGtal/images/ImageContainerBySTLVector.h"
44 #include "DGtal/images/ConstImageAdapter.h"
45 #include "ConfigExamples.h"
46 #include "DGtal/helpers/StdDefs.h"
47 #include "DGtal/base/Common.h"
48 #include "DGtal/io/readers/VolReader.h"
49 #include "DGtal/io/writers/GenericWriter.h"
50 #include "DGtal/kernel/BasicPointFunctors.h"
52 #include "DGtal/images/RigidTransformation3D.h"
55 
56 using namespace std;
57 using namespace DGtal;
58 using namespace functors;
59 using namespace Z3i;
60 
62 
63 int main( int , char** )
64 {
67  typedef ForwardRigidTransformation3D < Space > ForwardTrans;
68  typedef BackwardRigidTransformation3D < Space > BackwardTrans;
70  typedef DomainRigidTransformation3D < Domain, ForwardTrans > MyTransformedDomain;
71  typedef MyTransformedDomain::Bounds Bounds;
73  trace.beginBlock ( "Example rigidtransformation3d" );
75  ForwardTrans forwardTrans( Point ( 5, 5, 5 ), RealVector ( 1, 0, 1 ), M_PI_4, RealVector( 3, -3, 3 ) );
76  BackwardTrans backwardTrans( Point ( 5, 5, 5 ), RealVector ( 1, 0, 1 ), M_PI_4, RealVector( 3, -3, 3 ) );
79  MyTransformedDomain domainForwardTrans ( forwardTrans );
81  Identity idD;
82 
83  Image image = VolReader<Image>::importVol ( examplesPath + "samples/cat10.vol" );
85  Bounds bounds = domainForwardTrans ( image.domain() );
86  Domain transformedDomain ( bounds.first, bounds.second );
88  trace.beginBlock ( "Backward - Eulerian model" );
90  MyImageBackwardAdapter adapter ( image, transformedDomain, backwardTrans, idD );
92  adapter >> "backward_transform.pgm3d";
93  trace.endBlock();
94 
95  trace.beginBlock( "Forward - Lagrangian model" );
96  Image transformed ( transformedDomain );
98  for ( Domain::ConstIterator it = image.domain().begin(); it != image.domain().end(); ++it )
99  {
100  transformed.setValue ( forwardTrans ( *it ), image ( *it ) );
101  }
103  transformed >> "forward_transform.pgm3d";
104  trace.endBlock();
105  trace.endBlock();
106  return 0;
107 }
108 // //
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
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: implements methods to read a "Vol" file format.
Definition: VolReader.h:90
Aim: Define a simple default functor that just returns its argument.
ImageContainerBySTLVector< Domain, Value > Image