cs4501: introduction to computer vision filtering

39
CS4501: Introduction to Computer Vision Filtering, Frequency, and Edges Various slides from previous courses by: D.A. Forsyth (Berkeley / UIUC), I. Kokkinos (Ecole Centrale / UCL). S. Lazebnik (UNC / UIUC), S. Seitz (MSR / Facebook), J. Hays (Brown / Georgia Tech), A. Berg (Stony Brook / UNC), D. Samaras (Stony Brook) . J. M. Frahm (UNC), V. Ordonez (UVA).

Upload: others

Post on 16-Oct-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS4501: Introduction to Computer Vision Filtering

CS4501:IntroductiontoComputerVision

Filtering,Frequency,andEdges

Various slides from previous courses by: D.A.Forsyth(Berkeley/UIUC),I.Kokkinos(Ecole Centrale/UCL).S.Lazebnik (UNC/UIUC),S.Seitz(MSR/Facebook),J.Hays(Brown/GeorgiaTech),A.Berg(StonyBrook/UNC),D.Samaras(StonyBrook).J.M.Frahm (UNC),V.Ordonez(UVA).

Page 2: CS4501: Introduction to Computer Vision Filtering

• ImageProcessing:Brightness• ImageFiltering:MeanFilter• ImageBlurring• ImageGradients:TheSobelOperator

LastClass

Page 3: CS4501: Introduction to Computer Vision Filtering

• RecaponConvolutionalOperations• ImageGradients:TheSobelOperator• FrequencyDomain• FilteringinFrequency• GoogleColaboratory

Today’sClass

Page 4: CS4501: Introduction to Computer Vision Filtering

What we see What a computer seesSource: S. Narasimhan

ImagesasMatrices

Page 5: CS4501: Introduction to Computer Vision Filtering

ImagesasFunctionsz = 𝑓(𝑥, 𝑦)

• Thedomainofxandyis[0,img-width)and[0andimg-height)• x,andyarediscretizedintointegervalues.

Page 6: CS4501: Introduction to Computer Vision Filtering

BasicImageProcessing

𝐼 𝛼𝐼

𝛼 > 1

Page 7: CS4501: Introduction to Computer Vision Filtering

BasicImageProcessing

𝐼 𝛼𝐼

0 < 𝛼 < 1

Page 8: CS4501: Introduction to Computer Vision Filtering

Imagefiltering:Convolutionoperator

ImageCredit:http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/

𝑘(𝑥, 𝑦)

𝑔 𝑥, 𝑦 =11𝑘 𝑢, 𝑣 𝑓(𝑥 − 𝑢, 𝑦 − 𝑣)�

7

8

Page 9: CS4501: Introduction to Computer Vision Filtering

Image filtering: Convolution operatore.g.meanfilter

ImageCredit:http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/

𝑘(𝑥, 𝑦)

𝑘(𝑥, 𝑦) =

1/9 1/9 1/9

1/9 1/9 1/9

1/9 1/9 1/9

Page 10: CS4501: Introduction to Computer Vision Filtering

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 90 0 90 90 90 0 0

0 0 0 90 90 90 90 90 0 0

0 0 0 0 0 0 0 0 0 0

0 0 90 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0

0 10 20 30 30 30 20 10

0 20 40 60 60 60 40 20

0 30 60 90 90 90 60 30

0 30 50 80 80 90 60 30

0 30 50 80 80 90 60 30

0 20 30 50 50 60 40 20

10 20 30 30 30 30 20 10

10 10 10 0 0 0 0 0

[.,.]h[.,.]f

Imagefiltering111111111],[g ××

Credit: S. Seitz

],[],[],[,

lnkmflkgnmhlk

++=å

Page 11: CS4501: Introduction to Computer Vision Filtering

Image filtering: Convolution operatorImportantfilter:gaussian filter(gaussian blur)

ImageCredit:http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/

𝑘(𝑥, 𝑦)

𝑘(𝑥, 𝑦) =

1/16 1/8 1/16

1/8 1/4 1/8

1/16 1/8 1/16

Page 12: CS4501: Introduction to Computer Vision Filtering

Image filtering: Convolution operatore.g.gaussian filter(gaussian blur)

ImageCredit:http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/

Page 13: CS4501: Introduction to Computer Vision Filtering

SharpeningFilter

Original

111111111

000020000 -

Sharpening filter- Accentuates differences with local average

Source: D. Lowe

Page 14: CS4501: Introduction to Computer Vision Filtering

SharpeningFilter

Source: D. Lowe

Page 15: CS4501: Introduction to Computer Vision Filtering

Image filtering: Convolution operatorImportantFilter:Sobeloperator

ImageCredit:http://what-when-how.com/introduction-to-video-and-image-processing/neighborhood-processing-introduction-to-video-and-image-processing-part-1/

𝑘(𝑥, 𝑦)

𝑘(𝑥, 𝑦) =

1 0 -1

2 0 -2

1 0 -1

Page 16: CS4501: Introduction to Computer Vision Filtering

SobelinX

-101

-202

-101

Vertical Edge(absolute value)

Sobel

SlidebyJamesHays

Page 17: CS4501: Introduction to Computer Vision Filtering

SobelinY

-1-2-1

000

121

Horizontal Edge(absolute value)

Sobel

SlidebyJamesHays

Page 18: CS4501: Introduction to Computer Vision Filtering

Sobeloperatorsareequivalentto2Dpartialderivativesoftheimage• Verticalsobel operator– PartialderivativeinX(width)• Horizontalsobel operator– PartialderivativeinY(height)

• Cancomputemagnitudeandphaseateachlocation.

• Usefulfordetectingedges

Page 19: CS4501: Introduction to Computer Vision Filtering

https://en.wikipedia.org/wiki/Sobel_operator

Page 20: CS4501: Introduction to Computer Vision Filtering

Sobelfiltersare(approximate)partialderivativesoftheimage

𝜕𝑓(𝑥, 𝑦)𝜕𝑥

= lim=→?

𝑓 𝑥 + ℎ, 𝑦 − 𝑓(𝑥, 𝑦)ℎ

𝑓(𝑥, 𝑦) beyourinputimage,thenthepartialderivativeis:Let

𝜕𝑓(𝑥, 𝑦)𝜕𝑥

= lim=→?

𝑓 𝑥 + ℎ, 𝑦 − 𝑓(𝑥 − ℎ, 𝑦)2ℎ

Also:

Page 21: CS4501: Introduction to Computer Vision Filtering

Butdigitalimagesarenotcontinuous,theyarediscrete

ΔD𝑓[𝑥, 𝑦] = 𝑓[𝑥 + 1, 𝑦] − 𝑓[𝑥, 𝑦]

𝑓[𝑥, 𝑦] beyourinputimage,thenthepartialderivativeis:Let

ΔD𝑓[𝑥, 𝑦] = 𝑓[𝑥 + 1, 𝑦] − 𝑓[𝑥 − 1, 𝑦]Also:

Page 22: CS4501: Introduction to Computer Vision Filtering

Butdigitalimagesarenotcontinuous,theyarediscrete

ΔD𝑓[𝑥, 𝑦] = 𝑓[𝑥 + 1, 𝑦] − 𝑓[𝑥, 𝑦]

𝑓[𝑥, 𝑦] beyourinputimage,thenthepartialderivativeis:Let

ΔD𝑓[𝑥, 𝑦] = 𝑓[𝑥 + 1, 𝑦] − 𝑓[𝑥 − 1, 𝑦]Also:

-1 1

-1 0 1

k(x,y)=

k(x,y)=

Page 23: CS4501: Introduction to Computer Vision Filtering

SobelOperatorsSmoothinYandthenDifferentiateinX

1 0 -1k(x,y)=

1

2

1

* =

1 0 -1

2 0 -2

1 0 -1

SimilarlytodifferentiateinY

Page 24: CS4501: Introduction to Computer Vision Filtering

Frequency

FigurebyNationalInstruments

Page 25: CS4501: Introduction to Computer Vision Filtering

Anyfunctioncanbeapproximatedbyapolynomialfunction

…ifyouletyourpolynomialhaveahighdegree

…ANDyoucancomputethederivativesoftheoriginalfunctioneasily.

TaylorSeriesexpansion

Page 26: CS4501: Introduction to Computer Vision Filtering
Page 27: CS4501: Introduction to Computer Vision Filtering

Difficultinpractice

https://brilliant.org/wiki/taylor-series-approximation/

Page 28: CS4501: Introduction to Computer Vision Filtering

JeanBaptiste JosephFourier(1768-1830)hadcrazyidea(1807):Any univariate functioncanberewrittenasaweightedsumofsines andcosinesofdifferentfrequencies.

• Don’tbelieveit?– NeitherdidLagrange,Laplace,Poissonandotherbigwigs

– NottranslatedintoEnglishuntil1878!

• Butit’s(mostly)true!– calledFourierSeries– therearesomesubtlerestrictions

...themannerinwhichtheauthorarrivesattheseequationsisnotexemptofdifficultiesand...his

analysistointegratethemstillleavessomethingtobedesiredonthescoreofgeneralityandeven

rigour.

Laplace

LagrangeLegendre

SlidebyJamesHays

Page 29: CS4501: Introduction to Computer Vision Filtering

Example

SlidebyEmmanuelAgu

Page 30: CS4501: Introduction to Computer Vision Filtering

DiscreteFourierTransform

𝐹 𝑢 = 1 𝑓 𝑥 exp −2𝜋𝑖𝑥𝑢𝑁

NOP

DQ?

𝐹 𝑢 = 1 𝑓 𝑥 cos −2𝜋𝑥𝑢𝑁

+ 𝑖 sin −2𝜋𝑥𝑢𝑁

NOP

DQ?

Page 31: CS4501: Introduction to Computer Vision Filtering

InverseDiscreteFourierTransform

𝐹 𝑢 = 1 𝑓 𝑥 exp −2𝜋𝑖𝑥𝑢𝑁

NOP

DQ?

𝑓 𝑥 =1𝑁1 𝐹 𝑢 exp 2𝜋𝑖

𝑥𝑢𝑁

NOP

7Q?

DiscreteFourierTransform

Page 32: CS4501: Introduction to Computer Vision Filtering

Moregenerallyforimages(2DDFTandiDFT)

𝐹 𝑢, 𝑣 = 1 1 𝑓 𝑥, 𝑦 exp −2𝜋𝑖𝑥𝑢𝑀+𝑦𝑣𝑁

NOP

WQ?

XOP

DQ?

𝑓 𝑥, 𝑦 =1𝑀𝑁

1 1𝐹 𝑢, 𝑣 exp 2𝜋𝑖𝑥𝑢𝑀+𝑦𝑣𝑁

NOP

8Q?

XOP

7Q?

Page 33: CS4501: Introduction to Computer Vision Filtering

DiscreteFourierTransform- Visualization

SlidebyA.Zisserman

Page 34: CS4501: Introduction to Computer Vision Filtering

FourierTransform

• Fouriertransformstoresthemagnitudeandphaseateachfrequency• Magnitudeencodeshowmuchsignalthereisataparticularfrequency• Phaseencodesspatialinformation(indirectly)• Formathematicalconvenience,thisisoftennotatedintermsofrealandcomplexnumbers

22 )()( ww IRA +±=)()(tan 1

wwf

RI-=Amplitude: Phase:

SlidebyJamesHays

Page 35: CS4501: Introduction to Computer Vision Filtering

ImageFilteringintheFrequencyDomain

SlidebyA.Zisserman

Page 36: CS4501: Introduction to Computer Vision Filtering

ImageFilteringintheFrequencyDomain

SlidebyA.Zisserman

Page 37: CS4501: Introduction to Computer Vision Filtering

ImageFilteringintheFrequencyDomain

SlidebyA.Zisserman

Page 38: CS4501: Introduction to Computer Vision Filtering

TheConvolutionTheorem• TheFouriertransformoftheconvolutionoftwofunctionsistheproductoftheirFouriertransforms

• Convolution inspatialdomainisequivalenttomultiplication infrequencydomain!

]F[]F[]F[ hghg =*

]]F[][F[F* 1 hghg -=

Howcanthisbeuseful?

Page 39: CS4501: Introduction to Computer Vision Filtering

Questions?

39