IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Warping 2d algorithmSee full documentation
imagewarp2dImg (inImg,inWarpMotionTransform2d,inOptInterpolationPolicy)
imagewarp2dImg (inImg,inWarpMotionTransform2d)

Detailed Description

algorithm allowing to apply a motion transformation warping operation on a 2d image

This algorithm allows to apply a motion transformation defined by parameter $InWarpMotionTransform2d$ on an input image $InImg$. Available warping transformations are defined by enumerate ipsdk::math::transform::eGeometricTransform2dType.

Interpolation policy used during processing is defined by optional input parameter $InOptInterpolationPolicy$ (see ipsdk::imaproc::attr::eInterpolationPolicy).

On output, algorithm generates requested warped image $OutImg$ and optionally output mask image $OutOptMaskImg$. Size of output image is not ruled :

This process is illustrated by following figure :

warp2dImg1.png

If output image is not provided by user, a default output image size is computed using computeWarpedDefaultSize function.

Here is an example of application of Warp2dImg algorithm on a 2d image, in this case we apply a centered rotation on input image :

warp2dImg2.png

Here is another example of application of Warp2dImg algorithm on a 2d image, in this case we apply an homography on input image :

warp2dImg3.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLGeometricTransform as gtrans

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# case of a translation transformation
transform1 = PyIPSDK.createWarpMotionTransform2d(PyIPSDK.eGeometricTransform2dType.eGT2DT_Translation,
[10, 30])
outImg1 = gtrans.warp2dImg(inImg, transform1)
# case of a rotation transformation with retrieval of output optional mask image
# In this case we compute a suitable output image size and allocate
# output image and output optional mask
transform2 = PyIPSDK.createCenteredRotation(math.pi/3, inImg)
outputSizeX, outputSizeY = gtrans.computeWarpedDefaultSize(transform2, inImg)
outImg2 = PyIPSDK.createImageRgb(PyIPSDK.eImageBufferType.eIBT_UInt8, outputSizeX, outputSizeY)
outOptMaskImg2 = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_Binary, outputSizeX, outputSizeY)
gtrans.warp2dImg(inImg, transform2, PyIPSDK.eInterpolationPolicy.eIP_Cubic, outImg2, outOptMaskImg2)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLGeometricTransform/Processor/Warp2dImg/Warp2dImg.h>

Code Example

// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
// case of a translation transformation
math::transform::Translation2d translation(10, 30);
ImagePtr pOutImg1 = warp2dImg(pInImg, pTransform1);
// case of a rotation transformation with retrieval of output optional mask image
// In this case we compute a suitable output image size and allocate
// output image and output optional mask
WarpMotionTransform2dConstPtr pTransform2 = createCenteredRotation(M_PI / 3, *pInImg);
ipUInt64 outputSizeX, outputSizeY;
computeWarpedDefaultSize(*pTransform2, *pInImg, outputSizeX, outputSizeY);
ImageGeometryPtr pOutGeometry2 = geometryRgb2d(pInImg->getBufferType(), outputSizeX, outputSizeY);
MemoryImagePtr pOutImg2(boost::make_shared<MemoryImage>());
pOutImg2->init(*pOutGeometry2);
ImageGeometryPtr pOutMaskGeometry2 = geometry2d(eImageBufferType::eIBT_Binary, outputSizeX, outputSizeY);
MemoryImagePtr pOutOptMaskImg2(boost::make_shared<MemoryImage>());
pOutOptMaskImg2->init(*pOutMaskGeometry2);
warp2dImg(pInImg, pTransform2, eInterpolationPolicy::eIP_Cubic, pOutImg2, pOutOptMaskImg2);