29
EECS490: Digital Image Processing Lecture #10 Wraparound and padding Image Correlation Image Processing in the frequency domain A simple frequency domain filter Frequency domain filters High-pass, low-pass Apodization Zero-phase filtering Frequency domain filters ideal, Butterworth, Gaussian Ringing

Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Lecture #10

• Wraparound and padding

• Image Correlation

• Image Processing in the frequency domain

• A simple frequency domain filter

• Frequency domain filters

– High-pass, low-pass

– Apodization

• Zero-phase filtering

• Frequency domain filters

– ideal, Butterworth, Gaussian

– Ringing

Page 2: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Wraparound and Padding

f x( ) h x( ) =1

Mf m( )

m=0

h x m( )

DFT makes f & h periodic

If f and g are 400 points f★ggoes out to 800 points

Mirror h to get h(-m)

Now shift h(-m) to get h(x-m)

Wraparound comes from overlap of the periodic functions

© 2002 R. C. Gonzalez & R. E. Woods

We must pad h with 399 points ofzero to get the correct result withthis periodic function

This was nothere before

Page 3: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Wraparound and Padding

We also haveto padimages but intwo-dimensionsto get thecorrectconvolutionresults

Page 4: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

No blurring at edges — no padding

© 2002 R. C. Gonzalez & R. E. Woods

Wraparound and Padding

1

16

1 2 1

2 4 2

1 2 1

Page 5: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Wraparound and PaddingPadding with zeros

Page 6: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Wraparound and Padding

Page 7: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Image Correlation

Original images

Padded images

Correlation output

f x, y( )*h x, y( ) =1

MNf * m,n( )h x + m, y + n( )

n=0

N 1

m=0

M 1

© 2002 R. C. Gonzalez & R. E. Woods

Page 8: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Image Processing in theFrequency Domain

© 2002 R. C. Gonzalez & R. E. Woods

a. Pad original image to PxQb. Multiply padded image by (-1)x+y

d. Fourier transform F(u,v)e. Construct real, symmetric filter H(u,v) of size PxQf. Compute F(u,v)H(u,v)g. Compute Re[F-1 {F(u,v)H(u,v)}] and multiply by (-1)x+y

h. Crop to remove padding in result

Page 9: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Fourier Transform

© 2002 R. C. Gonzalez & R. E. Woods

Due to the shortextrusion

Page 10: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Simple Frequency Domain Filter

What if we simplymultiply F(0,0) byzero?

This is the minimalhigh-pass filter

© 2002 R. C. Gonzalez & R. E. Woods

Page 11: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Simple Frequency DomainFiltering

Multiplying F(0,0) by zeromakes the average imagevalue zero— these arenegative image values whichcannot be displayed, but getcropped to zero!

© 2002 R. C. Gonzalez & R. E. Woods

Page 12: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Gaussian Filters

Frequency domain filters

Corresponding spatialdomain filters

Low-pass filters High-pass filters

This is a Difference ofGaussians, called a DoG

Page 13: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Gaussian Filters

Low-pass filter

High-pass filters

Blurs image Enhances detail;lowers contrast

Addition of apreserves DC term

© 2002 R. C. Gonzalez & R. E. Woods

Page 14: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Frequency Domain Filters

© 2002 R. C. Gonzalez & R. E. Woods

1. Original frequencydomain filter H(f)

2. Spatial domainfilter h(x)= F-1{H(f)}

3. Padded spatialdomain filter hp(x)

4. Fourier transform ofpassed spatial domain filterhp(x)

Discontinuitiescaused by padding

Page 15: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Phase Filters

Results of multiplying ONLY thephase of an image by a constant

MOST image processing filters operate ONLY on themagnitude and are called zero-phase-shift filters

Page 16: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Frequency Domain FilteringExample

a. Original imageb. Padded imagec. Multiply by (-1)x+y

d. Fourier transform F(u,v)e. Centered Gaussian LPFH(u,v)f. Compute F(u,v)H(u,v)g. Compute F-1 {F(u,v)H(u,v)}and multiply by (-1)x+y

h. Crop to remove padding

Padded imagesoften show darkedges

Page 17: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Fourier Transform of an Image

600x600 pixels F(u,v)

Page 18: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Sobel spatial/frequency domainfilters

Frequency domain Sobel

Spatial domain Sobel,3x3

Frequency domainfiltering whereh(x,y) was paddedto 602x602 andcentered prior tomultiplying byF(u,v) in thefrequency domain

Spatial domainfiltering

Page 19: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Ideal Low-pass Filter

Do is picked based upon the fraction of image power to be removed

Page 20: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Test Pattern

Magnitude transformof padded test image

u =1

M xIf M=688 and, say, there are 688 pixels/incheach pixel in the Fourier transformscorresponds to u=1/inch

Page 21: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Filtering with Ideal LPF

Filtering the paddedtest image with anILPF in the frequencydomain

Page 22: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Computing the inverse Fourier transform of theILPF shows ringing in the spatial domain whichis clearly shown in Figure 4.42

Ringing

Page 23: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

© 2002 R. C. Gonzalez & R. E. Woods

Butterworth LPF

H u,v( ) =1

1+D u,v( )D0

2n

For n=1 there is no ringing. Theringing will increase as n increases.

Page 24: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Filtering with Butterworth filter,n=2

© 2002 R. C. Gonzalez & R. E. Woods

Page 25: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Spatial Butterworth filters

© 2002 R. C. Gonzalez & R. E. Woods

Page 26: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Gaussian LPF

H u,v( ) = eD2 u ,v( )

2D02

© 2002 R. C. Gonzalez & R. E. Woods

Page 27: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Low-pass Filters

© 2002 R. C. Gonzalez & R. E. Woods

Page 28: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Filtering with Gaussian LPF

© 2002 R. C. Gonzalez & R. E. Woods

Page 29: Lecture #10 - Case Western Reserve Universityengr.case.edu/.../eecs490f07/Lectures/Lecture10.pdf · 2012-02-16 · Lecture #10 • Wraparound and padding • Image Correlation •

EECS490: Digital Image Processing

Filtering for OCR

No filtering. Brokencharacters are difficult torecognize.

Filtered with a GLPF withD0=80. Characters are fullerand filled in.

© 2002 R. C. Gonzalez & R. E. Woods