You are on page 1of 101

CSE 7448 – Image Processing

Chapter 3. Intensity Transformation


and Spatial Filtering
Dec 2019

Prof. Chung/Worku J. (PhD)


Last week
 DI representation

 Spatial and Intensity resolution

 Interpolation

 Pixel relation

 Basic Mathematical operation

2
Outline
 Spatial and Transform domain

 Intensity Transformation Functions

 Image Histogram/Processing

 Histogram Equalization

 Histogram Matching (Specification)

 Summary

3
3.1 Background
3.1.1 Spatial Domain vs Transform Domain
► Spatial domain (p127)
This method directly processes the intensity values or pixel values of
the image plane and its results can immediately be interpreted by
humans.

► Transform domain
This method transforms the input images into a transform domain,
processes some operation in the domain, and applies the inverse
transform to return to the spatial domain as shown in belows
diagram:Fourier Inverse Fourier
Transform Transform

4
3.1.1 Spatial Domain vs Transform Domain

g ( x, y )  T [ f ( x, y )]) (3.1-1)
f ( x, y ) : input image Spatial – Transform
g ( x, y ) : output image domain domain

T : an operator on f defined over


a neighborhood of point ( x, y)
- The operator T can be a Fourier
Transformation in this book. The output
of T is much different from input image
and the shape in the input image
completely changed.

5
Spatial Domain Process

6
Spatial Domain Process
- Contrast stretching, Thresholding

Intensity transformation function


s  T (r )

Contrast stretching Thresholding


function function
7
3.2 Basic Intensity Transformation Functions

Intensity transformation
function
8
3.2.1 Image Negatives (p130)

Image negatives
intensity level s ( 0 ~ 255)

s  L 1 r
Output image –

r= input intensity level


s= output intensity level
L-1 = maximum intensity level
= 256 -1 = 255

r=0  s= (256-1)-0 =255


r=128  s=(256-1)-128 =127
r=255  s=(256-1)-255 = 0

Input image –
intensity level r ( 0 ~ 255)
9
Image Negatives

Image negatives
s  L 1 r

10
Example: Image Negatives
Ex:
w w=686

h
Ex:
h=790

Small
lesion

11
3.2.2 Log Transformations (p131)

Log Transformations
s  c log(1  r )

12
Example: Log Transformations

13
3.2.3 Power-Law (Gamma) Transformations


s  cr

14
Power-Law (Gamma) Transformations
void DibGammaCorrection(CDib& dib, float gamma)
{ register int i, j;
float invgamma = 1.f / gamma;

int w = dib.GetWidth(); int h = dib.GetHeight();

BYTE** ptr = dib.GetPtr();


for( j = 0 ; j < h ; j++ )
for( i = 0 ; i < w ; i++ )
{ ptr[j][i] = (BYTE)limit(pow((ptr[j][i]/255.f), invgamma)*255 + 0.5f); }
}


s  cr
15
Example: Gamma Corrections - p134

s=r2.5

s=r0.5

s=r2.5

16
Example: Gamma Transformations
Cathode ray tube
(CRT) devices have an
s=r2.5 intensity-to-voltage
response that is a
power function, with
exponents varying
from approximately
s  r1/2.5 1.8 to 2.5

s=r0.4
s=r2.5

17
Example: Gamma Transformations
s=r0.6

(a) original

18

s=r0.4 s=r0.3
Example: Gamma Transformations

s=r3.0

s=r4.0

s=r5.0
19
Piecewise-Linear Transformations
► Contrast Stretching
— Expands the range of intensity levels in an image so that it spans
the full intensity range of the recording medium or display device.

► Intensity-level Slicing
— Highlighting a specific range of intensities in an image often is of
interest.

20
pollen 꽃가루 , x700
21
Highlight the major
blood vessels and
study the shape of the
flow of the contrast
medium (to detect
blockages, etc.)

Measuring the actual


flow of the contrast
medium as a function
of time in a series of
images 22
Bit-plane Slicing

23
Bit-plane Slicing

24
Bit-plane Slicing
Bit 8, 7 Bit 8, 7, 6 Bit 8, t, 6, 5

25
► Experiment 3.1

► Select a image and implement:

 image negative

 Log and gamma transformation

 Contrast stretching

 Bit plane slicing

26
3.3 Histogram Processing (p142)
► 3.3.1 Histogram Equalization

► 3.3.2 Histogram Matching

► 3.3.3 Local Histogram Processing

► 3.3.4 Using Histogram Statistics for Image Enhancement

27
Histogram Processing

Histogram h( rk )  nk n0   n1  n2        

0 1 2 3 ..... 254 255

rk is the k th intensity value


nk is the number of pixels in the image with intensity rk

nk
Normalized histogram p( rk ) 
MN
nk : the number of pixels in the image of
size M  N with intensity rk

28
Histogram Processing

             

0 1 2 3 ..... 254 255

31
32
3.3.1 Histogram Equalization
The intensity levels are assumed in the interval [0, L-1].  ex. [0, 255]
r : input variable – intensity level of input image, s: the output variable for output image
Relation between r and s is transformation function T. Then ..
s = T (r) 0<= r <= L -1 (3.3-1)
that produce an output intensity level s for every pixel in input image having intensity r. We
assume that:
(a) T( r) is a “monotonically increasing function” in 0 <= r <=L-1; and
(b) 0 <= T( r) <= L-1 for 0 <= r <=L-1
Then, We use the inverse
r = T-1 ( s) 0<= s <=L-1 (3.2-2)
In which case we change the condition (a) to (a’) :
(a’) T( r) is a “strictly monotonically increasing function” in 0 <= r <=L-1;
Condition (a’) guarantees that the mapping from s back to r will be one-to-on, preventing ambiguities.
(page 144)
T(r)
T(r)

r r
33
Histogram Equalization
3.3.1 histogram equalization
• Probability theory: (page 145)
If pr(r) and T(r) are known, and T(r) is continuous and differentiable
over the range of values of interest,
then the PDF of the transformed (mapped) variable s can be obtained
using: dr
p s ( s )  pr ( r ) (3.3  3)
ds
• The PDF of the output intensity variable s is determined by the PDF of input r and
the transformation function [ recall that r and s are related by T( r)].
r
s  T (r )  ( L  1)  pr ( w)dw (3.3  4)
0
The right side of this equation is CDF (Cumulative distribution function)
of random variable r.
1) Transformation function of e.q. 3.3-4 satisfies condtion (a)
because the area under the function cannot decrease as r increases
2) When the upper limit of this eq. is r=(L-1), the integral evaluates to 1,
this satisfies condition (b)

34
Histogram Equalization (page 146)

By the Leibniz’s rule in calulus,


• From e.q. 3.3.-1 and 3.3-4:
S= T(r) 0<= r <= L – 1 (3.3-1)
ds dT (r ) dr
 p s ( s )  pr ( r ) (3.3  3)
dr dr ds
d  r
 ( L  1)  pr ( w) dw r
s  T (r )  ( L  1)  pr ( w)dw (3.3  4)
dr  0  0

 ( L  1) pr ( r ) (3.3  5)

•From e.q. 3.3.-3:


dr
ps ( s )  pr ( r )
ds
1
 pr ( r ) (3.3  6)
( L  1) pr (r )
1
 0  s  L 1
L 1

We see that as (eq. 3.3-6) shows, the resulting ps(s) always is uniform,
35
independently of the form of pr(r). Fig 3.18 ilustrates these concepts:
Histogram Equalization
Exercise 3.4: Illustration of eqs. (3.3-4) and (3.3-6)
• Suppose that the intensity values in an image have the PDF
 2r

pr ( r )   ( L  1) 2 for 0  r  L 1

 0 otherwise r
• From eq. (3.3-4) 2
r
s  T ( r )  ( L  1)  pr ( w) dw 
2 r 2 w r
2

L  1 0
w dw  
L 1 L 1
2
0

• From eq. (3.3-6) ps ( s )  pr ( r )


dr 0

ds
1


2r  dr 
( L  1) 2 
 ds 

1

2r  d r  2

( L  1) 2  dr L 1
 
2r L 1

( L  1) 2 2r
1

L 1 36

• As expected, the result ps (s) is a uniform PDF and independent of the form of pr(r)
Histogram Equalization
Exercise 3.4: Illustration of eqs. (3.3-4) and (3.3-6)
• Suppose that the intensity values in an image have the PDF
 2r

pr ( r )   ( L  1) 2 for 0  r  L 1

 0 otherwise r
• From eq. (3.3-4) 2
r
s  T ( r )  ( L  1)  pr ( w) dw 
2 r 2 w r
2

L  1 0
w dw  
L 1 L 1
2
0

• From eq. (3.3-6) ps ( s )  pr ( r )


dr 0

ds
1


2r  dr 
( L  1) 2 
 ds 

1

2r  d r  2

( L  1) 2  dr L 1
 
2r L 1

( L  1) 2 2r
1

L 1 37

• As expected, the result ps (s) is a uniform PDF and independent of the form of pr(r)
Histogram Equalization (page 148)

nk
Normalized histogram p( rk ) 
MN
nk : the number of pixels in the image of
size M  N with intensity rk
Continuous case:
r
s  T ( r )  ( L  1)  pr ( w) dw Eq. (3.3-4)
0
The right side of the eq. is recognized as the cumulative distribution function
(CDF) of random variable r.

Discrete values:
k
sk  T (rk )  ( L  1) pr (rj ) Eq. (3.3-8)
j 0
k nj L 1 k
 ( L  1)   nj k=0,1,..., L-1
j  0 MN MN j  0 38
Example 3.5 : Histogram Equalization ★★★
(page 148)

Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has
the intensity distribution shown in following table.
Get the histogram equalization transformation function and give the ps(sk)
for each sk.

39
Example: Histogram Equalization
• Use eq. 3.3-8 for sk :
Discrete values:
k
sk  T (rk )  ( L  1) pr (rj ) Eq. (3.3-8)
j 0

Solution:
0
s0  T (r0 )  7 pr (rj )  7  0.19  1.33 1
j 0

3
1
s1  T ( r1 )  7 pr ( rj )  7  (0.19  0.25)  3.08
j 0

s2  4.55  5 s3  5.67  6
s4  6.23  6 s5  6.65  7
s6  6.86  7 s7  7.00  7
40
Example: Histogram Equalization

41
Histogram Equalization Ex3.5

rk nk pr(rk) sk=T(rk)   sk sk   ps(sk) rk

r0=0 790 0.19 s0=1.33 → 1 0 ← 0  


r1=1 1023 0.25 s1=3.08 → 3 1 ← 0.19 0
r2=2 850 0.21 s2=4.55 → 5 2 ← 0
r3=3 650 0.16 s3=5.67 → 6 3 ← 0.25 1
r4=4 329 0.08 s4=6.23 → 6 4 ← 0  
r5=5 245 0.06 s5=6.55 → 7 5 ← 0.21 2
r6=6 122 0.03 s6=6.86 → 7 6 ← 0.24 3,4
r7=7 81 0.02 s7=7 → 7 7 ← 0.11 5,6,7
42
43
Histogram Equalization
 Input image vs Histogram equalized image

“lenna.bmp” image
and histogram

“lenna.bmp” image
after histogram
equalization

and its histogram

45
Histogram Equalization
 Input image vs Histogram equalized image

11.08
“camera man” image
and histogram

“camera man” image


after histogram
equalization

and its histogram

46
Histogram Equalization
 Histogram equalization does not give us always better images.

“child” image and


histogram

“child” image after


histogram
equalization

and its histogram

47
48
49
Question
Is histogram equalization always good?

No

50
3.3.2 Histogram Matching (Specification)
Histogram matching (histogram specification)
— generate a processed image that has a specified histogram

Let pr (r ) and pz ( z ) denote the continous probability


density functions of the variables r and z. pz ( z ) is the
specified probability density function.
Let s be the random variable with the probability
r
s  T ( r )  ( L  1)  pr ( w) dw
0

Define a random variable z with the probability


z
G ( z )  ( L  1)  pz (t ) dt  s
0
51
3.3.2 Histogram Matching (Specification)

Equations needed for Histogram Matching :


r
s  T (r )  ( L  1)  pr ( w)dw (3.3-10)
=(3.3-4)
0
z
G ( z )  ( L  1)  pz (t )dt  s (3.3-11)
0

1
z  G (s)  G 1
 T (r )  (3.3-11)

52
Histogram Matching: Procedure
1) Obtain pr(r) from the input image and then obtain the values of s
r
s  ( L  1)  pr ( w)dw (3.3-13)
0

2) Use the specified PDF and obtain the transformation function G(z)
z
G ( z )  ( L  1)  pz (t )dt  s (3.3-14)
0

3) Mapping from s to z ----


(3.3-15)

4) inverse transformation process : Obtain the output image by first equalizing the
input image using eq. (3.3-10); the pixel values in this image are the s values.
Perform the inverse mapping z = G-1(s) to obtain the corresponding pixel in
output image. The PDF of the output image will be the specified PDF.

z  G 1 ( s ) (3.3-16) 53
Histogram Matching: Example 3.7 (page 153)

Assuming continuous intensity values, suppose that an image has


the intensity PDF
 2r
 , for 0  r  L -1
pr (r )   ( L  1) 2

 0, otherwise

Find the transformation function that will produce an image
whose intensity PDF is
 3z 2
 , for 0  z  ( L -1)
pz ( z )   ( L  1) 3

 0, otherwise

54
Histogram Matching: Example
1) Find the histogram equalization transformation for the input image

r
s  T (r )  ( L  1)  pr ( w)dw  ( L  1) 
r 2w r2
dw 
0 0 ( L  1) 2
L 1
2) Find the histogram equalization transformation for the specified histogram

z z 3t 2 z3
G ( z )  ( L  1)  pz (t )dt  ( L  1)  dt  s
0 0 ( L  1) 3
( L  1) 2

3) The transformation function


1/3
1/3  2 r
2
 2 1/3
z  ( L  1) s 
2
 ( L  1)   ( L  1)r 
 L  1
4) From 3), get the image z, where the specified PDF can be obtained.

55
Histogram Matching: Discrete Cases (page 154-
155)
1) Compute the histogram pr(ri) of the given image and use it to find the histogram
equalization transformation sk in eq. (3.3-13). Round the resulting values, sk, to the
range [0, L-1] (3.3-13)
k
( L  1)
k
sk  T ( rk )  ( L  1) pr (rj )   n j k=0, 1, …, L-1
j 0 MN j  0
2) Use the specified PDF and compute the transformation function G(zq) for q = 0,
1, .., L-1 where pz(zi) are the values of the specified histogram. Round the values of G to the
integer range [0, L-1]. Store the values of qG in a table.
G ( zq )  ( L  1) pz ( zi )  sk (3.3-14)
i 0
3) Mapping from sk to zq : For every value of sk, k=0,1,2,…,L-1, use the stored value of G from
2) to find the corresponding value of zq so that G(zq) is closest to sk and store these mappings
from s to z. When more than one value of zq satisfies the given sk, choose the smallest value b
convention.
(3.3-15)

4) Inverse transformation: Form the histogram-specified image by first histogram-equalizing


the input image and then mapping every equalized pixel value s k to the corresponding zq in the
histogram-specified image using the mappings found in step 3).  Refer to the Ex. 3-8
zq  G 1 ( sk ) (3.3-16) 56
Example 3.8 : Histogram Matching
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity
distribution shown in the following table (on the left). Get the histogram transformation function
and make the output image with the specified histogram, listed in the table on the right.

a) Histogram of input image b) Histogram of specified image

57
Example: Histogram Matching
Step 1) Find the histogram equalization transformation sk
- Obtain the scaled histogram-equalized values,
from Ex) 3-5.

s0 = 1, s1 = 3, s2 = 5, s3 = 6,
s4 = 6, s5 = 7, s6 = 7, s7 = 7

Step 2) Obtain the transformation function G(zq):


- Compute all the values of the transformation function G,
using eq. (3.3-14) and Fig 3.22-(b):

58
Example: Histogram Matching
Step 3) Mapping from sk to zq so that G(zq) is closest to sk
- from step 1: histogram-equalized values sk
s0 = 1, s1 = 3, s2 = 5, s3 = 6, s4 = 6, s5 = 7, s6 = 7, s7 = 7
- from step 2: the transformation function G(zq), zq  G 1 ( sk )
zq G(zq) sk rk rk  z q
--------------------------------------------------------------------------
z0 --- G(z0)= 0 s0=1 --- r0 0  3
z1 --- G(z1)= 0 s1=3 --- r1 1  4
z2 --- G(z2)= 0 s2=5 --- r2 2  5
z3 --- G(z3)= 1 s3=6 --- r3 3  6
z4 --- G(z4)= 2 s4=6 --- r4
4  6
z5 --- G(z5)= 5 s5=7 --- r5
5  7
z6 --- G(z6)= 6 s6=7 --- r6
6  7
z7 --- G(z7)= 7 s7=7 --- r7 59
7  7
Histogram Matching Ex3.8

sk
ed
rm
d

s fo
un

an
ro

Tr
sk   ps(sk) rk zq pz(zq) G(zq) G(zq) sk ps(sk) pz(zq) zq
z0=0 0 0 → 0 z0=0
0 ← 0  
z1=1 0 0 → 0 z1=1
1 ← 0.19 0
z2=2 0 0 → 0 z2=2
2 ← 0
z3=3 0.15 1.05 → 1 1 0.19 0.19 z3=3
3 ← 0.25 1
z4=4 0.2 2.45 → 2 3 0.25 0.25 z4=4
4 ← 0  
z5=5 0.3 4.55 → 5 5 0.21 0.21 z5=5
5 ← 0.21 2
z6=6 0.2 5.95 → 6 6 0.24 0.24 z6=6
6 ← 0.24 3,4
z7=7 0.15 7 → 7 7 0.11 0.11 z7=7
7 ← 0.11 5,6,7 60
Example: Histogram Matching

61
Example: Histogram Matching

Original satellite image:


“ Mars moon” photo
62
Example: Histogram Equalization

Histogram equalized image

63
Example: Histogram Matching

Histogram matching
image

64
Example: Histogram Matching

Original satellite image: Histogram equalized Histogram matching


“ Mars moon” photo image image

65
► Summary
 Spatial and Transform domain

 Intensity Transformation Functions

 Image Histogram/Processing

 Histogram Equalization

 Histogram Matching (Specification)

66
► Thank you

67
3.3.3 Local Histogram Processing

11/15
Define a neighborhood and move its center from pixel to
pixel

At each location, the histogram of the points in the


neighborhood is computed. Either histogram equalization or
histogram specification transformation function is obtained

Map the intensity of the pixel centered in the neighborhood

Move to the next location and repeat the procedure

68
3.3.3 Local Histogram Processing: Example
(P 161)

69
3.3.4 Using Histogram Statistics
for Image Enhancement

Average Intensity L 1 M 1 N 1
1
m   ri p (ri ) 
MN
  f ( x, y )
x 0 y 0
i 0
L 1
un (r )   (ri  m) n p (ri )
i 0

Variance L 1 M 1 N 1
1
  u2 (r )   (ri  m) p (ri )   f ( x, y )  m 
2 2 2

i 0
MN x 0 y 0

70
3.3.4 Using Histogram Statistics
for Image Enhancement
The nth moment of r about its mean: (from section 2.6.8)
L 1
un (r )   (ri  m) n p (ri )
i 0
Average Intensity m:
L 1 M 1 N 1
1
m   ri p (ri ) 
MN
  f ( x, y )
x 0 y 0
i 0
Variance = the second moment:
L 1 M 1 N 1
1
  u2 (r )   (ri  m) p(ri )   f ( x, y )  m 
2 2 2

MN x 0 y 0
i 0

71
Using Histogram Statistics for Image
Enhancement
Let S denote a neighborhood of any pixel (x,y):
example: S size can be 3x3
Local average intensity
L 1
msxy   ri psxy (ri )
i 0

sxy denotes a neighborhood

Local variance
L 1
 s2xy   (ri  msxy ) 2 psxy (ri ) 72
i 0
Using Histogram Statistics for Image
Enhancement: Example

 E  f ( x, y ), if msxy  k0 mG and k1 G   sxy  k 2 G


g ( x, y )  
 f ( x, y ), otherwise

mG : global mean;  G : global standard deviation


k0  0.4; k1  0.02; k 2  0.4; E  4

SEM-Scanning Electron Microscope 73


3.4 Spatial Filtering (p 166)

A spatial filter consists of


(a) a neighborhood, and
(b) a predefined operation

- “Filtering” refers to accepting (passing) or rejecting certain frequency


components. “Low pass filter” passes low frequencies.
Main role is to enhance image quality such as reducing noises.
- spatial filter: is called also mask, kernel, template, and window.
- There is one-to-one correspondence between linear filters
and filters in frequency domain.
- Linear spatial filtering of an image of size MxN with a filter of
size mxn is given by the expression
a b
g ( x, y )    w(s, t ) f ( x  s, y  t )
s  a t  b
74
Spatial Filtering

Spatial filter
mask

Image section
under filter 75
Spatial Correlation

The correlation of a filter w( x, y ) of size m  n


with an image f ( x, y ), denoted as w( x, y ) f ( x, y )
a b
w( x, y ) f ( x, y )    w(s, t ) f ( x  s, y  t )
s  a t  b

a=(m-1)/2, b=(m-1)/2
Ex) an image of size MxN with a filter of size mxn
m=3, n=3  a=(3-1)/2= 2/2=1, b=1

76
Spatial Convolution

The convolution of a filter w( x, y ) of size m  n


with an image f ( x, y ), denoted as w( x, y ) f ( x, y )

a b
w( x, y ) f ( x, y )    w(s, t ) f ( x  s, y  t )
s  a t  b

s= -1, t= -1,  w(-1,-1) f(x+1, y+1)


-1, 0,  w(-1, 0) f(x+1, y)
-1, 1,  w(-1, 1) f(x+1, y-1)
0, -1,  w( 0,-1) f(x, y+1)
0, 0,  w( 0, 0) f(x, y)
0, 1,  w( 0, 1) f(x, y-1)
1, -1,  w( 1,-1) f(x-1, y+1) 77

1, 0,  w( 1, 0) f(x-1, y)
Correlation

Convolution

78
79
Smoothing Spatial Filters

Smoothing filters are used for blurring and for noise


reduction

Blurring is used in removal of small details and bridging of


small gaps in lines or curves

Smoothing spatial filters include linear filters and nonlinear


filters.

80
Spatial Smoothing Linear Filters

The general implementation for filtering an M  N image


with a weighted averaging filter of size m  n is given
a b

  w(s, t ) f ( x  s, y  t )
g ( x, y )  s  a t  b
a b

  w(s, t )
s  a t  b

where m  2a  1, n  2b  1.

81
Two Smoothing Averaging Filter Masks

82
1 1 1 1 1
1 1 1
1 1 1 1 1
1 1 1
1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1

1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1
83
Example: Gross Representation of Objects

84
Order-statistic (Nonlinear) Filters

— Nonlinear

— Based on ordering (ranking) the pixels contained in the


filter mask

— Replacing the value of the center pixel with the value


determined by the ranking result

E.g., median filter, max filter, min filter

- median filter: 1) sorting 2) select the value in the middle


- max filter: find the largest value in the filter section

85
Example: Use of Median Filtering for Noise Reduction

86
Sharpening Spatial Filters

► Foundation

► Laplacian Operator

► Unsharp Masking and Highboost Filtering

► Using First-Order Derivatives for Nonlinear Image


Sharpening — The Gradient

87
Sharpening Spatial Filters: Foundation

► 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 f(x) as the difference

2 f
 f ( x  1)  f ( x  1)  2 f ( x)
x 2

88
89
Sharpening Spatial Filters: Laplace Operator

The second-order isotropic derivative operator is the


Laplacian for a function (image) f(x,y)

 2
f  2
f
 f  2  2
2

x y
2 f
 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

 2 f  f ( x  1, y )  f ( x  1, y )  f ( x, y  1)  f ( x, y  1)
- 4 f ( x, y )
90
Sharpening Spatial Filters: Laplace Operator

91
Sharpening Spatial Filters: Laplace Operator

Image sharpening in the way of using the Laplacian:

g ( x, y )  f ( x, y )  c  2 f ( x, y ) 
where,
f ( x, y ) is input image,
g ( x, y ) is sharpenend images,
c  -1 if  2 f ( x, y ) corresponding to Fig. 3.37(a) or (b)
and c  1 if either of the other two filters is used.

92
93
Unsharp Masking and Highboost Filtering

► Unsharp masking
Sharpen images consists of subtracting an unsharp (smoothed)
version of an image from the original image
e.g., printing and publishing industry

► Steps
1. Blur the original image

2. Subtract the blurred image from the original

3. Add the mask to the original

94
Unsharp Masking and Highboost Filtering

Let f ( x, y ) denote the blurred image, unsharp masking is


g mask ( x, y )  f ( x, y )  f ( x, y )
Then add a weighted portion of the mask back to the original
g ( x, y )  f ( x, y )  k * g mask ( x, y ) k 0

when k  1, the process is referred to as highboost filtering.

95
Unsharp Masking: Demo

96
Unsharp Masking and Highboost Filtering: Example

97
Image Sharpening based on First-Order Derivatives

For function f ( x, y ), the gradient of f at coordinates ( x, y )


is defined as
 f 
 g x   x 
f  grad( f )      
 g y   f 
 y 

The magnitude of vector f , denoted as M ( x, y )


Gradient Image M ( x, y )  mag(f )  g x 2  g y 2
98
Image Sharpening based on First-Order Derivatives

The magnitude of vector f , denoted as M ( x, y )


M ( x, y )  mag(f )  g x 2  g y 2

M ( x, y ) | g x |  | g y |

z1 z2 z3
M ( x, y ) | z8  z5 |  | z6  z5 |
z4 z5 z6
z7 z8 z9
99
Image Sharpening based on First-Order Derivatives

Roberts Cross-gradient Operators


M ( x, y ) | z9  z5 |  | z8  z6 |

Sobel Operators
M ( x, y ) | ( z7  2 z8  z9 )  ( z1  2 z2  z3 ) |
z1 z2 z3  | ( z3  2 z6  z9 )  ( z1  2 z4  z7 ) |
z4 z5 z6
z7 z8 z9
100
Image Sharpening based on First-Order Derivatives

f’(x)=f(x+1)-f(x)
f’(y)=f(y+1)-f(y)

x 101
Example

102
Example:

Combining
Spatial
Enhancement
Methods

Goal:

Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail

103
Example:

Combining
Spatial
Enhancement
Methods

Goal:

Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail

104

You might also like