algorithm allowing to apply a motion transformation warping operation on a 2d image
This algorithm allows to apply a motion transformation defined by parameter
on an input image
. Available warping transformations are defined by enumerate ipsdk::math::transform::eGeometricTransform2dType.
Interpolation policy used during processing is defined by optional input parameter
(see ipsdk::imaproc::attr::eInterpolationPolicy).
On output, algorithm generates requested warped image
and optionally output mask image
. Size of output image is not ruled :
- pixels covered by transformed input image are processed using defined interpolation policy (and corresponding mask pixels are set to 1).
- pixels not covered are simply left to zero (and corresponding mask pixels are set to 0).
This process is illustrated by following figure :
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 :
Here is another example of application of Warp2dImg algorithm on a 2d image, in this case we apply an homography on input image :
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLGeometricTransform as gtrans
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
transform1 = PyIPSDK.createWarpMotionTransform2d(PyIPSDK.eGeometricTransform2dType.eGT2DT_Translation,
[10, 30])
outImg1 = gtrans.warp2dImg(inImg, transform1)
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
math::transform::Translation2d translation(10, 30);
ImagePtr pOutImg1 = warp2dImg(pInImg, pTransform1);
ipUInt64 outputSizeX, outputSizeY;
computeWarpedDefaultSize(*pTransform2, *pInImg, outputSizeX, outputSizeY);
MemoryImagePtr pOutImg2(boost::make_shared<MemoryImage>());
pOutImg2->init(*pOutGeometry2);
MemoryImagePtr pOutOptMaskImg2(boost::make_shared<MemoryImage>());
pOutOptMaskImg2->init(*pOutMaskGeometry2);