Image Warping: Prof. Eric Miller Elmiller@ece - Tufts.edu
Image Warping: Prof. Eric Miller Elmiller@ece - Tufts.edu
Fall 2007
Lecture 10-1
Rotate Translate
Scale
Fall 2007
Lecture 10-2
Overview
Seems like this should not be that hard to do In the end it is not, but getting there takes some thought Up to now we have been modifying the values of the pixels Now we are going to mess with the coordinates of the pixels Not surprisingly, this is going to take some mathematics
Fall 2007 EN 74-ECE Image Processing Lecture 10-3
Matlab Preliminaries
From here on out I want to think of an image as a sampled version of a 2D function centered at the origin located in the unit square with side length = 1; It just becomes easier to do things this way mathematically The Matlab becomes a bit more trouble
f = imread([imbase,'engineer.tif']); f = double(f); [nr nc] = size(f); x = linspace(-0.5,0.5,nc)'; y1 = linspace(-0.5,0.5,nr)'; y = ipud(y1); gure(1);clf;colormap gray imagesc(x,y,f);axis square;axis xy
Fall 2007
Lecture 10-4
Translation
f(x,y) g(x,y) (p,q) (x,y)
Basically, p and q define a new coordinate system for the image Image g is equal to image f evaluated in this new coordinate system
Fall 2007 EN 74-ECE Image Processing Lecture 10-5
Fall 2007
Lecture 10-6
A Bit on Interpolation
When we compute all the (p,q) pairs where we want to find f, odds are they will not correspond to places where we already know f Interpolation = procedure for taking the data where we know it and getting values for f where we need it Most basic forms:
Data at diamond = value of f at closest circle Data at diamond = average of close by fs
Fall 2007 EN 74-ECE Image Processing Lecture 10-7
Matlab Interpolation
Original coordinates built using meshgrid New coordinates built from meshgrid-ed X and Y
Fall 2007
Lecture 10-8
Rotation Transformation
Fall 2007
Lecture 10-9
Uniform Scaling
Scale by a factor of s>0
Nonuniform scaling
Less stretch near origin and more further away? More stretch near origin and more further away?
Fall 2007
Lecture 10-11
Nonuniform Rotation
Fall 2007
Lecture 10-12
Fall 2007
Lecture 10-13
Homework
Develop a Matlab function for creating a thumbnail of a given image. Verify that it works Create a movie of an image that is simultaneously rotating and shrinking What happens if we replace r in the nonuniform scaling and rotation by the following functions
Fall 2007
Lecture 10-14