Information Theory Fundamentals: Distance Between Two Images Based On Pixels
Information Theory Fundamentals: Distance Between Two Images Based On Pixels
Information Theory Fundamentals: Distance Between Two Images Based On Pixels
FUNDAMENTALS
Unit IV
Distance between two images based
on pixels
Session Meta Data
Reviewer
2 v 1.0
Agenda
• Introduction
• Neighbor of a pixel
• Absolute difference of two images
• Distance between two images based on pixels
1. The Euclidean distance
2. Cosine distance
3. Frobenius distance
4. Mean square error
5. Image histogram
• Summary
• Test your understanding
• References
3 v 1.0
Introduction
• Images are represented in rows and columns we have
the following syntax in which images are represented:
4 v 1.0
Neighbor of a pixel
• Let the position of pixel P be the
coordinates (x,y).
• It has two horizontal neighbors and two
vertical neighbors:
• Horizontal neighbors C: (x,y-1) D: (x,y+1)
• Vertical Neighbors: A: (x-1,y) B: (x+1,y)
• These horizontal and vertical neighbors
are called the 4-nighbors of P and the set
is denoted by
• N4(P)={A, B, C, D}={(x-1,y), (x+1,y), (x,y-
1), (x,y+1)}
• If P is on the border of the image, some of
the neighbors may not exist.
5 v 1.0
Neighbor of a pixel
• P also has four diagonal neighbors:
L: (x-1,y-1)
M: (x-1,y+1)
N : (x+1,y-1)
O: (x+1,y+1)
• This set is denoted by ND(P) ={L, M,
N, O}.
• All are together called the 8-
neighbors of P, and are denoted by
N8(P)
6 v 1.0
Absolute difference of two images
• Image difference
• It subtracts each element in array Y from the
corresponding element in array X and returns the
absolute difference in the corresponding element of the
output array Z.
7 v 1.0
Distance between two images based on
pixels
1. The Euclidean distance
2. Cosine distance
3. Frobenius distance
4. Mean square error
5. Image histogram
8 v 1.0
The Euclidean distance
• The distance between two
points in either the plane or
3-dimensional space
measures the length of a
segment connecting the
two points.
• It is the most obvious way
of representing distance
between two points.
9 v 1.0
The Euclidean distance
• If the points (x1,y1) and (x2,y2)
are in 2-dimensional space,
then the Euclidean distance
10 v 1.0
Distance between Test image & training image
11 v 1.0
Cosine distance for two points (vectors)
p = ( p1 , p2 , p3 ) & q = (q1 , q2 , q3 )
similarity = ( p1.q1 ) + ( p2 .q2 ) + ( p3 .q3 )
q1
similarity = p.q T = [ p1 p2 p3 ].q2
q3
• Distance = 1-similarity
12 v 1.0
Frobenius inner product
• Distance = 1 - similarity
13 v 1.0
e.g.
14 v 1.0
Example application
15 v 1.0
560 640 240 306
8 0 59415 24640
16 v 1.0
Mean squared error
• Suppose I and K are the original and the noisy images.
• MSE is referred to the error signal, which is the
difference between the original and distorted signals.
• If one of the signals is an original signal (image), and the
other is a distorted version of it whose quality is being
evaluated, then the MSE may also be regarded as a
measure of signal quality.
17 v 1.0
Histogram matching
• It transforms the 2-D grayscale or truecolor
image I returning output image J whose histogram
approximately matches the histogram of the reference
image ref.
• If both I and ref are truecolor RGB images, then Image
histogram matching matches each color channel
of I independently to the corresponding color channel of ref.
• If I is a truecolor RGB image and ref is a grayscale image,
then Image histogram matching matches each channel
of I against the single histogram derived from ref.
• If I is a grayscale image, then ref must also be a grayscale
image.
18 v 1.0
Applications
19 v 1.0
Measuring size of an object
20 v 1.0
Measuring size of an object
21 v 1.0
Summary
• The following distance measures have been studied:
1. The Euclidean distance
2. Cosine distance
3. Frobenius distance
4. Mean square error
5. Image histogram
22 v 1.0
Test your understanding
• If there is a very high peak right at the top end of the
histogram, what does this suggest?
• Suppose that you had a scene of three objects of
different distinct intensities against an extremely bright
background. What would the corresponding histogram
look like?
• What are the different ways to find the distance between
two images based on probability? What are the different
ways to find the distance between two images based on
probability?
• Explain the distance between them by any two distance
measure based on pixels with example.
23 v 1.0
References
• Thomas Cover, Joy Thomas, Elements of Information
Theory , Wiley Inderscience, 2nd Edition, 2006.
• R C Gonzalez, and R E Woods, Digital Image
Processing, Pearson, 2018.
24 v 1.0