-
Book Overview & Buying
-
Table Of Contents
GPU-Accelerated Computing with Python 3 and CUDA
By :
In this section, a spatial-domain convolutional filter for 2D grayscale images is implemented. The convolution operation is very common in signal and image processing. It will be used to blur an image and to enhance edges.
In a spatial-domain convolution, a small (e.g., 3×3 or 5×5) array, also called a kernel (not to be confused with a CUDA kernel), is slid across the image. The kernel weights and the corresponding image pixel values are multiplied, and the corresponding products are summed up. The sum is stored in the output pixel that corresponds to the kernel position.
Spatial domain versus frequency domain convolution
Mathematically, the convolution is equivalent to a multiplication in Fourier (frequency) space. Therefore, convolutions can also be calculated by multiplying the 2D Fourier transforms of the inputs and taking the inverse Fourier transform of the product. For images of comparable size, convolution in Fourier...