Chapter3 Image Enhancement in the Spatial Domain

Download Report

Transcript Chapter3 Image Enhancement in the Spatial Domain

Chapter3
Image Enhancement
in the Spatial Domain









3.0 Introduction
3.1 Background
3.2 Some Basic Gray Level Transformations
3.3 Histogram Processing
3.4 Enhancement Using Arimethic/Logic
Operations
3.5 Basics of Spatial Filtering
3.6 Smoothing Spatial Filters
3.7 Sharpening Spatial Filters
3.8 Combining Spatial Enhancement Methods
1
3.0 INTRODUCTION

1. Objective


to process an image so that the result is more
suitable for specific applications.
2. Categories
a. spatial domain methods.
 b. frequency domain methods.
 c. combinations of above two types.

2
3.1 BACKGROUND

1. Operate directly on an image f by the
following way:
g(x, y) = T [ f (x, y)]
where g is the processed image; and T is an
operator over an n  n neighborhood of f
 For simplicity in notation:
S = T(r)
r and s is the gray level of f(x,y)and g(x,y)
3
3.1 BACKGROUND
4
3.1 BACKGROUND

2. Point processing -- for n = 1, i.e.,
neighborhood = the pixel itself

3. Mask processing -- also called filtering;
for n  1; neighborhood = n  n pixels; using
masks.
5
4.2 ENHANCEMENT BY POINT
PROCESSING
4.2.1 Some Simple Intensity
Transformations
 4.2.2 Histogram Processing
 4.2.3 Image Subtraction
 4.2.4 Image Averaging

6
4.2.1 Some Simple Intensity
Transformations…(1)

1. Image negatives

given a pixel gray level ( g. l. ) r, output pixel g.
l. s is
L-1
s  T (r )  r  L  1
 ( L  1)  r
T
s
L-1 = largest g. l.
0
r
L-1
7
4.2.1 Some Simple Intensity
Transformations…(2)

2. Contrast stretching
(1) Stretching is useful for improving image
contrast.
 (2) General transformation diagram.

L-1
(r2,s2)
s
(r1,s1)
0
r
L-1 = largest g. l.
L-1
8
4.2.1 Some Simple Intensity
Transformations…(3)

(3) cases :
 a.
no change -- if r1 = s1 , r2 = s2 .
 b. thresholding -- if r1 = r2, s1 = 0, and s2 = L-1 ;
threshod value = r1 = r2.
 c. stretching -- if r1 r2 & s1 s2 ( to keep
monotonicity of transformation )
 d. Why dies stretching improve image contrast?
 e. How to stretch is problem - dependent
9
4.2.1 Some Simple Intensity
Transformations…(4)
L-1
(r2, s2)
=(r0,L-1)
T(C)
s
T(B)
(r1, s1)
=(r0,0)
0
r
r0
L-1 = largest g. l.
S=T(r)
T(A)
L-1
0
A
Mappings:
A=>T(A)
(longer => smaller)
B
C
B => T(B)
(smaller => larger )
CONTRAST IMPROVED)
C => T(C)
(larger => smaller)
10
4.2.1 Some Simple Intensity
Transformations…(5)

3. Compression of dynamic ranges
(1) Gray levels may be out of the display
range after certain transformations.
 (2) One way to compress is

S = T( r ) = c log(1+ | r | )
 where
c is a constant to make s to lie between 0
and L-1
11
4.2.1 Some Simple Intensity
Transformations…(6)

4. Gray level slicing
(1) Highlighting a specific g. l. range
 (2) Useful for many applications.
 (3) Two approaches:

 a.
use high values for desired ranges and low
values for others;
 b. use high values for desired ranges and keep the
values for others.

(4) See Fig 4.7
12
Fig 4.7
13
4.2.1 Some Simple Intensity
Transformations…(7)

5. Bit-plane slicing
(1) Highlighting “ contributions made by
specific bits to image appearance.
 (2) More important information is included in
higher- order bit planes; details in others (see
Fig. 4.8 )
 (3) Bit - plane 7 ( highest - order ) = result of
thresholding with threshold = 128
 (4) See Fig. 4.9

14
15
16
17
4.2.2
Histogram Processing…(1)

1. Definition and properties of histogram

(1) the histogram of a given image f is a
function
P( rk ) = nk / n
where rk = the kth g. l.;
nk = the no. of pixels with g.l. rk
n = the total no. of pixels in f.

N /n
(2) Diagram
of histogram
k
….
1
2
3
k
L-1
r
18
4.2.2
Histogram Processing…(2)
(3) Concept :
histogram = p.d.f ( probability density
function )
 (4) A histogram gives the global appearance
of an image .
 (5) Histograms of images with high and low
contrasts (see Fig. 4.10 )

19
20
4.2.2
Histogram Processing…(3)

2. Histogram equalization

(1) Equalization transformation of a given
image f :
r
s  T (r )   Pr ( w)dw 0  r  1,0  s  1
0
where Pr(w) is the histogram of f

(2) S above is exactly the c. d. f. of r ( c. d. f.
= cumulative distribution function )
21
4.2.2
Histogram Processing…(4)

(3) It can be shown by probability theory (see
textbook) that the new image with g. l. s has a
uniform distribution, i.e.,
0  s 1
Ps ( s)  1

(4) the transformation illustration
Pr(r)
Ps(s)
Equalization
Image with low contrast
r
Image with higher contrast
S
22
4.2.2
Histogram Processing…(5)
(5) Read the example in pp. 176-177.
 (6) Histogram equalization is also called
histogram flatting or linearization.
 (7) Discrete form of histogram equalization

k
k
nj
j 0
j 0
n
sk  T (rk )   Pr (rj )  
23
4.2.2
Histogram Processing…(6)

(8) A computation example
k
pixels
r
Pr®
s
1
2
0
0
0
0
0
3
1
1
1
1
1
4
2
2
2
2
3
5
6
3
6
3
6
9
7
4
8
4
8
17
5
6
5
6
23
1 3
6
1
6
1
24
9
7
0
7
0
24
17
x(1/8)
x(1/24)
x(1/24)
23 24
24
4.2.2
Histogram Processing…(7)
(9) A major advantage of histogram
equalization for image contrast enhancement
is that it can be applied automatically.
 (10) See Fig. 4.14 for a real example.


3. Histogram specification


See textbook
4. Local enhancement

See textbook
25
4.2.3
Image Subtraction

1. Computes the difference g of two
images f and h :
g ( x, y )  f ( x, y )  h ( x, y )

2. For application example, see Fig. 4.17
26
4.2.4
Image Averaging
1. Reduces noise by averaging several
copies of and identical image
 2. Method :
1 M

g ( x, y ) 
g ( x, y )

M
i
i
where gi(x, y) is one of copies of origin image
3. Why work ? Noise standard deviation
can be reduced to 1/n of origin
 4. See Fig. 4.18

27
4.3
Spatial Filtering
4.3.1 Background
 4.3.2 Smoothing Filtering
 4.3.3 Sharpening Filtering

28
4.3.1
Background…(1)
1. Spatial filtering is also called mask
processing.
 2. Masks ( also called spatial filters ) are
used
 3. High - frequency components in images:



noise, edges, sharp details, etc.
4. Low - frequency components in images:

uniform regions, slow - changing background
g. l., etc.
29

5. Type of spatial filtering :
4.3.1
Background…(2)

(2) Highpass filtering
 useful

for image sharpening
(3) Bandpass filtering
 mostly
used in image restoration
6. See Fig 4.19 for the above 3 types.
 7. Linear mask operation :

30
4.3.1
Background…(2)
w1
w4
w7
w2
w5
w8
Mask M

z1
z4
z7
z2
z5
z8
z3
z6
z9
Z5 = g. l. of current pixel
Neighborhood N
Operation : replace z5 by
R

w3
w6
w9
= MN = z1w1 + z2w2 +……. + z9w9
8. Nonlinear mask operation :

R is computed nonlinearly using information
of the neighborhood of current pixel as well as
the mask.
31
4.3.2
Smoothing Filters…(1)
1. Used for image blurring & noise
reduction.
 2. Useful for removing small details and
bridging small gaps in lines or curves.
 3. Lowpass spatial filtering :


1
1
(1) Mask for
1 331 neighborhood
M 
9
1
1
1
1
1
1
32
4.3.2
Smoothing Filters…(2)

(2) Operation -- replace z5 by
1 9
R  M  N   wi zi
9 i 1
(3) Also called neighborhood averaging
 (4) See Fig. 4.22 for effect


4. Median filtering

(1) Reducing noise without blurring images
33
4.3.2
Smoothing Filters…(3)

(2) Operation - replace
g. l. at (x, y) with the median of all the g. l.
of neighborhood.

(3) Meaning of median
 value
r
r such that
1
0 Pr (w)dw  2
 (i.e.,
P(x)
r = (1/2)tile of the p.d.f. )
r = median
x
Area = 1/2
34
4.3.2
Smoothing Filters…(4)

(4) An example:
given
10
20
20
20
15
25
20
20
99
g. l. z5 = 15 is replaced by median = 20

(5) For effect of median filtering, see Fig. 4.23
35
4.3.3
Sharpening Filters…(1)

1. Objective


highlighting or enhancing fine details in
images.
2. Applications
(1) electronic printing;
 (2) medical imaging;
 (3)industrial inspection;
 (4) target detection;
 etc.

36
4.3.3
Sharpening Filters…(2)

3. Basic highpass spatial filtering (HPSF)

(1) Mask for 33 neighborhood
1
M 
9


-1
-1
-1
-1
8
-1
-1
-1
1
(2) See Fig. 4.25 for effect of filtering
4. High best filtering

(1) Also called high-frequency emphasis
filtering.
37
4.3.3
Sharpening Filters…(3)

(2) Method :
high-best = A  (original) - lowpass
= (A-1)(original) + original lowpass
= (A-1)(original) + highpass
where A is a selected weight.
(3) Note that part of the original
is
-1
-1 image
-1
1
Where w=9A-1
added
back.
M   -1 w -1
(A =1  basic HPSF)
-1
-1
1
9
 (4) Equivalent mask

38
4.3.3
Sharpening Filters…(4)

5. Derivative filters


(1) Concept Averaging
(integration)
Difference
(differentiation)
Blurring
Sharpening
(2) The most common differentiation
operation is the gradient
39
4.3.3
Sharpening Filters…(5)

(3) Gradient
 a.
definition -- the gradient of a function f at a pixel
(x0, y0) is
 f 
 x 
f ( x, y )   f 
 
 y  x0 y0
 f 2 f 2 
 b. magnitude
fof
( x,gradient
y )  ( -) ( ) 
y 
 x
1/ 2
40
4.3.3
Sharpening Filters…(6)

(4) Approximation of gradient magnitude :
 a. Assume
the neighborhood (nbhd) g. l. of the
pixel at (x, y) are
N
 b.
z1
z4
z7
z2
z5
z8
z3
z6
z9

f  ( z5  z9)
With g. l. at (x, y) = z5

 ( z 6  z8) 
f  ( zform
5  z8)  ( z5  z 6)
in continuous
2
or
2
2 1/ 2
2 1/ 2
41
4.3.3
Sharpening Filters…(7)
 C.
in absolute difference form :
f  z5  z8  z5  z6
or
f  z5  z9  z6  z8
 d.
Roberts1 operators
for 20 2 nbhd
:
0
1
0
-1
MR1
-1
0
MR2
operation = | N  MR1 | + | N  MR2 | = | z5-z9 | + 42|
z6 - z8 |
4.3.3
Sharpening Filters…(8)
 d.
Prewitt operators for 3  3 nbhd :
-1
0
1
-1
0
1
-1
0
1
-1
-1
-1
MP1
0
0
0
1
1
1
MP2
operation = | N  MP1 | + | N  MP2 |
= | (z7+z8+z9) - (z1+z2+z3) | = | (z3+z6+z9) (z1+z4+z7) |
-1
-2
-1
-1
0
1
 e. Sobel
for-23  03 nbhd
:
0 operators
0
0
2
1
2
MS1
1
-1
0
1
MS2
operation = | N  MS1 | + | N  MS2 |
43
4.4 Enhancement
in Frequency Domain
4.4.1 Lowpass Filtering
 4.4.2 Highpass Filtering
 4.4.3 Homomorphic Filtering

44
4.4.1
Lowpass Filtering…(1)

1. Use


image blurring ( smoothing )
2. Goal

Want to find a transfer function H(u, v) in the
frequency domain to attenuate the high
frequency in the FT
F(u, v) of a given image f
1
g
(
x
,
y
)

F
[
H
(
u
,
v
)
F
(
u
,
v
)]
using the inverse FT
45
4.4.1
Lowpass Filtering…(2)

3. Ideal lowpass filter (ILPF)

(1) Definition -H(u, v) = 1
=0
if D(u, v)  D0
otherwise
where D(u, v) = distance from (0, 0) to (u, v);
and D0 is a constant ( called cutoff frequency )
(2) See Fig 4.30 for the filter shape in 3-D and
2-D
 (3) The ILPF cannot be implemented by
analog hardware ( but can be implemented by
software )

46
4.4.1
Lowpass Filtering…(3)

4. Additional review of the Fourier
transform
See sec.3.2~3.4 for FT, DFT, FFT
 See Fig. 4.31 for an example of Fourier
spectrum ( or simply called spectrum )

5. See Fig. 4.32 for effects of applying the
ILPF using different cutoff frequencies.
 6. The ILPF produces ringing effects; see
Fig. 4.32(d) for an example; and see Fig.
4.33 for the reason. Note Fig. 4.33(a) is

47
4.4.1
Lowpass Filtering…(4)

7. Butterworth lowpass filter ( BLPF )]

(1) A BLPF of order n with cutoff frequency at
1
D0 is defined Has
(u, v) 
1  AD(u, v) D0 
2n
 where
A = 1 or 0.414
(2) See Fig. 4.34 for the shape of the BLPF.
 (3) See Fig. 4.35 for the effects of applying
the BLPF with n = 1 for 5 D0 values.


8. The BLPF produces no ringing effect
due to the smoothness of its transfer
48
4.4.2
Highpass Filtering…(1)

1. Use


Image sharpening
2. Ideal highpass filter (IHPF)

(1) Transfer function
H(u, v) = 0
=1

if D(u, v)  D0
otherwise
(2) See Fig. 4.37 for shapes of the IHPF.
49
4.4.2
Highpass Filtering…(2)

3.Butterworth highpass filter (BHPF):

(1) Transfer function
1
H (u, v) 
2n
1  AD0 D(u, v)
where A = 1 or 0.414

(2) See Fig. 4.38 for shapes of the BHPF.
4.4.3 Homomorphic Filtering
 4.5 Generation of spatial masks from
frequency domain specifications

50

Read the textbook
4.6
Color Image Processing
4.6.0 Introduction
 4.6.1 Color fundamentals
 4.6.2 Color models
 4.6.3 Pseudo-color image processing
 4.6.4 Full color image processing

51
4.6.0
Introduction

1. Motivation
(1) Color is a powerful descriptor for
automated image analysis.
 (2) The human eye can discern thousands of
color shades and intensities ( but about only a
dozen of grey levels )


2. Study areas

(1) full color image processing
 still

in infancy
(2) Pseudo - color image processing
 assigning
color shades to monochrome intensity
52
4.6.1
Color Fundamentals…(1)

1. Colors of light
(1) Primary -- red (R), green (G), and blue (B)
 (2) Secondary -- magenta (R+B),
cyan (G+B)
yellow (R+G)
 (3) See plate III(a) for illustration.


2. Colors of pigments (colorants) -(1) Primary -- magenta, cyan, and yellow
 (2) Secondary -- red, green, and blue
 (3) See plate III(b) for illustration.

53
4.6.1
Color Fundamentals…(2)

3. Characteristics of color :

(1) Three basic characteristics
 a.
brightness -- chromatic notion of intensity
 b. hue -- dominant wavelength (color) perceived by
human eyes
 c. saturation -- amount of white light mixed with
hue
(2) Chromaticity -- hue + saturation
 (3) trimulus values

 amounts
of red, green, and blue (denoted as X, Y,
54
and Z, respectively ) for a color
4.6.1
Color Fundamentals…(2)

(4) trimulus coefficients -- x, y, z, with
x = X / (X + Y + Z)
y =Y / (X + Y + Z)
z = Z / (X + Y + Z)

(5) Chromaticity diagram -- Plate IV
55
4.6.2
Color models…(1)

1. Models :

(1) RGB (red, green, blue ) model
 useful
for hardware ; e. g., color monitors, TV
cameras, etc

(2) CMY ( cyan, magenta, yellow ) model
 useful

(3) YIQ ( luminance, inphase, quatrature )
model
 useful

for color printers
for color TV broadcasting
(4) HSI (hue, saturation, intensity ) model
 useful
for color image manipulation
56
4.6.2
Color models…(2)

2. Models most frequently used in image
processing


RGB, YIQ, HIS
3. RGB model
(1) Good for analysis of aerial & satellite
multispectral image data ( including 4 images
of G, R and two infrared ).
 (2) No good for natural scene image
processing if R, G, & B are treated separately
( e. g., human face processing ).

57
4.6.2
Color models…(3)

4. YIQ model :
(1) Y represents the luminance component.
 (2) Y and color information ( i.e., I + Q ) are
decoupled.
 (3) Contrast enhancement of an image in the
YIQ model can be achieved by applying
histogram equalization to the Y component
only.


5. HSI model :

(1) I represents intensity.
58
4.6.2
Color models…(4)
 b.
color information represented by H + S is close
to the color observed by eyes.


(3) Good for human color inspection works.
6. Model conversions :
(1) RGB  YIQ -- use Eq. 4.6-6
 (2) RGB  HSI -- use Eq. 4.6-11, 18, 21 for I,
H, S
 (3) HSI  RGB -- for detail, see pp 236-237
of the textbook.

59
4.6.3 Pseudo - color
image processing…(1)

1. Purpose


to assign color to monochrome images based
on properties of gray - level content of images.
2. Method
(1) Intensity slicing
 (2) Gray level to color transformation
 (3) Filtering


3. Intensity slicing

(1) slicing into two colors means the following
transformation
60
4.6.3 Pseudo - color
image processing…(2)
Color
c2
c1
I1

L
(2) General slicing means the following
Color
transformation
c
M
c2
c1
I1
I2
IM L
61
4.6.3 Pseudo - color
image processing…(3)

4. Gray level to color transformation
(1) More general than intensity slicing.
 (2) Method

 feed
image gray level into three (RGB)
independent transformation functions and display
the results in a color monitor ( see Fig. 4.50 for
illustration )
(3) For example, see Fig. 4.51 and Plate VI.
 (4) Advantages

 specific
details in images may be emphasized.
62
4.6.3 Pseudo - color
image processing…(4)

5. A filtering approach :
(1) The principle is the same as that of gray
level to color transformation except that the
transformation are performed in the frequency
domain.
 (2) See Fig. 4.52 for illustration.
 (3) Various forms of bandreject filters are used
here ( see the textbook

63
4.64 Full Color
Image Processing
1. Only color image enhancement is
discussed here.
 2. When the HIS model is used, intensity
is decoupled from color information. So,
we can enhance the I component using
any enhancement technique for
monochrome images.
 3.Detail procedure when the RGB model is
used :
RGB HSI
HIS` R`G`B`

64