IPSDK 0.2
IPSDK : Image Processing Software Development Kit
Isodata Threshold computationSee full documentation
scalarisoDataThreshold (inImg)

Detailed Description

computation of iso data threshold on one image

Isodata-based method, also known as Ridler-Calvard method [1] [2], is used to automatically perform the binarization of an input image. It assumes that the image is bi-modal (pixel intensities can be distinguished in 2 classes: background pixels and foreground pixels) and calculate the optimal threshold that separates these 2 classes. This algorithm was proposed by Ridler-Calvard in 1978 , and defines the threshold $T$ as the equidistant value between the average intensities of both classes:

\[ T = \frac{\bar{I}_B + \bar{I}_F}{2} \]

Where $\bar{I}_B$ is the mean intensity of the background pixels and $\bar{I}_F$ is the mean intensity of the foreground pixels.

An admissible threshold is close to the bin $b_i$, used to define the background and foreground classes:

\[ \vert T - H\left[ b_i \right] \vert < W \left( b_i \right) \]

Where $H\left[ b_i \right]$ is the histogram value for the bin $b_i$ and $W \left( b_i \right)$ is the width of this bin.

If thresholds are found, the algorithm retains the minimum and maximum thresholds respecting the previous assertion and returns the mean value between their average.

On the contrary, if no threshold has been found, the algorithm returns NumericLimits<ipsdk::ipReal64>::max().

References

[1] "Picture Thresholding Using an Iterative Selection Method", T. W. Ridler and S. Calvard, IEEE Transactions on Systems, Man, and Cybernetics, pages 630-632, August 1978

[2] "Survey over image thresholding techniques and quantitative performance evaluation", M. Sezgin and B. Sankur, Journal of Electronic Imaging, pages 146-168, January 2004

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
isoDataThresholdValue = bin.isoDataThreshold(inImg)

Example of C++ code :

Example informations

Header file

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

Code Example

// open input image
ImageGeometryPtr pInputImageGeometry = geometry2d(inType, sizeX, sizeY);
ImagePtr pInImg = loadRawImageFile(inPath, *pInputImageGeometry);
// Sample calculating automatically the histogram
// ----------------------------------------------
// compute otsu threshold associated to input image
ipReal64 isodataThresholdValue = isoDataThreshold(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 isodataThresholdValue_manualHisto = isoDataThreshold(pInImg, pHistogramData);