Home | | Schedule | | Assignments | | Lecture Notes
The purpose of this lab is to practice working with a real image, convolving an image with an operator, in preparation for detecting edges.
The M-Files and images that you need for this lab are contained in the assign2
subdirectory in the
csci363/assignments/assign2
directory. Create an assign2 directory
in your csci363 directory. (You will need the same files you create in this lab for
your second assignment, so you can keep all the files for the lab in the
assign2 directory). You can copy the files from the csci363 directories
using the cp command in LINUX. First change directories into your assign2 directory.
Then type:
cp ~csci363/assignments/assign2/* .
Note that the period at the end is required (it tells LINUX to name the files the same
name as the original file had). In MATLAB, set your
Current Directory to the assign2
folder.
In assignment 2, you will write functions to detect the zero crossings obtained from the convolution of a real image with Laplacian-of-Gaussian convolution operators of different size. In this lab, you will load in the image and convolve it with two different sized Laplacian of Gaussian operators to see the different effects of this convolution.
To begin this process, load in the image, yacht.jpg, and use imtool to view it:
>> yacht = imread('yacht.jpg');
>> imtool(yacht);
In the next steps you will convolve the image with a laplacian of a Gaussian.
Double click on the file, laplacian.m
and examine the function,
laplacian(w)
. This creates a 2D function that is the Laplacian of
a Gaussian function, where the width of the central positive region is given by
w
. Make two of these functions, one of size 4 and one of size 8, and
view them by creating a 3D graph, using the surf
function. The following
commands allow you to do this.
>> lap4 = laplacian(4);
>> lap8 = laplacian(8);
>> surf(lap4);
>> surf(lap8);
Note that you may have to bring the window labeled "Figure 1"
to the front
to view the functions. To view both graphs at the same time, open a new Figure window by
choosing "New" -> "Figure" from Matlab's FILE menu before you display the second graph. This
will cause the second graph to be displayed in the second figure window.
Next you can view what happens to the image when you convolve it with laplacian operators
of different size. The file, conv2D.m
, contains a function that will convolve
an image with a specified operator. Open the file in an editor window and note how the function
works. Next, convolve the yacht image with each of your filters, and display the results using
imtool. You can perform the convolution with the following statements:
conv4 = conv2D(yacht, lap4);
conv8 = conv2D(yacht, lap8);
Use imtool
to view the convolved images. How do they differ in appearance?
Start work on assignment 2.
Write the 2 functions described in Problems 1a and 1b of assignment 2 in lab.
Close all of the open windows by executing the following two commands in the Command Window:
close all
imtool close all
When you are done, quit out of MATLAB by selecting Quit MATLAB
from the
File menu.
Home | | Schedule | | Assignments | | Lecture Notes
Constance Royden--croyden@holycross.edu
Computer Science 363--Computational Vision
Last Modified: September 22, 2016
Page Expires: Auguest 24, 2017