Sunteți pe pagina 1din 33

Lecture 6 Sharpening Filters

1. The concept of sharpening filter


2
2. First and second order derivatives
3. Laplace filter
4. Unsharp p mask
5. High boost filter
6. Gradient mask
7. Sharpening image with MatLab
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
effect
ff t off a particular
ti l method th d off image
i acquisition.
i iti

• Blurring vs
vs. Sharpening

• Blurring/smooth is done in spatial domain by pixel averaging in a


neighbors,
i hb it iis a process off iintegration
t ti

• Sh
Sharpening
i is
i an inverse
i process, tot find
fi d th
the diff
difference by
b the
th
neighborhood, done by spatial differentiation.

2
Derivative operator

• The strength of the response of a derivative


operator 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
values.
values

3
Sharpening edge by First and second order derivatives

• Intensity function f =
f’
f
• First derivative f’ =

• Second-order derivative
f’’
f f’’
f-f
f’’ =

• f- f’’ =

4
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

∂f
= f ( x + 1) − f ( x)
∂x
• The second-order derivative of a one-dimensional
function f(x)
( ) is the difference

∂ f
2
= f ( x + 1) + f ( x − 1) − 2 f ( x)
∂x 2

5
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
derivatives along
l th
the ttwo spatial
ti l axes.

∂f ( x, y ) ∂f ( x, y ) ∂f ( x, y )
Gradient operator ∇f = = +
∂x∂y ∂x ∂y
(linear operator)
∂ 2
f ( x , y ) ∂ 2
f ( x, y )
Laplacian
p operator
p ∇ f =
2
+
(non-linear) ∂x 2
∂y 2

7
Discrete form of Laplacian

from
∂ f
2
= f ( x + 1, y ) + f ( x − 1, y ) − 2 f ( x, y )
∂x 2

∂2 f
= f ( x, y + 1) + f ( x, y − 1) − 2 f ( x, y )
∂y 2

∇ f = [ f ( x + 1, y ) + f ( x − 1, y )
2

+ f ( x, y + 1) + f ( x, y − 1) − 4 f ( x, y )]

8
Result Laplacian mask

9
Laplacian mask implemented an extension of
diagonal neighbors

10
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
image with
ith another
th image.
i
11
Effect of Laplacian Operator
• as it is a derivative operator,
– it highlights gray-level discontinuities in an image
– it deemphasizes regions with slowly varying gray levels
• tends to produce images that have
– grayish edge lines and other discontinuities, all superimposed on
a dark
dark,
– featureless background.

12
Correct the effect of featureless background

• easily by adding the original and Laplacian image.


• be careful with the Laplacian filter used

if th
the center
t coefficient
ffi i t
of the Laplacian mask is
⎧ f ( x, y ) − ∇ 2 f ( x, y ) negative
g ( x, y ) = ⎨
⎩ f ( x , y ) + ∇ 2
f ( x, y )
if the center coefficient
of the Laplacian mask is
positive

13
Example

• a). image of the North


pole 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
Mask of Laplacian + addition
• to simply the computation, we can create a mask which
do both operations, Laplacian Filter and Addition the
original
i i l iimage.

15
Mask of Laplacian + addition

g ( x, y ) = f ( x, y ) − [ f ( x + 1, y ) + f ( x − 1, y )
+ f ( x, y + 1) + f ( x, y − 1) + 4 f ( x, y )]
= 5 f ( x, y ) − [ f ( x + 1, y ) + f ( x − 1, y )
+ f ( x, y + 1) + f ( x, y − 1)]

0 -1 0
-1
1 5 -1
1
0 -1 0

16
Example

17
Note
⎧ f ( x, y ) − ∇ f ( x, y )
2
g ( x, y ) = ⎨
⎩ f ( x, y ) + ∇ f ( x, y )
2

0 -1
1 0 0 0 0 0 -1 0
-1 5 -1 = 0 1 0 + -1 4 -1
0 -1 0 0 0 0 0 -1 0

0 -1
1 0 0 0 0 0 -1 0
-1 9 -1 = 0 1 0 + -1 8 -1
0 -1
1 0 0 0 0 0 -1
1 0

18
Unsharp masking

f s ( x, y ) = f ( x, y ) − f ( x, y )
sharpened image = original image – blurred image

• to subtract a blurred version of an image produces


sharpening output image.

19
Unsharp mask
High-boost filtering

f hb ( x, y ) = Af ( x, y ) − f ( x, y )

fhb(x, y) = (A−1) f (x, y) − f (x, y) f (x, y)


= (A−1) f (x, y) − fs (x, y)
• generalized form of Unsharp masking
• A≥1

22
High-boost filtering

f hb ( x, y ) = ( A − 1) f ( x, y ) − f s ( x, y )
• if we use Laplacian filter to create sharpen image fs(x,y)
with addition of original image

⎧ f ( x, y ) − ∇ 2 f ( x, y )
f s ( x, y ) = ⎨
⎩ f ( x , y ) + ∇ 2
f ( x, y )

⎧ Af ( x, y ) − ∇ 2 f ( x, y )
f hb ( x, y ) = ⎨
⎩ Af ( x, y ) + ∇ f ( x, y )
2

23
High-boost Masks

„ A≥1
„ if A = 1,
1 it becomes “standard”
standard Laplacian sharpening

24
Example

25
Gradient Operator

• first derivatives are implemented using the


magnitude of the gradient.
gradient
⎡ ∂∂ff ⎤
⎡Gx ⎤ ⎢ ∂x ⎥
∇f = ⎢ ⎥ = ⎢ ∂f ⎥
⎣Gy ⎦ ⎢ ⎥
⎣⎢ ∂y ⎥⎦
1
∇f = mag (∇f ) = [G + G ]
x
2 2 2
y
1 commonly approx.
⎡⎛ ∂f ⎞ 2 ⎛ ∂f ⎞ 2
⎤ 2

= ⎢⎜ ⎟ + ⎜⎜ ⎟⎟ ⎥
⎢⎣⎝ ∂x ⎠ ⎝ ∂y ⎠ ⎥⎦
∇f ≈ G x + G y
the magnitude becomes nonlinear
26
Gradient Mask
z1 z2 z3
• simplest approximation, 2x2
z4 z5 z6
z7 z8 z9

G x = ( z8 − z 5 ) and G y = ( z 6 − z5 )
1 1
∇ f = [G + G ]
2
x
2
y
2
= [( z8 − z5 ) + ( z6 − z5 ) ]
2 2 2

∇ f ≈ z8 − z 5 + z 6 − z 5

27
Gradient Mask z1 z2 z3
z4 z5 z6
• Roberts cross-gradient operators, 2x2 z7 z8 z9

G x = ( z9 − z5 ) and G y = ( z8 − z 6 )
1 1
∇ f = [G + G ]
2
x
2
y
2
= [( z9 − z5 ) + ( z8 − z6 ) ]
2 2 2

∇ f ≈ z 9 − z 5 + z8 − z 6

28
Gradient Mask z1 z2 z3
z4 z5 z6
• Sobel operators, 3x3 z7 z8 z9

Gx = ( z7 + 2 z8 + z9 ) − ( z1 + 2 z 2 + z3 )
G y = ( z3 + 2 z6 + z9 ) − ( z1 + 2 z 4 + z7 )
∇f ≈ G x + G y
the weight value 2 is to
achieve smoothing by
giving more important
to the center point
29
Example

30
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 noise
content makes the
image difficult to
enhance

31
Example of Combining Spatial Enhancement Methods

• solve :
1. Laplacian to highlight fine detail
2. gradient to enhance prominent edges
3. gray-level transformation to increase the dynamic
range of gray levels

32

S-ar putea să vă placă și