methods for digital image processing basic ideas of image transforms

73
Methods for Digital Image Methods for Digital Image Processing Processing G ra y -le vel H isto g ram S p atial DFT DCT S p e c tral D ig ita l Im a g e C h a rac teristic s P o in t P ro c e ssin g M asking F ilterin g E nhancem ent D e g ra d a tio n M odels In ve rs e F ilterin g W ie n e r F ilterin g R esto ratio n P re -P ro c e ssin g In fo rm a tio n Theory L Z W (gif) Lossless T ra n sfo rm -b a se d (jp eg ) Lossy C om pression E d g e D etectio n Segm en tatio n S h a p e D escrip to rs T ex tu re M orphology D escrip tio n D ig ita l Im a g e P ro c e ssin g

Post on 15-Jan-2016

231 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Methods for Digital Image Processing Basic ideas of Image Transforms

Methods for Digital Image ProcessingMethods for Digital Image Processing

G ray-level Histogram

Spatial

DFT DCT

Spectral

Digital Im age Characteristics

Point Processing M asking Filtering

Enhancem ent

Degradation M odels Inverse Filtering W iener Filtering

Restoration

Pre-Processing

Inform ation Theory

LZW (gif)

Lossless

T ransform -based (jpeg)

Lossy

Com pression

Edge Detection

Segm entation

Shape Descriptors T exture M orphology

Description

Digital Im age Processing

Page 2: Methods for Digital Image Processing Basic ideas of Image Transforms

Basic ideasBasic ideas of Image of Image

TransformsTransforms

Page 3: Methods for Digital Image Processing Basic ideas of Image Transforms

Spatial FrequencySpatial Frequencyoror

Fourier TransformFourier Transform

Jean Baptiste Joseph Fourier

Page 4: Methods for Digital Image Processing Basic ideas of Image Transforms

Why are Spatial Frequencies Why are Spatial Frequencies important?important?

• Efficient data representation

• Provides a means for modeling and removing noise

• Physical processes are often best described in “frequency domain”

• Provides a powerful means of image analysis

Page 5: Methods for Digital Image Processing Basic ideas of Image Transforms

What is spatial frequency?What is spatial frequency?

• Instead of describing a function (i.e., a shape) by a series of positions

• It is described by a series of cosines

Page 6: Methods for Digital Image Processing Basic ideas of Image Transforms

What is spatial frequency?What is spatial frequency?

A

g(x) = A cos(x)

2

x

g(x)

Page 7: Methods for Digital Image Processing Basic ideas of Image Transforms

What is spatial frequency?What is spatial frequency?

Period (L)Wavelength ()Frequency f=(1/ )

Amplitude (A)Magnitude (A)

A cos(x 2/L)g(x) = A cos(x 2/) A cos(x 2f)

x

g(x)

Page 8: Methods for Digital Image Processing Basic ideas of Image Transforms

What is spatial frequency?What is spatial frequency?

A

g(x) = A cos(x 2f)

x

g(x)

(1/f)(1/f)

period

Page 9: Methods for Digital Image Processing Basic ideas of Image Transforms

But what if cosine is shifted in phase?But what if cosine is shifted in phase?

g(x) = A cos(x 2f + )

x

g(x)

Page 10: Methods for Digital Image Processing Basic ideas of Image Transforms

What is spatial frequency?What is spatial frequency?

g(x) = A cos(x 2f + )

A=2 mf = 0.5 m-1

= 0.25 = 45g(x) = 2 cos(x 2(0.5) + 0.25) 2 cos(x + 0.25)

x g(x)0.00 2 cos(0.25) = 0.707106...0.25 2 cos(0.50) = 0.00.50 2 cos(0.75) = -0.707106...0.75 2 cos(1.00) = -1.01.00 2 cos(1.25) = -0.707106…1.25 2 cos(1.50) = 01.50 2 cos(1.75) = 0.707106...1.75 2 cos(2.00) = 1.02.00 2 cos(2.25) = 0.707106...

Let us take arbitrary g(x)

We substitute values of A, f and

We calculate discrete values of g(x) for various values of x

Page 11: Methods for Digital Image Processing Basic ideas of Image Transforms

What is spatial frequency?What is spatial frequency?

g(x) = A cos(x 2f + )

x

g(x)We calculate discrete values of g(x) for various values of x

Page 12: Methods for Digital Image Processing Basic ideas of Image Transforms

Now we take discrete values of Now we take discrete values of AAii , f , fii

and and i

gi(x) = Ai cos(x 2fi + i), i = 0,1,2,3,...

x

Page 13: Methods for Digital Image Processing Basic ideas of Image Transforms

Now we substitute fNow we substitute fi i = i/N= i/N

gi(x) = Ai cos(x 2i/N + i), i = 0,1,2,3,…,N-1

f=i/N

0 N

gi(x) = Ai cos(x 2fi + i), i = 0,1,2,3,...

N = time interval

Page 14: Methods for Digital Image Processing Basic ideas of Image Transforms

Values for various values of Values for various values of i

gi(x) = Ai cos(x 2i/N + i), i = 0,1,2,3,…,N-1

f=i/N

0 N

We calculate values of function for various values of ii

Page 15: Methods for Digital Image Processing Basic ideas of Image Transforms

Substituting various values of Substituting various values of ii to the to the formula we get various cosinusoidesformula we get various cosinusoides

gi(x) = Ai cos(x 2i/N + i), i = 0,1,2,3,…,N-1

i=0 i=1 i=2

A0A1

A2

Page 16: Methods for Digital Image Processing Basic ideas of Image Transforms

Changing Changing NN to to N/2N/2

gi(x) = Ai cos(x 2i/N + i), i = 0,1,2,3,…,N/2 - 1

i=N/2 - 1i=0

If N equals the number of pixel in a line, then...

Lowest frequency Highest frequency

Page 17: Methods for Digital Image Processing Basic ideas of Image Transforms

What is spatial frequency?What is spatial frequency?

gi(x) = Ai cos(x 2i/N + i), i = 0,1,2,3,…,N/2-1

i=N/2-1i=0

If N equals the number of pixels in a line, then...

Lowest frequency Highest frequency

Page 18: Methods for Digital Image Processing Basic ideas of Image Transforms

What will happen if we take What will happen if we take N/2N/2??

gi(x) = Ai cos(x 2i/N + i), i = 0,1,2,3,…,N/2-1

i=N/2i=0

If N equals the number of pixel in a line, then...

Lowest frequency Too high Redundant frequency

Page 19: Methods for Digital Image Processing Basic ideas of Image Transforms

What is spatial frequency?What is spatial frequency?

12/

0

12/

0

/2cos)(Ni

iii

Ni

ii NixAxgxg

g(x) = A cos(x 2f + )

gi(x) = Ai cos(x 2i/N + i), i = 0,1,2,3,…,N/2-1

Page 20: Methods for Digital Image Processing Basic ideas of Image Transforms
Page 21: Methods for Digital Image Processing Basic ideas of Image Transforms
Page 22: Methods for Digital Image Processing Basic ideas of Image Transforms

We try to approximate a periodic We try to approximate a periodic function with standard trivial function with standard trivial (orthogonal, base) functions(orthogonal, base) functions

+

+=

Low frequency

Medium frequency

High frequency

Page 23: Methods for Digital Image Processing Basic ideas of Image Transforms

We add values from component We add values from component functions functions point by pointpoint by point

+

+=

Page 24: Methods for Digital Image Processing Basic ideas of Image Transforms

g(x)

i=1

i=2

i=3

i=4

i=5

i=63

0 127

xExample of periodic function created by summing standard trivial functions

Page 25: Methods for Digital Image Processing Basic ideas of Image Transforms

g(x)

i=1

i=2

i=3

i=4

i=5

i=10

0 127x

Example of periodic function created by summing standard trivial functions

Page 26: Methods for Digital Image Processing Basic ideas of Image Transforms

g(x)

g(x)

64 terms

10 terms

Example of periodic function created by summing standard trivial functions

Page 27: Methods for Digital Image Processing Basic ideas of Image Transforms

g(x)

i=1

i=2

i=3

i=4

i=5

i=630 127

x

Fourier Decomposition of a step function (64 terms)

Example of periodic function created by summing standard trivial functions

Page 28: Methods for Digital Image Processing Basic ideas of Image Transforms

g(x)

i=1

i=2

i=3

i=4

i=5

i=100 63

x

Fourier Decomposition of a step function (11 terms)

Example of periodic function created by summing standard trivial functions

Page 29: Methods for Digital Image Processing Basic ideas of Image Transforms

Main concept – summation of base Main concept – summation of base functionsfunctions

12/

0

/2cos)(Ni

iii NixAxg

Any function of x (any shape) that can be represented by g(x) can also be represented by the summation of cosine functions

Observe two numbers for every i

Page 30: Methods for Digital Image Processing Basic ideas of Image Transforms

Information is not lost when we Information is not lost when we change the domainchange the domain

gi(x) = 1.3, 2.1, 1.4, 5.7, …., i=0,1,2…N-1

N pieces of information

12/

0

/2cos)(Ni

iiii NixAxg

N pieces of informationN/2 amplitudes (Ai, i=0,1,…,N/2-1) andN/2 phases (i, i=0,1,…,N/2-1) and

SpatialSpatial Domain

Frequency Domain

Page 31: Methods for Digital Image Processing Basic ideas of Image Transforms

What is spatial frequency?What is spatial frequency?

gi(x)

Are equivalentThey contain the same amount of information

12/

0

/2cosNi

iii NixA and

The sequence of amplitudes squared is the SPECTRUM

Information is not lost when we Information is not lost when we change the domainchange the domain

Page 32: Methods for Digital Image Processing Basic ideas of Image Transforms

EXAMPLE

Page 33: Methods for Digital Image Processing Basic ideas of Image Transforms

A cos(x2i/N)frequency (f) = i/Nwavelength (p) = N/I

N=512i f p0 0 infinite1 1/512 51216 1/32 32256 1/2 2

Substitute values

Assuming N we get this table which relates frequency and wavelength of component functions

Page 34: Methods for Digital Image Processing Basic ideas of Image Transforms

More examples to give you some intuition….

Page 35: Methods for Digital Image Processing Basic ideas of Image Transforms

Fourier Transform NotationFourier Transform Notation• g(x) denotes an spatial domain function of real numbers

– (1.2, 0.0), (2.1, 0.0), (3.1,0.0), …

• G() denotes the Fourier transform

• G() is a symmetric complex function(-3.1,0.0), (4.1, -2.1), (-3.1, 2.1), …(1.2,0.0) …, (-3.1,-2.1), (4.1, 2.1), (-3.1,0.0)

• G[g(x)] = G(f) is the Fourier transform of g(x)

• G-1() denotes the inverse Fourier transform

• G-1(G(f)) = g(x)

Page 36: Methods for Digital Image Processing Basic ideas of Image Transforms

Power Spectrum and Phase SpectrumPower Spectrum and Phase Spectrum

• |G(f)|2 = G(f)G(f)* is the power spectrum of G(f)– (-3.1,0.0), (4.1, -2.1), (-3.1, 2.1), … (1.2,0.0),…, (-3.1,-2.1), (4.1, 2.1)

– 9.61, 21.22, 14.02, …, 1.44,…, 14.02, 21.22

• tan-1[Im(G(f))/Re(G(f))] is the phase spectrum of G(f)– 0.0, -27.12, 145.89, …, 0.0, -145.89, 27.12

complex

Complex conjugate

Page 37: Methods for Digital Image Processing Basic ideas of Image Transforms

1-D DFT and IDFT1-D DFT and IDFT• Discrete Domains

– Discrete Time: k = 0, 1, 2, 3, …………, N-1– Discrete Frequency: n = 0, 1, 2, 3, …………, N-1

• Discrete Fourier Transform

• Inverse DFT

Equal time intervals

Equal frequency intervals

1N

0k

nkN2

j;e ]k[x]n[X

1N

0n

nkN2

j;e ]n[X

N1

]k[x

n = 0, 1, 2,….., N-1

k = 0, 1, 2,….., N-1

Page 38: Methods for Digital Image Processing Basic ideas of Image Transforms

Fourier 2D Image Fourier 2D Image TransformTransform

Page 39: Methods for Digital Image Processing Basic ideas of Image Transforms

Another formula for Two-Dimensional Another formula for Two-Dimensional FourierFourier

A cos(x2i/N) B cos(y2j/M)fx = u = i/N, fy = v =j/M

Image is function of x and y

Now we need two cosinusoids for each point, one for x and one for y

Lines in the figure correspond to real value 1

Now we have waves in two directions and they have frequencies and amplitudes

Page 40: Methods for Digital Image Processing Basic ideas of Image Transforms

Fourier Transform of a Fourier Transform of a spotspot

Original image Fourier Transform

Page 41: Methods for Digital Image Processing Basic ideas of Image Transforms

Transform Results

image

spectrum

transform

Page 42: Methods for Digital Image Processing Basic ideas of Image Transforms

Two Dimensional Fast Fourier in Two Dimensional Fast Fourier in MatlabMatlab

Page 43: Methods for Digital Image Processing Basic ideas of Image Transforms

Filtering in Frequency Filtering in Frequency DomainDomain

… will be covered in a separate lecture on spectral approaches…..

Page 44: Methods for Digital Image Processing Basic ideas of Image Transforms

•H(u,v) for various values of u and v

•These are standard trivial functions to compose the image from

Page 45: Methods for Digital Image Processing Basic ideas of Image Transforms
Page 46: Methods for Digital Image Processing Basic ideas of Image Transforms

< < image

..and its spectrum

Page 47: Methods for Digital Image Processing Basic ideas of Image Transforms

Image and its spectrum

Page 48: Methods for Digital Image Processing Basic ideas of Image Transforms

Image and its spectrum

Page 49: Methods for Digital Image Processing Basic ideas of Image Transforms

Image and its spectrum

Page 50: Methods for Digital Image Processing Basic ideas of Image Transforms

Let g(u,v) be the kernelLet h(u,v) be the imageG(k,l) = DFT[g(u,v)]H(k,l) = DFT[h(u,v)]

Then DFT 1 G H g h

where means multiplicationand means convolution.

This means that an image can be filtered in the Spatial Domain or the Frequency Domain.

Convolution TheoremConvolution Theorem

This is a very important result

Page 51: Methods for Digital Image Processing Basic ideas of Image Transforms

Let g(u,v) be the kernelLet h(u,v) be the imageG(k,l) = DFT[g(u,v)]H(k,l) = DFT[h(u,v)]

Then

DFT 1 G H g h

where means multiplicationand means convolution.

Convolution TheoremConvolution Theorem

Instead of doing convolution in spatial domain we can do multiplication

In frequency domain

Convolution in spatial domain

Multiplication in spectral domain

Page 52: Methods for Digital Image Processing Basic ideas of Image Transforms

v

u

Image

Spectrum Noise and its spectrum

Noise filtering

Page 53: Methods for Digital Image Processing Basic ideas of Image Transforms

Image

v

u

Spectrum

Page 54: Methods for Digital Image Processing Basic ideas of Image Transforms

Image x(u,v)

v

u

Spectrum log(X(k,l))

l

k

Page 55: Methods for Digital Image Processing Basic ideas of Image Transforms

Spectrum log(X(k,l))

k

lv

u

Image x(u,v)

Image of cow with noise

Page 56: Methods for Digital Image Processing Basic ideas of Image Transforms

white noise white noise spectrum

kernel spectrum (low pass filter)

red noise red noise spectrum

Page 57: Methods for Digital Image Processing Basic ideas of Image Transforms

Filtering is done in spectral domain. Can be very complicated

Page 58: Methods for Digital Image Processing Basic ideas of Image Transforms

Image TransformsImage Transforms• Fast Fourier

– 2-D Discrete Fourier Transform

• Fast Cosine– 2-D Discrete Cosine Transform

• Radon Transform• Slant• Walsh, Hadamard, Paley, Karczmarz• Haar• Chrestenson• Reed-Muller

Page 59: Methods for Digital Image Processing Basic ideas of Image Transforms

Discrete Cosine Transform Discrete Cosine Transform (DCT)(DCT)

•Used in JPEG and Used in JPEG and MPEGMPEG

•Another Frequency Another Frequency Transform, with Transform, with Different Set of Basis Different Set of Basis FunctionsFunctions

Page 60: Methods for Digital Image Processing Basic ideas of Image Transforms

Discrete Cosine Discrete Cosine Transform in MatlabTransform in Matlab

Page 61: Methods for Digital Image Processing Basic ideas of Image Transforms

““Statistical” FiltersStatistical” Filters

•Median Filter also eliminates noise•preserves edges better than blurring

•Sorts values in a region and finds the median

•region size and shape

•how define the median for color values?

Page 62: Methods for Digital Image Processing Basic ideas of Image Transforms

““Statistical” Filters Statistical” Filters ContinuedContinued

•Minimum Filter Minimum Filter (Thinning)(Thinning)

•Maximum Filter Maximum Filter (Growing)(Growing)

•““Pixellate” FunctionsPixellate” FunctionsNow we can do this quickly in spectral domain

Page 63: Methods for Digital Image Processing Basic ideas of Image Transforms

•ThinninThinningg

•GrowinGrowingg

Page 64: Methods for Digital Image Processing Basic ideas of Image Transforms

Pixellate ExamplesPixellate Examples

Page 65: Methods for Digital Image Processing Basic ideas of Image Transforms

DCT FeaturesDCT Features

Fringe Pattern

DCT

DCT Coefficients

Zonal Mask

1 2

3

4

5

1 2 3 4 5

(1,1)(1,2)(2,1)(2,2)

.

.

.

FeatureVector

ArtificialNeuralNetwork

Can be used for face recognition, tell my story from Japan.

Page 66: Methods for Digital Image Processing Basic ideas of Image Transforms

Noise RemovalNoise Removal

Image with Noise Transform Image reconstructed

Transforms for Noise RemovalTransforms for Noise Removal

Page 67: Methods for Digital Image Processing Basic ideas of Image Transforms

Image Segmentation Recall: Image Segmentation Recall: Edge DetectionEdge Detection

f(x,y) Gradient Mask

fe(x,y)

-1 -2 -10 0 01 2 1

-1 0 1-2 0 2-1 0 1

Now we do this in spectral domain!!

Page 68: Methods for Digital Image Processing Basic ideas of Image Transforms

Image MomentsImage Moments2-D continuous function f(x,y), the moment of order (p+q) is:

....2 ,1 ,0,

),(

qp

dydxyxfyxm qppq

Central moment of order (p+q) is:

00

01

00

10 ;

where

),()()(

m

my

m

mx

dydxyxfyyxx qppq

Page 69: Methods for Digital Image Processing Basic ideas of Image Transforms

Image Moments (contd.)Image Moments (contd.)

Normalized central moment of order (p+q) is:

,.....3 ,2,for

;12

where

;00

qp

qp

pqpq

A set of seven invariant moments can be derived from pq

Now we do this in spectral domain!!

Page 70: Methods for Digital Image Processing Basic ideas of Image Transforms

Image TexturesImage Textures

The USC-SIPI Image Databasehttp://sipi.usc.edu/

Grass Sand Brick wall

Now we do this in spectral domain!!

Page 71: Methods for Digital Image Processing Basic ideas of Image Transforms

ProblemsProblems• There is a lot of Fourier and Cosine Transform

software on the web, find one and apply it to remove some kind of noise from robot images from FAB building.

• Read about Walsh transform and think what kind of advantages it may have over Fourier

• Read about Haar and Reed-Muller transform and implement them. Experiment

Page 72: Methods for Digital Image Processing Basic ideas of Image Transforms

SourcesSources• Howard Schultz, Umass

• Herculano De Biasi• Shreekanth Mandayam• ECE Department, Rowan University• http://engineering.rowan.edu/~shreek/fall01/dip/

http://engineering.rowan.edu/~shreek/fall01/dip/lab4.html

Page 73: Methods for Digital Image Processing Basic ideas of Image Transforms

Image CompressionImage CompressionPlease visit the website

http://www.cs.sfu.ca/CourseCentral/365/li/material/notes/Chap4/Chap4.html