convolveFFT  
Top  Previous  Next

convolveFFT ( integer Input, integer Kernel, integer Output [, integer Mode =0 ] )

Use this function to apply an FFT-based linear convolution or de-convolution to an image or selection. A user-defined kernel is used in the operation. While equivalent to the regular convolution, the FFT convolution is performed in the frequency rather than in the spatial domain. It also assumes that the image wraps around at edges, so the left edge is contiguous with the right and the top edge is contiguous with the bottom. Using FFT convolution is recommended for large kernels that cannot be supplied to the regular convolution due to the Overscan restriction or speed inefficiency.

Applying this function in the inverse mode will result in the linear de-convolution of the image.

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 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.  
 
Mode  
 
An optional boolean integer specifying whether the direction of the operation. Must be one of the following values:  
M_DIRECT – the function is applied in the direct mode (convolution)  
M_INVERSE – the function is applied in the inverse mode (de-convolution).  
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 applies a 113x113 lowpass filter to a sample image using the FFT convolution and then converts the result back to the original image by applying de-convolution.  
 
setCurDir ("samples")  
loadIm (1,"sample4.iwd")  
createIm(2,IM_GRAY,113,113,1)  
convolveFFT(1,2,3,M_DIRECT)  
convolveFFT(3,2,4,M_INVERSE)