Geometric Transformations - 2D, 3D
Geometric Transformations - 2D, 3D
Transformations
• A 2D image consists of rows and columns of pixels, where each pixel represents a single
point in the image.
• The width refers to the number of columns of pixels, while the height refers to the number
of rows.
• Each pixel in the image has coordinates (x, y) specifying its position within this plane.
In a 2D Cartesian coordinate system, every point is uniquely identified by a pair of numbers (x, y), where:
"x" represents the horizontal distance from a fixed reference line called the x-axis.
"y" represents the vertical distance from a fixed reference line called the y-axis.
Types of 2D
Transformations
• Translations (changing the location)
• Scaling (increasing or decreasing size)
• Rotation (rotate at any angle)
• Reflection (mirror image)
1. Translations
(changing the location)
• Moving the image horizontally (along the x-axis) and vertically (along the y-axis). This operation shifts the entire image without
changing its shape or orientation.
• We can translate points in the (x, y) plane to new positions by adding translation amounts to the coordinates of the points.
• For each point P(x, y) to be moved by dx units parallel to the x-axis and by dy units parallel to the y-axis, to the new point P’(x’, y’ ).
Example
Original Image:
• A (2,1)
• B (7,1)
• C (4,6)
Translated Image:
• A (6,4)
• B (11,4)
• C (8,9)
Applications
1. Graphic Design: move elements such as text, shapes, and images within a design canvas
2. User Interface Design: for positioning UI elements such as buttons, icons, and text labels.
4. Virtual Whiteboards: allows users to move and reposition digital objects such as text boxes, drawings, and sticky notes.
Translation
Original Translated 10
2. Scaling
(increasing or decreasing size)
• This operation changes the size of the image while preserving its shape.
• Points can be scaled (stretched) by Sx along the x-axis and by Sy along the y-axis into the new points by the multiplications:
• We can specify how much bigger or smaller by means of a “scale factor” { Sx, Sy)
• To double the size of an object we use a scale factor of 2, to half the size of an object we use a scale factor of 0.5
Example
Original Image:
• A (2,1)
• B (5,1)
• C (4,4)
Scaled Image:
• A (6,2)
• B (15,2)
• C (12,8)
Applications
2D scaling, which involves resizing an image along both the horizontal and vertical axes.
1. Image Editing and Photography: to adjust the size of images for different purposes (resizing photos to fit into a photo album,
enlarging images for printing without losing quality.
2. Responsive Web Design: that adapt to various screen sizes and devices.
3. Map Making: create maps at different scales to represent geographic features accurately while adjusting the size of the map.
4. Advertising: resize graphics and text for various marketing materials, such as banners and billboards.
Scaling
Original Scaled 14
3. Rotation
(rotate at any angle)
Rotating the image by a certain angle around a specified point. This operation changes the orientation of the image while preserving its
shape and size.
• Normally in rotations Cos works with x-axis and sin works with y-axis like:
Clockwise:
• A [10 5] ⎡cos 45 -sin45⎤
⎣sin45 cos45⎦
• [15/√2 -5/√2]
Applications
1. Image Alignment: used to align images that may be taken from different perspectives
2. Image Transformation: used for transforming images to present them in a desired viewing angle. For example, in document
processing applications, scanned documents may need to be rotated to align them properly for further analysis or OCR (Optical
Character Recognition).
Rotation
Original Rotated 19
4. Reflection
(mirror image)
• The mirror image for a two-dimensional reflection is generated relative to an axis of reflection by
rotating the object 180 degree about the reflection axis
Example
On x-axis :
• A (2,-2), B(1,-1),C(3,-1)
• Negative sign with y-axis
• On y-axis :
• A (-2,2), B(-1,1),C(-3,1)
• Negative sign with x-axis
Reflection
Original Reflected 22
Problem Statement
In some applications we require sequence of Transformations.
For example:
• Animation on each next move we may have object to be translated than scaled
• Similarly in games an object in a particular moment may have to be rotated as well as translated
That means we have to perform sequence of matrix operations but the matrix we have seen in the previous slides have order
which restrict them to be operated in sequence.
However, with slight reformulated we can bring them into the form where they can easily be operated in any sequence thus
efficiency can be achieved.
• A point is similar to its 2D counterpart; we simply add an extra component, Z, for the 3rd axis
• In the left-handed system the x axis increases going to the right, the y axis increases going up, and the z axis
increases going into the page/screen.
• The right-handed system is the same but with the z-axis pointing in the opposite direction.
3 Dimensional
In a 3D Cartesian coordinate system, every point is uniquely identified by a triple of numbers (x, y, z), where:
"z" represents the depth or distance from the plane containing the x and y axes, along the z-axis.
Types of 3D
Transformations
• Translations (changing the location)
• Scaling (increasing or decreasing size)
• Rotation (rotate at any angle)
1. Translations
(changing the location)
• Since now we are talking about 3D, therefore each point has 3 coordinates i.e. x, y and z. similarly, the
translation distances can also be specified in any of the 3 dimensions.
• P’ = P + T
Example
Original Image:
• Coordinates: A (2,1,0) , B (8,1,0), C (5,8,0)
• Translate ΔABC with a vector translation of (2,4,0)
• A (2+2 ,1+4, 0+0)
• B (8+2 ,1+4 ,0+0)
• C (5+2 ,8+4 ,0+0)
Translate Image:
• A (4,5,0) , B (10,5,0), C (7,12,0)
2. Scaling
(increasing or decreasing size)
• Scaling an object with transformation changes the size of the object and reposition the object relative to the coordinate origin.
• If the transformation parameters are not all equal, relative dimensions in the object are changed.
• Uniform Scaling : We preserve the original shape of an object with a uniform scaling
( Sx = Sy = Sz)
• Differential Scaling : We do not preserve the original shape of an object with a differential scaling
Original Image:
• Coordinates: A (2,1,0) , B (8,1,0), C (5,8,0)
• Translate ΔABC with a scaling unit of (2,4,0)
• A (2*2 ,1*4, 0*0)
• B (8*2 ,1*4 ,0*0)
• C (5*2 ,8*4 ,0*0)
Translate Image:
• A (4,4,0) , B (16,4,0), C (10,32,0)
3. Rotation
(rotate at any angle)
Moving the point from one position on a sphere whose center is at the origin to another position on the
sphere
Conceptually, you do the three rotations separately. First, you rotate around one axis, followed by another, then the last. ⚫ The order
of rotations is important when you cascade rotations; we will rotate first around the Z axis, then around the X axis, and finally
around the Y axis.
3. Rotation
(rotate at any angle)
Then it will be simple rotation like that have studied in the XY-Plane.