convolve
Top  Previous  Next

convolve ( integer Input, integer Kernel, integer Output [, integer Norm =1 ] )

Use this function to apply a linear convolution to an image or selection. A user-defined kernel is used in the operation. The kernel is a matrix of coefficients, which are multiplied by each pixel and its neighbors and then summed to produce a resultant value. The result is placed in the output image at the location of the original pixel. This operation is applied to all pixels in the input image by moving the kernel across the image pixel by pixel. Mathematically it is described as

   convolve

where
K is the kernel matrix of (2m+1)(2n+1) dimensions.

The kernel is supplied to the function as a grayscale image whose pixel intensities are used as matrix coefficients.

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.  
 
Mask  
 
An integer between 1 and 116 specifying the frame number of the grayscale image that contains the convolution kernel. The size of the kernel in either dimension must not exceed 2*Overscan+1. The Overscan setting is defined in ImageWarp Preferences. The image must be one of the following types: 8-bit, 16-bit, 32-bit, and floating point.  
 
Output  
 
An integer between 1 and 116 specifying the output image frame number. Values in the range of 100-116 correspond to hidden frames.  
 
Norm  
 
An optional boolean integer specifying whether the output image will be normalized. Must be one of the following values:  
FALSE – no normalization will be performed  
TRUE - the values of pixels in the output image will be normalized by being divided by the sum of the kernel coefficients.  
Default value: FALSE  
 
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 applies a custom convolution filter to it:  
 
setCurDir ("kernels")  
loadIm (101,"ShadowE.iwd")  
do  
grabim(0)  
convolve(0,101,1)  
loop  
loop