CS7321 Winter 1998
Problem Set Zero Solution
By Alan Daniels

The Assignment

The purpose of this assignment was to help us get familiar with MatLab. Here are the steps we were to follow:
  1. Take a picture of ourself using an IndyCam.
  2. Convert it from being RGB to being grayscale.
  3. Crop the image so that it only contains your face.
  4. Try various image processing functions to see what they do.
  5. Save the results as TIFFs, and convert to GIFs or JPEGs.
    (Note: I tried to save as GIFs, but MatLab 5.1 doesn't seem to support this).
Input Image Operations Output Image
The RGB Version. Converted to JPEG using imgworks on SGI.
Converted form RGB to grayscale, and cropped so that it only shows my head.
[rr gg bb] = tiffread('face.tif');
ii = rgb2gray(rr, gg, bb);
ii = imcrop(ii);
imwrite(ii, 'face1.tif', 'tif');
This is the grayscale image after applying the Hsv colormap, using the Colormap function. Sort of what I would look like after a nuclear explosion.
ii = imread('face1.tif');
imshow(ii);
colormap(hsv(256));
imwrite(ii, hsv(256), 'face2.tif', 'tif');
This is the grayscale image after applying the Hot colormap, using the Colormap function. Similar to how I might feel on a hot day...
ii = imread('face1.tif');
imshow(ii);
colormap(hot(256));
imwrite(ii, hot(256), 'face2.tif', 'tif');
This is an application of a Prewitt horizonal edge-emphasising filter. You have to scale back to a zero-to-one range after the filter.
ii = imread('face1.tif', 'tif');
hh = fspecial('prewitt');
i2 = filter2(hh, ii)/255;
i3 = i2 - min(min(i2)); %% Move the min to 0.
i3 = i3 / max(max(i3)); %% Scale from 0 to 1.
imwrite(i3, 'face4.tif', 'tif');
This is an application of a two-dimensional Laplacian operator. It does edge detection, but seems to wash everything out.
ii = imread('face1.tif', 'tif');
hh = fspecial('prewitt');
i2 = filter2(hh, ii)/255;
i3 = i2 - min(min(i2)); %% Move the min to 0.
i3 = i3 / max(max(i3)); %% Scale from 0 to 1.
imwrite(i3, 'face5.tif', 'tif');
This uses the Average filter to blur out the picture. Note that I used a 7x7 filter, since a 3x3 doesn't do much.
ii = imread('face1.tif', 'tif');
hh = fspecial('average', 7);
i2 = filter2(hh, ii)/255;
i3 = i2 - min(min(i2)); %% Move the min to 0.
i3 = i3 / max(max(i3)); %% Scale from 0 to 1.
imwrite(i3, 'face6.tif', 'tif');
Here, I used the RoiPoly function to select out my face from the rest of the background. Then, I multiplied this times the original picture, to cut out the background. We have to convert to "double" since the multiplication doesn't work on integer arrays.
ii = imread('face1.tif', 'tif');
rr = roipoly;
ii = double(ii);
rr = double(rr);
i2 = ii .* rr;
imwrite(i2, 'face7.tif', 'tif');