05 Computer Vision
05 Computer Vision
ﺻﺪق ﷲ اﻟﻌﻈﯿﻢ
1
واﻟﺼﻼة واﻟﺴﻼم ﻋﻠﻲ اﺷﺮف ﺧﻠﻖ ﷲ
ﻧﺒﯿﻨﺎ ﺳﯿﺪﻧﺎ ﻣﺤﻤﺪ ﺻﻠﻲ ﷲ ﻋﻠﯿﮫ وﺳﻠﻢ
2
Computer Vision
اﻟﺒﺮﯾﺪ اﻻﻟﻜﺘﺮوﻧﻲ
ghoniemy1@cis.asu.edu.eg
mayat@cis.asu.edu.eg
Office hours: Thu 9-11 at G03
3
Textbook:
Digital Image Processing
Rafael C. Gonzalez
4
Frequency-domain Processing
G&W Ch. 4
5
Difference between spatial domain and frequency
domain
Spatial Domain:
• we deal with image pixels as they
are
Frequency Domain:
• We first transform the image
to its frequency distribution
3/22/22 6
Transformation
• Fourier Series
• Fourier transformation
• Laplace transform
• Z transform
3/22/22 7
Frequency components
3/22/22 8
Fourier series
• Fourier was a mathematician in 1822. He give Fourier series and
Fourier transform to convert a signal into frequency domain
• Periodic signals can be broken down into further signals with the
following properties:
• The signals are sines and cosines
• The signals are harmonics of each other
3/22/22 9
Fourier series
• The last signal is the sum of all the
above signals
• This was the idea of the Fourier
3/22/22 10
Fourier transform
• Non periodic signals whose area under the curve is finite can also be
represented into integrals of the sines and cosines after being
multiplied by a certain weight.
• Can be used in:
• Image compression (e.g JPEG compression)
• Filtering
• Image analysis
• Images are non periodic signals à Fourier transform is used to
convert them into frequency domain
• For digital images we will be working on Discrete Fourier Transform
3/22/22 11
Fourier transform
• The Fourier transform of a continuous function f(t) of a continuous
variable, t, ℑ{f (t)}
3/22/22 12
Fourier transform
• Using Euler’s formula, we can write Eq. (4-20) as
3/22/22 13
Fourier transform
• Because the only variable left after integration is frequency, we say
that the domain of the Fourier transform is the frequency domain
3/22/22 14
Fourier transform
3/22/22 16
Discrete Fourier Transform
The Fourier term of a sinusoid include three things:
•Spatial Frequency: directly relates with the
brightness of the image
•Magnitude: directly relates with the contrast
(difference between maximum and minimum pixel
intensity)
•Phase: contains the color information
3/22/22 17
Discrete Fourier Transform (DFT)
• The Fourier transform of a sampled, band-limited function extending
from -∞ to ∞ is a continuous, periodic function that also extends from
− ∞ to ∞.
• In practice, we work with a finite number of samples, the DFT of such
finite sample sets:
3/22/22 19
Discrete Fourier Transform (DFT)
• It is more intuitive, especially in two dimensions, to use the notation x and y
for image coordinate variables and u and v for frequency variables, where
these are understood to be integers
3/22/22 21
Trigonometric Identities Relation to the Complex
Exponential Function
https://en.wikipedia.org/wiki/List_of_trigonometric_identities
3/24/22 22
3/22/22 23
The 2-d Discrete Fourier Transform And Its
Inverse
3/22/22 25
Filtering In The Frequency Domain
3/22/22 26
Filtering In The Frequency Domain
• We will take discrete Fourier transform of the image
• Then we will center the discrete Fourier transform, as we will bring
the discrete Fourier transform in center from corners
• Then we will apply filtering, means we will multiply the Fourier
transform by a filter function
• Then we will again shift the DFT from center to the corners
• Last step, take the inverse discrete Fourier transform, to bring the
result back from frequency domain to spatial domain
3/22/22 27
High pass frequency components and Low
pass frequency components
• The high pass frequency components denotes edges whereas the low
pass frequency components denotes smooth regions
3/22/22 29
High pass frequency components and Low
pass frequency components
3/22/22 30
Image smoothing in the frequency domain
using lowpass filters
3/22/22 31
Image smoothing in the frequency domain
using lowpass filters
• Gaussian low pass and Gaussian high pass filter minimize the problem that
occur in ideal low pass and high pass filter.
3/22/22 32
Revision for Midterm
3/23/22 33
Zooming and Shrinking Digital Images.
5 6 35 30 39 47 49 50 3 2
8 8 39 35 43 40 45 44 9 7
11 11 40 45 32 33 39 40 4 9
7 7 35 34 34 34 33 35 7 7
7 4 49 22 44 39 44 33 8 6
8 3 45 34 40 38 45 32 6 6
9 3 3 3 4 9 8 6 4 5
9 3 3 4 4 4 4 4 2 1
12
1
5
8
11
7
7
8
9
9
12 10
1 4
5 6
8 8
11 11
7 7
7 4
8 3
9 3
9 3
12 10 7
1 4 3
5 6 35
8 8 39
11 11 40
7 7 35
7 4 49
8 3 45
9 3 3
9 3 3
12 10 7 6
1 4 3 5
5 6 35 30
8 8 39 35
11 11 40 45
7 7 35 34
7 4 49 22
8 3 45 34
9 3 3 3
9 3 3 4
12 10 7 6 6
1 4 3 5 6
5 6 35 30 39
8 8 39 35 43
11 11 40 45 32
7 7 35 34 34
7 4 49 22 44
8 3 45 34 40
9 3 3 3 4
9 3 3 4 4
Lecture 5
12 10 7 6 6 14
1 4 3 5 6 6
5 6 35 30 39 47
8 8 39 35 43 40
11 11 40 45 32 33
7 7 35 34 34 34
7 4 49 22 44 39
8 3 45 34 40 38
9 3 3 3 4 9
9 3 3 4 4 4
Lecture 5
12 10 7 6 6 14 12
1 4 3 5 6 6 6
5 6 35 30 39 47 49
8 8 39 35 43 40 45
11 11 40 45 32 33 39
7 7 35 34 34 34 33
7 4 49 22 44 39 44
8 3 45 34 40 38 45
9 3 3 3 4 9 8
9 3 3 4 4 4 4
Lecture 5
12 10 7 6 6 14 12 7
1 4 3 5 6 6 6 9
5 6 35 30 39 47 49 50
8 8 39 35 43 40 45 44
11 11 40 45 32 33 39 40
7 7 35 34 34 34 33 35
7 4 49 22 44 39 44 33
8 3 45 34 40 38 45 32
9 3 3 3 4 9 8 6
9 3 3 4 4 4 4 4
Lecture 5
12 10 7 6 6 14 12 7 9
1 4 3 5 6 6 6 9 9
5 6 35 30 39 47 49 50 3
8 8 39 35 43 40 45 44 9
11 11 40 45 32 33 39 40 4
7 7 35 34 34 34 33 35 7
7 4 49 22 44 39 44 33 8
8 3 45 34 40 38 45 32 6
9 3 3 3 4 9 8 6 4
9 3 3 4 4 4 4 4 2
Lecture 5
12 10 7 6 6 14 12 7 9 5
1 4 3 5 6 6 6 9 9 9
5 6 35 30 39 47 49 50 3 2
8 8 39 35 43 40 45 44 9 7
11 11 40 45 32 33 39 40 4 9
7 7 35 34 34 34 33 35 7 7
7 4 49 22 44 39 44 33 8 6
8 3 45 34 40 38 45 32 6 6
9 3 3 3 4 9 8 6 4 5
9 3 3 4 4 4 4 4 2 1
Lecture 5
12 12 10 7 7 6 6 6 14 12 12 7 9 9 5
1 1 4 3 3 5 6 6 6 6 6 9 9 9 9
5 5 6 35 35 30 39 39 47 49 49 50 3 3 2
8 8 8 39 39 35 43 43 40 45 45 44 9 9 7
11 11 11 40 40 45 32 32 33 39 39 40 4 4 9
7 7 7 35 35 34 34 34 34 33 33 35 7 7 7
7 7 4 49 49 22 44 44 39 44 44 33 8 8 6
8 8 3 45 45 34 40 40 38 45 45 32 6 6 6
9 9 3 3 3 3 4 4 9 8 8 6 4 4 5
9 9 3 3 3 4 4 4 4 4 4 4 2 2 1
Lecture 5
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
9 9 9 9 6 6 6 6 6 5 3 3 4 1 1
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
7 9 9 44 45 45 40 43 43 35 39 39 8 8 8
9 4 4 40 39 39 33 32 32 45 40 40 11 11 11
7 7 7 35 33 33 34 34 34 34 35 35 7 7 7
6 8 8 33 44 44 39 44 44 22 49 49 4 7 7
6 6 6 32 45 45 38 40 40 34 45 45 3 8 8
5 4 4 6 8 8 9 4 4 3 3 3 3 9 9
1 2 2 4 4 4 4 4 4 4 3 3 3 9 9
Lecture 5
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
9 9 9 9 6 6 6 6 6 5 3 3 4 1 1
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
7 9 9 44 45 45 40 43 43 35 39 39 8 8 8
9 4 4 40 39 39 33 32 32 45 40 40 11 11 11
7 7 7 35 33 33 34 34 34 34 35 35 7 7 7
6 8 8 33 44 44 39 44 44 22 49 49 4 7 7
6 6 6 32 45 45 38 40 40 34 45 45 3 8 8
5 4 4 6 8 8 9 4 4 3 3 3 3 9 9
1 2 2 4 4 4 4 4 4 4 3 3 3 9 9
Lecture 5
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
9 9 9 9 6 6 6 6 6 5 3 3 4 1 1
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
7 9 9 44 45 45 40 43 43 35 39 39 8 8 8
9 4 4 40 39 39 33 32 32 45 40 40 11 11 11
7 7 7 35 33 33 34 34 34 34 35 35 7 7 7
6 8 8 33 44 44 39 44 44 22 49 49 4 7 7
6 6 6 32 45 45 38 40 40 34 45 45 3 8 8
5 4 4 6 8 8 9 4 4 3 3 3 3 9 9
1 2 2 4 4 4 4 4 4 4 3 3 3 9 9
Lecture 5
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
9 9 9 9 6 6 6 6 6 5 3 3 4 1 1
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
7 9 9 44 45 45 40 43 43 35 39 39 8 8 8
9 4 4 40 39 39 33 32 32 45 40 40 11 11 11
9 4 4 40 39 39 33 32 32 45 40 40 11 11 11
7 7 7 35 33 33 34 34 34 34 35 35 7 7 7
6 8 8 33 44 44 39 44 44 22 49 49 4 7 7
6 6 6 32 45 45 38 40 40 34 45 45 3 8 8
5 4 4 6 8 8 9 4 4 3 3 3 3 9 9
1 2 2 4 4 4 4 4 4 4 3 3 3 9 9
Lecture 5
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
9 9 9 9 6 6 6 6 6 5 3 3 4 1 1
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
7 9 9 44 45 45 40 43 43 35 39 39 8 8 8
9 4 4 40 39 39 33 32 32 45 40 40 11 11 11
9 4 4 40 39 39 33 32 32 45 40 40 11 11 11
7 7 7 35 33 33 34 34 34 34 35 35 7 7 7
6 8 8 33 44 44 39 44 44 22 49 49 4 7 7
6 8 8 33 44 44 39 44 44 22 49 49 4 7 7
6 6 6 32 45 45 38 40 40 34 45 45 3 8 8
5 4 4 6 8 8 9 4 4 3 3 3 3 9 9
1 2 2 4 4 4 4 4 4 4 3 3 3 9 9
Lecture 5
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
5 9 9 7 12 12 14 6 6 6 7 7 10 12 12
9 9 9 9 6 6 6 6 6 5 3 3 4 1 1
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
2 3 3 50 49 49 47 39 39 30 35 35 6 5 5
7 9 9 44 45 45 40 43 43 35 39 39 8 8 8
9 4 4 40 39 39 33 32 32 45 40 40 11 11 11
9 4 4 40 39 39 33 32 32 45 40 40 11 11 11
7 7 7 35 33 33 34 34 34 34 35 35 7 7 7
6 8 8 33 44 44 39 44 44 22 49 49 4 7 7
6 8 8 33 44 44 39 44 44 22 49 49 4 7 7
6 6 6 32 45 45 38 40 40 34 45 45 3 8 8
5 4 4 6 8 8 9 4 4 3 3 3 3 9 9
5 4 4 6 8 8 9 4 4 3 3 3 3 9 9
1 2 2 4 4 4 4 4 4 4 3 3 3 9 9
Lecture 5
Pixel replication
• is used to enlarge the image by two, also is
used to enlarge the image by any integer 12 10 7 6 6
on).
5 6 35 30 39
following image [ 5 x 5 ].
Lecture 5
12 10 7 8 6
1 4 3 5 6
5 6 35 30 39
8 8 39 35 43
11 11 40 45 32
Lecture 5
A slightly more sophisticated way:
of accomplishing gray-level assignments is bilinear
interpolation using the four nearest neighbors of a point.
Let (x', y') denote the coordinates of a point in the
zoomed image and let f(x', y') denote the gray level
assigned to it.
For bilinear interpolation, the assigned gray level is
given by:
f(x', y') = ax' + by' + cx'y' + d
where the four coefficients are determined from the four
equations in four unknowns that can be written using
the four nearest neighbors of point (x', y').
Lecture 5
f(x', y') = ax' + by' + cx'y' + d 12 10 7 8 6
For point (0,0) gray level =12
The by subsitute in the equation we 1 4 3 5 6
get
5 6 35 30 39
12 = a (0) + b (0) + c(0)(0) + d (1)
Then from this equation we get
8 8 39 35 43
d =12
Lecture 5
Example:
Let V be the set of gray – level values to define connectivity, for
example if only connectivity if pixels with intensities of 59, 60, and
61 is important, then V={59, 60, 61}.
We consider three types of connectivity:
4-connectivity. Two pixels p and q with values from V are 4-
connected if q is in the set N4(p).
8-connectivity. Two pixels p and q with values from V are 8-
connected if q is in the set N8(p).
m-connectivity. Two pixels p and q with values from V are m-
connected if :
i- q is in the set N4(p), or
ii- q is in ND(p) and the set N4(p)∩N4(q) is empty. ( this is the
set of pixels that are 4-neighbors of both p and q and whose values are
from V).
Lecture 5
0 1 1 0 1 1 0 1 1
0 1 0 0 1 0 0 1 0
0 0 1 0 0 1 0 0 1
Lecture 5
Problem 2.11 Consider the two image subsets, S1 and S2,
shown in the following figure. For V={1}, determine
whether these two subsets are (a) 4-adjacent, (b) 8-adjacent,
or (c) m-adjacent.
Note:
Two images S1 and S2 are adjacent if some pixel in S1
is adjacent to some pixel in S2.
Lecture 5
Let p and q be as shown in Fig. P2.11. Then,
(a) S1 and S2 are not 4 connected because q is not in the set N4(p);
(b) S1 and S2 are 8 connected because q is in the set N8(p);
(c) S1 and S2 are m connected because (i) q is in ND(p), and (ii) the
set N4(p) ∩ N4(q) is empty.
Lecture 5