Homework 4
16-311 Introduction to Robotics
Prof. Howie Choset
Due on 3:30 PM, Wednesday February 8th
- (70%) Group: Dead Reckoning
- (30%) Individual: Convolution.
Individual Work (but learning from each other is encouraged)
-
Write a C or MATLAB program to perform convolution (if you want to use another language, ask me but it is probably fine).
If written in MATLAB you should use only very basic functions and operators. The ''conv'' function is right out. If in doubt, write your own version of the function in question, or ask the head TA.
Your program should
input two pgm file names from the keyboard: one for the image and one for
the mask. It should save the result as "output.pgm".
Write a function that convolves the mask with the image.
The
size of the input and output images should be the same. To make things
easier, you will not have to worry about padding the edges of the input
image, as discussed in class. Instead, we will just accept that the
right-most and bottom-most pixels in the output image will be "wrong."
In other words, if the input image has r rows and
c columns and the mask has m rows and n columns, the output image
will have r rows and c columns but the first r-m+1 rows and c-n+1 columns
will have the output. Simply put zeros in the remaining rows and columns.
- Use your program to perform convolution on these two images with
each of the three masks provided for a total of six output images. Make a web page which shows these six images.
Be sure to do a contrast operation after the convolution, so that the values range from 0-255!
- Also answer the following questions.
- (a) What do these masks do to the input image?
- (b) What are the advantages of using a small mask? Why would you want to
use a large mask?
- (c) Suppose you wanted to identify the horizon in images at sea. What
mask might you use to do this?
- Some sample code based on last week's code is here.
A note:
There may be some confusion about the FlipMask routine in the code
provided for homework 4. Basically, this routine takes the input mask and
rotates it about the origin by 180 degrees. Why? Well, as you might
remember from class, convolution technically requires the mask to be
flipped. If you don't flip the mask, the operation is called correlation.
Many members of the vision community use the two interchangeably, which is
why we told you not to worry about flipping the mask. In the starter code
provided, we flipped the mask. You can opt to simply comment this out or
you can use the convensional/signal processing version of convolution and
flip the mask -- it is your choice. However, for the masks and images
provided, it really doesn't make much difference--do you know why? Please
be careful; it is easy to get confused, but resolving this confusion will
have a nice payoff!
Turn in:
Email the head TA with:
- A link to your web page (which has your images and a POINTER to your source code)
- A link to an AFS path with your executable or matlab script. The andrew unix machines have matlab installed, so you can test your code there using X-frowarding, or by running "matlab -nodesktop" which will give you a matlab command prompt and you can type the name of your executable there. As usual make sure I have permissions. If you use matlab, I'll need read permissions for your scripts and also write permissions in your folder so I can save the output image.
- Answers to the above questions (in the e-mail and/or on your webpage. Use a .pdf if you want anything other than text).
Last updated 1/26/10 by Alan Kraut