Synopsis
HxImageRep HxThreshold (HxImageRep img, HxValue level)
Input
HxImageRep img
HxValue level
Description
The function HxThreshold compares each pixel value with the given value of level. If the pixel value is smaller than `level' the corresponding pixel in the output image has value zero, otherwise the corresponding pixel in the output image has value one. The function HxThreshold only works for scalar images.
Remarks
Examples
Thresholding an image
#include "HxImageRepGlobalFuncs.h" #include "HxImageRep.h" HxImageRep HxThresholdExample1(HxImageRep img) { img = HxImageAsDouble(img); img = HxContrastStretch(img, 255.0); img = HxThreshold(img, 32.0); // 128.0 img = HxContrastStretch(img, 255.0); img = HxImageAsByte(img); return img; } int main(int argc, char* argv[]) { HxImageRep img = HxMakeFromFile(argv[1]); img = HxThresholdExample1(img); HxWriteFile(img, argv[2]); return 0; }
Input image for the HxThreshold example.
Output image of the HxThreshold example.
In this example we threshold an image, with threshold value 128.
See also
Keywords
Threshold, Segmentation,