The lecture presents the contents: Using a simpler operation to generate a higher order operation, Multiple summations, General formula, Doing the same with functions, Multiplication and addition of two functions, Operation that uses addition and multiplication...
Trang 1Department of Mechatronics
Chapter 6 Linear Filters
Prof Fei Fei Li, Stanford University
Trang 2• 2D Filter
– Convolution
– Linear Systems
Trang 3Department of Mechatronics
Multiplication
• Using a simpler operat ion to generate a higher
order operation
• Mult iple summat ions
• General form ula
Trang 4Doing the same with functions
• Applying the operations on
each value separated.
• The result is a function.
Trang 5Department of Mechatronics
Multiplication and addition of
two functions
Trang 6• Operation that uses addition and multiplication.
• Result is a function.
• It is a way to combine to functions.
• It is like weighting one function with the other.
• Flipping one function and then summing up the products for each positions for a given offset n.
( ) ( ) (n )
Trang 7Department of Mechatronics
Flipping the function
Trang 8Multiply and add
Trang 9Department of Mechatronics
Multiply and add
Trang 10Multiply and add
Trang 11Department of Mechatronics
Multiply and add
Trang 12Multiply and add
Trang 13Department of Mechatronics
Multiply and add
Trang 14Multiply and add
Trang 15Department of Mechatronics
Multiply and add
Trang 16Multiply and add
Trang 17Department of Mechatronics
Result
Trang 18Comparison
Trang 19Department of Mechatronics
Continuous Convolution
• Summation becomes an integral
Trang 21Department of Mechatronics
Filter
• Signal y(n) is a
convolution of u(n) with
the Transfer function
h(n)
• Filtering can be done by
the convolution of two signals
Trang 222D Filtering
A 2 D in 1 age f[i,j] can be fi l tered by a 2D kernel h[u,v] to
produce an output image g[i,j]
T hi s i s called a cross-correlation operation and written :
h i s called t l 1e " filter ", " kernel " or " mask ".
Trang 23Department of Mechatronics
2D Filtering
Trang 24Example finding edges
Differentiating to find the steep parts of t he picture
Trang 25Department of Mechatronics
Example Simple NoiseReduct i on
• Cutting of the high frequency noise by low pass
filtering with the sine like kernel
• For not changing the aspect of the image the sum
of the kernel must be 1
1/13
Trang 26Images asfunctions
• An Image as a function f from R 2 to R M :
f( x,y) gives the intensity at position ( x, y )
Defined over a rectangle, with a finite range:
Domanin Support range :[ , ]x[ , ] [0, 255]
f a b c d
Trang 27Department of Mechatronics
Images asfunctions
• A color imag e :
• An Image as a function f from R 2 to R M :
f( x,y) gives the intensity at position ( x, y )
Defined over a rectangle, with a finite range:
Domanin Support range
:[ , ]x[ , ] [0, 255]
f a b c d
( , ) ( , ) ( , )
Trang 28Images as discrete functions
• Images are usually digital (discrete):
- Sample the 20 space on a regular grid
• Represented as a matrix of integer values
Trang 29Department of Mechatronics
Images as discrete functions
Cartesian coordinates
Trang 30Images as discrete functions
Trang 31Department of Mechatronics
Systems and Filters
• Filtering:
original pixel values
Goals:
• Extract useful information from the images
Features (edges, corners, blobs )
Super-resolution ; in-pain t ing ; de-noising
Trang 32De -noi s i ng
Ori g in a l S a lt and p e pp e r n o i se
Super -re s olut i on
In-painting
Trang 33Department of Mechatronics
2D discrete- space systems (filters)
Trang 34Filter
Trang 35Department of Mechatronics
Moving average
Trang 36Moving average
Trang 37Department of Mechatronics
Moving average
Trang 38Moving average
Trang 39Department of Mechatronics
Moving average
Trang 40Moving average
Trang 41Department of Mechatronics
Moving average
• Replaces each pi x el w it h an
• Achie v e smoothing effect
Trang 42Moving average
Trang 43Department of Mechatronics
Shift-invariance
Trang 44Is the moving avera ge system is shift inva riant?
Trang 45Department of Mechatronics
Is the moving average system is shift invariant?
Trang 46Linear Systems (filters)
• Linear filtering:
- Fo rm a new i m age whose p i xe l s are a we i ghted
su m of orig i na l p i xe l va l ues
- Use t h e same set of weig h ts at eac h poi n t
• S is a linear sys t em ( f unc t ion) i ff i t S satisfies
Trang 47Department of Mechatronics
Linear Shift Invariant System - LSI
Trang 48The Dirac delta function as the limit (in the sense
of distributions) of the sequence of Gaussians
Kronecker delta
Trang 49Department of Mechatronics
LSI (linear shift invariant ) Systems
Impulse response
Trang 50Example: i mpu l se response of t h e 3 by 3 mov i ng
ave r age fi lte r :
LSI (linear shift invariant ) Systems
Trang 51Department of Mechatronics
An LSI system is completely specified by its impulse
response.
LSI (linear shift invariant ) Systems
sift i ng property of the de l ta f unction
Trang 52Discrete convolution
• Fold h[n,m] about or igin to form h[-k,-l]
• Shift the folded results by n,m to form h[n - k,m - I]
• Multiply h[n - k,m - I] by f[k,I]
• Sum over all k,I
• Repeat for every n, m
Trang 53Department of Mechatronics
Discrete convolution
• Fold h[n,m] about or igin to form h[-k,-l]
• Shift the folded results by n,m to form h[n - k,m - I]
• Multiply h[n - k,m - I] by f[k,I]
• Sum over all k,I
• Repeat for every n, m
Trang 54Discrete convolution
• Fold h[n,m] about or igin to form h[-k,-l]
• Shift the folded results by n,m to form h[n - k,m - I]
• Multiply h[n - k,m - I] by f[k,I]
• Sum over all k,I
• Repeat for every n, m
Trang 55Department of Mechatronics
Convolution in 2D - Examples
Original
Trang 56Original Filtered
Convolution in 2D - Examples
Trang 57Department of Mechatronics
Original
Convolution in 2D - Examples
Trang 58Origina l S hifted l eft
Convolution in 2D - Examples
Trang 59Department of Mechatronics
Origin al
Convolution in 2D - Examples
Trang 60Convolution in 2D - Examples
Trang 61Department of Mechatronics
Original
Convolution in 2D - Examples
Trang 62Convolution in 2D – Sharpening Filter
Or ig in al
Trang 63Department of Mechatronics
Trang 65Department of Mechatronics
Image support and edge effect
• A computer w ill only c onvolv e finite support signals.
ngula r region
fi ni t e support signa Is.
Trang 66• A computer will only convolve finite support signals.
• What happens at the edge?
Image support and edge effect
Trang 67Department of Mechatronics
Zero-Padding
Boundary Padding Options
See the reference page for imfilter for details.
Replicated Boundary Pixels
Trang 68Cross correlation
Trang 69Department of Mechatronics
Matlab: filter2 imfilter Matlab: conv2
Trang 70Filtering: Boundary Issues
• What is the size of the output?
• MATLAB: filter2(g,f,shape)
– shape = ‘full’: output size is sum of sizes of f and g
– shape = ‘same’: output size is same as f
– shape = ‘valid’: output size is difference of sizes of f and g
valid
g g
g g