Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
55 views

05 Computer Vision

The document discusses concepts related to image processing in the frequency domain. It explains the difference between the spatial domain and frequency domain. The key transforms used to convert signals from the time/spatial domain to the frequency domain are the Fourier series, Fourier transform, and discrete Fourier transform (DFT). Filters can be applied in the frequency domain to perform operations like blurring and sharpening. Low pass filters retain low frequency components related to smooth regions, while high pass filters retain high frequency components related to edges.

Uploaded by

mohamed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

05 Computer Vision

The document discusses concepts related to image processing in the frequency domain. It explains the difference between the spatial domain and frequency domain. The key transforms used to convert signals from the time/spatial domain to the frequency domain are the Fourier series, Fourier transform, and discrete Fourier transform (DFT). Filters can be applied in the frequency domain to perform operations like blurring and sharpening. Low pass filters retain low frequency components related to smooth regions, while high pass filters retain high frequency components related to edges.

Uploaded by

mohamed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

‫ﻗﺎﻟﻮا ﺳﺒﺤﺎﻧﻚ ﻻ ﻋﻠﻢ ﻟﻨﺎ إﻻ ﻣﺎ ﻋﻠﻤﺘﻨﺎ‬

‫إﻧــــﻚ أﻧــــﺖ اﻟـﻌــﻠــﯿــﻢ اﻟــﺤـــﻜــﯿــﻢ‬

‫ﺻﺪق ﷲ اﻟﻌﻈﯿﻢ‬

‫‪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

• A signal can be converted from time domain into frequency domain


using mathematical operators called transforms:

• Fourier Series
• Fourier transformation
• Laplace transform
• Z transform

3/22/22 7
Frequency components

Two major components:

• High frequency components


High frequency components correspond to edges in an image.
• Low frequency components
Low frequency components in an image correspond to smooth
regions.

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 represented into sum of sines and cosines


when multiplied with a certain weight

• 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

• If f(t) is real à transform in general is complex


• Note that the Fourier transform is an expansion of f(t) multiplied by
sinusoidal terms whose frequencies are determined by the values of
µ

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

• The units of the frequency variable µ depend on the units of t:


• If t represents time in seconds, the units of µ are cycles/sec or
Hertz (Hz)
• If t represents distance in meters, then the units of µ are
cycles/meter

3/22/22 14
Fourier transform

We used the trigonometric identity:


3/22/22 15
Fourier transform

Fourier Transform its Spectrum

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

The discrete Fourier transform is the sampled Fourier


transform, so it contains some samples that denotes
an image.

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:

• Given a set {fm} consisting of M samples of f(t), we have a set {Fm} of


M complex values corresponding to the discrete Fourier transform of
the input sample set
3/22/22 18
Discrete Fourier Transform (DFT)
• given {Fm}, we can recover the sample set {fm} by using the inverse
discrete Fourier transform (IDFT):

• We used m and n to denote discrete variables because it is typical to


do so for derivations.

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

• F(u) ≡ Fm and f (x) ≡ fn

The 1-D DFT pair


3/22/22 20
The mechanics of computing the DFT

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

2-D DFT pair, f ( x, y) ⇔ F (u, v)


• Where f (x, y) is a digital image of
size M × N
• As in the 1-D case, 2D DFT must
be evaluated for values of the
discrete variables u and v in the
ranges u = 0, 1, 2, ... , M − 1 and
v = 0, 1, 2, ... , N − 1
• Given the transform F(u,v), we
can obtain f(x,y) by using the
inverse discrete Fourier transform
(IDFT)
3/22/22 24
Filtering In The Frequency Domain
• The concept of filter in frequency domain is same as the concept of
a mask in convolution.
• After converting an image to frequency domain, some filters are
applied to perform different kind of processing on an image:
blurring, sharpening, smoothing, …

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

High Pass Filter


Low Pass Filter • When 0 is placed inside, we get
• When one is placed inside and the zero is placed
edges, which gives us a sketched
outside , we got a blurred image.
image
• Now as we increase the size of 1, blurring would be
increased and the edge content would be reduced
3/22/22 28
High pass frequency components and Low
pass frequency components
• The ideal low pass filter can be graphically represented as

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.

• This problem is known as ringing effect. This is due to reason because at


some points transition between one color to the other cannot be defined
precisely, due to which the ringing effect appears at that point.

3/22/22 32
Revision for Midterm

3/23/22 33
Zooming and Shrinking Digital Images.

We conclude the treatment of sampling and quantization


with a brief discussion on how to zoom and shrink a digital
image.
Zooming may be viewed as over sampling,
while Shrinking may be viewed as under sampling.
Zooming and Shrinking are applied to a digital image.
Zooming requires two steps:
The creation of new pixel locations, and
The assignment of gray levels to those new locations.
Let us start with a simple example:
Suppose that we have an image of size 10*10 pixels and we want
to enlarge it 1.5 times to 15*15pixels. Conceptually, one of the
easiest ways to visualize zooming is laying an imaginary 15*15
grid over the original image.
The spacing in the grid would be less than one pixel because we
are fitting it over a smaller image.
In order to perform gray-level assignment for any point in the
overlay, we look for the closest pixel in the original image and assign
its gray level to the new pixel in the grid.
When we are done with all points in the overlay grid, we simply
expand it to the original specified size to obtain the zoomed image.
This method of gray-level assignment is called nearest neighbor
interpolation.
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
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

number of times (triple, quadruple, and so 1 4 3 5 6

on).
5 6 35 30 39

• Example to enlarge the 8 8 39 35 43


given image by two.
• Let us consider the 11 11 40 45 32

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

For point (0,2) gray level = 10 11 11 40 45 32


Then 10 = a(0) + b(2) + c(0)(2)+ d (2)

For the third point


For point (2,0) gray level = 1 The by using the calculated four values
Then 1 = a(2) + b(0) + c(2)(0) + d (3) And we can able the calculate the gray
Level at the point ( 1,1 )
For the fourth point v(x', y') = ax' + by' + cx'y' + d
Then point (2,2) gray level = 4 Where a,b,c,d determine from above
Then 4 = a(2) +b(2) + c(2)(2) +d (4) X’ = 1, y’ =1
Then calculate v(x’, y’ ).
Then we solve the four equation the
find the values of a,b,c and d
Lecture 5
2.5.2 Adjacency, Connectivity, Regions, and
Boundaries:
Connectivity between pixels is an important concept
used in establishing boundaries of objects and
components of regions in an image.
To establish whether two pixels are connected :
we must determine if they are adjacent ( if they are 4-
neighbors ) and if their gray levels satisfy a specific
criterion of similarity ( if they are equal ).
Example, in binary image with values 0 and 1, two
pixels may be 4-neighbors, but they are not said to be
connected unless they have the same value.

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

(a) (b) (c)

Fig. 2.26 ( a ) Arrangement of pixels.


( b ) 8-neighbors of the pixel labeled “1”
( c ) m-neighbors of the same pixel.
The dashed lines are path between that pixel and its
neighbors.

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

You might also like