1 of 6 LAB 5: IMAGE FILTERING ECE180: Introduction to Signal Processing OVERVIEW You have recently learned about the convolution sum that serves as the basis of the FIR filter difference equation. The filter coefficient sequence {šš} ā equivalent to the filterās impulse response ā[š] ā may be viewed as a one-dimensional moving window that slides over the input signal š„[š] to compute the output signal š¦[š] at each time step. Extending the moving window concept to a 2-D array that slides over an image pixel array provides a useful and popular way to filter an image. In this lab project you will implement two types of moving-window image filters, one based on convolution and the other based on the median value of the pixel grayscale values spanned by the window. You will also gain experience with the built-in image convolution filter imfilter. OUTLINE 1. Develop and test a 3ļ“3 median filter 2. Develop and test a 3ļ“3 convolution filter 3. Evaluate the median and convolution filters to reduce noise while preserving edges 4. Study the behavior of various 3ļ“3 convolution filter kernels for smoothing, edge detection, and sharpening 5. Learn how to use imfilter to convolution-filter color images, and study the various mechanisms offered by imfilter to deal with boundary effects PREPARATION ā TO BE COMPLETED BEFORE LAB Study these tutorial videos: 1. Nested āforā loops -- http://youtu.be/q2xfz8mOuSI?t=1m8s (review this part) 2. Functions -- http://youtu.be/0zTmMIh6I8A (review as needed) Ensure that you have added the ECE180 DFS folders to your MATLAB path, especially the āimagesā and āmatlabā subfolders. Follow along with the tutorial video http://youtu.be/MEqUd0dJNBA, if necessary. LAB ACTIVITIES 1. Develop and test a 3ļ“3 median filter function: 1.1. Implement the following algorithm as the function med3x3: TIP: First implement and debug the algorithm as a script and then convert it to a function as a final step. Use any of the smaller grayscale images from the ECE180 āimagesā folder as you develop the function, or use the test image X described in the Step 1.2. (a) Create the function template and save it to an .m file with the same name as the function, (b) Accept a grayscale image x as the function input, http://youtu.be/q2xfz8mOuSI?t=1m8s http://youtu.be/0zTmMIh6I8A http://youtu.be/MEqUd0dJNBA 2 of 6 (c) Copy x to the output image y and then initialize y(:) to zero; this technique creates y as the same size and data type as x, (d) Determine the number of image rows and columns (see size), (e) Loop over all pixels in image x (subject to boundary limits): ļ® Extract a 3ļ“3 neighborhood (subarray) about the current pixel, ļ® Flatten the 2-D array to a 1-D array, ļ® Sort the 1-D array values (see sort), ļ® Assign the middle value of the sorted array to the current output pixel, and (f) Return the median-filtered image y. 1.2. Enter load lab_5_verify to load the