DGtal  1.1.0
images/exampleRigidtransformation2d.cpp

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

Geometric transformations
Result for backward model
#include <iostream>
#include <cmath>
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/io/writers/GenericWriter.h"
#include "DGtal/images/RigidTransformation2D.h"
using namespace std;
using namespace DGtal;
using namespace functors;
using namespace Z2i;
int main( int , char** )
{
typedef ForwardRigidTransformation2D < Space > ForwardTrans;
typedef BackwardRigidTransformation2D < Space > BackwardTrans;
typedef DomainRigidTransformation2D < Domain, ForwardTrans > MyDomainTransformer;
typedef MyDomainTransformer::Bounds Bounds;
trace.beginBlock ( "Example rigidtransformation2d" );
ForwardTrans forwardTrans( RealPoint ( 5, 5 ), M_PI_4, RealVector( 3, -3 ) );
BackwardTrans backwardTrans( RealPoint ( 5, 5 ), M_PI_4, RealVector( 3, -3 ) );
MyDomainTransformer domainTransformer ( forwardTrans );
Identity idD;
Image image = PGMReader<Image>::importPGM ( examplesPath + "samples/church.pgm" );
Bounds bounds = domainTransformer ( image.domain() );
Domain transformedDomain ( bounds.first, bounds.second );
trace.beginBlock ( "Backward - Eulerian model" );
trace.beginBlock( "Forward - Lagrangian model" );
Image forwardTransformedImage ( transformedDomain );
for ( Domain::ConstIterator it = image.domain().begin(); it != image.domain().end(); ++it )
{
forwardTransformedImage.setValue ( forwardTrans ( *it ), image ( *it ) );
}
forwardTransformedImage >> "forward_transform.pgm";
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:150
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
Image
ImageContainerBySTLVector< Domain, Value > Image
Definition: testSimpleRandomAccessRangeFromPoint.cpp:45
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
Aim: Import a 2D or 3D using the Netpbm formats (ASCII mode).
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:70
DGtal::HyperRectDomain_Iterator
Iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:154
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
DGtal::ImageSelector
Aim: Automatically defines an adequate image type according to the hints given by the user.
Definition: ImageSelector.h:67