IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Kittler Threshold binarizationSee full documentation
outImg,outThresholdkittlerThresholdImg (inImg)
scalarkittlerThresholdImg (inImg,outBinImg)
outImg,outThresholdkittlerThresholdImg (inImg,histogram)
scalarkittlerThresholdImg (inImg,histogram,outBinImg)

Detailed Description

Compute the Kittler threshold of an input image, and binarize the image using this threshold.

Kittler's method is used to automatically perform the binarization of an input image [1]. It assumes that the image is bi-modal (pixel intensities can be distinguished in 2 classes: background pixels and foreground pixels and that each mode can be approximated by a Gaussian. It then calculates the optimal threshold $t$ that separates these 2 classes, by minimizing the error :

\begin{eqnarray*} E & = & 1 + 2*(P_1(t)*\log(\sigma_1(t)) + P_2(t)*\log(\sigma_2(t)))\\ & & \quad - 2*(P_1(t)*\log(P_1(t)) + P2(t)*\log(P_2(t))) \end{eqnarray*}

See also
Kittler Threshold computation for more details about this error function.

On output, binarized image values are given by:

\[ OutBinImg[i] = \begin{cases} 1, & \text{if } InImg[i] \geq KittlerThreshold \\ 0, & \text{otherwise} \end{cases} \]

with $KittlerThreshold$ the threshold computed from Kittler's method.

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

Here is an example of automatic Kittler image thresholding applied to a 8-bits grey level image (on ouput, computed threshold equals 65) :

kittlerThresholdImg.png

[1] Kittler, J. & Illingworth, J. Minimum error thresholding Pattern Recognition, 1986, 19, 41 - 47

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLBinarization as bin

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# otsu threshold computation
outImg, kittlerThresholdValue = bin.kittlerThresholdImg(inImg)

Example of C++ code :

Example informations

Header file

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

Code Example

// open input image
ImageGeometryPtr pInputImageGeometry = geometry2d(inType, sizeX, sizeY);
ImagePtr pInImg = loadRawImageFile(inPath, *pInputImageGeometry);
// Sample with a generated output image
// ------------------------------------
// compute thresholded output image
KittlerResult kittlerResult = kittlerThresholdImg(pInImg);
// 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);
// compute thresholded output image
ipReal64 fOutThreshold = kittlerThresholdImg(pInImg, pOutImg);