IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Round values of a floating point image algorithm. More...

IPSDKIPLARITHMETIC_API image::ImagePtr ipsdk::imaproc::arithm::roundImg (const image::ImageConstPtr &pInRealImg, const image::eImageBufferType &inConvertImageBufferType)
 wrapper function for Round values of a floating point image More...
 
IPSDKIPLARITHMETIC_API void ipsdk::imaproc::arithm::roundImg (const image::ImageConstPtr &pInRealImg, const image::ImagePtr &pOutImg)
 wrapper function for Round values of a floating point image More...
 

Detailed Description

Round values of a floating point image algorithm.

This algorithm allows to round values of a floating point image to an integer target type.

Output image values are given by :

\[ OutImg[i] = round(InImg[i]) = \begin{cases} floor(InImg[i] + 0.5) & \text { if } InImg[i] >= 0 \\ floor(InImg[i] - 0.5) \text { otherwise} \end{cases} \]

Note
In case of a floating point output image, input image is simply copied without modification.
See also
http://en.wikipedia.org/wiki/Floor_and_ceiling_functions

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InRealImg [Input] image for processing operation (data contained in image buffer are reals) X
ipsdk::imaproc::attr::InConvertImageBufferType Input image buffer type parameter for image type convertion operation. X
ipsdk::imaproc::attr::OutImg [Output] image for processing operation ipsdk::imaproc::duplicateInOut (_pOutImg, _pInRealImg, _pInConvertImageBufferType)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSize (_pInRealImg,_pOutImg) && 
ipsdk::imaproc::bufferType (_pOutImg,_pInConvertImageBufferType)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLArithmetic as arithm

Code Example

# opening of input image
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# image bounding
outImg = arithm.roundImg(inImg, PyIPSDK.eImageBufferType.eIBT_UInt8)

Example of C++ code :

Example informations

Associated library

IPSDKIPLArithmetic

Header file

Code Example

// create input image
boost::shared_ptr<MemoryImage> pInImg(boost::make_shared<MemoryImage>());
ImageGeometryPtr pGeometry = geometry2d(eImageBufferType::eIBT_Real32, 512, 512);
pInImg->init(*pGeometry);
// fill it with random values
randomImg(createRange(20.0, 200.0), pInImg);
// apply image rounding
ImagePtr pOutImg = roundImg(pInImg, eImageBufferType::eIBT_UInt8);
See also
RoundImgLvl1
RoundImgLvl2
RoundImgLvl3

Function Documentation

◆ roundImg() [1/2]

IPSDKIPLARITHMETIC_API image::ImagePtr ipsdk::imaproc::arithm::roundImg ( const image::ImageConstPtr pInRealImg,
const image::eImageBufferType inConvertImageBufferType 
)

wrapper function for Round values of a floating point image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ roundImg() [2/2]

IPSDKIPLARITHMETIC_API void ipsdk::imaproc::arithm::roundImg ( const image::ImageConstPtr pInRealImg,
const image::ImagePtr pOutImg 
)

wrapper function for Round values of a floating point image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure