Example of 3D 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/VolReader.h"
#include "DGtal/io/writers/GenericWriter.h"
#include "DGtal/kernel/BasicPointFunctors.h"
#include "DGtal/images/RigidTransformation3D.h"
using namespace std;
using namespace functors;
using namespace Z3i;
{
typedef ForwardRigidTransformation3D < Space > ForwardTrans;
typedef BackwardRigidTransformation3D < Space > BackwardTrans;
typedef ConstImageAdapter<Image, Domain, BackwardTrans, Image::Value, Identity > MyImageBackwardAdapter;
typedef DomainRigidTransformation3D < Domain, ForwardTrans > MyTransformedDomain;
typedef MyTransformedDomain::Bounds Bounds;
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 );
MyImageBackwardAdapter adapter ( image, transformedDomain, backwardTrans, idD );
adapter >> "backward_transform.pgm3d";
Image transformed ( transformedDomain );
{
transformed.setValue ( forwardTrans ( *it ), image ( *it ) );
}
transformed >> "forward_transform.pgm3d";
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