Horus Doc || Global Function Guide || General documentation   | Function documentation  

HxThreshold

Synopsis

HxImageRep HxThreshold (HxImageRep img, HxValue level)

Input

HxImageRep img
The image you want to threshold.

HxValue level
The threshold 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

Valid input images
The input image should be a scalar image.

Valid level values
The level should be a scalar.

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

exampleImage1.gif

Input image for the HxThreshold example.

HxThresholdResult1.gif

Output image of the HxThreshold example.

In this example we threshold an image, with threshold value 128.

See also

HxTriStateThreshold,

Keywords

Threshold, Segmentation,


Generated on Mon Jan 27 15:45:02 2003 for GlobalFunctionGuide by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001