image = | darkThresholdImg (inImg,inMaxThreshold) |
image = | lightThresholdImg (inImg,inMinThreshold) |
image = | thresholdImg (inImg,inMinThreshold,inMaxThreshold) |
Binarize an input image by thresholding, given minimum and maximum input thresholds.
On output image values are given by:
(with
and
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
and
):
- 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
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
outImg = bin.thresholdImg(inImg, 50, 127)
Example of C++ code :
Example informations
Header file
#include <IPSDKIPL/IPSDKIPLBinarization/Processor/ThresholdImg/ThresholdImg.h>
Code Example
ImagePtr pAutoOutImg = thresholdImg(pInImg, fInMinThreshold, fInMaxThreshold);
boost::shared_ptr<MemoryImage> pOutImg(boost::make_shared<MemoryImage>());
pOutImg->init(*pOutputImageGeometry);
thresholdImg(pInImg, fInMinThreshold, fInMaxThreshold, pOutImg);