medialAxis
Top  Previous  Next

medialAxis ( integer Input, integer Output , integer Probe [, integer Mode =0 ] )

Use this function to perform the medial axis transform of a binary image or selection. The function works by finding local maxima on the
Distance Transform of the image, thus extracting those pixels equidistant from the boundaries of objects. The size and shape of the neighborhood kernel used in the operation is selected with the Probe parameter. The values in the output image represent the distances to the boundaries of the original objects and can be used to find their maximum and minimum widths. The operator could be inverted, restoring the original binary objects from their medial axes.

Parameters
 
Input  
 
An integer between 1 and 116 specifying the input image frame number. 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.  
 
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  
 
Mode  
 
An enumerated integer that describes the direction of the transform:  
 
M_DIRECT – performs the medial axis transform reducing objects to single pixels.  
M_INVERSE – performs the inverse transform which restores the original binary image from the result of its direct transform.  
Default value: M_DIRECT  
 
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 performs the direct medial axis transform and then restores the binary image by applying the inverse transform:  
 
setCurDir ("samples")  
loadIm(1,"sample4.IWD")  
threshGauss(1,1,0,1,0)  
medialAxis(1,2, PR_SQUARE, M_DIRECT)  
medialAxis(2,3, PR_SQUARE,M_INVERSE)