Description
1) Perform Gaussian smoothing on affleck_gray.png (or affleck_gray_flip.png). Try
with multiple sigma values, starting with larger values (e.g., from 20 to .5). When
does the face become recognizable to your friends? [2 pts]
sigma=1.0; % use different values
G = fspecial(‘gaussian’, 2*ceil(3*sigma)+1, sigma);
faceIm=double(imread(‘affleck_gray.png’));
gIm = imfilter(faceIm, G, ‘replicate’);
imshow(gIm/255); % double images need range of 0-1
imwrite(uint8(gIm), ‘gIm.bmp’);
NOTE: If you choose to use Python, find similar function calls/operators.
2) Write a function to compute and display the 2D Gaussian derivative masks Gx and
Gy for a given sigma. Sample the Gaussian derivative/gradient (2D) equation
directly (see class notes) at the appropriate x,y locations. Note: each mask is a square
2D matrix. [3 pts]
[Gx, Gy] = gaussDeriv2D(sigma);
3) Compute and display the gradient magnitude of an image (search the web for an
interesting image; convert to grayscale if necessary; make sure to upload the image
with your code in the Carmen submission). [2 pts]
gxIm = Imfilter(Im, Gx, ‘replicate’);
gyIm = Imfilter(Im, Gy, ‘replicate’);
magIm = sqrt(gxIm.^2 + gyIm.^2);
imagesc(magIm);
4) Threshold and display the magnitude image with different threshold T levels. [2 pts]
tIm = magIm > T;
imagesc(tIm);
[next page]
5) Compare the above results with the Sobel masks. [2 pts]
Fx = -fspecial(‘sobel’)’;
fxIm = imfilter(Im,Fx);
Fy = -fspecial(‘sobel’);
fyIm = imfilter(Im,Fy);
magIm = sqrt(fxIm.^2 + fyIm.^2);
tIm = magIm > T;
imagesc(tIm);
6) Run the MATLAB canny edge detector, edge(Im,’canny’), on your image and display
the default results. How does it compare? [2 pts]
7) Turn in all code, test images, printouts of images, and discussion of results. Make a
HW2.m script to do the above tasks and call needed functions. Upload your code and
selected images to Carmen. [2 pts]