The CONVOL_FFT function computes the convolution of an image using a product of Fourier transforms for speed. Because this algorithm uses Fourier transforms, complex numbers are used during the calculations. The returned result will either be a Float or a Double, and may differ from the CONVOL routine if Byte or Integer data are used.

Examples


 
; Sample image
array = READ_PNG(FILEPATH('mineral.png', $
  SUBDIRECTORY=['examples','data']))
 
; Edge detection kernel
kernel = [ [0,1,0],[-1,0,1],[0,-1,0] ]
 
; Convolution
result = CONVOL_FFT(array, kernel)
 
; Display images
im1 = IMAGE(array, LAYOUT=[2,1,1], RGB_TABLE=39, $,
  TITLE='Original Image')
im2 = IMAGE(result, LAYOUT=[2,1,2], /CURRENT, $
  TITLE='Processed with CONVOL_FFT')

Syntax


Result = CONVOL_FFT( Image, Kernel [, /AUTO_CORRELATION] [, /CORRELATE] [, IMAGE_FFT=value] [, KERNEL_FFT=value] [, /NO_PADDING] )

Return Value


Returns the result of the convolution as a Float or Double type.

Arguments


IMAGE

A two-dimensional array containing the input image. During the computation the image is padded with zeros so the kernel does not overlap one edge of the image with the opposite side of the image.

KERNEL

A two-dimensional array containing the kernel (or point spread function) to be used in calculating the convolution. To avoid shifting the resulting image, the kernel should be symmetric around the center point.

Keywords


AUTO_CORRELATION

Set this keyword to compute the auto correlation function of the image, which is the convolution of the image with itself. If this keyword is set, the value of Kernel is ignored.

CORRELATE

Set this keyword to use the Fourier transform of the Kernel to compute the cross-correlation of the image and the Kernel.

IMAGE_FFT

Set this keyword to the Fourier transform of Image (as returned in a previous call to CONVOL_FFT). If IMAGE_FFT is set to a named variable, the Fourier transform of Image is returned so that it can be used in future calculations.

KERNEL_FFT

Set this keyword to the Fourier transform of Kernel (as returned in a previous call to CONVOL_FFT). If KERNEL_FFT is set to a named variable, the Fourier transform of Kernel is returned so that it can be used in future calculations.

NO_PADDING

Set this keyword to prevent padding of the image with zeros. This will decrease the memory usage of the function, but may introduce artifacts at the edges of the result.

Note: The size of the returned IMAGE_FFT or KERNEL_FFT arrays depends upon the setting of NO_PADDING, and cannot be passed back in if the NO_PADDING setting is different than when the arrays were created.

Version History


8.1

Introduced

See Also


CONVOL, BLK_CON