Keywords: front-page

## Lab: Inverse Filtering

[Exercises] [Workspace]

Purpose: The purpose of this lab experiment is to demonstrate the basic concept of image restoration. In this example, the blurring function, and therefore, the inverse function, are known.

Activities:

1. Get the float type blurred image $DIP/data/lenina-blur-float.kdf and display it using the operators User defined and Display Image.

   1. Glyphs:Input/Output:Data Files:User defined
   2. Glyphs:Visualization:Non-Interactive Display:Display Image

2. Take the forward FFT of the image, use FFT operator (unity scaling), and display its spectrum using the Display Image operator.

   1. Glyphs:Arithmetic:Linear Transforms:FFT
   2. Glyphs:Visualization:Non-Interactive Display:Display Image

3. Read in the blurring kernel, $DIP/data/gauss-kernel-21x1.ascii, and plot it using the Display 2D Plot operator. This kernel is a 1D signal, width = 21.

   1. Glyphs:Input/Output:Data Files:User defined
   2. Glyphs:Visualization:Plot Display:Display 2D Plot

4. Take the forward FFT of the blurring kernel and display it. First zero extend it to the size of the blurred image. Use the Pad operator and then apply the FFT.

   1. Glyphs:Data Manip:Size & Region Operators:Pad
   2. Glyphs:Arithmetic:Linear Transforms:FFT
   3. Glyphs:Visualization:Non-Interactive Display:Display Image

5. Find the reciprocal of the kernel DFT using the operator Divide Into. Display the DFT of the inverse filter.

   1. Glyphs:Arithmetic:Two Operand Arithmetic:Divide Into
   2. Glyphs:Visualization:Non-Interactive Display:Display Image

6. Multiply the DFT of the blurred image with the inverse filter using the operator Multiply. Display the result using the Display Image operator.

   1. Glyphs:Arithmetic:Two Operand Arithmetic:Multiply
   2. Glyphs:Visualization:Non-Interactive Display:Display Image

7. Finally, take the inverse DFT of the last result (scale by 1/N), determine its magnitude using the Magnitudes operator, and display the result.

   1. Glyphs:Arithmetic:Linear Transforms:FFT
   2. Glyphs:Arithmetic:Complex Operators:Magnitudes
   3. Glyphs:Visualization:Non-Interactive Display:Display Image

8. Create and save an "Inverse Filtering" Procedure.

   1. Select all glyphs except those created in Step 1 (User defined and Display Image). Select the glyphs by placing the mouse cursor in the workspace, pressing the mouse button, and dragging it across the workspace to draw a "rubberband" around the glyphs you want to select. When you release the mouse button, the selected glyphs will have a dark black border. If not all of the glyphs that you need were selected, select additional ones by pressing down the "Shift" key, and while it is depressed, use the mouse to select additional glyphs.
   2. Create the procedure by opening the Control:Create Procedure cantata menu.
   3. Change the name of the procedure to "Inverse Filter" by placing the mouse cursor over the "Procedure" title and clicking. When the "new Icon Name" form comes up, type in the new procedure name and select "OK".
   4. To save the procedure, delete all the other glyphs, leaving only the procedure glyph in cantata. Save the workspace with the File:Save As menu.
   5. Clear the workspace for the next lesson.

Khoros Workspace
Execute the visual program c7s1inverse.wk