IMAGE ENHANCEMENT
IMAGE ENHANCEMENT
[IMAGE ENHANCEMENT ]
Mrs.S. Maheswari
AP/BME
1
Spatial Domain: Basic
intensity transformation
2
Spatial Domain: Basic intensity transformation
Spatial Domain vs. Transform Domain
• 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.
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 )
3
Spatial Domain Process
4
Spatial Domain Process
5
Point Processing
(Intensity Transformation)
s(x,y) = T{ r(x,y)}
Transformed Original
Gray Level Gray Level
Transformation
Function
>>imadjdemo
>>imadjust
6
Point Processing
• Pixel Operations :
• Point processing individual pixels
7
Image Negatives
Image negatives
s L 1 r
8
Example: Image Negatives
Small
lesion
9
Log Transformations
Log Transformations
s c log(1 r )
10
Example: Log Transformations
11
Power-Law (Gamma) Transformations
s cr
12
Applications
Gamma correction
Display the image accurately on the screen
Used to reproduce colors accurately.
Before releasing/storing the image in the website they are preprocessed
using gamma correction to make them suitable for all monitors and
computer systems.
• General Purpose contrast manipulation
• Enhancing images with washed out appearance.
13
Example: Gamma Transformations
14
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
1/2.5
s r
15
Example: Gamma Transformations
16
Example: Gamma Transformations
17
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.
18
19
Highlight the major blood
vessels and study the
shape of the flow of the
contrast medium (to
detect blockages, etc.)
20
Bit-plane Slicing
21
Bit-plane Slicing
22
Bit-plane Slicing
23
Some Basic Intensity Transformation Functions
24
Histogram Processing
25
Histogram Processing
1. Histogram Equalization
2. Histogram Matching
3. Local Histogram Processing
4. Using Histogram Statistics for Image Enhancement
Histogram h( rk ) nk
th
rk is the k 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
26
1.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.
27
28
Histogram Equalization
s T (r ) 0 r L 1
30
Histogram Equalization
s T (r ) 0 r L 1
ps ( s)ds pr (r )dr
31
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
32
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
33
Example
r
s T (r ) ( L 1) pr ( w)dw
0
r 2w
( L 1) 2
dw
0 ( L 1)
2
r
L 1
34
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
35
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 p s(sk)
for each sk.
36
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
37
Example: Histogram Equalization
38
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
39
Histogram Matching
r
s T (r ) ( L 1) pr ( w)dw
0
z
G ( z ) ( L 1) pz (t )dt s
0
1
z G ( s ) G 1
T (r )
40
Histogram Matching: Procedure
• 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)
z
G ( z ) ( L 1) pz (t )dt s
0
• Mapping from s to z
z G 1 ( s )
41
Histogram Matching: Example
0, otherwise
42
Histogram Matching: Example
• 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(z q),
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 )
44
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.
45
Example: Histogram Matching
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
46
Example: Histogram Matching
47
Example: Histogram Matching
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 s5 s6 s7
48
Example: Histogram Matching
rk
0
1
2
3
4
5
6
49
7
Example: Histogram Matching
rk zq
0 3
1 4
2 5
3 6
4 7
5 7
6 7
7 7
50
Example: Histogram Matching
51
Example: Histogram Matching
52
Example: Histogram Matching
53
Local Histogram Processing
54
Local Histogram Processing: Example
55
Using Histogram Statistics for Image
Enhancement
Average Intensity L 1 M 1 N1
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 N1
1
u2 (r ) (ri f ( x, y ) m
2 2 2
m) p (ri )
i 0
MN x 0 y 0
56
Using Histogram Statistics for Image
Enhancement
Local variance
L 1
2
s xy (ri msxy ) psxy (ri )
2
i 0
57
Using Histogram Statistics for Image
Enhancement: Example
58
Spatial Filtering
59
Spatial Filtering
A spatial filter consists of (a) a neighborhood, and (b) a
predefined operation
60
Spatial Correlation
a b
w( x, y ) f ( x, y ) w(s, t ) f ( x s, y t )
s a t b
61
Spatial Convolution
a b
w( x, y ) f ( x, y ) w( s, t ) f ( x s, y t )
s a t b
62
63
Smoothing & Sharpening
Spatial Filters
64
Fundamentals of Spatial Filtering
• Filtering term is borrowed from frequency
domain which means allowing or rejection.
• Similar smoothening applied directly on the pixel
is called spatial filtering Eg : Mask, kernels,
template or windows.
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
66
Example: Gross Representation of Objects
67
Order-statistic (Nonlinear) Filters
68
Sharpening Spatial Filters
• Purpose is to highlight transformation in intensity.
69
70
Sharpening Spatial Filters: Foundation
f
f ( x 1) f ( x)
x
2 f
2
f ( x 1) f ( x 1) 2 f ( x)
x
71
Sharpening Spatial Filters: Laplace Operator
72
Sharpening Spatial Filters: Laplace Operator
73
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.
74
75
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
76
Unsharp Masking and Highboost Filtering
77
Unsharp Masking: Demo
78
Unsharp Masking and Highboost Filtering: Example
79
Image Sharpening based on First-Order Derivatives
80
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
81
Image Sharpening based on First-Order Derivatives
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
82
Image Sharpening based on First-Order Derivatives
83
Example
84
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
85
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
86
Frequency Domain
87
Frequency Domain
•In the frequency domain, a digital image is converted from spatial domain to
frequency domain. In the frequency domain, image filtering is used for image
enhancement for a specific application. A Fast Fourier transformation is a tool of the
frequency domain used to convert the spatial domain to the frequency domain.
•Sampling Theorem :The theorem states that, if a function of time, f(t), contains no
frequencies of W hertz or higher, then it is completely determined by giving the value
of the function at a series of points spaced (2W) −1 seconds apart. The sampling rate of
2W samples per second is called the Nyquist rate.
•Aliasing can occur in signals sampled in time, for instance digital audio, or
the stroboscopic effect, and is referred to as temporal aliasing. It can also occur in
spatially sampled signals (e.g. moiré patterns in digital images), this type of aliasing
is called spatial aliasing.
•The Fourier Transform is an important image processing tool which is used to
decompose an image into its sine and cosine components. The output of the
transformation represents the image in the Fourier or frequency domain, while the
input image is the spatial domain equivalent.
•The discrete Fourier transform is actually the sampled Fourier transform, so it
contains some samples that denotes an image. In the above formula f(x,y) denotes
the image , and F(u,v) denotes the discrete Fourier transform
88
• The sampling rate determines the spatial resolution of the digitized image, while
the quantization level determines the number of grey levels in the digitized image. A
magnitude of the sampled image is expressed as a digital value in image processing.
• The Fourier Transform is an important image processing tool which is used to
decompose an image into its sine and cosine components. The output of the
transformation represents the image in the Fourier or frequency domain, while the
input image is the spatial domain equivalent.
• The sampling theorem specifies the minimum-sampling rate at which a continuous-
time signal needs to be uniformly sampled so that the original signal can be
completely recovered or reconstructed by these samples alone. This is usually
referred to as Shannon's sampling theorem in the literature.
• Aliasing occurs when a signal is sampled at a less than twice the highest
frequency present in the signal. Signals at frequencies above half the sampling rate
must be filtered out to avoid the creation of signals at frequencies not present in the
original sound.
89
NOISE REDUCTION:
•Noise characterized by sharp transitions in image intensity.
•Such transitions contribute to high frequency components of Fourier transform.
•Attenuating certain high frequency components result in blurring and reduction of image
noise.
IDEAL LOW-PASS FILTER:
90
Effects of Ideal Low Pass Filter
91
92
93
Sharpening Frequency Domain Filters
94
95
96