by: diako mardanbegi, phd student. transformation and projective geometry computer vision: relative...

82
Geometric Transformation & Projective Geometry by: Diako Mardanbegi, PhD student

Post on 19-Dec-2015

223 views

Category:

Documents


4 download

TRANSCRIPT

  • Slide 1
  • by: Diako Mardanbegi, PhD student
  • Slide 2
  • Transformation and Projective Geometry Computer Vision: Relative movement of a camera Object locations wrt. Camera Graphics Describe objects and cameras in a scene and how they should move in 3D scene. User interfaces (like WPF) relies heavy placing components relative to each other (2D) and for its 3D graphics engine.
  • Slide 3
  • Outline 2-D Transformations Representing Transformations Homogeneous form Multiple frames Cartesian Coordinate System Describe a local frame Orientation Translation Mapping between multiple frames 3-D Transformations Euler angles Quaternion Projective coordinate system Homography
  • Slide 4
  • 2-D Translation xx yy
  • Slide 5
  • Slide 6
  • 2-D Rotation about the origin
  • Slide 7
  • Rotation about the origin a b
  • Slide 8
  • 2-D Rotation about the origin Rotation about the origin ab
  • Slide 9
  • 2-D Rotation about a specified point
  • Slide 10
  • Rotation about a specified point o a b d c
  • Slide 11
  • 2-D Scaling relative to the origin Vertical shift proportional to vertical position Horizontal shift proportional to Horizontal position
  • Slide 12
  • 2-D Scaling relative to the origin Scaling relative to the origin a b
  • Slide 13
  • 2-D Scaling relative to a specified point Scaling relative to a specified point
  • Slide 14
  • Representing transformations Trick of additional coordinate makes this possible to express all transformations in a common linear form Old way: Cartesian coordinates N ew way: With additional coordinate (Homogeneous coordinates),,,
  • Slide 15
  • Representing transformations In homogeneous form homogeneous transformation: linear transformation of homogeneous coordinates x = H x
  • Slide 16
  • from Cartesian coordinates to Homogeneous coordinates from Homogeneous coordinates to Cartesian coordinates
  • Slide 17
  • Advantages Easy to compose multiple transformations after each other Combination of all transformations into a single matrix
  • Slide 18
  • Advantages for example :General 2-D Pivot-Point Rotation o a b d c
  • Slide 19
  • Inverse of transformations Easy to invert
  • Slide 20
  • Transformations Don t Commute ba
  • Slide 21
  • b a
  • Slide 22
  • Other 2-D transformations Reflection Shear 2
  • Slide 23
  • Homography matrix Full-generality 3 x 3 homogeneous transformation
  • Slide 24
  • Homography matrix Full-generality 3 x 3 homogeneous transformation Translation components
  • Slide 25
  • Homography matrix Full-generality 3 x 3 homogeneous transformation Scale/rotation components
  • Slide 26
  • Homography matrix Full-generality 3 x 3 homogeneous transformation Shear/rotation components
  • Slide 27
  • Homography matrix Full-generality 3 x 3 homogeneous transformation Homogeneous scaling factor
  • Slide 28
  • Homography matrix Full-generality 3 x 3 homogeneous transformation When these are zero (as they have been so far), H is an affine transformation
  • Slide 29
  • Why we are using only one fixed Cartesian system? Why we dont define a local coordinate system? o a b d c
  • Slide 30
  • We can do it, but first know about: What is exactly a cartesian coordinate system? How to describe a local frame in a fixed frame? How to express a point in each frame?
  • Slide 31
  • Cartesian Coordinate System A coordinate system in R n is defined by an origin o and n orthogonal basis vectors In R 3, positive direction of each axis X, Y, Z is indicated by unit vector i, j, k Let P = (x, y, z) T be a point in R 3 Coordinate is length of projection of vector from origin to point onto axis basis vector What do these values mean? x-axis y-axis z-axis O. P ? i j k
  • Slide 32
  • Vector Projection The projection of vector a onto u is that component of a in the direction of u
  • Slide 33
  • X Y. P A X Y B
  • Slide 34
  • Describe a local frame in a fixed frame X Y X Y homogeneous form : orientation of frame B relative to A A,BA,B X Y X Y A,BA,B A X Y X Y ( x, y) B : translation of frame B relative to A
  • Slide 35
  • Mapping from frame to frame X Y X Y. P A B A MappingTransformation
  • Slide 36
  • Slide 37
  • Definition: If a = (x a, y a, z a ) T and b = (x b, y b, z b ) T, then: c = a x b = (y a z b -z a y b, z a x b - x a z b, x a y b - y a x b ) T c is orthogonal to both a and b (direction given by right-hand r with magnitude k = i xjk = i xj Going from 2D to 3D Vector cross product
  • Slide 38
  • 3-D Translation P = T. P
  • Slide 39
  • 3-D Scaling
  • Slide 40
  • 3-D Rotation In 2-D, we are always rotating in the plane of the image, but in 3-D the axis of rotation itself is a variable Three canonical rotation axes are the coordinate axes X, Y, Z
  • Slide 41
  • 3-D Rotation Similar to 2-D rotation matrices, but with coordinate corresponding to rotation axis held constant
  • Slide 42
  • 3-D Rotation When object is to be rotated about an axis that is parallel to one of the coordinate axes
  • Slide 43
  • 3-D Rotation When an object is to be rotated about an axis that is not parallel to one of the coordinate axes Easiest way ?!
  • Slide 44
  • A B Orientation in 3-D
  • Slide 45
  • Hierarchy of frames +Yworld +Xworld +Zworld
  • Slide 46
  • 3-D Camera Coordinates Right-handed system From point of view of camera looking out into scene: +X right, - X left +Y down, -Y up +Z in front of camera, -Z behind
  • Slide 47
  • +Yworld +Xworld +Zworld Creating a simple WPF 3D space with camera: http://www.codeproject.com/KB/WPF/Wpf3DPrimer.aspx
  • Slide 48
  • Orientation in 3-D in 2D we have 4 elements in orientation matrix but we can locate the local frame by having only one angle . (we know the axis) in 3D we have 9 elements but how many angles do we need for locating the local frame in space? only 3
  • Slide 49
  • Eulers Theorem Eulers Theorem : Any two independent orthonormal coordinate frames can be related by a sequence of rotations (not more than three) about coordinate axes, where no two successive rotations may be about the same axis Eulers Theorem : Any two independent orthonormal coordinate frames can be related by a sequence of rotations (not more than three) about coordinate axes, where no two successive rotations may be about the same axis
  • Slide 50
  • Start with the frame coincident with a known frame {A}. Rotate {B} first about Z B by an angle , then about Y B by an angle and, finally, about X B by an angle Z-Y-X Euler angles
  • Slide 51
  • Euler angles representation Advantages Matrix representation The mathematics is well-known Disadvantages: Describing a general rotation as rotations about the three basis axes is not natural for an animator. Order is important Gimbal lock
  • Slide 52
  • Quaternions Euler: Any rotation of a rigid body can be described by defining an axis of rotation, often called the Euler rotation axis, and a rotation angle. Euler: Any rotation of a rigid body can be described by defining an axis of rotation, often called the Euler rotation axis, and a rotation angle. William Rowan Hamilton formulated quaternions, utilizing this Eulers theorem, as a method of representing rotations.
  • Slide 53
  • Quaternions Complex numbers are represented in the form where, and a,b are real numbers. Quaternion is an extended complex number
  • Slide 54
  • Rotation by Quaternions Any unit quaternion has the form for some angle and unit vector We will represent a point p in space by the quaternion We compute the rotation of point P about the unit vector I by an angle by using the unit quaternion and by Rodrigues formula :
  • Slide 55
  • Rotation by Quaternions We can also combine two rotation by multiplication of the involved quaternions. Example: 2
  • Slide 56
  • Quaternions representation Advantages: Simple composition Rotations Obvious geometrical interpretation Disanvantages: Quaternions only represent rotation Quaternion mathematics appears complicated
  • Slide 57
  • How does the model look in the view of the camera +Yworld +Xworld +Zworld +Ycamera +Xcamera +Zcamera
  • Slide 58
  • Texture mapping on 3D surfaces
  • Slide 59
  • Projective Geometry Outline Description of projective geometry in a plane Descriptions of Points and lines Projective transformations Example of application
  • Slide 60
  • Projective Geometry Euclidean geometry describes shapes as they are Properties of objects that are unchanged by rigid motions Lengths Angles Parallelism Projective geometry describes objects as they appear Lengths, angles, parallelism become distorted when we look at objects
  • Slide 61
  • 2D Projective Geometry Coordinates are called homogeneous or projective coordinates R is the coordinate vector of point M and (x,y,w) are its homogeneous coordinates the rays (x,y,w) and ( x, y, w) are the same and are mapped to the same point M L is the coordinate vector of line l and (a,b,c) are its homogeneous coordinates
  • Slide 62
  • From Projective Plane to Euclidean Plane How do we land back from the projective world to the 2D world of the plane? for Point: for line:
  • Slide 63
  • Point M belongs to line l if and only if: Two lines L=(a,b,c) and L=(a,b,c) intersect in the point R=LL The line through 2 points R and R is L=RR Projective Geometry in 2D
  • Slide 64
  • The points R=(x,y,0) do not correspond to finite points in the plane. they are points at infinity, also called ideal points The line L=(0,0,1) passes through all points at infinity, since L.R=0 Two parallel lines L=(a,b,c) and L=(a,b,c) intersect at the point R=LL=(c-c)(b,-a,0), i.e. (b,-a,0) Any line (a,b,c) intersects the line at infinity at (b,-a,0). so the line at infinity is the set of all points at infinity
  • Slide 65
  • Duality Duality principle: To any theorem of 2-D projective geometry there corresponds a dual theorem, which may be derived by interchanging the role of points and lines in the original theorem
  • Slide 66
  • Projective Transformations in a Plane Projectivity (Collineation or Homography) Mapping from points in plane to points in plane A homography is an invertible transformation from the real projective plane to the projective plane that maps straight lines to straight lines. 3 aligned points are mapped to 3 aligned points
  • Slide 67
  • Transformation of lines A mapping is a projectivity if and only if the mapping consists of a linear transformation of homogeneous coordinates Transformation for lines For a point transformation Definition: Projective transformation or 8DOF
  • Slide 68
  • Special Projectivities
  • Slide 69
  • A special case A plane to plane projective transformation 2D World plane Observer 2D Image plane (retina, film, canvas)
  • Slide 70
  • Example of Projective Transformations Central projection maps planar scene points to image plane by a projectivity The image of the same plannar scene from a second camera can be obtained from the image from the first camera by a projectivity
  • Slide 71
  • Applications of homographies
  • Slide 72
  • Mosaics
  • Slide 73
  • Remember that projectivity is from one plane to another plane
  • Slide 74
  • Camera Model Homogeneous form K: Camera Calibration Matrix Concise form
  • Slide 75
  • General mapping of a pinhole camera Xc = R(Xw Cw) Xc = RXw RCw Homogeneous form of Point on image Translation Rotation Camera Calibration
  • Slide 76
  • Corrected image (front-to-parallel)
  • Slide 77
  • Homography Automatically rectified floor The floor (enlarged)
  • Slide 78
  • Analysing patterns and shapes From Martin Kemp The Science of Art (manual reconstruction) Automatic rectification 2 patterns have been discovered !
  • Slide 79
  • Automatically rectified floor St. Lucy Altarpiece, D. Veneziano Analysing patterns and shapes What is the (complicated) shape of the floor pattern?
  • Slide 80
  • Analysing patterns and shapes From Martin Kemp, The Science of Art (manual reconstruction) Automatic rectification
  • Slide 81
  • The Ambassadors H. Holbein
  • Slide 82
  • Applications of Homographies summary Mosaics (Image processing) Involves computing homographies between pairs of input images (image-image mappings) Rendering textures (Computer graphics) Require planar scene surface and image plane. (scene-image mapping) Computing planar shadows (Computer graphics) Require apply H between two surfaces inside a 3D scene having the light source as the center of projections (Scene-Scene mapping) Remove perspective distortion (Computer vision) Involves computing H between image and 3D scene surfaces (image-scene mapping)