saltPepper
Top  Previous  Next

saltPepper ( integer Input, integer Output, integer Size, floating Level [, integer Mode =0,
integer Type =0 ] )  

Use this function to remove the salt & pepper type of noise from an image. The filter is based on the "top hat" technique that treats a pixel intensity as an elevation of a surface. Any pixel that protrudes through the "crown of the hat" which height is defined by a value of Level, is considered to be noise and replaced by the mean value under the "brim of the hat". This effectively removes bright noise (salt) from the image. The inverse procedure suppresses the dark noise (pepper).

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.  
 
Size  
 
An integer between 1 and 3 specifying the radius of the "hat" used in the function.  
 
Level  
 
A floating variable or constant specifying the height of the "hat's crown". Any pixel that differs from the pixels under the "brim" by more than this value is considered to be noise.  
 
Mode  
 
An enumerated integer specifying whether the noise should be removed or extracted. Must be one of the following values:  
 
M_REMOVE=0 – removes salt & pepper noise from the image.  
M_SELECT=1 – extracts salt & pepper noise from the image.  
Default value: M_REMOVE  
 
Type  
 
An enumerated integer specifying the type of noise to be processed. Must be one of the following values:  
 
M_SALT=0 – removes or extracts the bright noise.  
M_PEPPER=1 – remove or extracts the dark noise.  
Default value: M_SALT  
 
Example

This set of statements applies an impulse noise to a sample image and then suppresses the noise by applying the salt&pepper filter two times:  
 
setCurDir("samples")  
loadIm (1,"sample14.iwd")  
genImpulse (1,1,50)  
saltPepper (1,2,1,0,M_SALT)  
saltPepper (2,2,1,0,M_PEPPER)