topHat
Top  Previous  Next

topHat ( integer Input, integer Output, integer Iterations, integer Probe )

Use this function to detect small bright regions in an image or selection. The top-hat transformation works by subtracting the result of the
open operator from the original image. The shape and size of the neighborhood pattern which could be interpreted as the "brim of the hat" is selected with the Probe parameter.

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.  
 
Iterations  
 
A positive integer specifying how many times the operation will be applied.  
 
Probe  
 
An enumerated integer that describes the shape and size of the kernel used in the operation. The value is determined as a combination of four basic shapes constructed of 3 pixels:  
 
PR_VBAR=1 – vertical bar  
PR_BKSLASH=2 – diagonal bar (top left – bottom right)  
PR_HBAR=4 – horizontal bar  
PR_FWSLASH=8 –diagonal bar (bottom left – top right)  
 
The following frequently used shapes represent combinations of the basic shapes:  
 
PR_CROSS=5 – cross 3x3  
PR_DCROSS=10 – diagonal cross 3x3  
PR_SQUARE=15 – square 3x3  
 
You can also assign one kernel of size 5x5:  
 
PR_CIRCLE=16 – circle 5x5  
 
Error flags

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

Example
 
This set of statements adds an impulse noise to a sample image and then removes it by using the TopHat operator followed by BottomHat.  
 
setColorSpace(CS_RGB)  
setCurDir ("samples")  
loadIm (1,"sample14.iwd")  
genimpulse (1,1,200,50)  
tophat(1,101,PR_CROSS,1)  
subIm(1,101,102,0)  
bottomhat(102,101,PR_CROSS,1)  
addIm(102,101,2,0)