37
!"#$"%$ % Image Enhancement in the Frequency Domain Jesus J. Caban Outline ! Assignment #1 ! Paper Presentation & Schedule ! Frequency Domain ! Mathematical Morphology

Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

  • Upload
    others

  • View
    24

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%&

Image Enhancement in the Frequency Domain

Jesus J. Caban

Outline

!  Assignment #1

!  Paper Presentation & Schedule

!  Frequency Domain

!  Mathematical Morphology

Page 2: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#&

Assignment #1 !  Questions?

!  How’s OpenCV?

!  You have another 48hrs. Keep working!

Paper Presentation & Schedule !  Check the schedule online

for the date you are presenting

!  Check the reading list for your paper assignment

!  If your name is not there, please let me know

!  Let me know about errors

Page 3: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

'&

Presentation: Evaluation Form 1.  Delivery

2.  Visual Aids & Organization

3.  Topic & Papers

Possible change to the syllabus

!  Instead of reading and writing a question for each paper, do you want to only read one paper?

Page 4: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

(&

Image Enhancement in the Frequency Domain

Recall: Point Processing !  Based on the intensity of a single pixel only as opposed to a

neighborhood or region

Page 5: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

)&

Moving Window Transform: Example

original 3x3 average

Moving Window Transform: Example

original 3x3 average

Page 6: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

*&

Spatial Filtering: Smoothing

1/16 2/16 1/16

2/16 4/16

2/16

1/16 2/16

1/16

1/9 1/9 1/9

1/9 1/9

1/9

1/9 1/9

1/9

Spatial Filtering: Edge Enhancement

0 1 0

1 -4 1

0 1 0

-1 -2 -1

0 0 0

1 2 1

-1 0 1

-2 0 2

-1 0 1

Page 7: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

+&

Jean Baptiste Joseph Fourier !  Claim (1807): Any periodic function can be rewritten as a weighted sum of sines and cosines of different frequencies

!  Published his work in 1822: “La Théorie Analitique de la Chaleur”

!  His work was translated into English over 55+ years later (1878): “The Analytic Theory of Heat”

!  Researchers didn’t pay too much attention to his work when it was first published

!  Fourier Theory then became one of the most important mathematical theories in modern engineering

The General Idea

=

•  Any function that periodically repeats itself can be expressed as a sum of sines and cosines of different frequencies each multiplied by a different coefficient •  Resulting collection is called Fourier series

Page 8: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

,&

Frequency

Frequency is the number of occurrences of a repeating event per unit time

t0 t1 t2

Amplitude

The amplitude is the height of the wave.

Page 9: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

!&

Phase shifts

The same wave after a central section underwent a phase shift (e.g. passing through glass)

The phase shift describes how far to the left or right the wave slides.

Frequency Example !  g(t) = sin(2!f t) + (1/3)sin(2! (3f) t)

= +

Page 10: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%$&

Fourier Series - Example

First 60 Fourier approximations

Fourier Transform: Definition

! 

!  Changes in u and v obtain different basis functions of different frequencies

!  Point in the new image F(u,v) represent the contribution of that frequency to the original image

Sum of sine and cosine basis functions

Page 11: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%%&

Fourier Transform: Real & Imaginary Part !  General concept

f(x) F(w) Fourier Transform

•  For every w from 0 to inf, •  F(!) holds the amplitude A and phase " of the corresponding sine

2D Domain !  Any image can be captured in a single Fourier term that

encodes !  the spatial frequency !  the magnitude (positive or negative) !  the phase

x

y

u

v

Page 12: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%#&

Frequency Domain: Illustration

Frequency Domain: Illustration

Page 13: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%'&

Extension to 2D

(a-jb)

(a+jb) v

u

Frequency Domain: Properties

Page 14: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%(&

Properties of the Fourier Transform !  Rotation: rotated image is equivalent to rotated DFT

!  Scaling: a*f(x,y) is equivalent to a*F(u,v)

!  F(0,0) = average value of f(x,y)

!  Others: symmetry, distributive, etc…

The Discrete Fourier Transform (DFT) 1.  Given an image f(x,y) or size MxN

x = 0, 1, 2…M-1 y = 0,1,2…N-1

2.  Discrete Fourier Transform of f(x, y) is given by

u = 0, 1, 2…M-1 v = 0, 1, 2…N-1 j= sqrt(-1)

N

M

Origin

Page 15: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%)&

The Inverse DFT !  The key feature of a Fourier Transform is that it’s completely reversible

!  The inverse DFT is given by:

x = 0, 1, 2…M-1

y = 0, 1, 2…N-1

The Inverse DFT

Page 16: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%*&

!  Concept of convolution

!  Filter image by moving the convolution kernel.

Recall: Basics of Spatial Filtering

Convolution Theorem

!  Convolution in the spatial domain is equivalent to multiplication in the frequency domain

!  Convolution of large kernels to images can be performed by a simple multiplication

Page 17: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%+&

Recall: Smoothing Spatial Filtering 1/9

1/9 1/9

1/9 1/9! 1/9

1/9 1/9

1/9

Origin x

y Image f (x, y)

e = 1/9*106 + 1/9*104 + 1/9*100 + 1/9*108 + 1/9*99 + 1/9*98 + 1/9*95 + 1/9*90 + 1/9*85

= 98.3333

Filter Simple 3*3

Neighbourhood 106

104

99

95

100 108

98

90 85

1/9 1/9

1/9

1/9 1/9

1/9

1/9 1/9

1/9

3*3 Smoothing Filter

104 100 108

99 106 98

95 90 85

Original Image Pixels

*

The DFT and Image Processing To filter an image in the frequency domain:

1.  Compute F(u,v) the DFT of the image 2.  Multiply F(u,v) by a filter function H(u,v) 3.  Compute the inverse DFT of the result

Page 18: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%,&

Frequency Domain: Filters

1.  A low-pass filter: attenuates high frequencies

2.  A high-pass filter: attenuates low frequencies

3.  A band-pass filter: attenuates very low and very high frequencies

1. Low-pass Filters

!  Attenuates high frequencies and retains low frequencies unchanged. !  high frequencies correspond to sharp intensity changes

!  The result in the spatial domain is equivalent to that of a smoothing filter !  fine-scale details and noise in the spatial domain image are

filtered

Page 19: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

%!&

Ideal Low Pass Filter

Simply cut off all high frequency components that are a specified distance D0 from the origin of the transform

changing the distance changes the behaviour of the filter

Ideal Low Pass Filter

The transfer function for the ideal low pass filter can be given as:

Page 20: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#$&

Ideal Low Pass Filter (cont…)

Above we show an image, it’s Fourier spectrum and a series of ideal low pass filters of radius 5, 15, 30, 80 and 230 superimposed on top of it

Ideal Low Pass Filter (cont…)

Original image

Result of filtering with ideal low pass filter of radius 5

Result of filtering with ideal low pass filter of radius 30

Result of filtering with ideal low pass filter of radius 230

Result of filtering with ideal low pass

filter of radius 80

Result of filtering with ideal low pass

filter of radius 15

Page 21: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#%&

Ideal Low Pass Filter (cont…)

Result of filtering with ideal low pass filter of radius 5

Ideal Low Pass Filter (cont…)

Result of filtering with ideal low pass filter of radius 15

Page 22: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

##&

Butterworth Lowpass Filters The transfer function of a Butterworth lowpass filter of order n with cutoff frequency at distance D0 from the origin is defined as:

Butterworth Lowpass Filter (cont…)

Original image

Result of filtering with Butterworth filter of order 2 and cutoff radius 5

Result of filtering with Butterworth filter of order 2 and cutoff radius 30

Result of filtering with Butterworth filter of order 2 and cutoff radius 230

Result of filtering with Butterworth filter of

order 2 and cutoff radius 80

Result of filtering with Butterworth filter of

order 2 and cutoff radius 15

Page 23: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#'&

Gaussian Lowpass Filters The transfer function of a Gaussian lowpass filter is defined as:

Page 24: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#(&

Gaussian Lowpass Filters (cont…)

Original image

Result of filtering with Gaussian filter with cutoff radius 5

Result of filtering with Gaussian filter with cutoff radius 30

Result of filtering with Gaussian filter with cutoff radius 230

Result of filtering with Gaussian filter

with cutoff radius 85

Result of filtering with Gaussian filter

with cutoff radius 15

Lowpass Filters Compared

Result of filtering with ideal low pass

filter of radius 15

Result of filtering with Butterworth filter of order 2 and cutoff radius 15

Result of filtering with Gaussian filter

with cutoff radius 15

Page 25: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#)&

Lowpass Filtering Examples A low pass Gaussian filter is used to connect broken text

Lowpass Filtering Examples

Page 26: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#*&

Lowpass Filtering Examples

Different lowpass Gaussian filters used to remove blemishes in a photograph

1. High-pass Filters

!  Attenuates high frequencies and retains low frequencies unchanged. !  high frequencies correspond to sharp intensity changes

!  The result in the spatial domain is equivalent to that of a smoothing filter !  fine-scale details and noise in the spatial domain image are

filtered

Page 27: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#+&

High-pass Filters •  A highpass filter yields edge enhancement or edge detection

in the spatial domain

•  Edges contain mostly high frequencies while other areas of the image are rather constant gray level (i.e. low frequencies) which are suppressed.

Ideal High Pass Filters The ideal high pass filter is given as:

where D0 is the cut off distance as before

Page 28: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#,&

Ideal High Pass Filters (cont…)

Results of ideal high pass filtering with D0

= 15

Results of ideal high pass filtering with D0

= 30

Results of ideal high pass filtering with D0

= 80

Butterworth High Pass Filters The Butterworth high pass filter is given as:

where n is the order and D0 is the cut off distance as before

Page 29: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

#!&

Butterworth High Pass Filters (cont…)

Results of Butterworth

high pass filtering of

order 2 with D0 = 15

Results of Butterworth high pass filtering of order 2 with D0 = 80

Results of Butterworth high pass filtering of order 2 with D0 = 30

Gaussian High Pass Filters The Gaussian high pass filter is given as:

where D0 is the cut off distance as before

Page 30: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

'$&

Gaussian High Pass Filters (cont…)

Results of Gaussian high pass filtering

with D0 = 15

Results of Gaussian high pass filtering with D0 = 80

Results of Gaussian high pass filtering with D0 = 30

Highpass Filter Comparison

Results of ideal high pass filtering with D0 = 15

Page 31: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

'%&

Highpass Filter Comparison

Results of Butterworth high pass filtering of order 2 with D0 = 15

Highpass Filter Comparison

Results of Gaussian high pass filtering with D0 = 15

Page 32: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

'#&

Highpass Filter Comparison

Results of ideal high pass filtering with D0

= 15

Results of Gaussian high pass filtering with D0 = 15

Results of Butterworth high pass filtering of order 2 with

D0 = 15

Laplacian In The Frequency Domain

Lapl

acia

n in

the

freq

uenc

y do

mai

n 2-D

image of Laplacian in the

frequency domain

Page 33: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

''&

Frequency Domain Laplacian Example

Original image Laplacian filtered image

Laplacian image scaled

Enhanced image

Some Basic Frequency Domain Filters Low Pass Filter

High Pass Filter

Page 34: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

'(&

3. Band-pass Filters •  A bandpass filter attenuates very low and very high

frequencies, but retains a middle range band of frequencies.

•  Bandpass filtering is used to enhance edges (suppressing low frequencies) while reducing the noise at the same time (attenuating high frequencies).

Band-pass Filters: Example

Page 35: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

')&

Band-pass Filters: Example

Take-home message !  Frequency Domain (Properties)

!  Image filtering in Fourier Domain

!  Filters: !  Low-pass ! High-pass !  Band-pass

Page 36: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

'*&

Basic of filtering: Frequency Domain

!  How to filter in the frequency domain: 1.  Multiply the input image by (-1)x+y to center the transform 2.  Compute F(u,v) (The DFT of the image) 3.  Multiply F(u,v) by a filter function H(u,v) 4.  Compute the invert DFT of the resulting image 5.  Get the real part of the complex image 6.  Multiply the resulting image by (-1)x+y

Fast Fourier Transform !  The reason that Fourier based techniques have become so popular is the development of the Fast Fourier Transform (FFT) algorithm !  Allows the Fourier transform to be carried out in a reasonable amount of time !  Reduces the amount of time required to perform a Fourier transform by a factor of 100 – 600 times!

Page 37: Image Enhancement: Frequency Domain · 2010-09-20 · Image Processing in the frequency domain ! Image smoothing ! Image sharpening ! Fast Fourier Transform Acknowledgements ! Some

!"#$"%$&

'+&

Summary In this lecture we examined image enhancement in the frequency domain

! The Fourier series & the Fourier transform !  Image Processing in the frequency domain

!  Image smoothing !  Image sharpening

!  Fast Fourier Transform

Acknowledgements !  Some of the images and diagrams have been taken from the

Gonzalez et al, “Digital Image Processing” book.