contour
Top  Previous  Next

contour ( integer Input, integer Output , integer Mode, integer Probe )

Use this function to extract contours of objects in an image or selection. The function is based on the morphological gradient which works by combining the original image with the results of the
erode or dilate functions. The way these images are combined depends on the Mode chosen. The shape and size of the neighborhood pattern for the operation 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.  
 
Mode  
 
An enumerated integer that describes the mode in which the function operates. Must be one of the following values:  
 
M_INTERNAL=0 – extracts the internal contours of objects by subtracting the eroded image from the original one.  
M_EXTERNAL=1 – extracts the external contours of objects by subtracting the original image from the one.  
M_BOTH=2 – extracts both the internal and external contours of objects by subtracting the eroded image from the dilated one.  
 
Probe  
 
An enumerated integer that describes the shape and size of the kernel used in the operation. Select one of the following frequently used shapes:  
 
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)  
PR_CROSS=5 – cross 3x3  
PR_DCROSS=10 – diagonal cross 3x3  
PR_SQUARE=15 – square 3x3  
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 binarizes a sample image and extracts the internal contours of objects:  
 
setCurDir ("samples")  
loadIm (1,"sample4.iwd")  
threshold(1,1,M_PRESET,0.,113.,TRUE,FALSE)  
contour(1,2,0,15)