0% found this document useful (0 votes)
6 views82 pages

Chapter 2 Part 1 Linear Algebra Basics and Its Applications in Image Processing and CV

The document provides an overview of linear algebra and its critical role in digital image processing and computer vision. It explains how images can be represented as matrices and discusses various applications of linear algebra techniques, such as geometric transformations, image filtering, and compression. Additionally, it highlights the importance of distance metrics in machine learning algorithms like K-Means and K-Nearest Neighbors for classification and clustering tasks.

Uploaded by

nasser.shraifi
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)
6 views82 pages

Chapter 2 Part 1 Linear Algebra Basics and Its Applications in Image Processing and CV

The document provides an overview of linear algebra and its critical role in digital image processing and computer vision. It explains how images can be represented as matrices and discusses various applications of linear algebra techniques, such as geometric transformations, image filtering, and compression. Additionally, it highlights the importance of distance metrics in machine learning algorithms like K-Means and K-Nearest Neighbors for classification and clustering tasks.

Uploaded by

nasser.shraifi
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/ 82

Linear Algebra Basics and Its

Applications in Image Processing


& Computer Vision

ECE467
Image Processing & Robot Vision

Dr. Saqer S. Alja’afreh


Linear Algebra Basics Chapter 2

Which image you like?

Before Processing After Processing


Linear Algebra Basics Chapter 2

Should we have the say thanks for Image Processing?

It is OK to say that. But we should not forget the


hidden soldier “Linear Algebra”
Linear Algebra Basics Chapter 2
What is Linear Algebra?
• Linear Algebra is a branch of mathematics that deals with the study of
linear equations and their transformations. It involves the study of
vectors, matrices, and systems of linear equations.
• Linear algebra is a power-full tool. It comprises of algorithms/methods
which helps a lot in the real world specially in the study and
manipulation of images. Images are one of the highly used medium of
communication in today’s digital and social world.
• Linear Algebra is used in a wide variety of fields, including physics,
engineering, computer science, economics, and finance. It is used to
solve systems of equations, find eigenvalues and eigenvectors , analyze
linear transformations, and perform other mathematical operations.
Linear Algebra Basics Chapter 2
What is Digital Image Processing? Why?

=
• Image Processing is the process of transforming an image into a digital form and
performing certain operations to transform, enhance, and extract some useful
information from it.
• It involves the use of algorithms, software, and hardware to process digital images
typically obtained from sources like cameras, satellites, medical devices, or digital
sensors.
• Digital Image processing is the field of study that deals with manipulating digital
images using algorithms and mathematical models.
• Digital Image Processing becomes an essential tool for a wide range of
applications, including medical imaging, computer vision, remote sensing, and
more. In this blog, we will explore the basics of image processing and some of its
applications.
• At the heart lies the Linear algebra that provides the essential mathematical
foundation for a wide range of image processing techniques.
-

Linear Algebra Basics Chapter 2


What is Digital Image Processing? Why?
• Image Processing is an essential preprocessing step in many applications,
such as face recognition, object detection, and image compression.
• Image processing is done to enhance an existing image or to take out
important information from it. This is important in several Deep Learning-
based Computer Vision applications, where such preprocessing can
dramatically boost the performance of a model. Manipulating images, for
example, adding or removing objects to images, is another application,
especially in the entertainment industry.

Image processing is a
preprocessing step for computer vision
Linear Algebra Basics Chapter 2
Why Linear Algebra is crucial for Image Processing?
1. Digital Image is automatically written in the form of a matrix whose entries
are the pixels values. So any photo is associated to a matrix and vice-versa.
E.g. MATLAB can convert image to a matrix and any matrix to an image.
2. Linear algebra provides a powerful framework for representing and
manipulating digital images. In both spatial and frequency domain, a
digital image is represented as a matrix, where each element in the matrix
corresponds to a pixel value in the image.
Linear Algebra Basics Chapter 2
Why Linear Algebra is Crucial for Image Processing?
• We all share thousands of images, memes etc. to our known ones. But
when it comes to sharing large image files we need to compress it such that
the size of image got reduced significantly keeping the image quality and
content as good as possible. Images are represented as 3 dimensional(2 for
height and width and 1 for channel) array/matrix of pixels, and we all know
whenever matrix is coined linear algebra appears automatically.

• Linear Algebra has so many applications on image processing such as:


Geometric Transformations (Linear Transformations, and Non-linear
Transformations); Image Filtrations; Image Compression and Expansion
…etc).
Linear Algebra Basics Chapter 2
Applications of Linear Algebra in
Image Processing?

Stir t

W(X(t)) = X(f t)
,
Linear Algebra Basics Chapter 2
Linear Algebra
• Vectors
• Operations
• Matrix
• Operations
• Transformations
• Scaling
• Rotation
Important for
• Translation resizing
• Singular Value Decomposition
Linear Algebra Basics Chapter 2
Vectors
• Scalar: 𝑥 ∈ ℝ ↑

• Vector: 𝒙 ∈ ℝ𝑁
• Row Vector v ∈ ℝ1×𝑛
𝒙 = 𝑥1 𝑥2 ⋯ 𝑥𝑛]

𝑥1
𝑥
• Column vector v ∈ ℝ𝑛×1 :𝒙= 2 = 𝑥1 𝑥2 ⋯

𝑥𝑛
• Transpose
Linear Algebra Basics Chapter 2
Vectors Use
Applications
3
• Store data in memory
• Feature vectors
• Pixel values


Image Coordinates
Histogram for image segmentation.
De +
?

(zz)
• Any point in coordinate system Eideam
• Can be n dimensional distance
• Difference between two points
[𝑥1 − 𝑦1 𝑥2 − 𝑦2
&
𝑥3 − 𝑦3]
of vectors
Linear Algebra Basics Chapter 2
Vectors Operations/ norm[1] x
(1
= 6608]-

E
• Norm – Measure the magnitude of a Xil
vector (size of the vector). IIXII = ,

Types = 20

• p-norm
general
• 2-norm

• L1-norm simplest 1
x =

(1 6608]
-

2-norm examples

+ (5) + (6)
+
82

= Nad
Linear Algebra Basics Chapter 2
Vectors Operations/ norm[1]
Mathematical Example:
Find the Euclidian distance, Manhattan Distance, and Chebyshev Distance, and
Hamming Distance between the two vectors.

Manhattan difference : (tm 15-l=


+
13--21 + 10 -

El
| /m 0 + 1
=

Zudideanis
62 + T + = G =
1blea -
chebyshev : 1fIc Max (16-21 13-21 10 - E)
=

, ,
=
5
Hamming : 3 1)
=

Ham
Linear Algebra Basics Chapter 2

Vectors Operations/ norm[1]


Vectors Norm Applications in Image Processing & Computer Vision
• Different Distances measure. Different Distance Metrics

• Distance = it is a numerical measurement
of how far two objects or two pints are.
/

chebychea
• Distance metrics are used by a lot of
ZuclienAs

machine learning algorithms both
supervised and unsupervised. Manhattane

• Distance metrics are used to identify the



I/P data pattern to make decision the data the of differences between mateces

⑪ Hamming
Find
~
given to it. Distance
Linear Algebra Basics Chapter 2

Vectors Operations/ norm[1]


Vectors Norm Applications in Image Processing & Computer Vision
• The better distance metric, the better • Hamming Distance tells us the
Performance of classification, clustering, number of points where two
and also information retrieval. corresponding pieces of data
can be different
L1-norm or Manhattan Distance

L2-norm or Euclidean Distance

L∞-norm or Chebachev Distance


Chebyshev
Linear Algebra Basics Chapter 2

Vectors Operations/ norm[1]


Vectors Norm Applications in Image Processing & Computer Vision
Distance Metrics are used in well-known Algorithms like:
1. Clustering. Machine learning
simple Algorithm
Mulabeled used for
data - supervises
learning
Linear Algebra Basics Chapter 2

Vectors Operations/ norm[1]


Vectors Norm Applications in Image Processing & Computer Vision
Distance Metrics are used in well-known Algorithms like:
1. Clustering.
• K-Means: Subalgorithm
- In clustering algorithms, thereis no information about the
respective classes for the data points given. So, distance metrics
play an important part here.

- In K-Means, selection of several centroids is made that define


the number of clusters and each data point is then assigned to the
nearest centroid using a Euclidean distance metric.
Linear Algebra Basics Chapter 2

Vectors Operations/ norm[1]


Vectors Norm Applications in Image Processing & Computer Vision
Distance Metrics are used in well-known Algorithms like:
1. Clustering.
• Example
- In the
first image, we can see that there are
randomly placed centroids and in the second
image, using distance metric, the closest
cluster class is found.
• Despite not know labels, we just used #1 #2
distance metrics in K-means and clustered
the data in 3 classes by just using some
algorithms, proving how important these
distance metrics can be.
ft #I
Centroid] Centroz B ys /Heigh Weigh
4& So
(4 50)
,
(5,
G6)

·
5 56
k 5 83
S S
hz R W
8 6
[5 5 83)
6 90
.
,
2

tre + -4)
Row 5
> deaK」
- - 3 3- 34) 6
Euclidean ED fu k 8
5 6o

ka= 27·0 4meaning


distance low #,

E》R, 2 : 2
Pt belongs
4
S
&0
to centroid 2

betny o 2,
Cerbr d . , -f 4,ez
et u vpo C. 2
k = f23,5;6 f
Cmal -
s5
3
5
new Centrof
of K2

taking the
*s
average
67s
, =
-12 (3-30 +
m bl,e
42
o
.

dk, 5· 74a
E f k,
ED r k d = 24·S1IS#4
-E 2 (45-69
32 .
. + .

k Ceu b d
Le 5 a t4 +4 = 4
= 4
4
fn ED er, J, , 19. 1S

A, , , 2.5S 8 Bn

clustering
a
How can we use thes for
Pixels & images
Linear Algebra Basics Chapter 2

Vectors Operations/ norm[1]


Vectors Norm Applications in Image Processing & Computer Vision
Distance Metrics are used in well-known Algorithms like:
1. Classification
Linear Algebra Basics Chapter 2

Vectors Operations/ norm[1]


Vectors Norm Applications in Image Processing & Computer Vision
Distance Metrics are used in well-known Algorithms like:
2. Classification
• K-Nearest Neighbors (KNN): subayorthm for classification
- A non-probabilistic 2supervised
Data is
learningIalgorithm, KNN, doesn’t
ladded
produce the probability of membership of any data point on the
data set but it classifies the data into groups! KNN is one of the
biggest algorithms that uses metrics to find similarities and
dissimilarities. f
probability /I
&
distance 1)
gentor
Iman
Lovely
KNN
food

I
n

-niggorswa
Student age
20
Tuna
O Based on
Ali 10 Tuna O
algorithm
Sarah Lamp
22
chicken sayer's
Favorite
16
Leen
Lamb
Abdullah fool ?
Mona 18 all

lall
h=
Looking
Mohl
I n0

12
-0 N M
-
=

Sager
-
25 F=1
O
-

nearest
neighbor
is Sara
,
So fal .

foot is
Lamb,
same as
Sara
Linear Algebra Basics Chapter 2

Vectors Operations/ norm[1]


Vectors Norm Applications in Image Processing & Computer Vision
Distance Metrics are used in well-known Algorithms like:
2. Classification.
• Example
- KNN classifies data points and when a new data
point is to be classified, it finds out the Euclidean
distance of the new data point with all the data
points present on the graph, then sorts all the
distances. It then considers the k nearest distances
and then, based on that, it classifies the new data
point into an already existing class.
Linear Algebra Basics Chapter 2
Vectors Operations/ Inner Product[2]
• Inner product (dot product)
E

• Scalar number Multiplication


element-wise
• Multiply corresponding entries and add any two ordered
vectors

• Inner product (dot product)

• x.y is also |x||y|cos(angle between x and y)


• If B is a unit vector, A.B gives projection of A on B
Linear Algebra Basics Chapter 2
Vectors Operations/ Inner Product[2]
• Inner product (dot product) Applications in Image Processing & CV
• Scalar number
 Edge Detection: Calculating gradients in
• Multiply corresponding entries and add
filters like the Sobel filter.
 Template Matching: Measuring similarity
between a template and regions in an
image.
 Feature Extraction: Computing gradients
and orientations in feature descriptors like
Histogram Oriented Gradient (HOG).
Question
Answer: 106
If A= [-2 3 4] and B = [3 6 2], Find the projection of A on B? 7
A =

22 34]
B =
[362]
2 -

Norm of B = 376222-49
Unrest (B) =

Norm
=

[E]

(234]
B
A
=
:
=

T projectionof
A on B
Linear Algebra Basics Chapter 2
Vectors Operations/ Outer Product[3]
• Outer product
The outer product of vectors, unlike the dot product, produces a matrix rather than a
scalar. This operation has several applications in image processing and computer vision,
particularly in tasks that involve transformations, feature representation, and spatial
relationships.
Linear Algebra Basics Chapter 2
Vectors Operations/ Outer Product[3]
• Outer product
Example:

It has one drawback.


What is it?

(EX3)
(3x =
3x3
matrix
Linear Algebra Basics Chapter 2
Vectors Operations/ Outer Product[3]
• Outer product

7
-
It has one drawback.
What is it?
Resize

Incorrect Example
Example
Correct
Linear Algebra Basics Chapter 2
Linear Algebra IMPORTANTE
• Vectors * column Vector-Scalar (inner)
Now rector

• Operations
column Vector know rector-matix (outer)
• Matrix
• Operations Product
• Transformations
• Scaling
• Rotation
• Translation
• Singular Value Decomposition
Linear Algebra Basics Chapter 2
Matrix
• Array 𝑨 ∈ ℝ 𝑚×𝑛 of numbers with shape m by n,
• m rows and n columns
Matrix = is a rectangular array or
table of numbers, symbols,
or expressions, arranged in rows
and columns, which is used to
represent a mathematical object or
property of such an object.
• A row vector is a matrix with single row
• A column vector is a matrix with single column
Linear Algebra Basics Chapter 2
Matrices Use ⑳ numbers

reflect intensity ofcolor

• Image representation – RGB


• 3 numbers per pixel
• Stored as nxmx3 matrix
• To represent colors
Linear Algebra Basics Chapter 2
Matrices Use
#
• Image representation – grayscale
• One number per pixel
• Stored as nxm matrix
Linear Algebra Basics Chapter 2
Matrices Use
Q • Matrix Factorization
• SVD & PCA deploy matrices to analyze and
extract meaningful information from image
data like, Feature extraction, noise
reduction, and image compression.
Eage
③• Homogenous coordinate Channels
• The representation of 2D and 3D points in
homogenous coordinates is very important
in image processing and CV for performing
transformation, projections and camera
calibration.
Linear Algebra Basics Chapter 2
Digital Image represents a Matrix Function
• Example: Digital Image as a 2D function (f(x,y)):
If 𝑦 ∈ 0, 1 & 𝑥 ∈ 0, 1 Three different
levels mean three
And, a digital image is defined by the following function different colors

𝑓 𝑥, 𝑦 = 𝑥 + 𝑦
Then,
𝑓 0,0 𝑓 0,1 0+0 1+0
𝑓 𝑥, 𝑦 = = Then, our image is this:
𝑓 1,0 𝑓 1,1 0+1 1+1

0 1
𝑓 𝑥, 𝑦 =
1 2
Linear Algebra Basics Chapter 2
Matrices Operation

3
Adding a constant.
• Subtracting a constant. increase/decrease
• Multiplication by a constant. brightness
• Addition & Subtraction. D affects image
-

• Hadamard Product. masking & convolution


• Matrix Multiplication.
• Matrix Transpose.
• Determinant.
• Trace.
• Inverse.
Linear Algebra Basics Chapter 2
Matrix Operations/ Adding A Constant[1]
• Adding A Constant
Adding a constant to a matrix means adding that constant value to every single element
of the matrix.
Example

Brightening increased
Example on Image Processing
for underexposure
parts. However,
overdoing it can lead to

50 + = washed-out highlights
with loss of detail
Linear Algebra Basics Chapter 2
Matrix Operations/ Subtracting A Constant[2]
• Subtracting A Constant
Subtracting a constant from a matrix means subtracting that constant value from every
single element of the matrix.
Example

Darkening increased for


Example on Image Processing
overexposure parts.
However, excessive

- 50 =
darkening can obscure
details in shadows
Linear Algebra Basics Chapter 2
Matrix Operations/ Multiplication by A Constant[3]
• (Multiplication by A Constant).
multiplying a matrix by a constant means to make a its element’s range larger or smaller by
multiplying a it by a scalar value.
Example
Scaling intensity value of
image pixels. This will
increase the brightness if
Example on Image Processing the constant >1 &
decrease the brightness if
the constant <1.

× 0.5 = However, excess could


leads to lose details, and
obscuring details in
shadows, respectively.
Linear Algebra Basics Chapter 2
Matrix Operations/ Addition & Subtraction[4]
• Addition & Subtraction
Matrices can be added/subtracted only if they have the same dimension, and
addition/subtraction proceeds element by element.
Example The resulted image gets
brighter. Depending on the
maximal allowed pixel value
that is used, this operation
might result in saturated
Example on Image Processing pixels of the new image, i.e.
white pixels that have
reached the maximum value.

+ = This will lead to information


loss and should be avoided.
As a solution of this,
renormalization is good.
Linear Algebra Basics Chapter 2
Matrix Operations/ Addition & Subtraction[4]
• Addition & Subtraction
Matrices can be added/subtracted only if they have the same dimension, and
addition/subtraction proceeds element by element.
the resulting values may lie outside the allowed range of
pixel values. This will be the case when one image is
subtracted from another with lower pixel values. One
solution of this is to add a constant to the first image prior
doing the subtraction. The given example, the first image is
Example on Image Processing added to 150 first then subtracting is done.

150 + - =
-

Linear Algebra Basics Chapter 2


Matrix Operations/ Hadamard Product[5] Lot product of matric
Hadamard product (also known as the element-wise product) is a binary operation that
takes in two matrices of the same dimensions and returns a matrix of the multiplied
corresponding elements.
Example G H
·
=
N

[]
Example on Image Processing
Ge
 Masking: Hadamard multiplication can be used to create masks that selectively enhance or suppress specific
image regions. The original image is multiplied by a binary mask matrix (containing 1s and 0s) where 1s allow
the corresponding pixel values to pass through unchanged, and 0s effectively set those pixels to zero. This
allows you to focus on specific areas of interest in the image.
 Convolution: This is a much more common operation in image processing for tasks like filtering, blurring,
sharpening, and edge detection. It involves sliding a kernel (small matrix) over the image and performing
element-wise multiplication and summation with the corresponding pixel values.
Masking(Hudamard product

~
Linear Algebra Basics Chapter 2
Matrix Operations/ Multiplication[6] I can't stopboat
Multiplication means to apply the "dot product" of rows and columns.
Example
thinking a ht
BIV thoug
experiment

2x3 2x2

Example on Image Processing 23


⑦L
 Image Transformation: Linear & Affine transformations such as scaling, rotation, translation, and shearing
are all achieved using matrix multiplication. By manipulating transformation matrices, images can be resized,
rotated to any angle, or repositioned with ease.
Linear Algebra Basics Chapter 2
Matrix Operations/ Transpose[7] MS Mufasila .

Transpose means Flipping" a matrix over its diagonal. The rows and columns get swapped.
Example

Example on Image Processing


 Matrix transpose is a versatile tool in image processing. It allows for efficient image rotations and
flipping, reshaping data for specific algorithms, vectorization for feature extraction, and plays a role in
calculations involving matrix multiplication for filtering. By understanding matrix transposition, you
can effectively manipulate image data and perform various image processing tasks.
Linear Algebra Basics Chapter 2
Matrix Operations/ Determinant[8]
The determinant of a matrix is a single numerical value (Absolute Value) which is used
when calculating the inverse or when solving systems of linear equations. The determinant
of a matrix A is denoted |A| , or sometimes det(A). Shortcut
Example

Example on Image Processing

 The determinant is a less frequently used concept compared to other matrix operations in image
processing. However, its significance lies in the underlying principles it helps us understand, which are
essential for working with matrices in computer vision and image processing tasks..
Linear Algebra Basics Chapter 2
Matrix Operations/ Trace[9]
• Tr(A) = sum of diagonal elements
Example
• Properties
• Tr(AB) = Tr(BA)
• Tr(A + B) = Tr(A) + Tr(B)

Example on Image Processing


 Limited use in Threshold Techniques.
Limite Application
 Limited use in Normalization Techniques.
Linear Algebra Basics Chapter 2
Matrix Operations/ Inverse[10]
• Inverse
• Given a matrix A, its inverse A-1 is a matrix such that
AA-1 = A-1A = I
• Inverse does not always exist
• Singular vs non-singular
• Properties
• (A-1) -1 = A
• (AB) -1 = B-1A-1
Linear Algebra Basics Chapter 2
Special Matrices
• Symmetric matrix Zeros Matrix : • Skew-symmetric matrix
all elements are

𝑨𝑇 =𝑨
Zero
𝑨𝑇 = −𝑨
Is matix :
all elements are Is

• Identity matrix • Diagonal matrix


• Special diagonal matrix • Used for row scaling
• 1 along diagonals
𝑰. 𝑨 = 𝑨

def(A) =

I
Linear Algebra Basics Chapter 2

Geometric Transformations
 Geometric transformations are operations that manipulate geometric shapes (like points, lines, and
polygons) by changing their position, orientation, or size. These transformations can be applied to
vectors and matrices, which represent these shapes in image processing and computer vision.
Types
Linear Transformation (Non-Linear) Transformation
• A Linear transformation meets the following • A non-Linear transformation do not meet
three conditions linearity conditions.
T(v1 + v2) = T(v1) + T(v2)
T(c v1) = c T(v1)
T(0) = 0
• Sequential application of linear transformation is
again a linear transformation. ·
• Order of transformation is important as in case of
matrix multiplication.
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation
 Linear geometric transformations in image processing are operations that alter the geometric
structure of images using linear functions. These transformations are fundamental in image processing
tasks such as image alignment, object detection, and image enhancement.
Types
 Scaling

 Rotation

 Shearing

 Reflection

 Affine Transformation (Translation).


All linear transformations are affine transformations, but not all affine transformations are linear.
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation
 Always, Linear Transformation is used as matric-vector product.

transformations Ent
M
Parameters
Scaling
Shearing
flipping

New

transformation
originaa
matrix
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Scaling
 Given a coordinates of the object O = (Xold, Yold)
Scaling factor for X-axis = Sx
Scaling factor for Y-axis = Sy
Then, the new coordinates of the object O after scaling = (Xnew, Ynew)

XE
-

axis

y =

-
axis

Diagonal Matrix

 This scaling is achieved by using the following scaling


equations-
Xnew = Xold x Sx
Ynew = Yold x Sy
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Scaling
 For homogeneous coordinates, the above scaling matrix may be represented as a 3 x 3 matrix as:
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Scaling
Example: Given a square object with coordinate points A(0, 3), B(3, 3), C(3, 0), D(0, 0). Apply the scaling
parameter 2 towards X axis and 3 towards Y axis and obtain the new coordinates of the
Solution:
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Scaling
Question: Does image scaling affect the size of the image?
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Scaling Sx , Sy >2 Scale up
Numerical Example
Sx scale down
Question: Does image scaling affect the size of the image? , Sy < 1
Answer:
Yes, image scaling directly affects
the size of an image. Scaling
changes the dimensions of the ] CS on
image by multiplying the width
is
n
and height by specified scaling old 36pp
vector
factors. The result is an image
that is either larger or smaller
than the original, depending on Moterm
whether the scaling factors are us to
greater than or less than one. here !
Assume the image is a gray scale one of 8 bit pixel resolution. Calculate
the size before scaling and after scaling
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Rotation
 Given a coordinates of the object O = (Xold, Yold)
Initial angle of the object O with respect to origin = Φ
Rotation angle = θ
New coordinates of the object O after rotation = (Xnew, Ynew)
counterclockwise

 This Rotation is achieved by using the following a

Cockwe&
Rotation equations θ >0 Rotation Counter-Clockwise
cost Sing

θ <0 Rotation Clockwise


Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Rotation
 For homogeneous coordinates, the previous rotation matrix may be represented as a 3 x 3 matrix as:
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Rotation
Example: Given a line segment with starting point as (0, 0) and ending point as (4, 4). Apply 30 degree
rotation anticlockwise direction on the line segment and find out the new coordinates of the line.
Solution:
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Rotation
Example: Given a triangle with corner coordinates (0, 0), (1, 0) and (1, 1). Rotate the triangle by 90 degree anticlockwise

[e] to2)
direction and find out the new coordinates.

Solution: A
=
A +
10 2)
,

+C = (
()
2

]( j
-

,
= ,

c =

( =
-
-
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Shearing
 In a 2D plane, the object size can be changed along X direction as
well as Y direction. So, there are two versions of shearing:

 Consider a point object O has to be sheared in a 2D plane. its


 Initial coordinates of the object O = (Xold, Yold)
 Shearing parameter towards X direction = Shx
 Shearing parameter towards Y direction = Shy
 New coordinates of the object O after shearing = (Xnew, Ynew)
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Shearing
 Shearing in X Axis
Shearing in X axis is achieved by using the following shearing equations:

Xnew = Xold + Shx x Yold


Ynew = Yold

In Matrix form, the above shearing equations may be represented as:


Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Shearing
 Shearing in X Axis
For homogeneous coordinates, the above shearing matrix may be represented as a 3 x 3 matrix as
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Shearing
 Shearing in Y Axis
Shearing in Y axis is achieved by using the following shearing equations:
Xnew = Xold
Ynew = Yold + Shy × Xold

In Matrix form, the above shearing equations may be represented as:


Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Shearing
 Shearing in Y Axis
For homogeneous coordinates, the above shearing matrix may be represented as a 3 x 3 matrix as
Linear Algebra Basics Chapter 2
GeometricchangeTransformations
origin doesn't
meaning
Linear Transformation/ Shearing
Example: Given a triangle with points (1, 1), (0, 0) and (1, 0). Apply shear parameter 2 on X axis and 2 on Y axis and find
out the new coordinates of the object.

Solution: The new coordinates of the triangle

[2][i] ]
after shearing in Y axis = A (1, 3),
B(0, 0), C(1, 2).
A =
=

A
(b)(2) (i]
=
=

BE
=
B =

[8]
B B = =
[8]
[0 P](0] (0] [i] (2]
=
c =
=
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Reflection
 Reflection is a kind of rotation where the angle of rotation is 180 degree.
The reflected object is always formed on the other side of mirror.
The size of reflected object is same as the size of original object.

 Consider a point object O has to be reflected in a 3D plane. Let its


Initial coordinates of the object O = (Xold, Yold, Zold)
New coordinates of the reflected object O after reflection = (Xnew, Ynew, Znew)
Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Reflection
 Reflection Relative to YZ-Plane
This reflection is achieved by using the following reflection equations:
Xnew = -Xold
Ynew = Yold
Znew = Zold

In Matrix form, the above reflection equations may be represented as:


Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Reflection
 Reflection Relative to XZ-Plane
This reflection is achieved by using the following reflection equations:
Xnew = Xold
Ynew = -Yold
Znew = Zold

In Matrix form, the above reflection equations may be represented as:


Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Reflection
 Reflection Relative to XY-Plane
This reflection is achieved by using the following reflection equations:
Xnew = Xold
Ynew = Yold
Znew = -Zold

In Matrix form, the above reflection equations may be represented as:


Linear Algebra Basics Chapter 2
Geometric Transformations
Linear Transformation/ Reflection
Example: Given a triangle with corner coordinates (0, 0), (1, 0) and (1, 1). Reflect this triangle to the X-axis.
Linear Algebra Basics Chapter 2
Geometric Transformations
Affine Transformation/ Translation
 An affine transformation consists of two parts: a linear transformation and a
translation
Linear Algebra Basics Chapter 2
Geometric Transformations
Affine Transformation/ Translation
 Affine transformations may even change the origin.
 Affine transformations preserve lines and ratios of lengths over each line.
 Affine transformations may not preserve angles and length.
 Parallel lines remain parallel.
Linear Algebra Basics Chapter 2
Geometric Transformations
Affine Transformation/ Translation
 3D Translation is a process of moving an object from one position
to another in a three dimensional plane.
 Consider a point object O has to be moved from one position to
another in a 3D plane. Let its
Initial coordinates of the object O = (Xold, Yold, Zold)
New coordinates of the object O after translation = (Xnew, Ynew, ZNew)
Translation vector or Shift vector = (Tx, Ty, Tz)
 Given a Translation vector (Tx, Ty, Tz)-
Tx defines the distance the Xold coordinate has to be moved.
Ty defines the distance the Yold coordinate has to be moved.
Tz defines the distance the Zold coordinate has to be moved.
New coordinates of the reflected object O after reflection = (Xnew, Ynew,
Znew)
Linear Algebra Basics Chapter 2
Geometric Transformations
Affine Transformation/ Translation
 This translation is achieved by adding the translation coordinates
to the old coordinates of the object as:

Xnew = Xold + Tx (This denotes translation towards X axis)


Ynew = Yold + Ty (This denotes translation towards Y axis)
Znew = Zold + Tz (This denotes translation towards Z axis)
 In matrix form, the above translation equations may be represented a:
Linear Algebra Basics Chapter 2
Geometric Transformations
Affine Transformation/ Translation
Graphical Example:
• When we move from cartesian to
homogenous coordinates 2D image is moved
to z=1 plane in 3D .
• Embedding 2D image in 3D is useful to
perform linear transformation

• Going back to cartesian coordinates the


x and y homogenous coordinates after
transformation is divided by z coordinate.
• Projective transformations have 8
degrees of freedom
Linear Algebra Basics Chapter 2
Geometric Transformations
Affine Transformation/ Translation
Example: Given a 3D object with coordinate points A(0, 3, 1), B(3, 3, 2), C(3, 0, 0), D(0, 0, 0). Apply the
translation with the distance 1 towards X axis, 1 towards Y axis and 2 towards Z axis and obtain the new
coordinates of the object.

Answer: New coordinates of the object = A (1, 4, 3), B(4, 4, 4), C(4, 1, 2), D(1, 1, 2).

You might also like