DGtal  0.9.2
exampleRigidtransformation3d.cpp
1 
30 #include <iostream>
32 #include <cmath>
33 #include "DGtal/images/ImageSelector.h"
34 #include "DGtal/images/ImageContainerBySTLVector.h"
35 #include "DGtal/images/ConstImageAdapter.h"
36 #include "ConfigExamples.h"
37 #include "DGtal/helpers/StdDefs.h"
38 #include "DGtal/base/Common.h"
39 #include "DGtal/io/readers/VolReader.h"
40 #include "DGtal/io/writers/GenericWriter.h"
42 #include "DGtal/images/RigidTransformation3D.h"
45 
46 using namespace std;
47 using namespace DGtal;
48 using namespace functors;
49 using namespace Z3i;
50 
52 
53 int main( int , char** )
54 {
57  typedef ForwardRigidTransformation3D < Space > ForwardTrans;
58  typedef BackwardRigidTransformation3D < Space > BackwardTrans;
60  typedef DomainRigidTransformation3D < Domain, ForwardTrans > MyTransformedDomain;
61  typedef MyTransformedDomain::Bounds Bounds;
63  trace.beginBlock ( "Example rigidtransformation3d" );
65  ForwardTrans forwardTrans( Point ( 5, 5, 5 ), RealVector ( 1, 0, 1 ), M_PI_4, RealVector( 3, -3, 3 ) );
66  BackwardTrans backwardTrans( Point ( 5, 5, 5 ), RealVector ( 1, 0, 1 ), M_PI_4, RealVector( 3, -3, 3 ) );
69  MyTransformedDomain domainForwardTrans ( forwardTrans );
71  Identity idD;
72 
73  Image image = VolReader<Image>::importVol ( examplesPath + "samples/cat10.vol" );
75  Bounds bounds = domainForwardTrans ( image.domain() );
76  Domain transformedDomain ( bounds.first, bounds.second );
78  trace.beginBlock ( "Backward - Eulerian model" );
80  MyImageBackwardAdapter adapter ( image, transformedDomain, backwardTrans, idD );
82  adapter >> "backward_transform.pgm3d";
83  trace.endBlock();
84 
85  trace.beginBlock( "Forward - Lagrangian model" );
86  Image transformed ( transformedDomain );
88  for ( Domain::ConstIterator it = image.domain().begin(); it != image.domain().end(); ++it )
89  {
90  transformed.setValue ( forwardTrans ( *it ), image ( *it ) );
91  }
93  transformed >> "forward_transform.pgm3d";
94  trace.endBlock();
95  trace.endBlock();
96  return 0;
97 }
98 // //
void beginBlock(const std::string &keyword="")
Aim: Automatically defines an adequate image type according to the hints given by the user...
Definition: ImageSelector.h:66
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:69
Trace trace
Definition: Common.h:130
STL namespace.
double endBlock()
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:88
DGtal is the top-level namespace which contains all DGtal functions and types.
const Domain & domain() const
Definition: Image.h:192
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Space::RealVector RealVector
Definition: StdDefs.h:98