DGtal  1.3.beta
images/exampleRigidtransformation3d.cpp

Example of 3D rigid transformation using forward and backward model.

See also
Geometric transformations
Result for backward model
#include <iostream>
#include <cmath>
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "DGtal/images/ConstImageAdapter.h"
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/writers/GenericWriter.h"
#include "DGtal/kernel/BasicPointFunctors.h"
#include "DGtal/images/RigidTransformation3D.h"
using namespace std;
using namespace DGtal;
using namespace functors;
using namespace Z3i;
int main( int , char** )
{
typedef ForwardRigidTransformation3D < Space > ForwardTrans;
typedef BackwardRigidTransformation3D < Space > BackwardTrans;
typedef DomainRigidTransformation3D < Domain, ForwardTrans > MyTransformedDomain;
typedef MyTransformedDomain::Bounds Bounds;
trace.beginBlock ( "Example rigidtransformation3d" );
ForwardTrans forwardTrans( Point ( 5, 5, 5 ), RealVector ( 1, 0, 1 ), M_PI_4, RealVector( 3, -3, 3 ) );
BackwardTrans backwardTrans( Point ( 5, 5, 5 ), RealVector ( 1, 0, 1 ), M_PI_4, RealVector( 3, -3, 3 ) );
MyTransformedDomain domainForwardTrans ( forwardTrans );
Identity idD;
Image image = VolReader<Image>::importVol ( examplesPath + "samples/cat10.vol" );
Bounds bounds = domainForwardTrans ( image.domain() );
Domain transformedDomain ( bounds.first, bounds.second );
trace.beginBlock ( "Backward - Eulerian model" );
MyImageBackwardAdapter adapter ( image, transformedDomain, backwardTrans, idD );
adapter >> "backward_transform.pgm3d";
trace.beginBlock( "Forward - Lagrangian model" );
Image transformed ( transformedDomain );
for ( Domain::ConstIterator it = image.domain().begin(); it != image.domain().end(); ++it )
{
transformed.setValue ( forwardTrans ( *it ), image ( *it ) );
}
transformed >> "forward_transform.pgm3d";
return 0;
}
// //
DGtal::Image::setValue
void setValue(const Point &aPoint, const Value &aValue)
Definition: Image.h:247
DGtal::HyperRectDomain< Space >
DGtal::Trace::endBlock
double endBlock()
RealVector
Z3i::RealVector RealVector
Definition: sphereCotangentLaplaceOperator.cpp:71
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::ConstImageAdapter
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Definition: ConstImageAdapter.h:105
Image
ImageContainerBySTLVector< Domain, Value > Image
Definition: testSimpleRandomAccessRangeFromPoint.cpp:45
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::Image
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:69
DGtal::HyperRectDomain_Iterator
Iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:142
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::VolReader
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
DGtal::ImageSelector
Aim: Automatically defines an adequate image type according to the hints given by the user.
Definition: ImageSelector.h:66
Point
MyPointD Point
Definition: testClone2.cpp:383