ImageEn, unit ievision

TIEVisionImage.threshold

TIEVisionImage.threshold


Declaration

function threshold(thresh: double; maxval: double; threshType: TIEVisionThresholdType): double; safecall;


Description

Applies a fixed-level threshold to each pixel element.

Returns the computed threshold value when ievTHRESH_OTSU or ievTHRESH_TRIANGLE is specified.

Note: Pixel format of input image must be ie8g.

Parameter Description
thresh Threshold value (this is not needed if ievTHRESH_OTSU or ievTHRESH_TRIANGLE is used)
maxval Maximum value to use with the THRESH_BINARY and THRESH_BINARY_INV thresholding types
threshType Thresholding type. Optionally, you can OR the type with ievTHRESH_OTSU to use the optimal threshold value determined by Otsuís algorithm


Demo

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr


Example

// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );

  

// Apply a fixed-level threshold to each pixel element
ImageEnView1.IEBitmap.PixelFormat := ie8g;
ImageEnView1.IEBitmap.GetIEVisionImage().threshold( 0, 255, ievTHRESH_BINARY or ievTHRESH_OTSU );
ImageEnView1.Update();

// Thresholding values above 127
ImageEnView1.IEBitmap.PixelFormat := ie8g;
ImageEnView1.IEBitmap.GetIEVisionImage().threshold( 127, 255, ievTHRESH_BINARY );
ImageEnView1.Update();