Download presentation
Presentation is loading. Please wait.
1
Homework 4 Notes Connelly Barnes COS 323
2
MATLAB Semicolon at endline suppresses output. >> [1 2] ans = 1 2 >> [1 2];
3
Images imread(filename) reads image as: –h x w (greyscale) or –h x w x 3 (color) –uint8, values in [0, 255]. Do alignment in greyscale, doubles. A=double(imread(filename)); if size(A,3)==3 A = rgb2gray(A); end imshow(A) with double A assumes colors are in [0, 1]. So divide by 255 before imshow() at some point.
4
Image Transform imtransformSimple(A, [x y θ]) => Transformed image with same size as A.
5
Image Transform >> imshow(A);
6
Image Transform >>imshow(imtransformSimple(A,[100 0 pi/4]));
7
Parts of Assignment Paradigm: Write an error function, then minimize that function. Part 1: Image difference –F(x, y, theta) => Error –Want to minimize error. Part 2: Minimization –Minimizing a function of n variables is a well-studied problem, general solutions are known.
8
Image Difference Find sum squared difference on region where images overlap.
9
Image Difference Overlap region image 1's region. So in image 1's coordinates, can represent overlap region with a mask, 1 = overlap, 0 = no overlap.
10
Mask
11
If A, B are pair of images, then imtransformSimple(B, [x y θ]) transforms image B. To find mask, transform array of all ones with same parameters.
12
Image Difference Now follow directions of assignment: use mask to find sum squared difference. Use.* (element-wise product) operator, not * (matrix product) when multiplying mask against an image.
13
Minimization Given F(x, y, θ) (F: R 3 → R). Find vector [x y θ] minimizing F. If smooth, can find local minimum by general algorithm. So treat F as a black box and solve minimization independently of the previous part. Golden Section search finds local minimum of 1D function. Do Golden Section search for dimensions i=1, 2, 3, then repeat => taxicab minimization.
14
Minimization For convenience, loop over the dimension i that you're minimizing via Golden Section search (write F as a vector function). Extra credit: plot [x, y, θ] points that the algorithm searches over in 3D (use plot3() ), observe zig-zagging of taxicab minimization.
15
Merge Results Use mergeImages(A, B, [x y θ]) to get merged image. Use color.
16
Caveats Minimization finds a local minimum. Not necessarily the global minimum. x F Local Global
17
Solution Start with a good guess (gets full credit on this assignment). If F is quadratic, can solve exactly via a linear system. Not so in our case. General solution is to start with many random guesses (extra credit).
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.