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 std;
using namespace functors;
using namespace Z2i;
{
typedef ForwardRigidTransformation2D < Space > ForwardTrans;
typedef BackwardRigidTransformation2D < Space > BackwardTrans;
typedef ConstImageAdapter<Image, Domain, BackwardTrans, Image::Value, Identity > MyImageBackwardAdapter;
typedef DomainRigidTransformation2D < Domain, ForwardTrans > MyDomainTransformer;
typedef MyDomainTransformer::Bounds Bounds;
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 );
MyImageBackwardAdapter backwardImageAdapter ( image, transformedDomain , backwardTrans, idD );
backwardImageAdapter >> "backward_transform.pgm";
Image forwardTransformedImage ( transformedDomain );
{
forwardTransformedImage.setValue ( forwardTrans ( *it ), image ( *it ) );
}
forwardTransformedImage >> "forward_transform.pgm";
return 0;
}
void beginBlock(const std::string &keyword="")
Space::RealVector RealVector
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
ImageContainerBySTLVector< Domain, unsigned char > Type
int main(int argc, char **argv)
ImageContainerBySTLVector< Domain, Value > Image
HyperRectDomain< Space > Domain
PointVector< 3, double > RealPoint