IPSDK 0.2
IPSDK : Image Processing Software Development Kit
imageroundImg (inRealImg,inConvertImageBufferType)

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

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

Header file

#include <IPSDKIPL/IPSDKIPLArithmetic/Processor/RoundImg/RoundImg.h>

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);