0% found this document useful (0 votes)
35 views8 pages

Piyush Kaloya - Ip

This technical report discusses geometric operations used in image processing, focusing on transformations such as reflection, translation, scaling, rotation, and shearing. It explains the mathematical principles behind these transformations and provides Python code implementations using the OpenCV library. The report emphasizes the importance of understanding these techniques for various applications in computer vision and image manipulation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views8 pages

Piyush Kaloya - Ip

This technical report discusses geometric operations used in image processing, focusing on transformations such as reflection, translation, scaling, rotation, and shearing. It explains the mathematical principles behind these transformations and provides Python code implementations using the OpenCV library. The report emphasizes the importance of understanding these techniques for various applications in computer vision and image manipulation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

TECHNICAL REPORT WRITING FOR CA-2 EXAMINATON

TOPIC: “Geometric Operations used in Image Processing.”

NAME- PIYUSH KALOYA


CLASS- 3RD
SECTION- C
DEPARTMENT- COMPUTER SCIENCE & ENGINEERING
SUBJECT- IMAGE PROCESSING
SESSION- 2022-26
EMAIL ID- [email protected]

1|Page
Introduction
In the realm of visual data analysis, image processing is a vital discipline that encompasses a broad
array of techniques aimed at enhancing, transforming, and interpreting images. At the heart of
these techniques lie geometric transformations — a fundamental toolset that enables the
modification of an image’s spatial arrangement. These transformations are essential for a variety
of applications, including computer vision, medical imaging, robotics, and more.
Geometric transformations involve altering an image’s geometry by manipulating its pixels based
on predefined mathematical operations. These operations can include translations, rotations,
scalings, and shearing, among others. By applying these transformations, we can reposition, resize,
or distort an image in various ways while preserving its structural integrity.
Understanding the intricacies of geometric transformations in image processing is critical for
practitioners and researchers alike. It forms the foundation for a wide array of image-based
applications, such as image registration, object recognition, panoramic image stitching, and
augmented reality. Through this technical report, we embark on a journey to demystify these
transformations, exploring their types, underlying principles, and real-world applications.

Methodology
Reflection
Reflection transformation in image processing is a geometric operation that involves flipping an
image across a specific axis. The reflection can be done horizontally, vertically, or diagonally,
resulting in a mirrored version of the original image.

Horizontal Reflection
In horizontal reflection, each row of pixels is reversed, creating a mirror image along the horizontal
axis. Let I represent the original image and I_rh represent the horizontally reflected image.
This is the equation of this transformation:

where i and j are row and column indices, and h is the height of the image. Here’s the code
implementation of horizontal reflection:

2|Page
Figure 1: (left) Original Image (right) Image after horizontal reflection.

Vertical Reflection
In vertical reflection, each column of pixels is reversed, creating a mirror image along the vertical
axis. Let I represent the original image and I_rv represent the vertically reflected image.
The equation of this transformation is given by:

where i and j are row and column indices, and w is the width of the image. Here’s the code
implementation of vertical reflection:

Figure 2: (left) Original Image (right) Image after vertical reflection.

Translation
Translation is a fundamental geometric transformation involving the shifting of an object within
an image from one location to another. This shift can occur both horizontally and vertically,
determined by specified offset values measured in pixels. The translation equations for

3|Page
transforming the coordinates of a point (x, y) to a new point (x’, y’) with respective horizontal and
vertical offsets (tx, ty) can be expressed as follows:

To facilitate this transformation, we utilize a transformation matrix in the form of a 2×3 array:

where tx represents the horizontal shift and ty represents the vertical shift, both denoted in the
number of pixels by which we need to shift in their respective directions.
To implement this translation transformation in Python, the cv2.warpAffine() function is utilized,
requiring the translation matrix and the image as input. Here’s a Python script demonstrating how
to achieve image translation:

This script defines a function translate_image() to translate an input image by the specified
horizontal (tx) and vertical (ty) shifts using the provided transformation matrix and
the cv2.warpAffine() function.

Figure 3: (left) Original Image (right) Image after translation; It was used tx = 50 and ty=50.

Scaling
Scaling, a core geometric transformation, involves resizing an image in the horizontal (x) and/or
vertical (y) directions. This transformation is achieved using scaling equations, which determine
the new size of the image based on specified scaling factors.
4|Page
Let’s denote the scaling factors for the x and y directions as Sx and Sy respectively. The scaling
equations for transforming the coordinates of a point (x, y) to a new point (x’, y’) with the scaling
factors Sx and Sy can be expressed as follows:

In these equations, x’ and y’ represent the coordinates of the point after scaling, while x and y are
the original coordinates. The scaling factors Sx and Sy determine the extent of scaling in the
respective directions. If Sx and Sy are greater than 1, the image is enlarged in the x and y
directions, respectively. Conversely, if Sx and Sy are less than 1, the image is reduced in size.
To implement scaling in Python, we use transformation matrices. The scaling transformation
matrix takes the form of a 2×2 array:

In this matrix, Sx represents the scaling factor in the x-direction, and Sy represents the scaling
factor in the y-direction. The scaling matrix is then applied to each point in the image to achieve
the desired scaling effect.
Implementing scaling in Python involves using the scaling matrix and the `cv2.warpAffine()`
function from the OpenCV library. Here’s a Python script demonstrating how to achieve image
scaling:

In this script, we define a function scale_image() that takes an input image and scaling
factors scale_x and scale_y to resize the image accordingly. We use a scaling matrix with the
specified scaling factors and apply it to the image using cv2.warpAffine() to achieve the scaling
effect.

5|Page
Figure 4: (left) Original Image (right) Image after scaling; It was used scale_x = 1.2 and scale_y = 1.2.

Rotation
Rotation is a geometric transformation that involves changing the orientation of an image by a
specified angle around a given axis or point. The rotation can be mathematically expressed using
equations:

Here, x’ and y’ represent the coordinates of the point after rotation, and x and y are the original
coordinates. The angle \theta determines the amount of rotation to be applied. Trigonometric
functions such as cosine (cos) and sine (sin) play a fundamental role in these equations, influencing
the rotation outcome.
It’s important to handle points that fall outside the boundary of the output image appropriately
based on the specific application requirements. In practical implementation, programming
languages like Python utilize these equations within image manipulation frameworks to achieve
accurate and efficient image rotation.
In Python, implementing image rotation involves utilizing the rotation equations within image
manipulation libraries or frameworks. One popular library for this purpose is OpenCV. Here’s a
brief guide on how to perform image rotation using OpenCV:

Figure 5: (left) Original Image (right) Image after rotation; It was used rotation_angle = 45.

6|Page
Shearing
Shearing, much like rotation, is a fundamental geometric transformation used in image processing.
Unlike translation, shearing involves shifting the pixel values of an image either horizontally or
vertically, but the shift is not uniform across the image. This creates a distorted effect by displacing
parts of the image in different directions.
Mathematically, shearing can be expressed using equations that describe the transformation of
coordinates. Let’s denote the original coordinates as x and y and the transformed coordinates after
shearing as x’ and y’. The shearing can be applied either horizontally or vertically.

Horizontal Shearing:

Vertical Shearing:

In these equations, k represents the shearing factor, determining the amount of shear applied in the
respective direction. When k is positive, it shifts the points towards a specific direction, and
when k is negative, it shifts in the opposite direction.
Visualization helps to grasp this concept better. Imagine a rectangular image, and applying
horizontal shearing will shift the upper part of the image to the right and the lower part to the left,
creating a trapezoidal shape.
To implement image shearing in Python, we’ll use the similar approach of creating a shearing
matrix and applying it using the `cv2.warpAffine()` function from the OpenCV library. Below is a
Python script demonstrating how to achieve image shearing:

In this script, we define a function `shear_image()` that takes an input image and a shearing factor
to shear the image horizontally. We use a shearing matrix with the specified shearing factor and

7|Page
apply it to the image using `cv2.warpAffine()` to achieve the shearing effect. Finally, we display
the original and sheared images using OpenCV.

Figure 6: (left) Original Image (right) Image after rotation; It was used shear_factor = 0.25.

Conclusion
Geometric transformations are the building blocks of image processing, allowing us to alter images
in meaningful ways. From simple translations to complex perspective corrections, these
transformations empower various applications that rely on accurate image manipulation. As we
continue to advance in the field of image processing, a deeper understanding of geometric
transformations will be indispensable for innovating and improving the way we perceive and
interact with images.

References
1. Gonzalez, R. C., & Woods, R. E. (2018). Digital Image Processing (4th Edition). Pearson.
2. Szeliski, R. (2022). Computer Vision: Algorithms and Applications. Springer.
3. OpenCV Documentation - https://docs.opencv.org/
4. MathWorks Image Processing Toolbox -
https://www.mathworks.com/products/image.html
5. Research paper on geometric transformations: https://arxiv.org/abs/2001.00123

8|Page

You might also like