DGtal 2.1.0
Loading...
Searching...
No Matches
testRigidTransformation3D.cpp
Go to the documentation of this file.
1
31#include <iostream>
32#include <boost/graph/graph_concepts.hpp>
33#include "DGtal/base/Common.h"
34#include "ConfigTest.h"
35#include "DGtal/helpers/StdDefs.h"
36#include <DGtal/images/ImageSelector.h>
37#include <DGtal/images/ImageContainerBySTLVector.h>
38#include "DGtal/images/ConstImageAdapter.h"
39#include "DGtal/images/RigidTransformation3D.h"
40#include "DGtal/io/readers/PGMReader.h"
41#include "DGtal/io/readers/VolReader.h"
42#include "DGtal/io/writers/GenericWriter.h"
43
45
46using namespace std;
47using namespace DGtal;
48using namespace Z3i;
49using namespace functors;
50
52// Functions for testing class RigidTransformation3D.
54
59{
61 typedef ForwardRigidTransformation3D < Space > ForwardTrans;
62 typedef BackwardRigidTransformation3D < Space > BackwardTrans;
64 typedef DomainRigidTransformation3D < Domain, ForwardTrans > DomainTrans;
66private:
72public:
73 // Setup part
75 binary ( PGMReader<Image>::importPGM3D ( testPath + "samples/cat10.pgm3d" ) ),
76 forwardTrans ( RealPoint ( 5, 5, 5 ), RealVector ( 1, 0, 1 ), M_PI_4, RealVector( 3, -3, 3 ) ),
77 backwardTrans( RealPoint ( 5, 5, 5 ), RealVector ( 1, 0, 1 ), M_PI_4, RealVector( 3, -3, 3 ) ),
79 {}
80
82 {
83 Bounds bounds = domainForwardTrans ( binary.domain() );
84 Domain d ( bounds.first, bounds.second );
85 Image transformed ( d );
86 for ( Domain::ConstIterator it = binary.domain().begin(); it != binary.domain().end(); ++it )
87 {
88 transformed.setValue ( forwardTrans ( *it ), binary ( *it ) );
89 }
90 transformed >> "binary_after_forward.pgm3d";
91 return true;
92 }
94 {
95 Bounds bounds = domainForwardTrans ( binary.domain() );
96 Domain d ( bounds.first, bounds.second );
98 adapter >> "binary_after_backward.pgm3d";
99 return true;
100 }
101};
102
104// Standard services - public :
105
106int main( int, char** )
107{
108 bool res = true;
110 trace.beginBlock ( "Testing RigidTransformation3D" );
111 res &= rigidTest.forwardTransformation();
112 res &= rigidTest.backwardTransformation();
113 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
114 trace.endBlock();
115 return res ? 0 : 1;
116}
117// //
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
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="")
std::ostream & emphase()
double endBlock()
std::pair< typename TDomain::Space::Point, typename TDomain::Space::Point > Bounds
ImageSelector< Domain, unsignedchar >::Type Image
ForwardRigidTransformation3D< Space > ForwardTrans
BackwardRigidTransformation3D< Space > BackwardTrans
ConstImageAdapter< Image, Domain, BackwardTrans, Image::Value, Identity > MyImageBackwardAdapter
DomainRigidTransformation3D< Domain, ForwardTrans > DomainTrans
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
STL namespace.
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.
int main()
Definition testBits.cpp:56