Homework 5

Welcome to the fifth homework assignment. For this week you will be creating a image manipulation suite in Matlab. We will be focusing on three areas of image manipulation: filtering, rotation, and flipping. All the functions of this homework will be working with Matlab's RGB images, the array of m by n pixels with A(m,n) as a three element vector with the red, green, and blue color values. For this assignment, you may not use any included Matlab functions that directly solve the problem such as Matlab's image manipulation functions similar to the ones you are creating. See your book for more information on images.

 


 

Part 1

When we filter an image, we remove certain colors or combinations of colors from the image. Create a function called "hw5filter" that takes in four arguments. The first argument will be the array representing the image to filter. The next three arguments will be true/false values representing whether or not we want to include the red, green, and blue components respectively. You should return an RGB image array representing the filtered image. For example, consider the following image:

 

 

We can load the image into a 3 dimensional array "A" with the Matlab function "imread".

If we make the following calls to hw5filter, we get back an array representing filtered images like so:

B = hw5filter(A,1,1,1)

B = hw5filter(A,1,0,0)

B = hw5filter(A,0,1,0)

B = hw5filter(A,0,0,1)

B = hw5filter(A,1,0,1)

B = hw5filter(A,0,0,0)

 


 

Part 2

Create a function called hw5rotate that will rotate an image by 90 degree increments. The function takes in two arguments: an array representing an image to be rotated, and a scalar integer value representing the number of times to rotate the image by 90 degrees. If n is negative, rotate the image |n| times to the left. If n is positive, rotate it |n| to the right. For example:

B = hw5rotate(A,1)

B = hw5rotate(A,2)

B = hw5rotate(A,4)

B = hw5rotate(A,-1)

B = hw5rotate(A,-5)

 


 

Part 3

Lenna.mat is a black and white image which means Matlab represents the image with a two dimensional array.  Each value is scaled between 0 (black) and 255 (white).  Load the image of Lenna using the MATLAB command load 'lenna.mat'.  The result will be a multidimensional array, xx in your workspace. Write the function hw5flip(image), which returns a transformed version of the original image, like so:


Original Image.

After running the flip function, the image returned would be this:


Flipped Image.

Your hw5flip function should work with any image of a format that Matlab can work with.

To assist you in this homework, the function show_img has been provided for you to use with lenna.mat. Type "help show_img" for more information.

 


Turn In

Be sure each of your Matlab files has the appropriate header information. Also create a test script for your three functions. Your test script should thoroughly test each of the three functions with an image of your choice and either display the results of each test in a separate figure or write the resulting images to their own files.

Turn in the following to WebCT:




*Lenna is a digitized Playboy centerfold, from November 1972, and is one of the most widely used standard test images used for compression algorithms. Source: http://www.lenna.org.

*show_img Source: http://users.ece.gatech.edu/~dspfirst/