Transformation
Instructor: Neetu Singla
[email protected]Introduction
• Most computer vision applications makes use of image processing operations to pre-
process the image and convert it into a form suitable for further analysis.
• Examples of such operations include
• Exposure correction
• Color balancing
• Reduction of image noise
• Increasing sharpness
• Straightening the image by rotating it
• Transformation: A function or operator that takes an image as its input, performs some
function on the image and produces an image as its output.
• Depending on the transform chosen, the input and output images may appear entirely
different and have different interpretations.
Neetu Singla, NSUT
Image Transforms
Neetu Singla, NSUT
Point Operations: Example
• Image Enhancement
• Increase Brightness
• How?
Neetu Singla, NSUT
Point Operations: Example
• Image Enhancement
• Reversing the contrast
• Black -> White
• Dark Gray -> Light Gray
• How?
Neetu Singla, NSUT
Point Operations: Example
• Image Enhancement
• Stretching the contrast
• Light Gray - Dark Gray
• White - Black
• How?
Neetu Singla, NSUT
Local Operations Example: Moving
Average
Neetu Singla, NSUT
Local Operations: Example
Neetu Singla, NSUT
Local Operations: Example
Neetu Singla, NSUT
Local Operations: Example
Values of Noise pixels have been smoothen out.
Neetu Singla, NSUT
Global Operations: Example
• Image Coordinate Transform
• Eg. Fourier Transform
• Geometric Transformations
• Rotation
• Scaling
• Translation
• Etc.
Neetu Singla, NSUT
Geometric Transformations
Euclidean, Affine, Projective
2D Image Transformations
What is Translation?
• Translation is shifting an image in coordinate space by adding a specified value to
the x- and y- coordinates.
• So, if you know the shift in (x,y) direction, then you can create transformation
matrix as follows:
[1 0 0 1 1]
u=1*x + 0*y +tx* 1
u = x + 0 + 100
u= x + 100
Neetu Singla, NSUT
What is Translation?
• Translation is shifting an image in coordinate space by adding a specified value to
the x- and y- coordinates.
• So, if you know the shift in (x,y) direction, then you can create transformation
matrix as follows:
(0,0)
(15,13)
Neetu Singla, NSUT
What is Rotation?
• This technique rotates an image by a specified angle and by the given axis or
point.
• Rotation about the origin by an angle theta is given by:
Neetu Singla, NSUT
What is Scaling?
• Scaling means resizing an image which means an image is made bigger or smaller
in x- or/and y- direction.
• We can resize an image in terms of scaling factor.
• If we have an image of size (300 x 400) and we want to transform it into an image
of shape (600 x 200).
• The scaling in x-direction will be: 600/300 = 2. (Sx =2)
• Similarily, Sy = 200/400 = ½.
Neetu Singla, NSUT
What is Shearing?
• Shearing an image means shifting the pixels values either horizontally or
vertically.
• Basically, this shifts some part of an image to one direction and other part to
opposite direction.
• Horizontal shearing will shift the upper part to the right and lower part to the left.
• Here you can see in Figure that the upper part has shifted to the right and the
lower part to the left.
Neetu Singla, NSUT
What is Euclidean Transform?
(Isometric)
• It is a combination of Translation and Rotation.
• Properties:
• Three degree of Freedom
• Two for Translation
• One for Rotation
• Distance remains preserved
• Angle remains preserved
• Shapes remains preserved
• Rectangle will remain rectangle
• Theta- Rotation we want to give
• tx – Translation in x-axis
• ty – Translation in y-axis
Neetu Singla, NSUT
What is Affine Transform?
• It is a combination of Translation, Rotation, Scaling and Shearing.
• An affine transformation is a transformation that preserves co-linearity and the
ratio of distances ( for example- the midpoint of a line segment is still the
midpoint even after the transformation)
• The parallel lines in the original image will be parallel in the output image.
Three control points are needed for
generating Transformation Matrix
Neetu Singla, NSUT
What is Projective Transform?
• Changes the view point.
• The projective transform can handle changes caused by a tilt of the image plane relative to the object
plane.
• A projective transformation shows how the perceived objects change as the observer's viewpoint
changes. These transformations allow the creating of perspective distortion. Affine transformations
are used for scaling, skewing and rotation.
• Projective transformations do not preserve parallelism, length, and angle.
Neetu Singla, NSUT
What is Projective Transform?
Neetu Singla, NSUT
Projective Transform: Application
Document Scanning
Neetu Singla, NSUT
Book
Image Formation, Refer Chapter 2.1, 3.1
Computer Vision: Algorithms and Applications
Richard Szeliski
Assignment
a. Read an image into a variable.
b. Display the image.
c. Convert the image to grayscale.
d. Check the height and width of the image.
e. Extract R, G, B Channels. (BGR)
f. Extract the middle 100 pixels from the greyscale image.
g. Write a pair of nested "for" loops to set a grid of every 10th pixel horizontally and every
20th pixel vertically to 0.
h. Flip the image vertically. Then show the original and the flipped image side-by-side.
i. Write the combined image back to a new file.