Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
1
Image Processing:6. Linear Filters6. Linear Filters
Aleix M. [email protected]
Convolution
•Represent these weights as an image, H.•H is usually called the kernel.•The operation is called a convolution:
•Notice order of indices–all examples can be put in this form–it’s a result of the derivation expressing any shift-
invariant linear operator as a convolution.
Rij H iu, jvFuvu ,v
Example: Smoothing byAveraging Smoothing with a Gaussian
• Smoothing with an averageactually doesn’t compare at all well with a defocussedlens–Most obvious difference
is that a single point oflight viewed in adefocussed lens lookslike a fuzzy blob; but theaveraging process wouldgive a little square.
•A Gaussian gives a goodmodel of a fuzzy blob
exp x2 y2
22
An Isotropic Gaussian Smoothing with a Gaussian
2
Differentiation and convolution
•Recall
•This is linear and shiftinvariant, so must bethe result of aconvolution.
•We could approximatethis as:
fx
lim0
f x , y
f x, y
f
x
f xn1,y f xn , y x
Finite differences
Finite differences responding tonoise
Increasing noise => (this is zero mean additive gaussian noise).
Gradients and edges
•Points of sharp change in an image are interesting:–change in reflectance,–change in object,–change in illumination,–and noise.
•Sometimes called edge points.
•General strategy–determine image gradient.–now mark points where gradient magnitude is
particularly large wrt neighbours (ideally, curves of suchpoints).
There are three major issues:1) The gradient magnitude at different scales is different; which should
we choose?2) The gradient magnitude is large along thick trail; how
do we identify the significant points?3) How do we link the relevant points up into curves?
3
Let be a transform of size J x J where,
Fourier Transform:
)2
exp(1
),( klJ
iJ
lkJJ
k, l = 0,1,…..,J-1JJ
Then the discrete Fourier transform can be defined as:NNQ ,P MM
M M N NF f and
1,,1,0
2exp),(1
),(1
0
1
0
Mu
Nnv
Mmu
inmfMN
vuFM
m
N
n
1,,1,0 Nv
eq(1)
The properties of the discrete Fourier Transform are the sameas the continuous Fourier transform wrt linearity, shift,modulation, convolution, multiplication and correlationproperties.
The inverse transform matrix is
)2
exp(),(1 klJ
ilkJJ
1JJ
And thus the inverse Fourier transform is given by:
1,,1,0
2exp),(),(1
0
1
0
Mm
Nnv
Mmu
ivuFnmfM
u
N
v
1,,1,0 Nn
The kernel function of the discrete transform (seeeq 1) is given by:
Nnv
Mmu
i2exp
(image values can be viewed as weighted sum of periodicpatterns!)
For implementation of the discrete Fouriertransform, equation (1) can be modified to:
1,,1,0
2exp),(
2exp
11),(
1
0
1
0
Mu
Mimu
nmfN
invNM
vuFM
m
N
n
1,,1,0 Nv
The term in the square bracket is the 1D Fourier transformof the mth line, and can be calculated using a FFT. Thus,to perform the 2D Fourier transform each line of the imagecan be computed and replaced with it Fourier transform,and then the 1D FFT of the columns can be computed.
The frequency spectrum is defined as:
),(),(),( 22 vuIvuRvuF
The phase spectrum is given by:
),(),(
tan),( 1vuRvuI
vu
The power spectrum (power spectrum density) is givenby:
),(),(),(),( 222 vuIvuRvuFvuP
The Fourier transform of real function is a complex function, thatis,
F(u,v)=R(u,v) + iI(u,v)
where R(u,v) and I(u,v) are real and imaginary parts of F(u,v)
Power
Square
What happens when thesquare is shifted?
Shifted square
What happens when thesquare is scaled? Say,what if we make itsmaller… What will the FFT look like?
Explain why this makessense.
4
Now, what if we take this tothe extreme, a single-pixelsquare? What do youpredict the DFT will looklike
A single pixel is “on” –roughlycorresponding to animpulse.
Does this make sense?How can we test ouridea that this is “white”?
OK, so now let’s spread thoseimpulses out. Whatshould happen?
And spread them out a bitmore? By now, it’s obvious…
Examples
We’ve placed the zero frequency at the center of the plot.
The “cross” pattern arises from two sources: the edges in the image and the edges of the image.
imshow(log(abs(fftshift(F))),[],'notruesize');colormap(jet); colorbar
5
Another example The convolution of two images f and h of the same size M x Nresults in periodic image g given by:
1
0
1
0
),(),(1
),(M
m
N
n
nbmahnmfMN
bag
According to the convolution theorem f, g, and h and theirtransforms are related by the equation:
),(),(),( vuHvuFvuG Thus we get the following–which dramaticallyreduces the computational cost of convolving“large” masks:
1
0
1
0
2exp),(),(),(M
u
N
v Nbv
Mau
ivuHvuFbag
Using Fourier Transform to calculate image convolutions.
Other Transforms•There are a great many other tranforms, each
with different characteristics and differentuses.•These include:–Hadamard–DCT–Wavelets,–Etc.
The basic forms•Low pass: small values located far from the
co-ordinate regions. Suppresses edges,smoothes/blurs.•High-pass: small values near the origin.
Enhances sharp edges.•Band-pass: select frequencies in a range that
you wish to enhance, or pick directionalresponses that you wish to enhance.
The basic forms.lowpass highpass
bandpass
Example: LPF
6
Example: Band-pass filter Bandstop Filter
Example: High Pass Filter