Keywords: front-page

## Lab: DFT: Linear Convolution

[Exercises] [Workspace]

Purpose: The purpose of this lab exercise is to experiment with linear convolution in the spatial and frequency domains.

Activities:

1. Read the image $DIP/data/gull.kdf, reduce it to 1/2 its size (shrink), zero pad it to 256x256 and display it. Use the following operators: User defined, Shrink, Pad, and Display Image.

   1. Glyphs:Input/Output:Data Files:User defined
   2. Glyphs:Data Manip:Size & Region Operators:Shrink
   3. Glyphs:Data Manip:Size & Region Operators:Pad
   4. Glyphs:Visualization:Non-Interactive Display:Display Image

2. Read the Laplacian convolution kernel, $DIP/data/laplacian.ascii, and zero pad it to the same dimensions as the input image, using User defined and Pad operators. Print the values of the original kernel using the File Viewer operator. The kernel is stored as a 3x3 matrix in ASCII, and can be read automatically by Khoros operators (therefore, it is not necessary to use a import operator to read it).

   1. Glyphs:Input/Output:Data Files:User defined
   2. Glyphs:Input/Output:Information:File Viewer
   3. Glyphs:Data Manip:Size & Region Operators:Pad

3. Take the forward Fourier transform of both the image and the zero padded kernel, and multiply the results. Now take the inverse Fourier transform, extract the real part, and display the result. This is convolution in the frequency domain. Use the FFT, Multiply, Real Part and Display Image operators.

   1. Glyphs:Arithmetic:Linear Transforms:FFT
   2. Glyphs:Arithmetic:Two Operand Arithmetic:Multiply
   3. Glyphs:Arithmetic:Complex Operators:Real Part
   4. Glyphs:Visualization:Non-Interactive Display:Display Image

4. Perform the spatial domain convolution of the Laplacian kernel with the shrink/padded image, and display the result. Use operators LinearOp (Linear Operator) and Display Image.

   1. Glyphs:Arithmetic:Linear Transforms:LinearOp (Linear Operator)
   2. Glyphs:Visualization:Non-Interactive Display:Display Image

5. Take the absolute difference between the results obtained by convolving in the frequency domain and by convolving in the spatial domain. Determine the maximum difference between these two methods using the Statistics operator.

   1. Glyphs:Arithmetic:Two Operand Arithmetic:Absolute Diff
   2. Glyphs:Visualization:Non-Interactive Display:Display Image
   3. Glyphs:Data Manip:Analysis & Information:Statistics
   4. Glyphs:Input/Output:Information:File Viewer

Exercises

1. Suggest another method for performing linear convolution where the output dimensions are the same as the original input image.
2. Perform the same experiment but with different kernels (low pass, high pass).
3. What happens if no zero padding is performed?
4. Experiment with different images.

Khoros Workspace
Execute the visual program c6s3convolution-fft.wk