IPSDK 4.1
IPSDK : Image Processing Software Development Kit
Simple Threshold binarization
imagedarkThresholdImg (inImg,inMaxThreshold)
imagelightThresholdImg (inImg,inMinThreshold)
imagethresholdImg (inImg,inMinThreshold,inMaxThreshold)

Detailed Description

Binarize an input image by thresholding, given minimum and maximum input thresholds.

On output image values are given by:

\[ OutBinImg[i] = \begin{cases} 1, & \text{if } InThresholdMin \leq InImg[i] \leq InThresholdMax \\ 0, & \text{otherwise} \end{cases} \]

(with $InThresholdMin$ and $InThresholdMax$ corresponding to the minimum and maximum output thresholds)

Input and output images must have same size and buffer type.

Warning
The behaviour of this algorithm is undetermined if InThresholdMin or InThresholdMax is out of input image data type range.

Here is an example of a binary threshold operation applied to an 8-bits grey levels input image (with $InThresholdMin=127$ and $InThresholdMax=200$):

thresholdImg.png
See also
http://en.wikipedia.org/wiki/Thresholding_%28image_processing%29

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLBinarization as bin

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# threshold computation
outImg = bin.thresholdImg(inImg, 50, 127)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLBinarization/Processor/ThresholdImg/ThresholdImg.h>

Code Example

// open input image
ImageGeometryPtr pInputImageGeometry = geometry2d(inType, sizeX, sizeY);
ImagePtr pInImg = loadRawImageFile(inPath, *pInputImageGeometry);
// Sample with a generated output image
// ------------------------------------
// thresholding of input image
ImagePtr pAutoOutImg = thresholdImg(pInImg, fInMinThreshold, fInMaxThreshold);
// Sample with a provided output image
// -----------------------------------
// create output image
ImageGeometryPtr pOutputImageGeometry = geometry2d(eImageBufferType::eIBT_Binary, sizeX, sizeY);
boost::shared_ptr<MemoryImage> pOutImg(boost::make_shared<MemoryImage>());
pOutImg->init(*pOutputImageGeometry);
// thresholding of input image
thresholdImg(pInImg, fInMinThreshold, fInMaxThreshold, pOutImg);