scalar = | otsuThreshold (inImg) |
scalar = | otsuThreshold (inImg,histogram) |
Computation of the binary threshold on one image, using Otsu method.
Otsu's method 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). It then calculates the optimal threshold that separates these 2 classes, by minimizing their intra-class variance. In this implementation, the alternate method (maximizing the inter-classes variance) is used. It has the advantage to be faster than the first method.
- See also
- http://en.wikipedia.org/w/index.php?title=Otsu%27s_method&oldid=617320940 for more details.
Example of Python code :
Example imports
import PyIPSDK
import PyIPSDK.IPSDKIPLBinarization as bin
Code Example
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
otsuThresholdValue = bin.otsuThreshold(inImg)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLBinarization/Processor/OtsuThreshold/OtsuThreshold.h>
Code Example
ipReal64 outThresholdValue = otsuThreshold(pInImg);
const ipReal64 min = 50.;
const ipReal64 max = 250.;
const ipReal64 fBinWidth = 2.;
ipReal64 outThresholdValue_manualHisto = otsuThreshold(pInImg, pHistogramData);