Professional Documents
Culture Documents
Lect 02
Lect 02
Lect 02
► Spatial domain
image plane itself, directly process the intensity values of the image plane
► Transform domain
process the transform coefficients, not directly process the intensity values of
the image plane
11/14/22 2
Spatial Domain Process
g ( x, y ) T [ f ( x, y )])
f ( x, y ) : input image
g ( x, y ) : output image
T : an operator on f defined over
a neighborhood of point ( x, y )
11/14/22 3
Spatial Domain Process
11/14/22 4
Spatial Domain Process
11/14/22 5
Some Basic Intensity Transformation Functions
11/14/22 6
Image Negatives
Image negatives
s L 1 r
11/14/22 7
Example: Image Negatives
Small
lesion
11/14/22 8
Log Transformations
Log Transformations
s c log(1 r )
11/14/22 9
Example: Log Transformations
11/14/22 10
Power-Law (Gamma) Transformations
s cr
11/14/22 11
Example: Gamma Transformations
11/14/22 12
Example: Gamma Transformations
Cathode ray tube
(CRT) devices have an
intensity-to-voltage
response that is a
power function, with
exponents varying
from approximately
1.8 to 2.5
11/14/22 13
Example: Gamma Transformations
11/14/22 14
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.
11/14/22 15
11/14/22 16
Highlight the major
blood vessels and
study the shape of the
flow of the contrast
medium (to detect
blockages, etc.)
11/14/22 18
Bit-plane Slicing
11/14/22 19
Bit-plane Slicing
11/14/22 20
► In terms of intensity transformation functions, it is not difficult to show that the binary image for the 8th bit plane of
an 8-bit image can be obtained by processing the input image with a thresholding intensity transformation function
that maps all intensities between 0 and 127 to 0 and maps all levels between 128 and 255 to 1.
It is left as an exercise (Problem 3.4) to obtain the intensity transformation functions for generating the other bit planes.
► Decomposing an image into its bit planes is useful for analyzing the relative importance of each bit in the image, a
process that aids in determining the adequacy of the number of bits used to quantize the image. Also, this type of
decomposition is useful for image compression (the topic of Chapter 8), in which fewer than all planes are used in
reconstructing an image.
► The reconstruction is done by multiplying the pixels of the nth plane by the constant pow(2, n-1)
► This is nothing more than converting the nth significant binary bit to decimal.
► Each plane used is multiplied by the corresponding constant, and all planes used are added to obtain the gray scale
image. Thus, to obtain Fig. 3.15(a), we multiplied bit plane 8 by 128, bit plane 7 by 64, and added the two planes.
► Although the main features of the original image were restored, the reconstructed image appears flat, especially in the
background. This is not surprising because two planes can produce only four distinct intensity levels.
11/14/22 21
Histogram Processing
► Histogram Equalization
► Histogram Matching
11/14/22 22
Histogram Processing
Histogram h( rk ) nk
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
11/14/22 23
11/14/22 24
Histogram Equalization
The intensity levels in an image may be viewed as
random variables in the interval [0, L-1].
Let pr (r ) and ps ( s) denote the probability density
function (PDF) of random variables r and s.
11/14/22 25
Histogram Equalization
s T (r ) 0 r L 1
11/14/22 26
Histogram Equalization
s T (r ) 0 r L 1
11/14/22 27
Histogram Equalization
r
s T (r ) ( L 1) pr ( w)dw
0
ds dT (r ) d r
dr
dr
( L 1)
dr 0
pr ( w) dw
( L 1) pr (r )
pr (r )dr pr (r ) pr (r ) 1
ps ( s )
ds ds ( L 1) pr (r ) L 1
dr
11/14/22 28
Example
Suppose that the (continuous) intensity values
in an image have the PDF
2r
2
, for 0 r L-1
pr (r ) ( L 1)
0, otherwise
11/14/22 29
Example
r
s T (r ) ( L 1) pr ( w)dw
0
r 2w
( L 1) 2
dw
0 ( L 1)
2
r
L 1
11/14/22 30
Histogram Equalization
Continuous case:
r
s T (r ) ( L 1) pr ( w)dw
0
Discrete values:
k
sk T (rk ) ( L 1) pr (rj )
j 0
k nj L 1 k
( L 1) nj k=0,1,..., L-1
j 0 MN MN j 0
11/14/22 31
Example: Histogram Equalization
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.
11/14/22 32
Example: Histogram Equalization
0
s0 T (r0 ) 7 pr (rj ) 7 0.19 1.33 1
j 0
1
s1 T (r1 ) 7 pr (rj ) 7 (0.19 0.25) 3.08 3
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
11/14/22 33
Example: Histogram Equalization
11/14/22 34
11/14/22 35
11/14/22
Question
Is histogram equalization always good?
No
11/14/22 37
Histogram Matching
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
► Obtain pr(r) from the input image and then obtain the values of s
r
s ( L 1) pr ( w)dw
0
► Use the specified PDF and obtain the transformation function G(z)
“histogram equalization transformation for the specified histogram”
z
G ( z ) ( L 1) pz (t )dt s
0
► Mapping from s to z
z G 1 ( s )
11/14/22 39
Histogram Matching: Example
11/14/22 42
Histogram Matching: Discrete Cases
► Obtain pr(rj) from the input image and then obtain the values of
sk, round the value to the integer range [0, L-1].
k
( L 1) k
sk T (rk ) ( L 1) pr (rj ) nj
j 0 MN j 0
► Use the specified PDF and obtain the transformation function
G(zq), round the value to the integer range [0, L-1].
q
G ( zq ) ( L 1) pz ( zi ) sk
i 0
► Mapping from sk to zq
zq G 1 ( sk )
11/14/22 43
Example: 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.
11/14/22 44
Example: Histogram Matching
s0 1, s1 3, s2 5, s3 6, s4 7,
s5 7, s6 7, s7 7.
Compute all the values of the transformation function G,
0
G ( z0 ) 7 pz ( z j ) 0.00 0
j 0
G ( z1 ) 0.00 0 G( z2 ) 0.00 0
G ( z3 ) 1.05 1 G( z4 ) 2.45 2
G ( z5 ) 4.55 5 G( z6 ) 5.95 6
G ( z7 ) 7.00 7
11/14/22 45
Example: Histogram Matching
s0 1, s1 3, s2 5, s3 6, s4 7,
s5 7, s6 7, s7 7.
Compute all the values of the transformation function G,
0
G ( z0 ) 7 pz ( z j ) 0.00 0
j 0
G ( z1 ) 0.00 0 G( z2 ) 0.00 0
G ( z3 ) 1.05 1 s0 G( z4 ) 2.45 2 s1
G ( z5 ) 4.55 5 s2 G( z6 ) 5.95 6 s3
G ( z7 ) 7.00 7 s4 s 5 s 6 s7
11/14/22 46
Example: Histogram Matching
s0 1, s1 3, s2 5, s3 6, s4 7,
s5 7, s6 7, s7 7.
rk
0
1
2
3
4
5
11/14/22
6 47
7
Example: Histogram Matching
rk zq
03
1 4
25
36
47
57
67
77
11/14/22 48
Example: Histogram Matching
11/14/22 49
Example: Histogram Matching
11/14/22 50
Example: Histogram Matching
11/14/22 51
Example: Histogram Matching
11/14/22 52
Local Histogram Processing
► 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
11/14/22 53
Local Histogram Processing: Example
11/14/22 54
Using Histogram Statistics for Image Enhancement
Average Intensity L 1
1 M 1 N 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
1 M 1 N 1
u2 (r ) (ri f ( x, y ) m
2 2 2
m) p (ri )
i 0
MN x 0 y 0
11/14/22 55
Using Histogram Statistics for Image Enhancement
Local variance
L 1
2
s xy (ri msxy ) psxy (ri )
2
i 0
11/14/22 56
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
11/14/22 57
Spatial Filtering
11/14/22 58
Spatial Filtering
11/14/22 59
Spatial Correlation
a b
w( x, y ) f ( x, y ) w(s, t ) f ( x s, y t )
s a t b
11/14/22 60
Spatial Convolution
a b
w( x, y ) f ( x, y ) w(s, t ) f ( x s, y t )
s a t b
11/14/22 61
11/14/22 62
11/14/22 63
11/14/22 64
11/14/22 65
Smoothing Spatial Filters
11/14/22 66
Spatial Smoothing Linear Filters
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.
11/14/22 67
Two Smoothing Averaging Filter Masks
11/14/22 68
11/14/22 69
Example: Gross Representation of Objects
11/14/22 70
Order-statistic (Nonlinear) Filters
— Nonlinear
11/14/22 71
Example: Use of Median Filtering for Noise Reduction
11/14/22 72
Sharpening Spatial Filters
► Foundation
► Laplacian Operator
11/14/22 73
Sharpening Spatial Filters: Foundation
f
f ( x 1) f ( x)
x
2 f
2
f ( x 1) f ( x 1) 2 f ( x)
x
11/14/22 74
11/14/22 75
Sharpening Spatial Filters: Laplace Operator
11/14/22 77
Sharpening Spatial Filters: Laplace Operator
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.
11/14/22 78
11/14/22 79
Image scaling (Ch2)
(OR) y= ((x-min)/(max-min))*255
11/14/22 80
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
11/14/22 81
Unsharp Masking: Demo
11/14/22 82
Unsharp Masking and Highboost Filtering
11/14/22 83
Unsharp Masking and Highboost Filtering: Example
11/14/22 84
Image Sharpening based on First-Order Derivatives
M ( x, y ) | g x | | g y |
z1 z2 z3
M ( x, y ) | z8 z5 | | z6 z5 |
z4 z5 z6
z7 z8 z9
11/14/22 86
Image Sharpening based on First-Order Derivatives
Sobel Operators
M ( x, y ) | ( z7 2 z8 z9 ) ( z1 2 z2 z3 ) |
| ( z3 2 z6 z9 ) ( z1 2 z4 z7 ) |
11/14/22 88
Example
89
11/14/22
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
11/14/22 90
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
11/14/22 91