Coe4Tn3 Image Processing: Image Enhancement in The Spatial Image Enhancement in The Spatial Domain
Coe4Tn3 Image Processing: Image Enhancement in The Spatial Image Enhancement in The Spatial Domain
CoE4TN3
• g(x,y)=T[f(x,y)]
Image Processing – f(x,y): input image, g(x,y): processed image
– T: an operator
2 5
Contrast Stretching
m r
Dark Light
3 6
1
Spatial Domain: Point Processing Exercise
• A 4x4 image is given as follow.
Contrast Stretching 1) The image is transformed using the point transform shown.
Find the pixel values of the output image.
15 63 132 133
Original Enhanced 11 60 142 140
0 r
11 60 142 138 20 130
7 10
s=T(r) s s=T(r)
s
r Dark m r
Dark m Light Light
Thresholding
8 11
9 12
2
Image Negative Power-law Transformation
s = cr γ
• If γ <1: maps a narrow range of dark input
values into a wider range of output values.
• If γ >1:opposite of the above effect.
effect
• The process used to correct this power-law
response phenomena is called gamma
correction.
13 16
s = c log(1 + r )
• Log transformation: maps a narrow range of
low gray-level
gray level input image into a wider range
of output levels.
• Expand the values of dark pixels in an image
while compressing the higher-level values.
14 17
15 18
3
Power-law Transformation
Gray-level Slicing
• Highlights a specific range of gray-levels in an image
s
2 basic methods:
1. Display a high value for
all gray levels in the
range of interest and a r
Dark A B Light
low value for all other
2. Brighten the desired
range of gray levels but
preserve the gray level
tonalities r
Dark A B Light
19 22
20 23
Original Image
21 24
4
Bit-plane Slicing Exercise
• A 4x4 image is given as follow.
1) The image is transformed using the point transform shown.
Find the pixel values of the output image.
2) What is the 7-th bit plane of this image
15 63 132 133
11 60 142 140 10
r
11 60 142 138 14 130
25 28
26 29
n
• Problem: an image with gray levels between 0 and 7
is given below. Find the histogram of the image
• Higher order bit planes of an image carry a
significant amount of visually relevant details.
1 6 2 2 0: 1/16 4: 3/16
1 3 3 3 1: 3/16 5: 0/16
• Lower order planes contribute more to fine
2: 2/16 6: 3/16
(often imperceptible) details. 4 6 4 0
1 6 4 7 3: 3/16 7: 1/16
27 30
5
Histogram Equalization (HE): Example 2
Before HE After HE
31 34
32 35
Before HE After HE
33 36
6
Local Enhancement Local Enhancement
m = ∑i =0 ri p (ri )
L −1
σ 2 = ∑i =0 (ri − m) 2 p (ri )
L −1
37 40
mS xy = ∑r s ,t
( s ,t )∈Sxy
p (rs ,t ) σ 2 Sxy = ∑ (r
( s ,t )∈Sxy
s ,t − mSxy ) 2 p(rs ,t )
• Local Enhancement
⎧ E ⋅ f ( x, y ) mS xy ≤ k 0 M G , k1 DG ≤ σ S xy ≤ k 2 DG
g ( x, y ) = ⎨
⎩ f ( x, y ) otherwise
38 41
39 42
7
Logic Operations Image Averaging
• When dealing with logic operations on gray-level
images, pixel values are processed as strings of K noisy observation images
binary numbers. g i ( x, y ) = f ( x, y ) + η i ( x, y )
• AND, OR, COMPLEMENT (NOT)
Averaging
1 K
AND = g ( x, y ) =
K
∑ g ( x, y )
i =1
i
We have
1 2
OR =
E{g ( x, y )} = f ( x, y ) σ g2 ( x , y ) = σ η ( x, y )
M
43 46
Image Subtraction
g(x,y)=f(x,y)-h(x,y)
• Example: imaging blood vessels and arteries in a
body. Blood stream is injected with a dye and X-ray
images are taken before and after the injection
– f(x,y):
f( ) iimage after
ft injecting
i j ti a dye
d
– h(x,y): image before injecting the dye
• The difference of the 2 images yields a clear display
of the blood flow paths.
44 47
Spatial filtering
45 48
8
Spatial Filtering
Example 1
49 52
Spatial Filtering
Example 2
s = − at = − b
50 53
51 54
9
Median Filtering Sharpening Filters
55 58
56 59
57 60
10
Laplacian Laplacian
• The filter is expected to be isotropic: response of the
filter is independent of the direction of discontinuities
in an image.
• Simplest 2-D isotropic second order derivative is the
Laplacian:
∂2 f ∂2 f
∇2 f = +
∂x 2 ∂y 2
∇ 2 f = f ( x + 1, y ) + f ( x − 1, y ) + f ( x, y + 1)
+ f ( x, y − 1) − 4 f ( x, y )
61 64
Laplacian Laplacian
G( ) f(
G(x,y)= f(x,y)-[f(x+1,y)+
) [f( 1 ) f( f(x-1,y)+
1 ) f(f(x,y+1)
1)
+f(x,y-1)]+ 4f(x,y)
= 5f(x,y)-[f(x+1,y)+ f(x-1,y)+ f(x,y+1)
+ f(x,y-1)]
62 65
⎧ Laplacian
L l i maskk
⎪⎪ f ( x, y ) − ∇ f ( x, y ) center is negative
2
g ( x, y ) = ⎨
Laplacian mask
⎪ f ( x, y ) + ∇ 2 f ( x, y )
⎩⎪ center is positive
63 66
11
Laplacian: Example 2 High-boost Filtering with Laplacian
0 -1 0
-1 8 -1
0 -1 0
67 70
-1 -1 -1
-1 9 -1
-1 -1 -1
68 71
69 72
12