image filtering: part ii
TRANSCRIPT
![Page 1: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/1.jpg)
Image Filtering: Part II
Jianping Fan
Dept of Computer Science
UNC-Charlotte
Course Website: http://webpages.uncc.edu/jfan/itcs5152.html
![Page 2: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/2.jpg)
Recap of Filtering
• Linear filtering is dot product at each position
– Not a matrix multiplication
– Can smooth, sharpen, translate (among many other uses)
• Be aware of details for filter size, extrapolation, cropping
111
111
111
![Page 3: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/3.jpg)
© 2006 Steve Marschner • 3
Median filters
• A Median Filter operates over a window by selecting the median intensity in the window.
• What advantage does a median filter have over a mean filter?
• Is a median filter a kind of convolution?
Slide by Steve Seitz
![Page 4: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/4.jpg)
© 2006 Steve Marschner • 4
Comparison: salt and pepper noise
Slide by Steve Seitz
![Page 5: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/5.jpg)
Review: questions
1. Write down a 3x3 filter that returns a positive value if the average value of the 4-adjacent neighbors is less than the center and a negative value otherwise
2. Write down a filter that will compute the gradient in the x-direction:
gradx(y,x) = im(y,x+1)-im(y,x) for each x, y
Slide: Hoiem
![Page 6: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/6.jpg)
Review: questions
3. Fill in the blanks:a) _ = D * B
b) A = _ * _
c) F = D * _
d) _ = D * D
A
B
C
D
E
F
G
H I
Filtering Operator
Slide: Hoiem
![Page 7: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/7.jpg)
Today’s Class
• Fourier transform and frequency domain
– Frequency view of filtering
– Hybrid images
– Sampling
• Reminder: Read your textbook
– Today’s lecture covers material in 3.4
Slide: Hoiem
![Page 8: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/8.jpg)
Why does the Gaussian give a nice smooth image, but the square filter give edgy artifacts?
Gaussian Box filter
![Page 9: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/9.jpg)
Jean Baptiste Joseph Fourier (1768-1830)
had crazy idea (1807):Any univariate function can be rewritten as a weighted sum of sines and cosines of different frequencies.
• Don’t believe it? – Neither did Lagrange,
Laplace, Poisson and other big wigs
– Not translated into English until 1878!
• But it’s (mostly) true!– called Fourier Series
– there are some subtle restrictions
...the manner in which the author arrives at these equations is not exempt of difficulties and...his
analysis to integrate them still leaves something to be desired on the score of generality and even rigour.
Laplace
LagrangeLegendre
![Page 10: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/10.jpg)
How would math
have changed if the
Slanket or Snuggie
had been invented?
![Page 11: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/11.jpg)
A sum of sines
Our building block:
Add enough of them to get any signal g(x) you want!
xAsin(
![Page 12: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/12.jpg)
Frequency Spectra
• example : g(t) = sin(2πf t) + (1/3)sin(2π(3f) t)
= +
Slides: Efros
![Page 13: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/13.jpg)
Frequency Spectra
![Page 14: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/14.jpg)
= +
=
Frequency Spectra
![Page 15: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/15.jpg)
= +
=
Frequency Spectra
![Page 16: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/16.jpg)
= +
=
Frequency Spectra
![Page 17: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/17.jpg)
= +
=
Frequency Spectra
![Page 18: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/18.jpg)
= +
=
Frequency Spectra
![Page 19: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/19.jpg)
= 1
1sin(2 )
k
A ktk
Frequency Spectra
![Page 20: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/20.jpg)
Example: Music
• We think of music in terms of frequencies at different magnitudes
Slide: Hoiem
![Page 21: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/21.jpg)
Other signals
• We can also think of all kinds of other signals the same way
xkcd.com
![Page 22: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/22.jpg)
Fourier analysis in images
Intensity Image
Fourier Image
http://sharp.bu.edu/~slehar/fourier/fourier.html#filtering
![Page 23: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/23.jpg)
Fourier Transform
• Fourier transform stores the magnitude and phase at each frequency– Magnitude encodes how much signal there is at a particular frequency
– Phase encodes spatial information (indirectly)
– For mathematical convenience, this is often notated in terms of real and complex numbers
22 )()( IRA )(
)(tan 1
R
IAmplitude: Phase:
![Page 24: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/24.jpg)
Fourier Bases
in Matlab, check out: imagesc(log(abs(fftshift(fft2(im)))));
![Page 25: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/25.jpg)
IntermissionSlow mo guys – Saccades and CRTs
• https://youtu.be/Fmg9ZOHESgQ?t=21s
• https://youtu.be/3BJU2drrtCM
![Page 26: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/26.jpg)
Man-made Scene
![Page 27: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/27.jpg)
Can change spectrum, then reconstruct
![Page 28: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/28.jpg)
Low and High Pass filtering
![Page 29: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/29.jpg)
The Convolution Theorem
• The Fourier transform of the convolution of two functions is the product of their Fourier transforms
• Convolution in spatial domain is equivalent to multiplication in frequency domain!
]F[]F[]F[ hghg
]]F[][F[F* 1 hghg
![Page 30: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/30.jpg)
Filtering in spatial domain
-101
-202
-101
* =
![Page 31: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/31.jpg)
Filtering in frequency domain
FFT
FFT
Inverse FFT
=
Slide: Hoiem
![Page 32: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/32.jpg)
Why does the Gaussian give a nice smooth image, but the square filter give edgy artifacts?
Gaussian Box filter
Filtering
![Page 33: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/33.jpg)
Gaussian
![Page 34: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/34.jpg)
Box Filter
![Page 35: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/35.jpg)
Is convolution invertible?
• If convolution is just multiplication in the Fourier domain, isn’t deconvolution just division?
• Sometimes, it clearly is invertible (e.g. a convolution with an identity filter)
• In one case, it clearly isn’t invertible (e.g. convolution with an all zero filter)
• What about for common filters like a Gaussian?
![Page 36: Image Filtering: Part II](https://reader031.vdocuments.site/reader031/viewer/2022012411/616a695e11a7b741a352356f/html5/thumbnails/36.jpg)
Project 1: Image Filtering
• Design a system for image filtering: you can select one of these two filters: (a) Gaussian filter; (b) sharpening filter.
• Experimental result demonstration: original images vs. filtered images