Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The...
Transcript of Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The...
![Page 1: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/1.jpg)
Lecture 6 Sharpening Filters
1. The concept of sharpening filter2 First and second order derivatives2. First and second order derivatives3. Laplace filter4. Unsharp maskp5. High boost filter6. Gradient mask7. Sharpening image with MatLab
![Page 2: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/2.jpg)
Sharpening Spatial Filters
• To highlight fine detail in an image or to enhance detail that has been blurred, either in error or as a natural ff t f ti l th d f i i itieffect of a particular method of image acquisition.
• Blurring vs Sharpening• Blurring vs. Sharpening
• Blurring/smooth is done in spatial domain by pixel averaging in a i hb it i f i t tineighbors, it is a process of integration
Sh i i i t fi d th diff b th• Sharpening is an inverse process, to find the difference by the neighborhood, done by spatial differentiation.spatial differentiation.
2
![Page 3: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/3.jpg)
Derivative operator
• The strength of the response of a derivative operator is proportional to the degree ofoperator is proportional to the degree of discontinuity of the image at the point at which the operator is applied.
• Image differentiation – enhances edges and other discontinuities (noise)– deemphasizes area with slowly varying gray-level
valuesvalues.
3
![Page 4: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/4.jpg)
Sharpening edge by First and second order derivatives
• Intensity function f =f’
• First derivative f ’ =f
• Second-order derivative f ’’
f f’’
f ’’ =f-f
• f- f’’ =
4
![Page 5: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/5.jpg)
First and second order difference of 1D
• The basic definition of the first-order derivative of a one-dimensional function f(x) is the difference
)()1( xfxfxf
−+=∂∂
• The second-order derivative of a one-dimensional function f(x) is the difference
x∂
( )
)(2)1()1(2
xfxfxff++=
∂ )(2)1()1(2 xfxfxfx
−−++=∂
5
![Page 6: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/6.jpg)
![Page 7: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/7.jpg)
First and Second-order derivative of 2D
• when we consider an image function of two variables, f(x, y), at which time we will dealing with partial d i ti l th t ti lderivatives along the two spatial axes.
yxfyxfyxf ∂∂∂ )()()(y
yxfx
yxfyxyxf
∂∂
+∂
∂=
∂∂∂
=∇),(),(),(f
(linear operator)
Gradient operator
2
2
2
22 ),(),( yxfyxff
∂∂
+∂
∂=∇
(linear operator)
Laplacian operator 22 yxf
∂∂p p
(non-linear)
7
![Page 8: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/8.jpg)
Discrete form of Laplacian
)(2)1()1(2
yxfyxfyxff−−++=
∂from ),(2),1(),1(2 yxfyxfyxfx
++=∂
)(2)1()1(2
ffff∂ ),(2)1,()1,(2 yxfyxfyxfy
f−−++=
∂∂
),1(),1([2 yxfyxff −++=∇)],(4)1,()1,(
),1(),1([yxfyxfyxf
yxfyxff−−+++
++∇
8
![Page 9: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/9.jpg)
Result Laplacian mask
9
![Page 10: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/10.jpg)
Laplacian mask implemented an extension of diagonal neighbors
10
![Page 11: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/11.jpg)
Other implementation of Laplacian masks
give the same result, but we have to keep in mind that when combining (add / subtract) a Laplacian-filtered i ith th i
11
image with another image.
![Page 12: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/12.jpg)
Effect of Laplacian Operator• as it is a derivative operator,
– it highlights gray-level discontinuities in an imageit deemphasizes regions with slowly varying gray levels– it deemphasizes regions with slowly varying gray levels
• tends to produce images that have – grayish edge lines and other discontinuities, all superimposed on
a darka dark, – featureless background.
12
![Page 13: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/13.jpg)
Correct the effect of featureless background
• easily by adding the original and Laplacian image.• be careful with the Laplacian filter used• be careful with the Laplacian filter used
if th t ffi i t
⎩⎨⎧
∇∇−
=)()(),(),(
),( 2
2
ffyxfyxf
yxg
if the center coefficient of the Laplacian mask is negative
⎩⎨
∇+ ),(),()( 2 yxfyxf
yg
if the center coefficient of the Laplacian mask is of the Laplacian mask is positive
13
![Page 14: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/14.jpg)
Example
• a). image of the North pole of the moonpole of the moon
• b). Laplacian-filtered image with
1 1 1
1 -8 1
1 1 1
• c). Laplacian image scaled for display purposes
• d). image enhanced by addition with original image
14
image
![Page 15: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/15.jpg)
Mask of Laplacian + addition
• to simply the computation, we can create a mask which do both operations, Laplacian Filter and Addition the
i i l ioriginal image.
15
![Page 16: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/16.jpg)
Mask of Laplacian + addition
)](4)1()1(),1(),1([),(),( −++−=
fffyxfyxfyxfyxg
),1(),1([),(5)],(4)1,()1,(
−++−=+−+++
yxfyxfyxfyxfyxfyxf
)]1,()1,( −+++ yxfyxf
0 -1 0
-1 5 -11 5 1
0 -1 0
16
![Page 17: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/17.jpg)
Example
17
![Page 18: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/18.jpg)
Note
⎩⎨⎧
∇+∇−
=)()(),(),(
),(2
2
yxfyxfyxfyxf
yxg
0 -1 0 0 0 0
⎩ ∇+ ),(),( yxfyxf
0 -1 00 1 0-1 5 -10 -1 0
0 1 00 0 0
= + -1 4 -10 -1 0
0 1 0 0 0 0 0 -1 00 -1 0-1 9 -10 1 0
0 0 00 1 00 0 0
= +0 -1 0-1 8 -10 -1 0
18
0 -1 0 0 0 0 0 1 0
![Page 19: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/19.jpg)
Unsharp masking
)()()( yxfyxfyxf = ),(),(),( yxfyxfyxfs −=
sharpened image = original image – blurred imagesharpened image = original image – blurred image
• to subtract a blurred version of an image produces sharpening output image.
19
![Page 20: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/20.jpg)
Unsharp mask
![Page 21: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/21.jpg)
![Page 22: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/22.jpg)
High-boost filtering
)()()( yxfyxAfyxf −= ),(),(),( yxfyxAfyxfhb =
)()()1(),(),(),()1(),(
ffAyxfyxfyxfAyxfhb −−=
),(),()1( yxfyxfA s−−=
• generalized form of Unsharp masking• A ≥ 1
22
![Page 23: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/23.jpg)
High-boost filtering
),(),()1(),( yxfyxfAyxf shb −−=• if we use Laplacian filter to create sharpen image fs(x,y)
with addition of original image
),(),()(),( yfyfyf shb
with addition of original image
⎨⎧ ∇−
=),(),(
)(2 yxfyxf
yxf⎩⎨
∇+=
),(),(),( 2 yxfyxf
yxfs
⎧
⎩⎨⎧
∇+∇−
=)()(),(),(
),(2
2
yxfyxAfyxfyxAf
yxfhb
23
⎩ ∇+ ),(),( yxfyxAf
![Page 24: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/24.jpg)
High-boost Masks
A ≥ 1if A = 1 it becomes “standard” Laplacian sharpeningif A = 1, it becomes standard Laplacian sharpening
24
![Page 25: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/25.jpg)
Example
25
![Page 26: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/26.jpg)
Gradient Operator
• first derivatives are implemented using the magnitude of the gradientmagnitude of the gradient. ⎤⎡∂fmagnitude of the gradientmagnitude of the gradient.
⎥⎥⎥⎤
⎢⎢⎢⎡
∂∂∂
=⎥⎦
⎤⎢⎣
⎡=∇ f
xf
GGxf
⎥⎥⎦⎢
⎢⎣∂
⎦⎣yfGy
2122 ][)f( +=∇=∇ GGmagf yx
21
22
⎥⎥⎤
⎢⎢⎡
⎟⎟⎠
⎞⎜⎜⎝
⎛∂∂
+⎟⎠⎞
⎜⎝⎛∂∂
=ff
commonly approx.
⎥⎦⎢⎣⎟⎠
⎜⎝ ∂
⎟⎠
⎜⎝ ∂ yx
yx GGf +≈∇
26
the magnitude becomes nonlinearyx
![Page 27: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/27.jpg)
Gradient Mask
• simplest approximation, 2x2z1 z2 z3
z4 z5 z6z4 z5 z6
z7 z8 z9
)( and )( 5658 zzGzzG yx −=−=
212
562
582
122 ])()[(][ zzzzGGf yx −+−=+=∇
5658 zzzzf −+−≈∇
27
![Page 28: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/28.jpg)
Gradient Mask z1 z2 z3
z z z• Roberts cross-gradient operators, 2x2
z4 z5 z6
z7 z8 z9
)( and )( 6859 zzGzzG yx −=−= )()( 6859 yx
212
682
592
122 ])()[(][ zzzzGGf −+−=+=∇ 6859 ])()[(][ zzzzGGf yx ++∇
6859 zzzzf −+−≈∇ 6859 zzzzf +≈∇
28
![Page 29: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/29.jpg)
Gradient Mask z1 z2 z3
z z z• Sobel operators, 3x3
z4 z5 z6
z7 z8 z9
)2()2( 321987 zzzzzzGx ++−++=)2()2( 741963 zzzzzzGy ++−++=
yx GGf +≈∇
the weight value 2 is to achieve smoothing by giving more important
29
giving more important to the center point
![Page 30: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/30.jpg)
Example
30
![Page 31: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/31.jpg)
Example of Combining Spatial Enhancement Methods
• want to sharpen the original image and bring out more skeletal detail.
• problems: narrow dynamic range of gray level and high noiselevel and high noise content makes the image difficult toimage difficult to enhance
31
![Page 32: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/32.jpg)
Example of Combining Spatial Enhancement Methods
• solve : 1. Laplacian to highlight fine detail2. gradient to enhance prominent edges3. gray-level transformation to increase the dynamic
range of gray levelsrange of gray levels
32
![Page 33: Lecture 6 Sharpening Filters - bohr.wlu.ca · 2016-08-25 · Lecture 6 Sharpening Filters 1. The concept of sharpening filter 2. First and second order derivativesFirst and second](https://reader030.fdocuments.net/reader030/viewer/2022040505/5e3b42d39c94ad45fb5e7c85/html5/thumbnails/33.jpg)