Example of 2D rigid transformation using forward and 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/PGMReader.h"
#include "DGtal/io/writers/GenericWriter.h"
#include "DGtal/images/RigidTransformation2D.h"
using namespace functors;
using namespace Z2i;
{
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;
Bounds bounds = domainTransformer ( image.domain() );
Domain transformedDomain ( bounds.first, bounds.second );
MyImageBackwardAdapter backwardImageAdapter ( image, transformedDomain , backwardTrans, idD );
backwardImageAdapter >> "backward_transform.pgm";
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;
}
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)
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Import a 2D or 3D using the Netpbm formats (ASCII mode).
ImageContainerBySTLVector< Domain, Value > Image
HyperRectDomain< Space > Domain