Homework 4 Notes - PowerPoint PPT Presentation

About This Presentation
Title:

Homework 4 Notes

Description:

Homework 4 Notes Connelly Barnes COS 323 MATLAB Semicolon at endline suppresses output. [1 2] ans = 1 2 [1 2]; Images imread(filename) reads image as: h x ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 18
Provided by: prin129
Category:

less

Transcript and Presenter's Notes

Title: Homework 4 Notes


1
Homework 4 Notes
  • Connelly Barnes
  • COS 323

2
MATLAB
  • Semicolon at endline suppresses output.
  • gtgt 1 2
  • ans
  • 1 2
  • gtgt 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.
  • Adouble(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 ?) gt
  • Transformed image with same size as A.

5
Image Transform
  • gtgt imshow(A)

6
Image Transform
  • gtgtimshow(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) gt 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
Mask
  • 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 R3 ? 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 i1, 2,
    3, then repeat gt 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.

F
Local
Global
x
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).
Write a Comment
User Comments (0)
About PowerShow.com