

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A problem set for cmsc 426 students, focusing on image matching and transformation. The tasks include writing code to find the sum of square differences between rectangular portions of images (sum of squared differences, ssd), comparing a small template to an image in all possible translations using ssd, and finding the best instances of the template in the image. Additionally, there are challenge problems to make the code faster by building a gaussian pyramid and starting the matching at a small scale, and to find the 3d coordinates of points in an image and align them with given coordinates.
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


The class web page contains an image and a template that you can download. Your goal is to find the regions in the image that best match the template.
a) Write code to find the sum of square differences between two rectangular portions of images that are of equal size. d = SSD(R1, R2) should take two matrices representing portions of images and return the SSD between them. Test your function on:
R1 = [1, 0, 0, 2; 2, 1, 0, 1]; R2 = [0, 2, 1, 1; 1, 0, 0, 1];
Turn in your result and code. Hint: You should do this without using any loops, just with matrix operations. If you use loops, you may find that your subsequent code is very slow. 40 pts
b) Write code to compare a small template to an image in all possible translations of the template, computing the SSD. Only consider translations that place the template completely inside the image. A=brute_force_ssd(T,I) should return a matrix, A, that gives the SSD between T and a subset of I, for every possible shift of T. You only need to shift T by integer values, don’t worry about interpolation. Test your code using the template and image from the web page. Display and print the result A with the command imagesc(A). Turn in this display and your code. 30 pts.
c) Now write code to find the best instances of the template in the image. The best instance is the one that positions the template in the image to minimize the SSD. The second best one has minimal SSD of all templates that don’t overlap the best one (if you don’t watch this condition, your second best template will probably be shifted one pixel from your best template; not a useful result). Display the position of the six best, non- overlapping instances of the template in the image. You can visualize the position of the templates as you like. For example, you might use a matlab command to draw six red rectangles on top of the image, each the size and position of the template. Turn in a plot of your results and your code. 30 pts.
Experiment with starting the matching at different scales. How small a scale can you start with and still get good results?
Turn in pictures showing the Gaussian pyramid for the template and the image. Turn in pictures showing the six best templates you found, at the largest scale. Turn in several of these pictures, illustrating how the results vary depending on the scale you begin matching. Use the functions tic and toc to measure the speedup you gained with multiscale matching, and report the results. Also turn in your code. 20 pts.