IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit

Computation of the binary threshold on one image, using Kittler method. More...

IPSDKIPLBINARIZATION_API ipReal64 ipsdk::imaproc::bin::kittlerThreshold (const ipsdk::image::ImageConstPtr &pInImg)
 wrapper function for Kittler binary threshold on one image More...
 
IPSDKIPLBINARIZATION_API ipReal64 ipsdk::imaproc::bin::kittlerThreshold (const ipsdk::image::ImageConstPtr &pInImg, const ipsdk::imaproc::attr::HistogramDataPtr &pHistogram)
 wrapper function for computing the Kittler threshold on one image, using the histogram provided as argument More...
 

Detailed Description

Computation of the binary threshold on one image, using Kittler method.

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*}

Where $P_i$ is the cumulated histogram for the class $i = \left\{1, 2\right\}$ and $sigma_i$ is the associated standard deviation :

\begin{eqnarray*} P_1(t) = & \sum_{i=1}^{t}{h(i)} \qquad & P_2(t) = \sum_{i=t+1}^{N}{h(i)}\\ \mu_1(t) = & \sum_{i=1}^{t}{\frac{h(i) \times i}{P_1(t)}} \qquad & \mu_2(t) = \sum_{i=t+1}^{N}{\frac{h(i) \times i}{P_2(t)}}\\ \sigma_1(t) = & \frac{\sum_{i=1}^{t}{h(i) \times (i-\mu_1(t))^2}}{P_1(t)} \qquad & \sigma_2(t) = \frac{\sum_{i=t+1}^{N}{h(i) \times (i-\mu_2(t))^2}}{P_2(t)} \end{eqnarray*}

With $N$ being the number of pixel in the image and $h(i)$ the histograme value for the intensity $i$.

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

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InOutOptHistogram [InOut Optional] histogram properties X
ipsdk::imaproc::attr::OutThreshold [Output] threshold value for image binarization X

Global Rule description

Global rule description for algorithm :
ipsdk::processor::none ()

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
kapurThresholdValue = bin.kittlerThreshold(inImg)

Example of C++ code :

Example informations

Associated library

IPSDKIPLBinarization

Header file

Code Example

// open input image
ImageGeometryPtr pInputImageGeometry = geometry2d(inType, sizeX, sizeY);
ImagePtr pInImg = loadRawImageFile(inPath, *pInputImageGeometry);
// Sample calculating automatically the histogram
// ----------------------------------------------
// compute Kittler threshold associated to input image
ipReal64 outThresholdValue = kittlerThreshold(pInImg);
// Sample with the histogram as input parameter
// ----------------------------------------------
// Set the histogram parameters
const ipReal64 min = 50.;
const ipReal64 max = 250.;
const ipReal64 fBinWidth = 2.;
HistoMsrParamsPtr pHistoPrms = createHistoMsrParamsWithBinWidth(min, max, fBinWidth);
// Compute the histogram
HistogramDataPtr pHistogramData = histogramMsr(pInImg, pHistoPrms);
// compute otsu threshold associated to input image
ipReal64 outThresholdValue_manualHisto = kittlerThreshold(pInImg, pHistogramData);
See also
KittlerThresholdLvl1

Function Documentation

◆ kittlerThreshold() [1/2]

IPSDKIPLBINARIZATION_API ipReal64 ipsdk::imaproc::bin::kittlerThreshold ( const ipsdk::image::ImageConstPtr pInImg)

wrapper function for Kittler binary threshold on one image

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

wrapper function for computing the Kittler threshold on one image. In this version of the function, the histogram of the image is automatically computed, with a bin width of 1.0

Note
the binarized image is not computed
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ kittlerThreshold() [2/2]

IPSDKIPLBINARIZATION_API ipReal64 ipsdk::imaproc::bin::kittlerThreshold ( const ipsdk::image::ImageConstPtr pInImg,
const ipsdk::imaproc::attr::HistogramDataPtr pHistogram 
)

wrapper function for computing the Kittler threshold on one image, using the histogram provided as argument

Note
the binarized image is not computed
Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure