CSCI 363 Computational Vision--Spring 2023

    Lab 2

    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.

    Make sure to have Professor Royden check off the images and functions you create in this lab before you leave lab.

    Processing a real image

    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.

    Before you leave the lab:

    Have Professor Royden check you off for the following images completed in lab:
    • Graph of the Laplacian of a Gaussian of size 4
    • Graph of the Laplacian of a Gaussian of size 8
    • Image of the yacht convolved with the size 4 Laplacian operator
    • Image of the yacht convolved with the size 8 Laplacian operator
    • Your function to compute the locations of zero crossings (zc.m)
    • Your function to compute the slopes of zero crossings (zeros2D.m)

    Close all of the open windows by executing the following two commands in the Command Window:

       close all
       imtool close all

    Quit MATLAB

    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: February 8, 2023
    Page Expires: February 8, 2024