SlideShare a Scribd company logo
Ch3. Image enhancement in spatial domain
-1-
Ch3. Image Enhancement in
the Spatial Domain
Ch3. Image enhancement in spatial domain
-2-
Contents
3.1 Background
3.2 Some basic gray level transformations
3.3 Histogram processing
3.4 Enhancement using arithmetic/logic operations
3.5 Basics of spatial filtering
3.6 Smoothing spatial filters
3.7 Sharpening spatial filters
3.8 Combining spatial enhancement methods
Ch3. Image enhancement in spatial domain
-3-
3.1 Background
 Two categories in image enhancement
approaches
1) Spatial domain processing
1) Based on direct manipulation of pixels in an image plane
itself
2) Frequency domain processing
• Based on modifying the Fourier transform of an image
 Spatial domain processing
–
– Where, f(x,y): input image, g(x,y): processed image, T:
an operator on f, defined over some neighborhood of
(x,y)
 
)
,
(
)
,
( y
x
f
T
y
x
g 
Ch3. Image enhancement in spatial domain
-4-
 Neighborhood of (x,y)
– Use a square or rectangular subimage area centered at
(x,y):
– Mask (filters, kernels, templates, windows): mask
processing or filtering
Ch3. Image enhancement in spatial domain
-5-
– In case of 1x1 (that is, a single pixel): point processing
•
• Where, r: gray level of f(x,y), s: gray level of g(x,y)
• examples:
 Contrast stretching: Fig 3.2(a)
 Thresholding: Fig 3.2(b)
)
(r
T
s 
Ch3. Image enhancement in spatial domain
-6-
3.2 Some basic gray level transformations
 3 types of gray-
level transformation
functions
1) Linear: negative and
identity
transformations
2) Logarithmic: log and
inverse-log
transformations
3) Power-law: nth
power and nth root
transformations
Ch3. Image enhancement in spatial domain
-7-
 Image negatives
– Function:
– Reverse the intensity levels of an image:
positive  negative
levels
gray
of
num
where 


 L
r
L
s ,
1
Ch3. Image enhancement in spatial domain
-8-
 Log transformations
– General form:
– Expand the values of dark pixels while compressing the
higher-level values.
– The opposite is true of the inverse log transformation
– Characteristic: compress the dynamic range of images
with large variations in pixel values
0
)
1
log( 


 r
c
r
c
s const,
where
,
Ch3. Image enhancement in spatial domain
-9-
– example: Fourier spectrum
0 ~ 1.5x106  0 ~ 255
Ch3. Image enhancement in spatial domain
-10-
 Power-law transformations
– Basic form: const
postive
and
where
, 
 

c
cr
s
Ch3. Image enhancement in spatial domain
-11-
– Gamma correction:
• Intensity-to-voltage
response of CRT:
=1.8~2.5
• If =2.5, s = r1/2.5 = r0.4
– Example 3.1 & Fig 3.8
– Example 3.2 & Fig 3.9
Ch3. Image enhancement in spatial domain
Example: Gamma Transformations
Ch3. Image enhancement in spatial domain
Example: Gamma Transformations
Ch3. Image enhancement in spatial domain
Example: Gamma Transformations
Ch3. Image enhancement in spatial domain
-15-
 Piecewise-linear
transformation functions
– Contrast stretching:
• Increase the dynamic range
of the gray levels
• If r1=s1 and r2=s2, then
identity function
• If r1= r2, s1=0 and s2=L-1,
then thresholding function
• In general, r1 r2 and s1s2,
so the function is single
valued and monotonically
increasing
Ch3. Image enhancement in spatial domain
-16-
– Gray-level slicing
• Highlighting a specific range of gray level in an image
Ch3. Image enhancement in spatial domain
5/11/2024
Highlight the major
blood vessels and study
the shape of the flow of
the contrast medium (to
detect blockages, etc.)
Measuring the actual
flow of the contrast
medium as a function of
time in a series of
images
Ch3. Image enhancement in spatial domain
-18-
– Bit-plane slicing:
• Highlighting the specific bit planes
• The higher-order bits contain the majority of the visually
significant data
• Useful for image compression
• Bit-plane 7 is a thresholded (binary) image with 127
• Fig 3.13 & 3.14
Ch3. Image enhancement in spatial domain
Bit-plane Slicing
Ch3. Image enhancement in spatial domain
Bit-plane Slicing
Ch3. Image enhancement in spatial domain
-21-
3.3 Histogram processing
– Histogram function of a digital image:
• Discrete function h(rk)=nk, where rk : k th gray level, nk :
number of pixels with gray level rk
– Normalized histogram
• p(rk)=nk/n, for k=0,1,…,L-1, where n : total number of
pixels
• Sum of all components of the normalized histogram is
equal to 1
– Fig 3.15
• High dynamic range  uniform distribution
 histogram equalization
Ch3. Image enhancement in spatial domain
-22-
Ch3. Image enhancement in spatial domain
-23-
3.3.1 Histogram equalization
– Assume that gray level r is continuous and normalized
to [0,1], that is,
s = T(r) 0  r  1
– Assume that the transformation function T(r) satisfies
the following conditions:
(a)T(r) is single-valued and monotonically increasing in the
interval 0  r  1
(b) 0  T(r)  1 for 0  r  1
Ch3. Image enhancement in spatial domain
-24-
– If the inverse transformation function
r = T-1(s) 0  s  1 satisfies the above conditions,
then
– If we use CDF(Cumulative Distribution Function) of r for
the transformation function, that is,
– Then, the above equation satisfies both conditions of (a)
and (b).
PDF
is
p()
where
,
)
(
)
(
)
(
1
s
T
r
r
s
ds
dr
r
p
s
p












r
r dw
w
p
r
T
s
0
)
(
)
(
Ch3. Image enhancement in spatial domain
-25-
)
(
)
(
)
(
0
r
p
dw
w
p
dr
d
dr
r
dT
dr
ds
r
r
r










1
0
1
)
(
1
)
(
)
(
)
(





s
r
p
r
p
ds
dr
r
p
s
p
r
r
r
s
If we use CDF for the transformation function, histogram of
the transformed image becomes uniform.
 Histogram equalization
 Uniform density
- Thus,
[Leibniz’s rule]
Ch3. Image enhancement in spatial domain
-26-
– In digital image, gray level is discrete. Thus,
and, transformation function for histogram equalization
is
– also, inverse transformation function is
– Example 3.3, Fig 3.17, and Fig 3.18
1
,
,
2
,
1
,
0
)
( 

 L
k
n
n
r
p k
k
r 
1
,
,
2
,
1
,
0
)
(
)
(
0
0









L
k
n
n
r
p
r
T
s
k
j
j
k
j
j
r
k
k

1
,
,
2
,
1
,
0
)
(
1


 
L
k
s
T
r k
k 
Ch3. Image enhancement in spatial domain
5/11/2024 27
Ch3. Image enhancement in spatial domain
-31-
3.3.3 Local enhancement
 Histogram processing for entire image: global
 Local histogram processing:
– Define a square or rectangular neighborhood and move the
center of this area from pixel to pixel. At each location,
histogram equalization or histogram matching is obtained
– Another approach is to utilize non-overlapping regions, but it
usually produces an undesirable checkerboard effect.
Ch3. Image enhancement in spatial domain
-32-
3.3.4 Use of histogram statistics for
image enhancement
 Some statistical parameters obtainable directly from
the histogram for image enhancement
 nth moment:
– and . The second moment is
 variance of r ( )
)
(
)
(
)
(
)
(
1
0
1
0
i
L
i
i
L
i
i
n
i
n
r
p
r
m
r
m
r
p
m
r
r









:
of
value
mean
the
is
where

i
i r
r
p level
gray
of
histogram
normalized
:
)
(
1
0 
 0
1 






1
0
2
2 )
(
)
(
)
(
L
i
i
i r
p
m
r
r
 )
(
2
r

 measure of average gray level
 measure of average contrast
Ch3. Image enhancement in spatial domain
-35-
3.4 Enhancement using
arithmetic/logic operations
 Arithmetic/logic operations: pixel-by-pixel basis
 Arithmetic operations
– Image subtraction
– Image addition
– Image multiplication
– Image division
 Logic operations
– NOT: negative transformation
– AND/OR
• Used for masking
• Masking is ROI(region of interest) processing
Ch3. Image enhancement in spatial domain
-36-
Ch3. Image enhancement in spatial domain
-37-
3.4.1 Image subtraction
 Difference between f(x,y) and h(x,y):
 Subtraction is the enhancement of difference between
images.
 Fig 3.28:
 Example 3.7, Fig 3.29
 Comments on implementation
– The difference image can range –255~255 => need to scale to
0~255
• Add 255 and then divide by 2
• (diff image – min)x255/max; max: maximum of (diff image – min)
image
 Image subtraction can be used for segmentation (changes)
)
,
(
)
,
(
)
,
( y
x
h
y
x
f
y
x
g 

Ch3. Image enhancement in spatial domain
-38-
Ch3. Image enhancement in spatial domain
-39-
3.42 Image averaging
 Consider a noisy image g(x,y), original image f(x,y), noise
(x,y)
 At every (x,y), assume that noise is uncorrelated and has
zero average, then averaging K different noisy images
 Example 3.8, Fig 3.30, 3.31
)
,
(
)
,
(
)
,
( y
x
y
x
f
y
x
g 


2
)
,
(
2
)
,
(
1
1
)
,
(
)}
,
(
{
)
,
(
1
)
,
(
y
x
y
x
g
K
i
i
K
y
x
f
y
x
g
E
y
x
g
K
y
x
g


 

 

and
that
follows
it
then
)
,
(
)
,
(
1
y
x
y
x
g
K


 
Ch3. Image enhancement in spatial domain
-40-
3.5 Basics of spatial filtering
 Response of linear filtering with 3x3 mask at (x,y)
– Fig 3.32
)
1
,
1
(
)
1
,
1
(
)
,
1
(
)
0
,
1
(
)
,
(
)
0
,
0
(
)
,
1
(
)
0
,
1
(
)
1
,
1
(
)
1
,
1
(
















y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w
R


Ch3. Image enhancement in spatial domain
-41-
Ch3. Image enhancement in spatial domain
-42-
3.5 Basics of spatial filtering
 In general, linear filtering with m x n mask
– w(s,t): convolution mask, or convolution kernel
2
/
)
1
(
,
2
/
)
1
(
)
,
(
)
,
(
)
,
(






 

 

n
b
m
a
t
y
s
x
f
t
s
w
y
x
g
a
a
s
b
b
t
where
Ch3. Image enhancement in spatial domain
-43-
 Fig 3.33: 3x3 spatial filter mask
 Nonlinear spatial filters
– Filtering operation is based conditionally on the values
of the pixels in the neighborhood under consideration
– Example: median filtering
 Handling methods for boarder pixels
1) Not process the pixels at a distance no less than (n-
1)/2 pixels from the border
2) “padding” the image by adding rows and columns of
0’s







9
1
9
9
2
2
1
1
i
i
i z
w
z
w
z
w
z
w
R 
Ch3. Image enhancement in spatial domain
-44-
3.6 Smoothing spatial filters
 Smoothing linear filters
– Used for blurring and for noise reduction
– Averaging filter, or lowpass filter
– Undesirable side effect: blur edges
– Fig 3.34: (a)box filter, (b)weighted average
Ch3. Image enhancement in spatial domain
45
Ch3. Image enhancement in spatial domain
-46-
3.6 Smoothing spatial filters
 Smoothing linear filters
– General implementation for weighted average filtering
– Example 3.9 & Fig 3.35, Fig 3.36



 


 



 a
a
s
b
b
t
a
a
s
b
b
t
t
s
w
t
y
s
x
f
t
s
w
y
x
g
)
,
(
)
,
(
)
,
(
)
,
(
Ch3. Image enhancement in spatial domain
47
Ch3. Image enhancement in spatial domain
48
Example: Gross Representation of Objects
Ch3. Image enhancement in spatial domain
-49-
3.6.2 Order-statistics filters
 Based on ordering (ranking) the pixels: nonlinear
spatial filters
 Median filter
– Replace the value of a pixel by the median of the gray
levels in the neighborhood of that pixel
– advantages:
• Excellent noise reduction capabilities
• Less blurring than linear smoothing filters of similar size
• Effective in the presence of impulse noise (or salt-and
pepper noise)
– Example 3.10
Ch3. Image enhancement in spatial domain
50
Example: Use of Median Filtering for Noise
Reduction
Ch3. Image enhancement in spatial domain
-51-
3.7 Sharpening spatial filters
 Sharpening:
– To highlight fine detail in an image
– To enhance detail that has been blurred
 Applications
– Electronic printing
– Medical imaging
– Industrial inspection
– Autonomous guidance in military systems
 Accomplished by spatial differentiation
Ch3. Image enhancement in spatial domain
-52-
3.7.1 Foundation
 First-order derivative of 1-D function f(x)
 second-order derivative of 1-D function f(x)
 Fig 3.38
– First-order derivatives
• Produce thicker edges
• Stronger response to a gray-level steps
– Second-order derivatives
• Stronger response to fine detail, such as thin lines and isolated
points
• Double response at step changes in gray-level
)
(
)
1
( x
f
x
f
x
f





)
(
2
)
1
(
)
1
(
2
2
x
f
x
f
x
f
x
f







Ch3. Image enhancement in spatial domain
-53-
Ch3. Image enhancement in spatial domain
-54-
3.7.2 Laplacian
– Isotropic filter: independent of the direction  rotation
invariant
 Development of the method
– Lapacian: simplest isotropic derivative operator, Linear
operator
– discrete form (partial 2nd-order derivative in x, y direction)
2
2
2
2
2
y
f
x
f
f







)
,
(
2
)
1
,
(
)
1
,
(
)
,
(
2
)
,
1
(
)
,
1
(
2
2
2
2
y
x
f
y
x
f
y
x
f
y
f
y
y
x
f
y
x
f
y
x
f
x
f
x
















:
direction
:
direction
Ch3. Image enhancement in spatial domain
-55-
– 2-D Laplacian is obtained by summing two components
  )
,
(
4
)
1
,
(
)
1
,
(
)
,
1
(
)
,
1
(
2
y
x
f
y
x
f
y
x
f
y
x
f
y
x
f
f 









Ch3. Image enhancement in spatial domain
-56-
– Adding the original and Laplacian images (superimpose)
– Example 3.11 & Fig 3.40












positive
is
mask
Laplacian
the
of
t
coefficien
center
the
if
negative
is
mask
Laplacian
the
of
t
coefficien
center
the
if
)
,
(
)
,
(
)
,
(
)
,
(
)
,
( 2
2
y
x
f
y
x
f
y
x
f
y
x
f
y
x
g
Ch3. Image enhancement in spatial domain
-57-

More Related Content

PPT
IMAGE PROCESSING--image-------enhancement-----2.ppt
PPT
Spatial domain and filtering
PPTX
Module 2
PDF
Image Enhancement in the Spatial Domain.pdf
PPTX
IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN.pptx
PDF
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
PPTX
Image Enhancement in Spatial Domain
PPTX
Image enhancement
IMAGE PROCESSING--image-------enhancement-----2.ppt
Spatial domain and filtering
Module 2
Image Enhancement in the Spatial Domain.pdf
IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN.pptx
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
Image Enhancement in Spatial Domain
Image enhancement

Similar to Ch 3. Image Enhancement in the Spatial Domain_okay.ppt (20)

PPT
Image enhancement in spatial domain.ppt
PDF
Lec_3_Image Enhancement_spatial Domain.pdf
PPT
Digital Image Processing UNIT-2.ppt
PDF
Image Enhancement
PDF
4 image enhancement in spatial domain
PPTX
3rd unit.pptx
PDF
2024-master dityv5y65v56u4b6u64u46p 0318-25.pdf
PDF
Image enhancement
PPT
Chap5 imange enhancemet
PPTX
computer vision and pattern recognition.pptx
PPTX
Chapter 3 image enhancement (spatial domain)
PPT
Image Enhancement in the Spatial Domain1.ppt
PPT
Image enhancement in the spatial domain1
PPTX
Image Enhancement in Spatial Frequency Domain
PPT
Digital Image through Scanner, Digital Camera. Concept of Gray Levels.
PPT
chap3.ppt
PPT
PPTX
image enhancement-POINT AND HISTOGRAM PROCESSING.pptx
PPTX
Digital Image Processing Unit -2 Notes complete
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Image enhancement in spatial domain.ppt
Lec_3_Image Enhancement_spatial Domain.pdf
Digital Image Processing UNIT-2.ppt
Image Enhancement
4 image enhancement in spatial domain
3rd unit.pptx
2024-master dityv5y65v56u4b6u64u46p 0318-25.pdf
Image enhancement
Chap5 imange enhancemet
computer vision and pattern recognition.pptx
Chapter 3 image enhancement (spatial domain)
Image Enhancement in the Spatial Domain1.ppt
Image enhancement in the spatial domain1
Image Enhancement in Spatial Frequency Domain
Digital Image through Scanner, Digital Camera. Concept of Gray Levels.
chap3.ppt
image enhancement-POINT AND HISTOGRAM PROCESSING.pptx
Digital Image Processing Unit -2 Notes complete
Chapter 3 Spatial Domain Image Processing.pdf
Ad

Recently uploaded (20)

PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPT
Project quality management in manufacturing
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Welding lecture in detail for understanding
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Digital Logic Computer Design lecture notes
PPTX
Geodesy 1.pptx...............................................
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
PPT on Performance Review to get promotions
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
bas. eng. economics group 4 presentation 1.pptx
Project quality management in manufacturing
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Model Code of Practice - Construction Work - 21102022 .pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Welding lecture in detail for understanding
CYBER-CRIMES AND SECURITY A guide to understanding
R24 SURVEYING LAB MANUAL for civil enggi
Digital Logic Computer Design lecture notes
Geodesy 1.pptx...............................................
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPT on Performance Review to get promotions
Ad

Ch 3. Image Enhancement in the Spatial Domain_okay.ppt

  • 1. Ch3. Image enhancement in spatial domain -1- Ch3. Image Enhancement in the Spatial Domain
  • 2. Ch3. Image enhancement in spatial domain -2- Contents 3.1 Background 3.2 Some basic gray level transformations 3.3 Histogram processing 3.4 Enhancement using arithmetic/logic operations 3.5 Basics of spatial filtering 3.6 Smoothing spatial filters 3.7 Sharpening spatial filters 3.8 Combining spatial enhancement methods
  • 3. Ch3. Image enhancement in spatial domain -3- 3.1 Background  Two categories in image enhancement approaches 1) Spatial domain processing 1) Based on direct manipulation of pixels in an image plane itself 2) Frequency domain processing • Based on modifying the Fourier transform of an image  Spatial domain processing – – Where, f(x,y): input image, g(x,y): processed image, T: an operator on f, defined over some neighborhood of (x,y)   ) , ( ) , ( y x f T y x g 
  • 4. Ch3. Image enhancement in spatial domain -4-  Neighborhood of (x,y) – Use a square or rectangular subimage area centered at (x,y): – Mask (filters, kernels, templates, windows): mask processing or filtering
  • 5. Ch3. Image enhancement in spatial domain -5- – In case of 1x1 (that is, a single pixel): point processing • • Where, r: gray level of f(x,y), s: gray level of g(x,y) • examples:  Contrast stretching: Fig 3.2(a)  Thresholding: Fig 3.2(b) ) (r T s 
  • 6. Ch3. Image enhancement in spatial domain -6- 3.2 Some basic gray level transformations  3 types of gray- level transformation functions 1) Linear: negative and identity transformations 2) Logarithmic: log and inverse-log transformations 3) Power-law: nth power and nth root transformations
  • 7. Ch3. Image enhancement in spatial domain -7-  Image negatives – Function: – Reverse the intensity levels of an image: positive  negative levels gray of num where     L r L s , 1
  • 8. Ch3. Image enhancement in spatial domain -8-  Log transformations – General form: – Expand the values of dark pixels while compressing the higher-level values. – The opposite is true of the inverse log transformation – Characteristic: compress the dynamic range of images with large variations in pixel values 0 ) 1 log(     r c r c s const, where ,
  • 9. Ch3. Image enhancement in spatial domain -9- – example: Fourier spectrum 0 ~ 1.5x106  0 ~ 255
  • 10. Ch3. Image enhancement in spatial domain -10-  Power-law transformations – Basic form: const postive and where ,     c cr s
  • 11. Ch3. Image enhancement in spatial domain -11- – Gamma correction: • Intensity-to-voltage response of CRT: =1.8~2.5 • If =2.5, s = r1/2.5 = r0.4 – Example 3.1 & Fig 3.8 – Example 3.2 & Fig 3.9
  • 12. Ch3. Image enhancement in spatial domain Example: Gamma Transformations
  • 13. Ch3. Image enhancement in spatial domain Example: Gamma Transformations
  • 14. Ch3. Image enhancement in spatial domain Example: Gamma Transformations
  • 15. Ch3. Image enhancement in spatial domain -15-  Piecewise-linear transformation functions – Contrast stretching: • Increase the dynamic range of the gray levels • If r1=s1 and r2=s2, then identity function • If r1= r2, s1=0 and s2=L-1, then thresholding function • In general, r1 r2 and s1s2, so the function is single valued and monotonically increasing
  • 16. Ch3. Image enhancement in spatial domain -16- – Gray-level slicing • Highlighting a specific range of gray level in an image
  • 17. Ch3. Image enhancement in spatial domain 5/11/2024 Highlight the major blood vessels and study the shape of the flow of the contrast medium (to detect blockages, etc.) Measuring the actual flow of the contrast medium as a function of time in a series of images
  • 18. Ch3. Image enhancement in spatial domain -18- – Bit-plane slicing: • Highlighting the specific bit planes • The higher-order bits contain the majority of the visually significant data • Useful for image compression • Bit-plane 7 is a thresholded (binary) image with 127 • Fig 3.13 & 3.14
  • 19. Ch3. Image enhancement in spatial domain Bit-plane Slicing
  • 20. Ch3. Image enhancement in spatial domain Bit-plane Slicing
  • 21. Ch3. Image enhancement in spatial domain -21- 3.3 Histogram processing – Histogram function of a digital image: • Discrete function h(rk)=nk, where rk : k th gray level, nk : number of pixels with gray level rk – Normalized histogram • p(rk)=nk/n, for k=0,1,…,L-1, where n : total number of pixels • Sum of all components of the normalized histogram is equal to 1 – Fig 3.15 • High dynamic range  uniform distribution  histogram equalization
  • 22. Ch3. Image enhancement in spatial domain -22-
  • 23. Ch3. Image enhancement in spatial domain -23- 3.3.1 Histogram equalization – Assume that gray level r is continuous and normalized to [0,1], that is, s = T(r) 0  r  1 – Assume that the transformation function T(r) satisfies the following conditions: (a)T(r) is single-valued and monotonically increasing in the interval 0  r  1 (b) 0  T(r)  1 for 0  r  1
  • 24. Ch3. Image enhancement in spatial domain -24- – If the inverse transformation function r = T-1(s) 0  s  1 satisfies the above conditions, then – If we use CDF(Cumulative Distribution Function) of r for the transformation function, that is, – Then, the above equation satisfies both conditions of (a) and (b). PDF is p() where , ) ( ) ( ) ( 1 s T r r s ds dr r p s p             r r dw w p r T s 0 ) ( ) (
  • 25. Ch3. Image enhancement in spatial domain -25- ) ( ) ( ) ( 0 r p dw w p dr d dr r dT dr ds r r r           1 0 1 ) ( 1 ) ( ) ( ) (      s r p r p ds dr r p s p r r r s If we use CDF for the transformation function, histogram of the transformed image becomes uniform.  Histogram equalization  Uniform density - Thus, [Leibniz’s rule]
  • 26. Ch3. Image enhancement in spatial domain -26- – In digital image, gray level is discrete. Thus, and, transformation function for histogram equalization is – also, inverse transformation function is – Example 3.3, Fig 3.17, and Fig 3.18 1 , , 2 , 1 , 0 ) (    L k n n r p k k r  1 , , 2 , 1 , 0 ) ( ) ( 0 0          L k n n r p r T s k j j k j j r k k  1 , , 2 , 1 , 0 ) ( 1     L k s T r k k 
  • 27. Ch3. Image enhancement in spatial domain 5/11/2024 27
  • 28. Ch3. Image enhancement in spatial domain -31- 3.3.3 Local enhancement  Histogram processing for entire image: global  Local histogram processing: – Define a square or rectangular neighborhood and move the center of this area from pixel to pixel. At each location, histogram equalization or histogram matching is obtained – Another approach is to utilize non-overlapping regions, but it usually produces an undesirable checkerboard effect.
  • 29. Ch3. Image enhancement in spatial domain -32- 3.3.4 Use of histogram statistics for image enhancement  Some statistical parameters obtainable directly from the histogram for image enhancement  nth moment: – and . The second moment is  variance of r ( ) ) ( ) ( ) ( ) ( 1 0 1 0 i L i i L i i n i n r p r m r m r p m r r          : of value mean the is where  i i r r p level gray of histogram normalized : ) ( 1 0   0 1        1 0 2 2 ) ( ) ( ) ( L i i i r p m r r  ) ( 2 r   measure of average gray level  measure of average contrast
  • 30. Ch3. Image enhancement in spatial domain -35- 3.4 Enhancement using arithmetic/logic operations  Arithmetic/logic operations: pixel-by-pixel basis  Arithmetic operations – Image subtraction – Image addition – Image multiplication – Image division  Logic operations – NOT: negative transformation – AND/OR • Used for masking • Masking is ROI(region of interest) processing
  • 31. Ch3. Image enhancement in spatial domain -36-
  • 32. Ch3. Image enhancement in spatial domain -37- 3.4.1 Image subtraction  Difference between f(x,y) and h(x,y):  Subtraction is the enhancement of difference between images.  Fig 3.28:  Example 3.7, Fig 3.29  Comments on implementation – The difference image can range –255~255 => need to scale to 0~255 • Add 255 and then divide by 2 • (diff image – min)x255/max; max: maximum of (diff image – min) image  Image subtraction can be used for segmentation (changes) ) , ( ) , ( ) , ( y x h y x f y x g  
  • 33. Ch3. Image enhancement in spatial domain -38-
  • 34. Ch3. Image enhancement in spatial domain -39- 3.42 Image averaging  Consider a noisy image g(x,y), original image f(x,y), noise (x,y)  At every (x,y), assume that noise is uncorrelated and has zero average, then averaging K different noisy images  Example 3.8, Fig 3.30, 3.31 ) , ( ) , ( ) , ( y x y x f y x g    2 ) , ( 2 ) , ( 1 1 ) , ( )} , ( { ) , ( 1 ) , ( y x y x g K i i K y x f y x g E y x g K y x g         and that follows it then ) , ( ) , ( 1 y x y x g K    
  • 35. Ch3. Image enhancement in spatial domain -40- 3.5 Basics of spatial filtering  Response of linear filtering with 3x3 mask at (x,y) – Fig 3.32 ) 1 , 1 ( ) 1 , 1 ( ) , 1 ( ) 0 , 1 ( ) , ( ) 0 , 0 ( ) , 1 ( ) 0 , 1 ( ) 1 , 1 ( ) 1 , 1 (                 y x f w y x f w y x f w y x f w y x f w R  
  • 36. Ch3. Image enhancement in spatial domain -41-
  • 37. Ch3. Image enhancement in spatial domain -42- 3.5 Basics of spatial filtering  In general, linear filtering with m x n mask – w(s,t): convolution mask, or convolution kernel 2 / ) 1 ( , 2 / ) 1 ( ) , ( ) , ( ) , (             n b m a t y s x f t s w y x g a a s b b t where
  • 38. Ch3. Image enhancement in spatial domain -43-  Fig 3.33: 3x3 spatial filter mask  Nonlinear spatial filters – Filtering operation is based conditionally on the values of the pixels in the neighborhood under consideration – Example: median filtering  Handling methods for boarder pixels 1) Not process the pixels at a distance no less than (n- 1)/2 pixels from the border 2) “padding” the image by adding rows and columns of 0’s        9 1 9 9 2 2 1 1 i i i z w z w z w z w R 
  • 39. Ch3. Image enhancement in spatial domain -44- 3.6 Smoothing spatial filters  Smoothing linear filters – Used for blurring and for noise reduction – Averaging filter, or lowpass filter – Undesirable side effect: blur edges – Fig 3.34: (a)box filter, (b)weighted average
  • 40. Ch3. Image enhancement in spatial domain 45
  • 41. Ch3. Image enhancement in spatial domain -46- 3.6 Smoothing spatial filters  Smoothing linear filters – General implementation for weighted average filtering – Example 3.9 & Fig 3.35, Fig 3.36              a a s b b t a a s b b t t s w t y s x f t s w y x g ) , ( ) , ( ) , ( ) , (
  • 42. Ch3. Image enhancement in spatial domain 47
  • 43. Ch3. Image enhancement in spatial domain 48 Example: Gross Representation of Objects
  • 44. Ch3. Image enhancement in spatial domain -49- 3.6.2 Order-statistics filters  Based on ordering (ranking) the pixels: nonlinear spatial filters  Median filter – Replace the value of a pixel by the median of the gray levels in the neighborhood of that pixel – advantages: • Excellent noise reduction capabilities • Less blurring than linear smoothing filters of similar size • Effective in the presence of impulse noise (or salt-and pepper noise) – Example 3.10
  • 45. Ch3. Image enhancement in spatial domain 50 Example: Use of Median Filtering for Noise Reduction
  • 46. Ch3. Image enhancement in spatial domain -51- 3.7 Sharpening spatial filters  Sharpening: – To highlight fine detail in an image – To enhance detail that has been blurred  Applications – Electronic printing – Medical imaging – Industrial inspection – Autonomous guidance in military systems  Accomplished by spatial differentiation
  • 47. Ch3. Image enhancement in spatial domain -52- 3.7.1 Foundation  First-order derivative of 1-D function f(x)  second-order derivative of 1-D function f(x)  Fig 3.38 – First-order derivatives • Produce thicker edges • Stronger response to a gray-level steps – Second-order derivatives • Stronger response to fine detail, such as thin lines and isolated points • Double response at step changes in gray-level ) ( ) 1 ( x f x f x f      ) ( 2 ) 1 ( ) 1 ( 2 2 x f x f x f x f       
  • 48. Ch3. Image enhancement in spatial domain -53-
  • 49. Ch3. Image enhancement in spatial domain -54- 3.7.2 Laplacian – Isotropic filter: independent of the direction  rotation invariant  Development of the method – Lapacian: simplest isotropic derivative operator, Linear operator – discrete form (partial 2nd-order derivative in x, y direction) 2 2 2 2 2 y f x f f        ) , ( 2 ) 1 , ( ) 1 , ( ) , ( 2 ) , 1 ( ) , 1 ( 2 2 2 2 y x f y x f y x f y f y y x f y x f y x f x f x                 : direction : direction
  • 50. Ch3. Image enhancement in spatial domain -55- – 2-D Laplacian is obtained by summing two components   ) , ( 4 ) 1 , ( ) 1 , ( ) , 1 ( ) , 1 ( 2 y x f y x f y x f y x f y x f f          
  • 51. Ch3. Image enhancement in spatial domain -56- – Adding the original and Laplacian images (superimpose) – Example 3.11 & Fig 3.40             positive is mask Laplacian the of t coefficien center the if negative is mask Laplacian the of t coefficien center the if ) , ( ) , ( ) , ( ) , ( ) , ( 2 2 y x f y x f y x f y x f y x g
  • 52. Ch3. Image enhancement in spatial domain -57-