Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

Class to apply an arbitrary series of affine transformations \. More...

#include <AffineOp.h>

Inheritance diagram for icl::filter::AffineOp:
icl::filter::BaseAffineOp icl::utils::Uncopyable icl::filter::UnaryOp icl::utils::Configurable icl::filter::RotateOp icl::filter::ScaleOp icl::filter::TranslateOp

List of all members.

Public Member Functions

 AffineOp (core::scalemode eInterpolate=core::interpolateLIN)
 Constructor.
void reset ()
 resets the internal Matrix
void rotate (double dAngle)
 adds a rotation
void translate (double x, double y)
 adds a traslation
void scale (double x, double y)
 adds a scale
virtual void apply (const core::ImgBase *poSrc, core::ImgBase **ppoDst)
 Applies the affine transform to the image.
void setAdaptResultImage (bool on)
 sets whether the result image is is scaled and translated to contain the whole result image
bool getAdaptResultImage () const
 returns the Adapt Result image option

Private Member Functions

template<typename T >
void affine (const core::ImgBase *poSrc, core::ImgBase *poDst)
void applyT (const double p[2], double aResult[2])
void getShiftAndSize (const utils::Rect &roi, utils::Size &size, double &xShift, double &yShift)

Static Private Member Functions

static void useMinMax (const double aCur[2], double aMin[2], double aMax[2])

Private Attributes

void(AffineOp::* m_aMethods [core::depthLast+1])(const core::ImgBase *poSrc, core::ImgBase *poDst)
 array of class methods used to transform depth8u and depth32f images
double m_aadT [2][3]
core::scalemode m_eInterpolate
bool m_adaptResultImage
 internal flag

Detailed Description

Class to apply an arbitrary series of affine transformations \.

Affine operations apply transform pixel locations using affine matrix transformation. To optimize performance concatenated affine transformation's matrices are pre-multiplied.

Adapt Result Image

In some cases, it might make sense to automatically adapt the destinate image so that it contains the whole warping result image. Consider the following example

        source image:
                                           +
        A---------+                   +--/---\--+
        |         |                   |/       \|
        |         |    -------->     /|         |\
        |    A    |     rot(45)     + |    A'   | +
        |         |                  \|         |/
        |         |                   |\       /|
        +---------+                   +--\---/--+
                                           +
        

But obviously, the result image's corners are cut. If the "Adapt Result Image" option is set to true, the result image would be scaled to contain the whole rotated image and the affine matrix's shift is adpated in order to fit the result completely into the result image. If otherwise "Adpat Result Image is false, the result image's size will be identical to the source images size and the corners of the rotated image are cropped.

Please note: this options is by default set to "true". Only the TranslateOp will set it to false by default, because a pure translation is just compensated completely by the result image adaption.

Benchmarks

example: a 300x400 rgb 8u-image was scaled by 1.001 and rotated by 1-360 degree in 3.6 degree steps We used a 2Ghz Core2Duo machine and g++ 4.3 with -O4 and -march=native flags set

With IPP: neares neighbour interpolation: 1ms linear interpolation 5ms

C++-Fallback: neares neighbour interpolation: 22ms linear interpolation 52ms


Constructor & Destructor Documentation

Constructor.


Member Function Documentation

template<typename T >
void icl::filter::AffineOp::affine ( const core::ImgBase poSrc,
core::ImgBase poDst 
) [private]
virtual void icl::filter::AffineOp::apply ( const core::ImgBase poSrc,
core::ImgBase **  ppoDst 
) [virtual]

Applies the affine transform to the image.

Implements icl::filter::UnaryOp.

void icl::filter::AffineOp::applyT ( const double  p[2],
double  aResult[2] 
) [private]

returns the Adapt Result image option

See also:
Adapt Result Image
void icl::filter::AffineOp::getShiftAndSize ( const utils::Rect roi,
utils::Size size,
double &  xShift,
double &  yShift 
) [private]

resets the internal Matrix

to

          1 0 0
          0 1 0
          0 0 
          
void icl::filter::AffineOp::rotate ( double  dAngle)

adds a rotation

Parameters:
dAngleangle in degrees (clockwise)
void icl::filter::AffineOp::scale ( double  x,
double  y 
) [inline]

adds a scale

Parameters:
xscale-factor in x-direction
yscale-factor in y-direction different values for x and y will lead to a dilation / upsetting deformation
void icl::filter::AffineOp::setAdaptResultImage ( bool  on) [inline]

sets whether the result image is is scaled and translated to contain the whole result image

See also:
Adapt Result Image
void icl::filter::AffineOp::translate ( double  x,
double  y 
) [inline]

adds a traslation

Parameters:
xpixels to translate in x-direction
ypixels to translate in y-direction
static void icl::filter::AffineOp::useMinMax ( const double  aCur[2],
double  aMin[2],
double  aMax[2] 
) [static, private]

Member Data Documentation

double icl::filter::AffineOp::m_aadT[2][3] [private]

internal flag

void(AffineOp::* icl::filter::AffineOp::m_aMethods[core::depthLast+1])(const core::ImgBase *poSrc, core::ImgBase *poDst) [private]

array of class methods used to transform depth8u and depth32f images


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines