Chapter 3: Image Enhancement in De
9yetial Bofoain
1. Background
2. Some basic in†ensi†y †ransforma†ion functions
3. Histogram processing
4. Fundamentals of spatial filtering
5. Smoothing spatial filters
6. Sharpening spatial filters
R.C. Gonzalez 8 R.E.Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 1
• Spatial domain processing: direc† manipulation of pixels in an image
• Two categories of spatial (domain) processing
• Intensity †ransforma†ion:
- Operate onsingle pixels
- Contras† manipulation, image †hresholding
• Spatial filtering
- Work in a neighborhood of every pixel in an image
- Image smoothing, image sharpening
R.C. Gonzalez 8 R.E.Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 2
9.1 Baekgrsi»n8
• Spatial domain methods: operate directly on pixels
• Spatial domain processing
g(x,y) = T[f(x, y)j
f(x, y): inpu† image
g(x, y): output (processed) image
T: operator
• Operator T is defined over a neighborhood of point (x, y)
R.C. Gonzalez & R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 3
3.1 Bn8kgound
Oi'igin Spatial fiI†erin9
(.i, y) in an image
in the spatial
domain. The
neighborhood is
moved from pixel
to pixel in the
image to generate
an output image.
- For any location (x,y), ou†pu† image g(x,y) is equal †o †he
result of applying T to the neighborhood of (x,y) in f
• Filter: mask, kernel, template, window
R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 4
3,1 Baekgrcund
• The simplest formof T: g depends only on the value of f at (x, y)
T becomes in†ensi†y (gray-level) †ronsforma†ion function
s - T(r)
r: in†ensi†y of f(x,y)
s: intensity Of g(x,y)
• Point processing: enhancement at any point depends only on the
gray level at that point
R.C. Gonzalez & R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 5
8.1 Beekgr‹eund
Poin† processing
FIGURf 3.2
• (a) Contrast stretching
• Values of r below k are compressed into a narrow ranpe of s
• (b) Thresholding
R.C. Gonzalez & R E. Woods Dept. ol In1ernet & MuIIii1 edit Eng . Chnnghoon Yi›n 6
r: pixel value before processing
s: pixel value after processing
T: †ransforrna†ion
s = T(r)
• 3 types
• Linear (iden†i†y and negative †ronsforma†ions)
• Logarithmic (log and inverse-log transformations)
• Power-law (nth power and n†h roo† †ransforrna†ions)
R.C. Gonzalez & R E. Woods Depl. of It41erne1 & Multimedia Eng., Changhoon Yiin
3.a Some &sic Gay Le'wlmnsRvroatians
FGUR£3.3 Some
basic gray-level
transformation
functions used for
imaye
cnhnnccnicnl.
R.C. Gonzales 6 R.E.Woocls
L/4
0
nth root
Dopt. of Internet &Multimedia Eng., Chanqhooo Yim
3.2.1 Image Negatives
FMUB£3.9
(a)Original
digital
mammogram.
(b) Negative
iro•8e obtained
using the negative
transformation in
Eg. (ñ.2-I).
(CTourtesy of G.E.
Medical Systems.)
• Negative of an image with gray level [0, L-1]
s - L- 1 - r
• Enhancing whi†e or gray de†oil embedded in dark regions
of an image
R.C. Gonzales & R.E. Woods Dept. of Internet &Multimedia Eng., Changhoon Yim 9
3.2.2 Log Transformations
• General form of log transformation
s c log(Ur)
c: constant, r 0
• This transformation maps o narrow range of low gray-level
values in †he inpu† image in†o a wider range of ou†pu† levels
• Classical application of log †ransforma†ion:
Display of Fourier spec†rum
R.C. Gonzalez 8 R.E.Woods Dep. of Internet & Mulùmedia Enq., Changhoon Yim 10
3.2.2 Log Transformations
(a) Fnutier
spectrum.
(b) Result of
applying the log
transformation
given in
Eg t3 2-2) with
c = 1.
• (a) Original Fourier spectrum: 0 - t,50O,000 range
scaled to 0 - 255
• (b) Result of log transformation: 0 - 6.2 range
scaled to 0 - 255
R.C. Gonzales & R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 11
3.2.3 Power-Law Transformations
R.C. Gonzalez & R E. Woods
tl f. — I
Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 12
3.2.3 Power-Law Transformations
• Basic form of power-law †ransforma†ions
- ‹
”
positive cons†an†s
• Gamma correction:
process of correcting †his power-law response
• Example: ca†hode ray †ube (CRT)
In†ensi†y †o voltage response is power function wi†h
exponen† (y) i.8 †o 2.5
Solution: preprocess †he ‹npu† image by performing
transformation
s r!/2.5 rd.4
R.C. Gonzalez 8 R.E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 13
3.2.3 Power-Law Transformations
(aJ Linear-wedge
eray-scare image.
(h) Response of
monitor to linear
w<kye.
m‹›nitnr.
R.C. Gonzales 6 R.E. Woods
CRTmonitor gammacorrection example
Dopt. of Internet & Multimedia Eng., Changhoon Yim 14
3.2.3 Power-Law Transformations
original
-0.4
R.C. Gonzales 6 R.E. Woods
MRI gamma correction example
rcnMencc NiRj
imqe of a
fractured humiin
tr8nsftirmHiicHJin
Ed. f3.2•3 wiih
r = t and
y= 0.3
y 0.6
15
original
R.C. Gonzales &
3.2.3 Power-Law Transformations
FIGURE 3.9
(a) Aerial in›age
(h)—{rl) Results nf
transformationin
Ed. (ñ.2-1) with
t = 1.I›.4.ft.arid
.U,respectively.
(Original image
for this trample
couples}' uf
NASA.)
y 4.0
Arial image gamma correction example
y 3.0
y 5.0
16
3.2.4 Piecewise-Linear Transformation Functions
Piecewise lineor “' "’4
Rmu† of con†rs†
stretching
R.C. Gonzales & R.E. W‹
Contras† s†re†ching
31/4
Low contrast
image
F
I
G
UR
E 9.10
stretching.
(aFormof
lfS0SfiOffSd!iUfl
function. (h) A
low-contrast
imnge. (c) Result
of contrast
s1retchi°8
(d) Resull of
lhtexbolding.
(Original image
courtesy of
Research School
of Biological
ficienccs,
Australian
University,
Canberra,
Australia.)
Result of
†hresholdi^9
17
3.2.4 Piecewise-Linear Transformation Functions
Contras† s†re†chin
(c) Contrast stretching
•t. *
I
N (• in. 0), (r , s2) (’ma.,L
—
I)
r „ rmo, minimum, maxmum level of image
(d) Thresholding:
’I ’2 m, s, 0, *2 L"1
m: mean gray level
R.C. Gonzalez 8 R.E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 18
3.2.4 Piecewise-Linear Transformation Functions
R.C. Gonzales & R.E. Woods
In†ensi†y-level slicing
1 —1 0
Dept. of Internet &Multimedia Eng., Changhoon Yim
FMURG B.I1
(a)this
highlights rangc
{A, B}of eray
levels and reduces
constant level.
transformation
highlights range
[ A, 8] t›tlt
preserres all
othor lovelx
(c) An image.
(d) Result of
u•ng‹he
19
3.2.4 Piecewise-Linear Transformation Functions
In†ensi† -level st icin
(a) Display a high value for all gray levels in the range
of interest, and a low value for al) other imapes
- produces binary image
(b)Briph†ens †hedesired range of graylevels
but preservesthe background and other parts
R.C. Gonzalez &R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 20
n b c
FlGURfi 3.12 (a) Aortic angiogram. (b) Result of using a slicing transformation of the type illustrated in Fig.
3.11(a), with the range of intensities of interest seleGtcd in the upper end of the gray scale. (c) Result of
using the transformation in Fig. 3.11(b), with the selected area set to black, so that grays in the area of thc
hlood vessels and kidneys were preserved. (Original image courtesy of Dr. Thomas R. Gest. University of
Michigan Medical School.)
3.2.4 Piecewise-Linear Transformation Functions
In†ensi†y-level slicing
R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 21
3.2.4 Piecewise-Linear Transformation Functions
R.C. Gonzales 6 R.E. Woods
Bi†-plane slicing
Bit plane 8
(most signi
FIGURE 3.13
Bit-plane
representation or
an &bit image.
Bit planc 1
(least significant)
Dopt. of Internet & Multimedia Eng., Changhoon Yim 22
a b c
d e f
g b i
FlGURfi L) 4 (a) An 8-bit gray-scale image of size 500 x 1192 pixels.(b) through (i) Bit planes 1 through 8,
with bit plane 1 corresponding to the least significant bit. Each bit plane is a binary ioiage.
3.2.4 Piecewise-Linear Transformation Functions
Bit-plane slicing
R.C. Gonzales & R.E. Woods Dept. of Internet &Multimedia Eng., Changhoon Yim 23
a b c
FlGURfi 3.15 Images reconstnicted using (a) bit planes 8 and 7; (b) bit planes 8, 7. and 6; and (c) bit planes 8,
7,6, and 5. Compare (c) with Fig.3.14(a).
(a) Multiply bi† plane 8 by 128
Multiply bi† plane 7 by 64
Add the results of two planes
3.2.4 Piecewise-Linear Transformation Functions
Bi†-plane slicing
R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 24
• The histogram of digital image with gray levels in the
range [0, L-1] is a discrete function
• h(rk) k
rk: k†h 9••y level
nk:number of pixels in image having gray levels rt
• Normalized histogram
p(rk) °k °
n: †o†al number of pixels in image
n MN (M: row dimension, N: column dimension)
R.C. Gonzalez & R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 25
R.C. G
3.9 Hls%gam Presasstng
• horizonal axis:
rk(kth intensity value)
• vertical axis:
k number of pixels, or
nt/n: normalized number
R£ 3 6 Fcu haHc image rypcs: datk, light. few
C€TfltT BSt. held their col i espnndin¿ histagi anus.
rnet & Multimedia Eng
high
26
3.3.1 Histogram Equalization
r: in†ensi†ies of †he image †o be enhanced
r is in †he range [0, L-1]
r 0: black, r L-1: whi†e
s: processed gray levels for every pixel value r
s= T(r), 0 ‹ r ‹ L
—
/
Requirements of †ransforma†ion function T
(a) T(r) is a (s†ric†Iy) mOnO†OniCaIly increasing in †he in†ervaI
0 :! r ‹ L
—
I
(b) 0 ‹ T(r) ‹ L-t for 0 ‹ r ‹ L-1
• Inverse transformation
r - T '(s), 0 ‹s ‹L-1
R.C. Gonzalez 8 R.E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 27
Single
3.3.1 Histogram Equalization
Intensity †ransforma†ion function
0 Multiple Single L —1
values value
R.C. Gonzalez 6 R.E. Woods
T{r)
Dept. of Internet & Multimedia Eng., Changhoon Yim
a b
IlGURfi 8•l 7
(a) Monotonically
increasing
function, showing
how multiple
values can map to
a single value.
(b) Strictly
monotonically
increasing
function.This is a
one-to-one
mapping, both
ways
28
3.3.1 Histogram Equalization
In†ensi†y leveis: random variable in in†ervai [0, L.-1]
dr
de
probabiii†y densi†y function (PDF)
.r = T r) = (L —1))(t pr(«)d+ cumula†ive dis†ribu†ion function (CDF)
d’ 'T $')
r d
{L ' ) d
' d r " ' ’ ” ( J
1
] = (L )Ür(r)
1
(L —1)p,.(r) L —
1 0 <s < L—
l
Uniforrn probabili†y densi†y function
R.C. Gonzalez & R E. Woods Depl. of Interne1 & Mullimedia Eng , Changhoon Yim 29
P F ( ’ )
a b
FIGURI US (a) An arbitrary PDF. (b) Result of applying the transformation in
Eq. (3.3-4) to all intensity levels, r.The resulting intensities s, have a uniform PDF,
independently of the form of the PDF of the r's.
3.3.1 Histogram Equalization
(J.3-4)
R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 30
3.3.1 Histogram Equalization
P )—
n
k —
—
0,1,2,..., L —
1
MN
MN: †o†al number of pixels in image
nt: number of pixels having gray level rt
L:†o†aI number of possible gray levels
L —
1
MN 2
k
n k —
—
0,1,2,..,L—
l
--
• histogram equalization (histogram linearixo†ion):
Processed image is obtained by mapping each pixel ^k(
in†o corresponding level st (ou†pu† image)
npu† image)
R.C. Gonzalez 8 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 31
ro' 790 0.19
rt = 1 1023 0.25
= 2 85D 0.21
rz -- 3 656 0.16
r4= 4 329 0.08
rz —
—
5 245 0.06
r6 6 122 0.03
g7' 7 BI 0.02
.20
3.3.1 Histogram Equalization
4.2
Intensity
distribution and
histogram values
for a 3-bit,
64 x 64 digital
image.
.20
.15
.05
0 1 2 3 4 5 6 7 0 1 2 3 4 S 6 7 0 1 2 3 4 5 6 7
a b c
FlotiRfi 0.I 9 Illustration of histogram equalization of a 3-bit (8 intensity levels) image. (a) Original
histogram. (b) Transformation function. (c) Equalized histogram.
R.C. Gonzales &R.E. Woods Dept. of Internet &Multimedia Eng., Changhoon Yim 32
3.3.1 Histogram Equalization
His†opram equalization
from dark image (1)
His†oprom equalization
from ligh† image (2)
Histogram equalization
from low contras† image (3)
Histogram equalization
from high contras† image (4)
33
128
Transformation functions
255
3.3.1 Histogram Equalization
R.C. Gonzalez 6 R.E. Woods
64
- - (2)
128 192 255
Dept. of Internet & Multimedia Eng., Changhoon Yim
FIGURE3.2J
Transformation
functions for
histogram
equalization.
Transformations
(1) through (4)
were obtained from
the histograms of
the images (from
top to bottom) in
the lefi column of
Fig.3.20 using
Eq.(3 3-8).
34
3.3.3 Local Histogram Processing
• Histogram processing methods in previous section are global
• Global methods are suitable for overall enhancemen†
• Histogram processing techniques are easily adapted †o )ocaI
enhancement
- Example
(b) Global histogram equalization
Considerable enhancemen† of noise
(c) Local his†ogram equaI‹zo†ion using 7x7 neighborhood
Reveals (enhances) the small squares inside the dark squares
Contains finer noise texture
R.C. Gonzalez & R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 35
a b c
FlG4JRfi R2fi (a) Original image. (b) Resuit of global histogram equalization. (c) Result of local
histogram equalization applied to (a), using a neighborhood of size 3 x 3.
3.3.3 Local Histogram Processing
Original image
Global histogram
equalized image
koCal histogram
equalized image
R.C. Gonzales & R.E. Woods Dept. of Internet &Multimedia Eng., Changhoon Yim 36
3.3.4 Use ofHistogram Statistics for Image Enhancement
r: discre†e random variable represen†ing in†ensi†y values in †he range [0, L
—
1]
p(rá): normolized his†ogram componen† corresponding †o value rá
—rt/)" p(r,) nth momen† of r
c
—
i
r,per,)
i=0
›
Z •. —••2
p(ri)
i=0
m
/'2(r)
1
MN
R.C. Gonzalez 8 R.E. Woods
if —
I N—I
mean (average) value of r
Variance of r, 62(r)
M —
1 N —
l
MN Z L If •
sample mean
) —
m]2
sample variance
Dept. of Internet & Multimedia Eng., Changhoon Yim 37
3.3.4 Use ofHistogram Statistics for Image Enhancement
• Global mean and variance are measured over entire image
Used for gross adjus†men† of overall intensity and contras†
• Local mean and variance are measured locally
Used for local adjus†men† of local in†ensi†y and contras†
(x,y): coordinate of a p‹xeI
Sgt: neighborhood (subimage), centered on (x,y)
• , rt.t: L possible intensity values
p : histogram of pixe)s in region Sxt
local mean
2
R.C. Gonzalez & R E. Woods
L—
I
= ri —md )‘ p r, ) local variance
Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 38
3.3.4 Use of Histogram Statistics for Image Enhancement
• A measure whether an area is relatively liph† or dark a† (x,y)
Compare †he local average gray level ^*s †o the global mean md
(x,y) is a candidate for enhancement i* s ‹ ko s
• Enhance areas that have low contrast
Compare †he local standard deviation *s ,†o †he global standard
deviation 6G
(x,y) is a candidate for enhancemen† if bSt ‹ k
, 6G
• Res†ric† lowest values of contras†
(x,y) is a candidate for enhancemen† if k] 6c‹ 6s
• Enhancemen† is processed simply multiplying †he gray )evel
by acons†an† E
R.C. Gonzalez 8 R.E. Woods
s„
E J’{x, y) il
f{x, y)
c
ko AND i c —
< s„ —
<
otherwise
Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 39
3.3.4 Use of Histogram Statistics for Image Enhancement
Problem: enhance dark areas while leaving †heligh† area
as unchanged as possible
a b c
FlGUitfi a.2fi (a) SEM image of a lungslen filament magnified approximately 130x.
(b) Resull of globsl histogram equalization. (c) Image enhanced using local histogram
statistics. (Original image courtesy of Mr. Michael Shaffer. Department of Geological
Sciences University of Oregon. Eugene.)
E = 4.0, = 0.4, k/ = 0.02, km 0.4, Local region (neighborhood) size: 3x3
R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 40
3.6 Fundamentals ofSpetial Nltedng
• Operations wi†h †hevalues of the image pixels in the neighborhood
and the corresponding values of subimoge
• Subimoge: filter, mask, kernel, template, window
•Values in †he fil†er subimage: coefficien†
• Spatial filtering operations are performed directly on †hep‹xeIs
of an image
• One-to-one correspondence between
linear spatial filters and filters in †he frequency
domain
Ghap 3 Intensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 41
3.4.1Mechanics ofSpatial Filtering
• A spatial fil†er consists of
(1) a neighborhood (typically a small rectangle)
(2) a predefined operation
• A processed (filtered) image is generated as the center of
the fil†er visi†s each pixel in †he inpu† image
• Linear spatial filtering using 3x3 neighborhood
• At any point (x,y), the response, g(x,y), of the filter
g(x,y) - w(-1,-1)f(x-1,y-1)• w(-1,0)f(x-1,y)•
• w(0,0)f(x,y) + ...• w(1,0)f(x•1,y)• w(1,1)f(x•1,y•1)
Chap.3 intensity Transformations and Spatial Filt6rin0 Dept. of Internet & Mulñmedia Eng., Changhoon Yim 42
3.4.1 Mechanics of Spatial Filtering
Chap.3 IrtTonsity Trar sfurrnaiur s and Spatial Filtcring Dept. ol In1ernet &MuIIii1edit Eng . Chnnghoon Yi›n 43
3.4.1 Mechanics of Spatial Filtering
•Filtering of on imoge f wi†h a fiI†er w of size m x n
a (m-1) / 2, b (n-1) / 2 or m 2a•1, n 2b•1
(a, b: posi†ive integer)
a b
g • v) — Z w{s,t)f{x s, y t)
s——
—
at—
—
—
b
Chap.3 intensity Transformations and Spatial Filt6rin0 Dept. of Internet & Multimedia Eng., Changhoon Yim 44
3.4.2 Spatial Correlation and Convolution
(a) 0 0 0 1 0 0 0 0 1 2 3 2 8
1 2 3 2 8
Staztfng p«cIkm abgnmrnl
I 2 3 2 8
0 b 0 1 0 b 0 0 8 2 3 2 1 (i)
8 2 3 2 1
8 2 3 2 1
ta) 0 0 0 0 0 0 0 i 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 t1)
1 2 3 2 8 8 2 3 2 I
(¢) 0 0 0 0 0 0 0 I D 0 0 0 0 0 0 0 0 II II 0 ¢I II 0 ! 0 0 II 0 0 II ¢J 0 (ITI)
1 2 3 2 8 8 2 3 2 1
{I) 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 {n)
Fñ0 e l a t i o n rr•ili Full coovofuiio0 result
(g) 0 0 0 8 2 3 2 1 0 0 0 0 0 0 0 1 2 3 2 8 0 0 0 0 {o)
{h)
uAlM
0 6 ] J 2 1 U 0 0 1 2 3 2 b If 0
Fi I £ Illustmtioa of 1-Dcorrelation and tonvoluiion of a filter with a discrete unit impulse. hfote that
qp$ correlation rindconvolution are functions of &ip&cement.
qpyj
3.4.2 Spatial Correlation and Convolution
Ghap.3 Intensité-
FIGURE 3.30
filiet wiih :i 2-D
c1iscretc•, unit
3t)i1l J'YfS.
46
3.4.2 Spatial Correlation and Convolution
• Correlation of a fil†er w(x,y) of size m x n wi†h on image f(x,y)
a b
g{x v) L was,t)f{x+s,y t)
s=-a t—--b
• Convolu†ion of w(x,y) and f(x,y)
8 •. yJ —
—°
Z
b
I w{s,t)f{x —
s, y—
t)
Chap.3 Intensity Trarisformatlons and Spatla| Filter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 47
3.4.3 Vector Representation of Linear Filtering
• Linear spa†iaI filtering by m xn fil†er
• Linear spatial filtering by 3 x 3 fil†er
9
@ W j -I- W2 2 " ' •+ Wg g
— W¡'i —
" ^
Chap.3 Intensity Trarisformatlons and Spatla| Filter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 48
’6
3.4.3 Vector Representation of Linear Filtering
FIGURE 3.31
Anot her
represent iiiic›n ul
a pener‹i1 ? x ?
tilter mask.
• Spatial filtering a† †he border of an image
• Limit the cen†er of †he mask no less †han (n-1)/2 pixels
from †he border -› Smaller filtered image
• Padding -› Effect near the border
• Adding rows and columns of 0’s
• Replico†ing rows and columns
Ghap.3 Intensity Transformations and Spatial Filtering Dept. of Internet & Muflimedia Eng., Changhoon Yim 49
3.4.4 Generating Spatial Filter Masks
• Linear spatial filtering by 3 x 3 fiI†er
• Average value in 3 x 3 ne‹9hborhood
R —
—
• Gaussian function
/z(x, y) e 2 '
Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 50
3.5 Smoothing Spatial FilNrs
• Linear spatial filters for smoothing:
averaging filters, lowpass filters
• Noise reduction
•Undesirable side effec†:blur edges
standard
average
Ghap 3 Intensity Transformalions and Spatial Filtering
weiph†ed
ave°•9e
Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 51
3.5.1 Smoothing Linear Filters
• Standard averapinp by 3x3 filter
1 9
• Weighted averaging
Reduce blurring compared †o standard averaging
•General impIemen†a†ion for filtering wi†h a weighted
averaging fil†er of size m x n (m-2a•I, n-2b+1)
was,t) f{x + s,y+t)
Chap.3 intensity Transformations and Spatial Filt6rin0
Z Z ›r(s,t)
Dept. of Internet & Mulñmedia Eng., Changhoon Yim 52
3.5.1 Smoothing Linear Filters
Resul† of smoo†hing with square averaging fiI†er masks
n=s
Ghap.3 Inlensity Transformalions and Spatial Filtei
aa a a a a a a a a a a a
«aa a a a
n:3
n-9
n=35
53
a b c
FlGURfi 8.8J (a) Imnge of size 528 X 485 pixels fiom the Hubble Space Telescope. (b) Image filtered with a
15 X 15 averaging mask. (c) Result of thresholding (b). (Oi iginal image courtesy of NASA.)
3.5.1 Smoothing Linear Filters
Application example of spatial averaging
Original 15x1fi averaging Resul† of thresholding
Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 54
3.5.2 Order-Statistic (Nonlinear) Filters
• Order-s†a†is†iC f‹l†ers are nonlinear spatial filters
whose response ‹s based on ordering (ranking) †he pixels
• Median fil†er
• Replaces †he pixel value by †he median of †he gray levels
in †he neighborhood of †ha† pixel
• Effective for impulse noise (sat†-and-pepper noise)
• Isolated clusters of pixels †ho† are high† or dark
wi†h respec† †o †heir neighbors, and whose area is less
†han n2/2, ore eliminated by an n x n median fiI†er
• Median
• 3x3 neighborhood: 5†h larges† value
• 5x5 neighborhood: 13†h larges† value
• Max fil†er: selec† maximum value in †he neighborhood
• Min fiI†er: selec† minimum value in †heneighborhood
Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 55
a b c
flr•URfi 3J5 (a) X-ray imoge of circuit board corrupted by sait-and-pepper noise. (b) Noise reduction wiih
a 3 x 3 averaging tttask. (c) Noise reduction with a 3 S 3 median fitter. (Original image courtesy of Mr.
fosepb E. Pascente, Lixi, Inc)
3.5.2 Order-Statistic Filters
Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 56
3.6 SRarpenlng Spatial Filters
• Objective of sharpening:
highlight fine detail to enhance detail †ha† has been blurred
• Image blurring can be accomplished by digital averaging
Digital averaging is similar †o spatial in†egra†ion
• Image sharpehing can be done by digital differen†ia†ion
Digi†al differentiation is similar †o spatial derivative
•Image differen†ia†ionenhances edges and o†her discon†inui†ies
Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 57
3.6.1 Foundation
• Image sharpening by firs†- and second-order deriV¢t†ives
• Derivatives are defined in terms of differences
Requiremen† of firs† derivative
1) Mus† be zero in fla† areas
2) Must be nonzero at the onset (start) of step and romp
3) Mus† be nonzero aIOn ramps
• Requiremen† of second derivative
I) Must be zero in flat areas
2) Must be nonzero at the onset (start) of step and romp
3) Must be zero along ramps of constant slope
Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 58
3.6.1 Foundation
!f (x) = /(x +l) —/(x)
*f (x —
1) = f x) —]’ —
!)
firs†-order derivative
/(x +1)+ (A 1) —
2 (A) second-order derivo†ive
Ghap.3 Ir lensity Transformalions and Spatial Filtering Depl. of It41erne1 & Multimedia Eng., Changhoon Yiin 59
I› 6 6 b 5 4 3 2 I  1 1 1 I I› 6 I› 6 6
3.6.1 Foundation
£itensity transition
ns y ”
-
1st derivative
2nd derivative
0 II —
l —
I —
I - 1 —
1
0 tl —
1 0 t1 t1 0
0 0 0 0 0 5 0 0 0 0
1 tl 0 0 0 5 —
5 0 0 0
—
2 —
-3 -
—
4 —
—
5 —
D o o o
Chap.3 Irceneity Traraformatlons and Spatial FIIter1ng
. . ' •
LdSecond derwatrve ' •
Dept. of Internet &Multimedia Eng., Changhoon Yim
litustraiioo of the
deri›atis'es of a
l-D digital
tepreseniing a
action of a
horizontal
intensity profile
from an image. In
(a}and (c) data
poiats are joined
by dashed fiaes as
a visualization aid.
60
3.6.1 Foundation
• A† †he ramp
• Firs†-order derivative is nonzero along †he ramp
• Second-order derivative is zero along †heramp
• Second-order derivative is rionzero only at the onset and end
of †he ramp
•At the step
• Both the first- and second-order deriVCttives are nonzero
• Second-order derivative has a transition from positive †o negative
(zero crossing)
• Some conclusions
• First-order der‹V¢itives generally produce thicker edges
• Second-order derivatives have stronger response †ofine de†aiI
• Firs†-order derivatives generally produce s†ron9erresponse
to gray-level step
• Second-order derivatives produce a double response a†step
Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 61
3.6.2 Use of Second Derivatives for Enhancement
• Isotropic filters: ro†a†ion invorian†
• Simplex† isotropic second—order derivative opera†or‹ Laplacian
2-D Laplacian operation
—
—
f(x +1,y) f(x —
1,y) —
2f(•, ) x-direction
—
—f[x, y+ I) + J’(x, y —
1) —
2/’(x, y) y-direction
P2
f x, y)= [f x+1,y) f{x —
1,y) f{x, y+1)+ f{x, y —
1)]—
4 f{x, y)
Chap.3 intensity Transformations and Spatial Filt6rin0 Dept. of Internet & Multimedia Eng., Changhoon Yim 62
3.6.2 Use of Second Derivatives for Enhancement
4 neighbors
nego ti ve cen†cr coeff icient
8 neighbors
negat Ave CE'n†er' coef I icier†
4 neigh bows
positive cen†er cock I icien†
8 neighbocs
positive cen†er coef I icien†
Chap.3 IrtTonsity Trar sfurrnaiur s and Spatial Filtcring Dept. ol In1ernet &MuIIii1 edit Eng . Chnnghoon Yi›n 63
3.6.2 Use ofSecond Derivatives for Enhancement
• Image enhancemen† (sharpening) by Laplacian operation
g(x, y) —
—
f{x, y) —92
f(x, y) if the center coefficient of the
Laplacian mask is negative
f{x, y)+ 02
f x, y) if the center coefficient of the
Laplacian mask is positive
SimpIÏfiCa†iOn
g(•. )= f(•. y)—[f(•+i,›)+ f •—i,v)+ f •. y+ )
+ f{x, y —
l)] + 4f(x, y)
—
—
5 f lx, y) —[f lx +1, y)+ f ‹x —
!, y1
+ f{x, y+ l)+ f{x, y —l))
Chap.3 intensité Transformations and Spatial Filt6ri€0 Dep. of Internet & Mullmedia Enq., Changhoon Yim 64
3.6.2 Use of Second Derivatives for Enhancement
(a) Image of ihe
North P‹ile tif the
NIOOS.
(hj Laplacian-
filtered image
(c) Lajuacian
ima CSCBled for
display {xJrpr›sus
(d) Image
and:invM fry
using Eq. (3.7-fi).
courtesy of
NASA.I
Chap.3 imensiry iiar+srormmions arm opa‹iai riner‹ng
Original image
Laplacian image
Enhanced image
(original-Laplacian)
65
3.6.2 Use of Second Derivatives for Enhancement
Enhanced image
4 neighbors
Chaps Irceneity Traraf
ffia¥Bfi 3AI (a) Fnniposito Laplncian mask. {h) A secrmd comjx›site masL. (c) Scannirg
electron microscojx' imago. (d) and (e) Results of filtering with the masks in (a) and (h).
respectively. Nute hue' mudi sharper (e) is lhan(d). (Original imago courtesy of Mr.ldichael
Sfialfer. Deparlment of Geological Sciences, UniYersit¿ of Uregorr. Eugene.)
OrignolimAge
Enhanced image
8 neighbors
66
3.6.3 Unsharp Masking and Highboost Filtering
g. nsk(^.y)' f(•.›) —
f ix. y) original image —
blurred ima9e
g(• y)—
—
f› y)+k ,.„,(• ›)
• When k=1, unsharp masking
• When k »1, highboostfiI†ering
Chap.3 Intensity Trarisformatlons and Spatla| Filter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 67
3.6.3 Unsharp Masking and Highboost Filtering
Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng
Oi'iginal signal
Blurred signal
Unsharp mask
Shai pened signal
a
b
d
HGtflt£ 3A9 I-D
illustration of the
mechanics of
unsharp masking.
(a) Original
signal. (b) Blurred
signal with
original shown
dashed for refere-
nce.(c) Unsharp
mask. (d) Sharp-
ened signal.
obtaincd by
adding (c) to (a).
Dept. of Internet & Multimedia Eng., Changhoon Yim 68
3.6.3 Unsharp Masking and Highboost Filtering
Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng
b
d
e
fIGURE 3.40
(a)Original
image.
(b)Result of
blurring with a
Gaussian filter.
(c) Unsharp
mask. (d) Result
of usin,q urisharp
masking.
(e) Result of
using highboost
filtering.
Dept. of Internet & Multimedia Eng., Changhoon Yim 69
3.6.4 Using First-Order Derivatives for Image Sharpening
• Firs† derivatives in image processing is implemented
using †he magnitude of †he gradien†
9 f grad(f) 8x D
x
M{x, y) = mag(fif) =[g2 +
bx by
2 1/ 2
Chap.3 Intensity Traraformatlonsand Spatlal Fllterlng
gradient of f at (x,y)
mapni†ude of grodien†
Approximation of ma9ni†ude
of grodien† by absolute values
Dept. of Internet &Multimedia Eng., Chanqhoon Yim 70
tS Z6
3.6.4 Using First-Order Derivatives for Image Sharpening
â
b c
FIGURE3AI
A 3 x 3 region of
an image (the es
are intensity
values).
(bHc) Roberts
cross gradient
operators.
(d)—(e) So0el
opetaiorn. All the
mask coefficients
sum to zero,as
expected of a
derivative
operator.
Chaps Intensity Traraformatlons ar<I Spatial Fl1terlng
-2
Dept, of Internet &Multimedia Eng., Changhoon Yim
3x3 region
Roberts opero†ors
Sobel operators
71
3.6.4 Using First-Order Derivatives for Image Sharpening
• Simples† approximation †o firs†-order derivative
• Roberts cross-gradien† operators
M(x, y) = [g2 -F8$
buz _
( •
9
)2
*s
)2 Jl/2
(*8 ’6
Chap.3 Intensity Trarisformatlons and Spatla| Filter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 72
3.6.4 Using First-Order Derivatives for Image Sharpening
• Sobel operators
- (z7 + 2e +
+J(z + 2e6 +
)
— (‹i + 2e2 + z3)J
) —
(°i + 2e + z7)
Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 73
3.7.3 Use ofFirst Derivatives for Enhancement
Optcol image of
contact lens
Chap. 3 Int6n9ity' T/8raformatlons arld Spatial F||ter|ng
Sobel gradient
Dopt. of Internet & Multimedia Eng., Changhoon Yim
Optical image of
contact lens (note
defects on the
boundary al 4 and
fi ti'clock .
tl›) finhel
gradient.
Original image
courtesy of
Mr. Pele Site
Pcrccplics
L”orpnr0tion.)
74

Image Enhancement in Spatial Frequency Domain

  • 1.
    Chapter 3: ImageEnhancement in De 9yetial Bofoain 1. Background 2. Some basic in†ensi†y †ransforma†ion functions 3. Histogram processing 4. Fundamentals of spatial filtering 5. Smoothing spatial filters 6. Sharpening spatial filters R.C. Gonzalez 8 R.E.Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 1
  • 2.
    • Spatial domainprocessing: direc† manipulation of pixels in an image • Two categories of spatial (domain) processing • Intensity †ransforma†ion: - Operate onsingle pixels - Contras† manipulation, image †hresholding • Spatial filtering - Work in a neighborhood of every pixel in an image - Image smoothing, image sharpening R.C. Gonzalez 8 R.E.Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 2
  • 3.
    9.1 Baekgrsi»n8 • Spatialdomain methods: operate directly on pixels • Spatial domain processing g(x,y) = T[f(x, y)j f(x, y): inpu† image g(x, y): output (processed) image T: operator • Operator T is defined over a neighborhood of point (x, y) R.C. Gonzalez & R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 3
  • 4.
    3.1 Bn8kgound Oi'igin SpatialfiI†erin9 (.i, y) in an image in the spatial domain. The neighborhood is moved from pixel to pixel in the image to generate an output image. - For any location (x,y), ou†pu† image g(x,y) is equal †o †he result of applying T to the neighborhood of (x,y) in f • Filter: mask, kernel, template, window R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 4
  • 5.
    3,1 Baekgrcund • Thesimplest formof T: g depends only on the value of f at (x, y) T becomes in†ensi†y (gray-level) †ronsforma†ion function s - T(r) r: in†ensi†y of f(x,y) s: intensity Of g(x,y) • Point processing: enhancement at any point depends only on the gray level at that point R.C. Gonzalez & R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 5
  • 6.
    8.1 Beekgr‹eund Poin† processing FIGURf3.2 • (a) Contrast stretching • Values of r below k are compressed into a narrow ranpe of s • (b) Thresholding R.C. Gonzalez & R E. Woods Dept. ol In1ernet & MuIIii1 edit Eng . Chnnghoon Yi›n 6
  • 7.
    r: pixel valuebefore processing s: pixel value after processing T: †ransforrna†ion s = T(r) • 3 types • Linear (iden†i†y and negative †ronsforma†ions) • Logarithmic (log and inverse-log transformations) • Power-law (nth power and n†h roo† †ransforrna†ions) R.C. Gonzalez & R E. Woods Depl. of It41erne1 & Multimedia Eng., Changhoon Yiin
  • 8.
    3.a Some &sicGay Le'wlmnsRvroatians FGUR£3.3 Some basic gray-level transformation functions used for imaye cnhnnccnicnl. R.C. Gonzales 6 R.E.Woocls L/4 0 nth root Dopt. of Internet &Multimedia Eng., Chanqhooo Yim
  • 9.
    3.2.1 Image Negatives FMUB£3.9 (a)Original digital mammogram. (b)Negative iro•8e obtained using the negative transformation in Eg. (ñ.2-I). (CTourtesy of G.E. Medical Systems.) • Negative of an image with gray level [0, L-1] s - L- 1 - r • Enhancing whi†e or gray de†oil embedded in dark regions of an image R.C. Gonzales & R.E. Woods Dept. of Internet &Multimedia Eng., Changhoon Yim 9
  • 10.
    3.2.2 Log Transformations •General form of log transformation s c log(Ur) c: constant, r 0 • This transformation maps o narrow range of low gray-level values in †he inpu† image in†o a wider range of ou†pu† levels • Classical application of log †ransforma†ion: Display of Fourier spec†rum R.C. Gonzalez 8 R.E.Woods Dep. of Internet & Mulùmedia Enq., Changhoon Yim 10
  • 11.
    3.2.2 Log Transformations (a)Fnutier spectrum. (b) Result of applying the log transformation given in Eg t3 2-2) with c = 1. • (a) Original Fourier spectrum: 0 - t,50O,000 range scaled to 0 - 255 • (b) Result of log transformation: 0 - 6.2 range scaled to 0 - 255 R.C. Gonzales & R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 11
  • 12.
    3.2.3 Power-Law Transformations R.C.Gonzalez & R E. Woods tl f. — I Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 12
  • 13.
    3.2.3 Power-Law Transformations •Basic form of power-law †ransforma†ions - ‹ ” positive cons†an†s • Gamma correction: process of correcting †his power-law response • Example: ca†hode ray †ube (CRT) In†ensi†y †o voltage response is power function wi†h exponen† (y) i.8 †o 2.5 Solution: preprocess †he ‹npu† image by performing transformation s r!/2.5 rd.4 R.C. Gonzalez 8 R.E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 13
  • 14.
    3.2.3 Power-Law Transformations (aJLinear-wedge eray-scare image. (h) Response of monitor to linear w<kye. m‹›nitnr. R.C. Gonzales 6 R.E. Woods CRTmonitor gammacorrection example Dopt. of Internet & Multimedia Eng., Changhoon Yim 14
  • 15.
    3.2.3 Power-Law Transformations original -0.4 R.C.Gonzales 6 R.E. Woods MRI gamma correction example rcnMencc NiRj imqe of a fractured humiin tr8nsftirmHiicHJin Ed. f3.2•3 wiih r = t and y= 0.3 y 0.6 15
  • 16.
    original R.C. Gonzales & 3.2.3Power-Law Transformations FIGURE 3.9 (a) Aerial in›age (h)—{rl) Results nf transformationin Ed. (ñ.2-1) with t = 1.I›.4.ft.arid .U,respectively. (Original image for this trample couples}' uf NASA.) y 4.0 Arial image gamma correction example y 3.0 y 5.0 16
  • 17.
    3.2.4 Piecewise-Linear TransformationFunctions Piecewise lineor “' "’4 Rmu† of con†rs† stretching R.C. Gonzales & R.E. W‹ Contras† s†re†ching 31/4 Low contrast image F I G UR E 9.10 stretching. (aFormof lfS0SfiOffSd!iUfl function. (h) A low-contrast imnge. (c) Result of contrast s1retchi°8 (d) Resull of lhtexbolding. (Original image courtesy of Research School of Biological ficienccs, Australian University, Canberra, Australia.) Result of †hresholdi^9 17
  • 18.
    3.2.4 Piecewise-Linear TransformationFunctions Contras† s†re†chin (c) Contrast stretching •t. * I N (• in. 0), (r , s2) (’ma.,L — I) r „ rmo, minimum, maxmum level of image (d) Thresholding: ’I ’2 m, s, 0, *2 L"1 m: mean gray level R.C. Gonzalez 8 R.E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 18
  • 19.
    3.2.4 Piecewise-Linear TransformationFunctions R.C. Gonzales & R.E. Woods In†ensi†y-level slicing 1 —1 0 Dept. of Internet &Multimedia Eng., Changhoon Yim FMURG B.I1 (a)this highlights rangc {A, B}of eray levels and reduces constant level. transformation highlights range [ A, 8] t›tlt preserres all othor lovelx (c) An image. (d) Result of u•ng‹he 19
  • 20.
    3.2.4 Piecewise-Linear TransformationFunctions In†ensi† -level st icin (a) Display a high value for all gray levels in the range of interest, and a low value for al) other imapes - produces binary image (b)Briph†ens †hedesired range of graylevels but preservesthe background and other parts R.C. Gonzalez &R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 20
  • 21.
    n b c FlGURfi3.12 (a) Aortic angiogram. (b) Result of using a slicing transformation of the type illustrated in Fig. 3.11(a), with the range of intensities of interest seleGtcd in the upper end of the gray scale. (c) Result of using the transformation in Fig. 3.11(b), with the selected area set to black, so that grays in the area of thc hlood vessels and kidneys were preserved. (Original image courtesy of Dr. Thomas R. Gest. University of Michigan Medical School.) 3.2.4 Piecewise-Linear Transformation Functions In†ensi†y-level slicing R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 21
  • 22.
    3.2.4 Piecewise-Linear TransformationFunctions R.C. Gonzales 6 R.E. Woods Bi†-plane slicing Bit plane 8 (most signi FIGURE 3.13 Bit-plane representation or an &bit image. Bit planc 1 (least significant) Dopt. of Internet & Multimedia Eng., Changhoon Yim 22
  • 23.
    a b c de f g b i FlGURfi L) 4 (a) An 8-bit gray-scale image of size 500 x 1192 pixels.(b) through (i) Bit planes 1 through 8, with bit plane 1 corresponding to the least significant bit. Each bit plane is a binary ioiage. 3.2.4 Piecewise-Linear Transformation Functions Bit-plane slicing R.C. Gonzales & R.E. Woods Dept. of Internet &Multimedia Eng., Changhoon Yim 23
  • 24.
    a b c FlGURfi3.15 Images reconstnicted using (a) bit planes 8 and 7; (b) bit planes 8, 7. and 6; and (c) bit planes 8, 7,6, and 5. Compare (c) with Fig.3.14(a). (a) Multiply bi† plane 8 by 128 Multiply bi† plane 7 by 64 Add the results of two planes 3.2.4 Piecewise-Linear Transformation Functions Bi†-plane slicing R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 24
  • 25.
    • The histogramof digital image with gray levels in the range [0, L-1] is a discrete function • h(rk) k rk: k†h 9••y level nk:number of pixels in image having gray levels rt • Normalized histogram p(rk) °k ° n: †o†al number of pixels in image n MN (M: row dimension, N: column dimension) R.C. Gonzalez & R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 25
  • 26.
    R.C. G 3.9 Hls%gamPresasstng • horizonal axis: rk(kth intensity value) • vertical axis: k number of pixels, or nt/n: normalized number R£ 3 6 Fcu haHc image rypcs: datk, light. few C€TfltT BSt. held their col i espnndin¿ histagi anus. rnet & Multimedia Eng high 26
  • 27.
    3.3.1 Histogram Equalization r:in†ensi†ies of †he image †o be enhanced r is in †he range [0, L-1] r 0: black, r L-1: whi†e s: processed gray levels for every pixel value r s= T(r), 0 ‹ r ‹ L — / Requirements of †ransforma†ion function T (a) T(r) is a (s†ric†Iy) mOnO†OniCaIly increasing in †he in†ervaI 0 :! r ‹ L — I (b) 0 ‹ T(r) ‹ L-t for 0 ‹ r ‹ L-1 • Inverse transformation r - T '(s), 0 ‹s ‹L-1 R.C. Gonzalez 8 R.E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 27
  • 28.
    Single 3.3.1 Histogram Equalization Intensity†ransforma†ion function 0 Multiple Single L —1 values value R.C. Gonzalez 6 R.E. Woods T{r) Dept. of Internet & Multimedia Eng., Changhoon Yim a b IlGURfi 8•l 7 (a) Monotonically increasing function, showing how multiple values can map to a single value. (b) Strictly monotonically increasing function.This is a one-to-one mapping, both ways 28
  • 29.
    3.3.1 Histogram Equalization In†ensi†yleveis: random variable in in†ervai [0, L.-1] dr de probabiii†y densi†y function (PDF) .r = T r) = (L —1))(t pr(«)d+ cumula†ive dis†ribu†ion function (CDF) d’ 'T $') r d {L ' ) d ' d r " ' ’ ” ( J 1 ] = (L )Ür(r) 1 (L —1)p,.(r) L — 1 0 <s < L— l Uniforrn probabili†y densi†y function R.C. Gonzalez & R E. Woods Depl. of Interne1 & Mullimedia Eng , Changhoon Yim 29
  • 30.
    P F (’ ) a b FIGURI US (a) An arbitrary PDF. (b) Result of applying the transformation in Eq. (3.3-4) to all intensity levels, r.The resulting intensities s, have a uniform PDF, independently of the form of the PDF of the r's. 3.3.1 Histogram Equalization (J.3-4) R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 30
  • 31.
    3.3.1 Histogram Equalization P)— n k — — 0,1,2,..., L — 1 MN MN: †o†al number of pixels in image nt: number of pixels having gray level rt L:†o†aI number of possible gray levels L — 1 MN 2 k n k — — 0,1,2,..,L— l -- • histogram equalization (histogram linearixo†ion): Processed image is obtained by mapping each pixel ^k( in†o corresponding level st (ou†pu† image) npu† image) R.C. Gonzalez 8 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 31
  • 32.
    ro' 790 0.19 rt= 1 1023 0.25 = 2 85D 0.21 rz -- 3 656 0.16 r4= 4 329 0.08 rz — — 5 245 0.06 r6 6 122 0.03 g7' 7 BI 0.02 .20 3.3.1 Histogram Equalization 4.2 Intensity distribution and histogram values for a 3-bit, 64 x 64 digital image. .20 .15 .05 0 1 2 3 4 5 6 7 0 1 2 3 4 S 6 7 0 1 2 3 4 5 6 7 a b c FlotiRfi 0.I 9 Illustration of histogram equalization of a 3-bit (8 intensity levels) image. (a) Original histogram. (b) Transformation function. (c) Equalized histogram. R.C. Gonzales &R.E. Woods Dept. of Internet &Multimedia Eng., Changhoon Yim 32
  • 33.
    3.3.1 Histogram Equalization His†opramequalization from dark image (1) His†oprom equalization from ligh† image (2) Histogram equalization from low contras† image (3) Histogram equalization from high contras† image (4) 33
  • 34.
    128 Transformation functions 255 3.3.1 HistogramEqualization R.C. Gonzalez 6 R.E. Woods 64 - - (2) 128 192 255 Dept. of Internet & Multimedia Eng., Changhoon Yim FIGURE3.2J Transformation functions for histogram equalization. Transformations (1) through (4) were obtained from the histograms of the images (from top to bottom) in the lefi column of Fig.3.20 using Eq.(3 3-8). 34
  • 35.
    3.3.3 Local HistogramProcessing • Histogram processing methods in previous section are global • Global methods are suitable for overall enhancemen† • Histogram processing techniques are easily adapted †o )ocaI enhancement - Example (b) Global histogram equalization Considerable enhancemen† of noise (c) Local his†ogram equaI‹zo†ion using 7x7 neighborhood Reveals (enhances) the small squares inside the dark squares Contains finer noise texture R.C. Gonzalez & R E. Woods Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 35
  • 36.
    a b c FlG4JRfiR2fi (a) Original image. (b) Resuit of global histogram equalization. (c) Result of local histogram equalization applied to (a), using a neighborhood of size 3 x 3. 3.3.3 Local Histogram Processing Original image Global histogram equalized image koCal histogram equalized image R.C. Gonzales & R.E. Woods Dept. of Internet &Multimedia Eng., Changhoon Yim 36
  • 37.
    3.3.4 Use ofHistogramStatistics for Image Enhancement r: discre†e random variable represen†ing in†ensi†y values in †he range [0, L — 1] p(rá): normolized his†ogram componen† corresponding †o value rá —rt/)" p(r,) nth momen† of r c — i r,per,) i=0 › Z •. —••2 p(ri) i=0 m /'2(r) 1 MN R.C. Gonzalez 8 R.E. Woods if — I N—I mean (average) value of r Variance of r, 62(r) M — 1 N — l MN Z L If • sample mean ) — m]2 sample variance Dept. of Internet & Multimedia Eng., Changhoon Yim 37
  • 38.
    3.3.4 Use ofHistogramStatistics for Image Enhancement • Global mean and variance are measured over entire image Used for gross adjus†men† of overall intensity and contras† • Local mean and variance are measured locally Used for local adjus†men† of local in†ensi†y and contras† (x,y): coordinate of a p‹xeI Sgt: neighborhood (subimage), centered on (x,y) • , rt.t: L possible intensity values p : histogram of pixe)s in region Sxt local mean 2 R.C. Gonzalez & R E. Woods L— I = ri —md )‘ p r, ) local variance Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 38
  • 39.
    3.3.4 Use ofHistogram Statistics for Image Enhancement • A measure whether an area is relatively liph† or dark a† (x,y) Compare †he local average gray level ^*s †o the global mean md (x,y) is a candidate for enhancement i* s ‹ ko s • Enhance areas that have low contrast Compare †he local standard deviation *s ,†o †he global standard deviation 6G (x,y) is a candidate for enhancemen† if bSt ‹ k , 6G • Res†ric† lowest values of contras† (x,y) is a candidate for enhancemen† if k] 6c‹ 6s • Enhancemen† is processed simply multiplying †he gray )evel by acons†an† E R.C. Gonzalez 8 R.E. Woods s„ E J’{x, y) il f{x, y) c ko AND i c — < s„ — < otherwise Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 39
  • 40.
    3.3.4 Use ofHistogram Statistics for Image Enhancement Problem: enhance dark areas while leaving †heligh† area as unchanged as possible a b c FlGUitfi a.2fi (a) SEM image of a lungslen filament magnified approximately 130x. (b) Resull of globsl histogram equalization. (c) Image enhanced using local histogram statistics. (Original image courtesy of Mr. Michael Shaffer. Department of Geological Sciences University of Oregon. Eugene.) E = 4.0, = 0.4, k/ = 0.02, km 0.4, Local region (neighborhood) size: 3x3 R.C. Gonzalez 6 R.E. Woods Dept. of Internet & Multimedia Eng., Changhoon Yim 40
  • 41.
    3.6 Fundamentals ofSpetialNltedng • Operations wi†h †hevalues of the image pixels in the neighborhood and the corresponding values of subimoge • Subimoge: filter, mask, kernel, template, window •Values in †he fil†er subimage: coefficien† • Spatial filtering operations are performed directly on †hep‹xeIs of an image • One-to-one correspondence between linear spatial filters and filters in †he frequency domain Ghap 3 Intensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 41
  • 42.
    3.4.1Mechanics ofSpatial Filtering •A spatial fil†er consists of (1) a neighborhood (typically a small rectangle) (2) a predefined operation • A processed (filtered) image is generated as the center of the fil†er visi†s each pixel in †he inpu† image • Linear spatial filtering using 3x3 neighborhood • At any point (x,y), the response, g(x,y), of the filter g(x,y) - w(-1,-1)f(x-1,y-1)• w(-1,0)f(x-1,y)• • w(0,0)f(x,y) + ...• w(1,0)f(x•1,y)• w(1,1)f(x•1,y•1) Chap.3 intensity Transformations and Spatial Filt6rin0 Dept. of Internet & Mulñmedia Eng., Changhoon Yim 42
  • 43.
    3.4.1 Mechanics ofSpatial Filtering Chap.3 IrtTonsity Trar sfurrnaiur s and Spatial Filtcring Dept. ol In1ernet &MuIIii1edit Eng . Chnnghoon Yi›n 43
  • 44.
    3.4.1 Mechanics ofSpatial Filtering •Filtering of on imoge f wi†h a fiI†er w of size m x n a (m-1) / 2, b (n-1) / 2 or m 2a•1, n 2b•1 (a, b: posi†ive integer) a b g • v) — Z w{s,t)f{x s, y t) s—— — at— — — b Chap.3 intensity Transformations and Spatial Filt6rin0 Dept. of Internet & Multimedia Eng., Changhoon Yim 44
  • 45.
    3.4.2 Spatial Correlationand Convolution (a) 0 0 0 1 0 0 0 0 1 2 3 2 8 1 2 3 2 8 Staztfng p«cIkm abgnmrnl I 2 3 2 8 0 b 0 1 0 b 0 0 8 2 3 2 1 (i) 8 2 3 2 1 8 2 3 2 1 ta) 0 0 0 0 0 0 0 i 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 t1) 1 2 3 2 8 8 2 3 2 I (¢) 0 0 0 0 0 0 0 I D 0 0 0 0 0 0 0 0 II II 0 ¢I II 0 ! 0 0 II 0 0 II ¢J 0 (ITI) 1 2 3 2 8 8 2 3 2 1 {I) 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 {n) Fñ0 e l a t i o n rr•ili Full coovofuiio0 result (g) 0 0 0 8 2 3 2 1 0 0 0 0 0 0 0 1 2 3 2 8 0 0 0 0 {o) {h) uAlM 0 6 ] J 2 1 U 0 0 1 2 3 2 b If 0 Fi I £ Illustmtioa of 1-Dcorrelation and tonvoluiion of a filter with a discrete unit impulse. hfote that qp$ correlation rindconvolution are functions of &ip&cement. qpyj
  • 46.
    3.4.2 Spatial Correlationand Convolution Ghap.3 Intensité- FIGURE 3.30 filiet wiih :i 2-D c1iscretc•, unit 3t)i1l J'YfS. 46
  • 47.
    3.4.2 Spatial Correlationand Convolution • Correlation of a fil†er w(x,y) of size m x n wi†h on image f(x,y) a b g{x v) L was,t)f{x+s,y t) s=-a t—--b • Convolu†ion of w(x,y) and f(x,y) 8 •. yJ — —° Z b I w{s,t)f{x — s, y— t) Chap.3 Intensity Trarisformatlons and Spatla| Filter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 47
  • 48.
    3.4.3 Vector Representationof Linear Filtering • Linear spa†iaI filtering by m xn fil†er • Linear spatial filtering by 3 x 3 fil†er 9 @ W j -I- W2 2 " ' •+ Wg g — W¡'i — " ^ Chap.3 Intensity Trarisformatlons and Spatla| Filter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 48
  • 49.
    ’6 3.4.3 Vector Representationof Linear Filtering FIGURE 3.31 Anot her represent iiiic›n ul a pener‹i1 ? x ? tilter mask. • Spatial filtering a† †he border of an image • Limit the cen†er of †he mask no less †han (n-1)/2 pixels from †he border -› Smaller filtered image • Padding -› Effect near the border • Adding rows and columns of 0’s • Replico†ing rows and columns Ghap.3 Intensity Transformations and Spatial Filtering Dept. of Internet & Muflimedia Eng., Changhoon Yim 49
  • 50.
    3.4.4 Generating SpatialFilter Masks • Linear spatial filtering by 3 x 3 fiI†er • Average value in 3 x 3 ne‹9hborhood R — — • Gaussian function /z(x, y) e 2 ' Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 50
  • 51.
    3.5 Smoothing SpatialFilNrs • Linear spatial filters for smoothing: averaging filters, lowpass filters • Noise reduction •Undesirable side effec†:blur edges standard average Ghap 3 Intensity Transformalions and Spatial Filtering weiph†ed ave°•9e Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 51
  • 52.
    3.5.1 Smoothing LinearFilters • Standard averapinp by 3x3 filter 1 9 • Weighted averaging Reduce blurring compared †o standard averaging •General impIemen†a†ion for filtering wi†h a weighted averaging fil†er of size m x n (m-2a•I, n-2b+1) was,t) f{x + s,y+t) Chap.3 intensity Transformations and Spatial Filt6rin0 Z Z ›r(s,t) Dept. of Internet & Mulñmedia Eng., Changhoon Yim 52
  • 53.
    3.5.1 Smoothing LinearFilters Resul† of smoo†hing with square averaging fiI†er masks n=s Ghap.3 Inlensity Transformalions and Spatial Filtei aa a a a a a a a a a a a «aa a a a n:3 n-9 n=35 53
  • 54.
    a b c FlGURfi8.8J (a) Imnge of size 528 X 485 pixels fiom the Hubble Space Telescope. (b) Image filtered with a 15 X 15 averaging mask. (c) Result of thresholding (b). (Oi iginal image courtesy of NASA.) 3.5.1 Smoothing Linear Filters Application example of spatial averaging Original 15x1fi averaging Resul† of thresholding Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 54
  • 55.
    3.5.2 Order-Statistic (Nonlinear)Filters • Order-s†a†is†iC f‹l†ers are nonlinear spatial filters whose response ‹s based on ordering (ranking) †he pixels • Median fil†er • Replaces †he pixel value by †he median of †he gray levels in †he neighborhood of †ha† pixel • Effective for impulse noise (sat†-and-pepper noise) • Isolated clusters of pixels †ho† are high† or dark wi†h respec† †o †heir neighbors, and whose area is less †han n2/2, ore eliminated by an n x n median fiI†er • Median • 3x3 neighborhood: 5†h larges† value • 5x5 neighborhood: 13†h larges† value • Max fil†er: selec† maximum value in †he neighborhood • Min fiI†er: selec† minimum value in †heneighborhood Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 55
  • 56.
    a b c flr•URfi3J5 (a) X-ray imoge of circuit board corrupted by sait-and-pepper noise. (b) Noise reduction wiih a 3 x 3 averaging tttask. (c) Noise reduction with a 3 S 3 median fitter. (Original image courtesy of Mr. fosepb E. Pascente, Lixi, Inc) 3.5.2 Order-Statistic Filters Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 56
  • 57.
    3.6 SRarpenlng SpatialFilters • Objective of sharpening: highlight fine detail to enhance detail †ha† has been blurred • Image blurring can be accomplished by digital averaging Digital averaging is similar †o spatial in†egra†ion • Image sharpehing can be done by digital differen†ia†ion Digi†al differentiation is similar †o spatial derivative •Image differen†ia†ionenhances edges and o†her discon†inui†ies Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 57
  • 58.
    3.6.1 Foundation • Imagesharpening by firs†- and second-order deriV¢t†ives • Derivatives are defined in terms of differences Requiremen† of firs† derivative 1) Mus† be zero in fla† areas 2) Must be nonzero at the onset (start) of step and romp 3) Mus† be nonzero aIOn ramps • Requiremen† of second derivative I) Must be zero in flat areas 2) Must be nonzero at the onset (start) of step and romp 3) Must be zero along ramps of constant slope Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 58
  • 59.
    3.6.1 Foundation !f (x)= /(x +l) —/(x) *f (x — 1) = f x) —]’ — !) firs†-order derivative /(x +1)+ (A 1) — 2 (A) second-order derivo†ive Ghap.3 Ir lensity Transformalions and Spatial Filtering Depl. of It41erne1 & Multimedia Eng., Changhoon Yiin 59
  • 60.
    I› 6 6b 5 4 3 2 I 1 1 1 I I› 6 I› 6 6 3.6.1 Foundation £itensity transition ns y ” - 1st derivative 2nd derivative 0 II — l — I — I - 1 — 1 0 tl — 1 0 t1 t1 0 0 0 0 0 0 5 0 0 0 0 1 tl 0 0 0 5 — 5 0 0 0 — 2 — -3 - — 4 — — 5 — D o o o Chap.3 Irceneity Traraformatlons and Spatial FIIter1ng . . ' • LdSecond derwatrve ' • Dept. of Internet &Multimedia Eng., Changhoon Yim litustraiioo of the deri›atis'es of a l-D digital tepreseniing a action of a horizontal intensity profile from an image. In (a}and (c) data poiats are joined by dashed fiaes as a visualization aid. 60
  • 61.
    3.6.1 Foundation • A††he ramp • Firs†-order derivative is nonzero along †he ramp • Second-order derivative is zero along †heramp • Second-order derivative is rionzero only at the onset and end of †he ramp •At the step • Both the first- and second-order deriVCttives are nonzero • Second-order derivative has a transition from positive †o negative (zero crossing) • Some conclusions • First-order der‹V¢itives generally produce thicker edges • Second-order derivatives have stronger response †ofine de†aiI • Firs†-order derivatives generally produce s†ron9erresponse to gray-level step • Second-order derivatives produce a double response a†step Ghap.3 Inlensity Transformalions and Spatial Filtering Depi. of Interne1 & Mullimedia Eng , Changhoon Yim 61
  • 62.
    3.6.2 Use ofSecond Derivatives for Enhancement • Isotropic filters: ro†a†ion invorian† • Simplex† isotropic second—order derivative opera†or‹ Laplacian 2-D Laplacian operation — — f(x +1,y) f(x — 1,y) — 2f(•, ) x-direction — —f[x, y+ I) + J’(x, y — 1) — 2/’(x, y) y-direction P2 f x, y)= [f x+1,y) f{x — 1,y) f{x, y+1)+ f{x, y — 1)]— 4 f{x, y) Chap.3 intensity Transformations and Spatial Filt6rin0 Dept. of Internet & Multimedia Eng., Changhoon Yim 62
  • 63.
    3.6.2 Use ofSecond Derivatives for Enhancement 4 neighbors nego ti ve cen†cr coeff icient 8 neighbors negat Ave CE'n†er' coef I icier† 4 neigh bows positive cen†er cock I icien† 8 neighbocs positive cen†er coef I icien† Chap.3 IrtTonsity Trar sfurrnaiur s and Spatial Filtcring Dept. ol In1ernet &MuIIii1 edit Eng . Chnnghoon Yi›n 63
  • 64.
    3.6.2 Use ofSecondDerivatives for Enhancement • Image enhancemen† (sharpening) by Laplacian operation g(x, y) — — f{x, y) —92 f(x, y) if the center coefficient of the Laplacian mask is negative f{x, y)+ 02 f x, y) if the center coefficient of the Laplacian mask is positive SimpIÏfiCa†iOn g(•. )= f(•. y)—[f(•+i,›)+ f •—i,v)+ f •. y+ ) + f{x, y — l)] + 4f(x, y) — — 5 f lx, y) —[f lx +1, y)+ f ‹x — !, y1 + f{x, y+ l)+ f{x, y —l)) Chap.3 intensité Transformations and Spatial Filt6ri€0 Dep. of Internet & Mullmedia Enq., Changhoon Yim 64
  • 65.
    3.6.2 Use ofSecond Derivatives for Enhancement (a) Image of ihe North P‹ile tif the NIOOS. (hj Laplacian- filtered image (c) Lajuacian ima CSCBled for display {xJrpr›sus (d) Image and:invM fry using Eq. (3.7-fi). courtesy of NASA.I Chap.3 imensiry iiar+srormmions arm opa‹iai riner‹ng Original image Laplacian image Enhanced image (original-Laplacian) 65
  • 66.
    3.6.2 Use ofSecond Derivatives for Enhancement Enhanced image 4 neighbors Chaps Irceneity Traraf ffia¥Bfi 3AI (a) Fnniposito Laplncian mask. {h) A secrmd comjx›site masL. (c) Scannirg electron microscojx' imago. (d) and (e) Results of filtering with the masks in (a) and (h). respectively. Nute hue' mudi sharper (e) is lhan(d). (Original imago courtesy of Mr.ldichael Sfialfer. Deparlment of Geological Sciences, UniYersit¿ of Uregorr. Eugene.) OrignolimAge Enhanced image 8 neighbors 66
  • 67.
    3.6.3 Unsharp Maskingand Highboost Filtering g. nsk(^.y)' f(•.›) — f ix. y) original image — blurred ima9e g(• y)— — f› y)+k ,.„,(• ›) • When k=1, unsharp masking • When k »1, highboostfiI†ering Chap.3 Intensity Trarisformatlons and Spatla| Filter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 67
  • 68.
    3.6.3 Unsharp Maskingand Highboost Filtering Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng Oi'iginal signal Blurred signal Unsharp mask Shai pened signal a b d HGtflt£ 3A9 I-D illustration of the mechanics of unsharp masking. (a) Original signal. (b) Blurred signal with original shown dashed for refere- nce.(c) Unsharp mask. (d) Sharp- ened signal. obtaincd by adding (c) to (a). Dept. of Internet & Multimedia Eng., Changhoon Yim 68
  • 69.
    3.6.3 Unsharp Maskingand Highboost Filtering Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng b d e fIGURE 3.40 (a)Original image. (b)Result of blurring with a Gaussian filter. (c) Unsharp mask. (d) Result of usin,q urisharp masking. (e) Result of using highboost filtering. Dept. of Internet & Multimedia Eng., Changhoon Yim 69
  • 70.
    3.6.4 Using First-OrderDerivatives for Image Sharpening • Firs† derivatives in image processing is implemented using †he magnitude of †he gradien† 9 f grad(f) 8x D x M{x, y) = mag(fif) =[g2 + bx by 2 1/ 2 Chap.3 Intensity Traraformatlonsand Spatlal Fllterlng gradient of f at (x,y) mapni†ude of grodien† Approximation of ma9ni†ude of grodien† by absolute values Dept. of Internet &Multimedia Eng., Chanqhoon Yim 70
  • 71.
    tS Z6 3.6.4 UsingFirst-Order Derivatives for Image Sharpening â b c FIGURE3AI A 3 x 3 region of an image (the es are intensity values). (bHc) Roberts cross gradient operators. (d)—(e) So0el opetaiorn. All the mask coefficients sum to zero,as expected of a derivative operator. Chaps Intensity Traraformatlons ar<I Spatial Fl1terlng -2 Dept, of Internet &Multimedia Eng., Changhoon Yim 3x3 region Roberts opero†ors Sobel operators 71
  • 72.
    3.6.4 Using First-OrderDerivatives for Image Sharpening • Simples† approximation †o firs†-order derivative • Roberts cross-gradien† operators M(x, y) = [g2 -F8$ buz _ ( • 9 )2 *s )2 Jl/2 (*8 ’6 Chap.3 Intensity Trarisformatlons and Spatla| Filter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 72
  • 73.
    3.6.4 Using First-OrderDerivatives for Image Sharpening • Sobel operators - (z7 + 2e + +J(z + 2e6 + ) — (‹i + 2e2 + z3)J ) — (°i + 2e + z7) Chap.3 Intensity Traraformatlons and Spat|a| F|lter|ng Dept. of Internet & Multimedia Eng., Changhoon Yim 73
  • 74.
    3.7.3 Use ofFirstDerivatives for Enhancement Optcol image of contact lens Chap. 3 Int6n9ity' T/8raformatlons arld Spatial F||ter|ng Sobel gradient Dopt. of Internet & Multimedia Eng., Changhoon Yim Optical image of contact lens (note defects on the boundary al 4 and fi ti'clock . tl›) finhel gradient. Original image courtesy of Mr. Pele Site Pcrccplics L”orpnr0tion.) 74