670 likes | 891 Views
Introduction to Computer Vision Lecture 10 Chapter 6: Geometric Transformations. Speaker: Yuheng Wang Email: yxw9636@rit.edu Date: 01/26 /2012. Outline. Geometric Transformation Theory Linear transformations Affine transformations Projective transformations Matlab Implementation.
E N D
Introduction to Computer VisionLecture 10Chapter 6: Geometric Transformations Speaker: Yuheng Wang Email: yxw9636@rit.edu Date: 01/26 /2012
Outline • Geometric Transformation Theory • Linear transformations • Affine transformations • Projective transformations • Matlab Implementation
Geometric Transformations • Original Image
Geometric Transformations • Scaling
Geometric Transformations • Rotation
Geometric Transformations • Affine Transformation
Geometric Transformations • Projective Transformation
Coordinate Mapping • Transformation: (x, y) = T{(w, z)} T(w, z) y z x w f(w, z) g(x, y )
Coordinate Mapping • Transformation: (w, z) = T-1{(x, y)} T-1 (x, y) z y w x f(w, z) g(x, y )
(w, z)= (2x, 2y) Textbook Page 280 Figure 6.2 (x, y)= (w/2,z/2) Transformations: (x, y) = T{(w, z)} = (w/2,z/2) (w, z) = T-1{(x, y)} = (2x, 2y)
Linear Transformations • An operation than change the figure in some way, can be either or a combination of: • Translation: “slide” • Rotation: “turn” • Reflection: “flip” • Reference: • http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/geometry//geo-tran.html
Translation • Move the object without changing the image size and orientation
Rotation • Turn the object about around certain fixed point (the rotation center) Rotation Center
Reflection • Flip the object over a line (the line of reflection) Line of Reflection
Method to implement transformations Find coordinates (x, y) of the original image Use the transformation rule to change original coordinates (x, y) to (x’, y’) Show the new image using (x’, y’)
Translation x’= x + 4 y’= y - 1 y 0 x
Rotation theta = 90o y 0 x
Reflection y 0 x
Scaling y 0 x
Scaling • multiplying each of its • coordinates by a scalar y x 0
Overall workflow Find coordinates (x, y) of the original image Use the transformation rule to change original coordinates (x, y) to (x’, y’) Show the new image using (x’, y’)
Mathematical Definition • A geometric transformation is a matrix(vector) T that maps the pixel (x, y) to a new position (x’, y’) x’ = Tx(x, y) y’=Ty(x, y)
Linear Transformations • Recall: • x’ = Tx(x, y) y’=Ty(x, y) • Polynomial Format • Matrix Format Transformation Matrix T
Affine Transformations • Recall: • x’ = Tx(x, y) y’=Ty(x, y) • Polynomial Format • Matrix Format Transformation Matrix T
Affine Transformations • Perceptually, Affine Transformations are linear combinations of • Translation • Rotation • Scaling
LinearTransformations y • Rotation x 0
LinearTransformations y • Scaling x 0
LinearTransformations y • Reflection along X-axis x 0
LinearTransformations • Reflection along Y-axis y x 0
Linear Transformations • Shearing along X-axis y x 0
LinearTransformations • Shearing along Y-axis y x 0
AffineTransformations y • Rotation x 0
Affine Transformations • Scaling y x 0
Affine Transformations y • Shearing x 0
Affine Transformations y • Reflection x 0
Affine Transformations y • Translation x 0
Summary Translation Scaling Rotation Shearing
Textbook Page 286 Table 6.1 Summary
Vanishing Point Horizon Line Vanishing Point
Matlab Implementation • Transformation Techniques • Affine Transformations • Projective Transformations • Matlab Implementation • function maketform • function imtransform
help maketform • maketform Create spatial transformation structure (TFORM). • T = maketform(TRANSFORMTYPE,...) creates a multidimensional spatial transformation structure (a 'TFORM struct') that can be used with TFORMFWD, TFORMINV, FLIPTFORM, IMTRANSFORM, or TFORMARRAY. TRANSFORMTYPE can be 'affine', 'projective', 'custom', 'box', or 'composite'. Spatial transformations are also called geometric transformations. • ……
Several Forms • T = maketform('affine',A); • T = maketform('affine',U,X); • T = maketform('projective',A); • T = maketform('projective',U,X); • T = maketform('custom',NDIMS_IN,NDIMS_OUT, FORWARD_FCN,INVERSE_FCN, TDATA);
T = maketform('custom',NDIMS_IN, NDIMS_OUT,FORWARD_FCN,INVERSE_FCN, TDATA • Parameters • NDIMS_IN and NDIMS_OUT are the numbers of input and output dimensions. • FORWARD_FCN and INVERSE_FCN are function handles to forward and inverse functions. • TDATA can be any MATLAB array and is typically used to store parameters of the custom transformation. It is accessible to FORWARD_FCN and INVERSE_FNC via the "tdata" field of T.
help imtransform • imtransform Apply 2-D spatial transformation to image. • B = imtransform(A,TFORM) transforms the image A according to the 2-D spatial transformation defined by TFORM, which is a tform structure as returned by MAKETFORM or CP2TFORM. If ndims(A) > 2, such as for an RGB image, then the same 2-D transformation is automatically applied to all 2-D planes along the higher dimensions. • ……
clear all, close all, clc Im = checkerboard(50); figure, imshow(Im), axis on; title('Original Checkerboard');
Im = imread('cameraman.tif');figure, imshow(Im), axis on;title(‘Fig.1. Original Gray Scale Image'); axis on
Matlab for Scaling sx=0.5; sy=1; Tscale=[sx 0 0; 0 sy 0; 0 0 1]; tScale=maketform('affine',Tscale); ImScale=imtransform(Im, tScale); figure, imshow(ImScale), axis on; title('Scaled Checkerboard'); Textbook Page 289