threshTrim
Top  Previous  Next

threshTrim ( integer Input, integer Output, integer Channel, integer Left, integer Right
[, integer Invert =0, floating& Lev1, floating& Lev2 ] )  

Use this function to automatically separate objects of interest from the background by defining a threshold range based on trimming an image histogram at the end points. For color images thresholding can be performed on the luminance, hue or saturation channel. The function creates a binary output image and returns calculated thresholds.

Parameters
 
Input  
 
An integer between 0 and 116 specifying the input image frame number. A value of 0 represents the DMA memory buffer of the video device. Values in the range of 100-116 correspond to hidden frames.  
 
Output  
 
An integer between 1 and 116 specifying the output image frame number. Values in the range of 100-116 correspond to hidden frames.  
 
Channel  
 
An enumerated integer specifying the color channel that will be used for histogram analysis and thresholding. Must be one of the following values:  
 
TH_LUMINANCE=0 – separate the objects of interest based on the intensity distribution.  
TH_HUE=1 – separate the objects of interest based on the color pigment distribution.  
TH_SATURATION=2 - separate the objects of interest based on the color saturation distribution.  
 
This parameter is disregarded for grayscale images.  
 
Left, Right     
 
Floating variables or constants specifying the percentage of pixels that will be ignored at the left-most and right-most histogram bins.  
 
Invert  
 
An optional boolean integer that defines if the foreground range should be inverted. Must be one of the following values:  
 
FALSE=0 – normal mode of thresholding. The pixels whose values fall within the range between the calculated threshold levels will be treated as foreground ones, while the pixels with values outside the range will be treated as background ones.  
TRUE=1 – inverted mode of thresholding. The pixels whose values fall within the range between the calculated threshold levels will be treated as background ones, while the pixels with values outside the range will be treated as foreground ones.  
Default value: FALSE  
 
Lev1, Lev2  
 
Optional floating variables that return the minimum and maximum levels calculated from the histogram analysis and used for thresholding. The number of variables submitted should correspond to the amount of phases specified by the Phases argument.  

Error flags

ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  

Example

This set of statements continuously grabs an image and binarizes it using the trimming of the histogram:  
 
do  
grabim(110)  
threshTrim(110,1,TH_LUMINANCE,5,0)  
loop