IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Algorithm allowing to resize a 2d image. More...

IPSDKIPLGEOMETRICTRANSFORM_API image::ImagePtr ipsdk::imaproc::gtrans::zoom2dImg (const image::ImageConstPtr &pInImg, ipReal64 xZoomFactor, ipReal64 yZoomFactor, const ipsdk::imaproc::attr::eZoomInterpolationMethod &interpolationMethod)
 wrapper function for image 2d zoom algorithm More...
 
IPSDKIPLGEOMETRICTRANSFORM_API image::ImagePtr ipsdk::imaproc::gtrans::zoom2dImg (const image::ImageConstPtr &pInImg, ipReal64 zoomFactor, const ipsdk::imaproc::attr::eZoomInterpolationMethod &interpolationMethod)
 wrapper function for image 2d zoom algorithm More...
 
IPSDKIPLGEOMETRICTRANSFORM_API void ipsdk::imaproc::gtrans::zoom2dImg (const image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::eZoomInterpolationMethod &interpolationMethod, const image::ImagePtr &pOutImg)
 wrapper function for image 2d zoom algorithm More...
 
IPSDKIPLGEOMETRICTRANSFORM_API void ipsdk::imaproc::gtrans::zoom2dImg (const image::ImageConstPtr &pInImg, ipReal64 xZoomFactor, ipReal64 yZoomFactor, const ipsdk::imaproc::attr::eZoomInterpolationMethod &interpolationMethod, const image::ImagePtr &pOutImg)
 wrapper function for image 2d zoom algorithm More...
 

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

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InZoomInterpolationMethod [Input] interpolation method for image zoom algorithms X
ipsdk::imaproc::attr::InOptOutputImg2dSize [Input Optional] expected output image 2d size X
ipsdk::imaproc::attr::InOptScaleFactor2d [Input Optional] 2d scale factor X
ipsdk::imaproc::attr::OutImg [Output] image for processing operation customOutput (_pOutImg, outputZoom2d(_pInImg,_pInOptScaleFactor2d,_pInOptOutputImg2dSize))

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::noInSitu (_pInImg,_pOutImg) && 
ipsdk::processor::If (
 ipsdk::processor::isSet (_pInOptOutputImg2dSize),
 ipsdk::processor::Not (
  ipsdk::processor::isSet (_pInOptScaleFactor2d)),
 ipsdk::processor::isSet (_pInOptScaleFactor2d)) && 
ipsdk::imaproc::matchSize (eMatchImageSizeType::eMIST_ZCT,_pInImg,_pOutImg) && 
ipsdk::imaproc::customImageProperty (_pOutImg,
 matchZoom2d (_pInImg,_pInOptScaleFactor2d,_pInOptOutputImg2dSize))

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

Associated library

IPSDKIPLGeometricTransform

Header file

Code Example

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

Function Documentation

◆ zoom2dImg() [1/4]

IPSDKIPLGEOMETRICTRANSFORM_API image::ImagePtr ipsdk::imaproc::gtrans::zoom2dImg ( const image::ImageConstPtr pInImg,
ipReal64  xZoomFactor,
ipReal64  yZoomFactor,
const ipsdk::imaproc::attr::eZoomInterpolationMethod interpolationMethod 
)

wrapper function for image 2d zoom algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ zoom2dImg() [2/4]

IPSDKIPLGEOMETRICTRANSFORM_API image::ImagePtr ipsdk::imaproc::gtrans::zoom2dImg ( const image::ImageConstPtr pInImg,
ipReal64  zoomFactor,
const ipsdk::imaproc::attr::eZoomInterpolationMethod interpolationMethod 
)

wrapper function for image 2d zoom algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ zoom2dImg() [3/4]

IPSDKIPLGEOMETRICTRANSFORM_API void ipsdk::imaproc::gtrans::zoom2dImg ( const image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::eZoomInterpolationMethod interpolationMethod,
const image::ImagePtr pOutImg 
)

wrapper function for image 2d zoom algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ zoom2dImg() [4/4]

IPSDKIPLGEOMETRICTRANSFORM_API void ipsdk::imaproc::gtrans::zoom2dImg ( const image::ImageConstPtr pInImg,
ipReal64  xZoomFactor,
ipReal64  yZoomFactor,
const ipsdk::imaproc::attr::eZoomInterpolationMethod interpolationMethod,
const image::ImagePtr pOutImg 
)

wrapper function for image 2d zoom algorithm

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure