IPSDK 0.2
IPSDK : Image Processing Software Development Kit
imagezoom2dImg (inImg,xZoomFactor,yZoomFactor,interpolationMethod)
imagezoom2dImg (inImg,zoomFactor,interpolationMethod)

Detailed Description

Algorithm allowing to resize a 2d image.

This algorithm allows to resize a 2d image using one of the available interpolation methods
The user can resize a 2d image either to the expected output image size or by specifying the scale factors along the x and y axis.

If the user provides the buffer of the output image, he has to initialize its dimensions with the correct values. If the user requests a resize operation by specifying the scale factors, for instance, the dimensions of the output image must equal to:

The enumerate ipsdk::attr::eZoomInterpolationMethod permits to specify the interpolation method to use to resize the image. The following interpolation methods are available:

Here is, from the following input image:

zoom2dImg_inImg.png

an example of zoom with a scale factor that equals to 10 along x and y axis, with different interpolation methods (left image: nearest neighbour; center image: bilinear interpolation; right image: bicubic interpolation):

zoom2dImg_outImg.png

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLGeometricTransform as gtrans

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
xScaleFactor = 11.4
yScaleFactor = 10.2
# initialization of output image
inImg2dSize = PyIPSDK.createImg2dSize(inImg.getSizeX(), inImg.getSizeY())
scaleFactor = PyIPSDK.createScaleFactor2d(xScaleFactor, yScaleFactor)
outImg2dSize = gtrans.getZoom2dOutputImageSize(inImg2dSize, scaleFactor)
outImg2dSizeX = outImg2dSize.xSz
outImg2dSizeY = outImg2dSize.ySz
outGeometry = PyIPSDK.geometry2d(inImg.getBufferType(), outImg2dSizeX, outImg2dSizeY)
outImg = PyIPSDK.createImage(outGeometry)
# 2d zoom
gtrans.zoom2dImg(inImg, xScaleFactor, yScaleFactor, PyIPSDK.eZoomInterpolationMethod.eZIM_NearestNeighbour, outImg)

Example of C++ code :

Example informations

Header file

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

Code Example

// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
if(inImageBufferType != pInImg->getBufferType())
pInImg = convertImg(pInImg, inImageBufferType);
ImagePtr pOutImg = zoom2dImg(pInImg, xScaleFactor, yScaleFactor, interpolationMethod);