SlideShare a Scribd company logo
1 of 31
Download to read offline
TJ Cham
2011/12 S1
Image Intensity
Transformations and Filtering
Cham Tat Jen
SCSE CE7491 Digital Image Processing
1
TJ Cham
2011/12 S1
Contents
• Point Processing
– Gray-level transformations
– Contrast stretching
– Histogram equalization
• Arithmetic / Logic Operations
• Spatial filtering
– Convolution
– Smoothing filters
– Sharpening filters
– Order statistics filter
SCSE CE7491 Digital Image Processing
2
TJ Cham
2011/12 S1
Two classes of processing in the
spatial domain
• Point Processing
– Each pixel’s new gray-level does
not depend on other pixel’s gray-
level
• Spatial Filtering
– Each pixel’s new gray-level
depends on current gray-level of
neighbouring pixels
SCSE CE7491 Digital Image Processing
3
TJ Cham
2011/12 S1
Point Processing
• Pixel gray-level transformation expressed as a function
• Some transformations may be dependent on global
statistics, e.g.
– Maximum and minimum pixel gray-levels present in
the image
– Histogram of pixel gray-levels
)
(r
T
s =
SCSE CE7491 Digital Image Processing
4
TJ Cham
2011/12 S1
Pixel Intensity Transformation
Original gray-levels
New
gray-levels
0 255
0
255
r
s
SCSE CE7491 Digital Image Processing
5
TJ Cham
2011/12 S1
6
SCSE CE7491 Digital Image Processing
Image Negatives
• Inverting gray-levels produced equivalent
of photographic negatives
• For image with gray-levels in the range [0,
L-1], transformation is
0 255
0
255
r
s
r
L
s −
−
= 1
TJ Cham
2011/12 S1
7
SCSE CE7491 Digital Image Processing
Contrast Stretching
• Increase contrast of images captured under poor illumination, wrong
camera setting, etc.
– Maximizes dynamic range
• rmax = max gray-level present
in image
• rmin = min gray-level present
in image 0 255
0
255
r
s










−
−

=
max
max
min
min
max
min
min
255
255
0
r
r
r
r
r
r
r
r
r
r
r
s
rmax
rmin
TJ Cham
2011/12 S1
8
SCSE CE7491 Digital Image Processing
Contrast Stretching
• Min present gray-level ➔ 0
• Max present gray-level ➔ 255
• Linear scale in-between
TJ Cham
2011/12 S1
9
SCSE CE7491 Digital Image Processing
Gray-Level Histograms of Images
• A gray-level histogram of an image
shows how frequently different gray-
levels appear in the image
• Can be represented as bin counts, or
probability distributions if divided by
total number of pixels in the image
• Example:
Pixel gray levels
Frequency
/
probability
TJ Cham
2011/12 S1
10
SCSE CE7491 Digital Image Processing
Histogram Equalization
• Histogram equalization attempts to flatten the gray-level histogram
through a gray-level transformation
• Q: What is this gray-level transformation?
Pixel gray levels
Frequency
/
probability
Pixel gray levels
Frequency
/
probability
?
TJ Cham
2011/12 S1
11
SCSE CE7491 Digital Image Processing
Histogram Equalization
• Can be used improve contrast of details in images containing very
light and dark regions
• E.g.
TJ Cham
2011/12 S1
12
SCSE CE7491 Digital Image Processing
Histogram Equalization
• Consider pixel gray-levels normalized to [0,1],
i.e. 0 ≤ r ≤ 1, 0 ≤ s ≤ 1
• The transformation s = T(r) for histogram equalization must satisfy the
following:
– T(r) is single-valued and monotonically increasing in the
interval 0 ≤ r ≤ 1
– 0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1
• In continuous domain, histogram equalized by:
– Transformation same as cumulative
distribution function for gray-levels!

=
=
r
r d
p
r
T
s
0
)
(
)
( 

TJ Cham
2011/12 S1
r
r
s
s
pr(r)
ps(s)
Conservation of
histogram count
dr
r
p
ds
s
p r
s )
(
)
( =
SCSE CE7491 Digital Image Processing
13
TJ Cham
2011/12 S1
Histogram Equalization
r
r
s
s
pr(r)
ps(s)

=
r
r dr
r
p
s )
(
dr
r
p
ds r )
(
1 =

1
SCSE CE7491 Digital Image Processing
14
TJ Cham
2011/12 S1
15
SCSE CE7491 Digital Image Processing
Histogram Equalization
• Note derivation is only for
continuous gray-levels
• Need to adapt to discrete gray
levels in digital images
– Cumulative sum of histogram
bins
• See recommended text and
Matlab help for details of
discrete algorithms
TJ Cham
2011/12 S1
16
SCSE CE7491 Digital Image Processing
Arithmetic / Logic Operations
• An image is also an array of numbers
• We can carry out arithmetic and logic operations with
other images, e.g.
– Image masking
– Image subtraction
– Image averaging
TJ Cham
2011/12 S1
17
SCSE CE7491 Digital Image Processing
Image Masking
• Regions of interest in an image can be selected by AND
or OR operations with image masks, e.g.
)
,
(
&
)
,
(
)
,
( y
x
m
y
x
f
y
x
g =
TJ Cham
2011/12 S1
18
SCSE CE7491 Digital Image Processing
Image Subtraction
• Image subtraction can be used to detect changes from
one image to the next
)
,
(
)
,
(
)
,
( y
x
h
y
x
f
y
x
g −
=
TJ Cham
2011/12 S1
19
SCSE CE7491 Digital Image Processing
Image Averaging
• For series of static images, image
averaging can be used to suppress
additive noise
• Best performance under i.i.d. zero-
mean assumptions
– f(x,y) is the ideal but unknown
image
– η is an additive zero-mean,
uncorrelated noise

+
= )
,
(
)
,
( y
x
f
y
x
g
TJ Cham
2011/12 S1
20
SCSE CE7491 Digital Image Processing
Spatial Filtering
• Spatial filtering computes each pixel new gray-level based on the
existing gray-levels of neighboring pixels
• Linear spatial filtering involves convolving a normal (large) image
with a small image known as a filter, mask, kernel, template or
window
TJ Cham
2011/12 S1
21
SCSE CE7491 Digital Image Processing
Discrete 2D Convolution
• Images are finite – assume pixel values to be zero outside image
boundaries
• Consider a filter h(x,y)
– size: width = 2a+1, height = 2b+1
– usually treat centre pixel as origin (0,0)
• Discrete 2D convolution expressed as
 
 
−
= −
=
−
= −
=
−
−
+
+
=
−
−
=
a
a
u
b
b
v
a
a
u
b
b
v
v
u
h
v
y
u
x
f
v
u
h
v
y
u
x
f
y
x
g
)
,
(
)
,
(
)
,
(
)
,
(
)
,
(
TJ Cham
2011/12 S1
22
SCSE CE7491 Digital Image Processing
2D Spatial Filtering Steps
• To compute output value at a specific pixel location
(x’,y’):
1. Rotate filter h(u,v) 180° around to get h(-u,-v)
2. Overlay filter centre pixel at input image location
(x’,y’)
3. Multiply overlapping image and filter pixels, and sum
4. Put sum in output image (x’,y’) location.
TJ Cham
2011/12 S1
23
SCSE CE7491 Digital Image Processing
2D Spatial Filtering Example
• For g = I * h, compute g(5,3), g(6,3), …
1 8 6 5 7 5 3 9 4
7 5 4 4 7 5 5 3 1
0 6 6 2 0 8 0 2 10
5 5 4 8 2 2 10 6 8
9 1 7 1 6 9 2 9 1
7 9 9 4 6 9 0 1 2
8 3 1 5 0 8 1 8 0
-0.3 -0.2 0.1
-0.3 -0.4 0.1
0.4 0.3 0.3
I = h =
g(5,3) = (0.3)(0) + (0.3)(8) + (0.4)(0) + (0.1)(2) + (-0.4)(2) + (-0.3)(10)
+ (0.1)(6) + (-0.2)(9) + (-0.3)(2) = -3
g(6,3)= (0.3)(8) + (0.3)(0) + (0.4)(2) + (0.1)(2) + (-0.4)(10) + (-0.3)(6)
+ (0.1)(9) + (-0.2)(2) + (-0.3)(9) } = -4.6
-0.3 -0.2 0.1
-0.3 -0.4 0.1
0.4 0.3 0.3
TJ Cham
2011/12 S1
24
SCSE CE7491 Digital Image Processing
Impulse Response and Point-Spread
Function
• The filter h(x,y) may also be considered as the impulse response of
the filter system
• With an impulse input (i.e. f =  )
• Sometimes, h(x,y) is also known as the Point-Spread Function
(PSF), since an input impulse becomes ‘spread out’
)
,
(
)
,
(
)
,
(
)
,
(
y
x
h
v
u
h
v
y
u
x
y
x
g
a
a
u
b
b
v
=
−
−
=  
−
= −
=

TJ Cham
2011/12 S1
25
SCSE CE7491 Digital Image Processing
Averaging Filter
• Also known as a box filter
• Different filter sizes may also be
used
1 1 1
1 1 1
1 1 1
1
9
×
TJ Cham
2011/12 S1
26
SCSE CE7491 Digital Image Processing
Gaussian Smoothing
• Gaussian smoothing filters have the shape of a 2D uniform variate
Normal density function
• Compute at discrete values for different size spatial filters, and
normalize sum of filter coefficients to 1
– E.g. 3x3 filter
2
2
2
2
2
2
1
)
,
( 

y
x
e
y
x
h
+
−
=
0.075114 0.123841 0.075114
0.123841 0.20418 0.123841
0.075114 0.123841 0.075114
TJ Cham
2011/12 S1
27
SCSE CE7491 Digital Image Processing
Sharpening Linear Filters
• Averaging ≈ integration ➔ image blurring
• Therefore, differentiation ➔ image sharpening
• Applying filters that enhance image derivatives will
sharpen images
TJ Cham
2011/12 S1
28
SCSE CE7491 Digital Image Processing
Laplacian Filter
• The Laplacian of a 2D function f is defined
by
• A discrete approximation of the operator is
represented by the filter
2
2
2
2
2
y
f
x
f
f


+


=
 1 1 1
1 -8 1
1 1 1
TJ Cham
2011/12 S1
29
SCSE CE7491 Digital Image Processing
High Boost Filtering
• Laplacian filter enhances edges only
– eliminates slowly varying image regions – may not be desirable
• High boost filtering
– mix original image f(x,y) and Laplacian filtered image fs(x,y)
1
),
,
(
)
,
(
)
1
(
)
,
( 
+
−
= A
y
x
f
y
x
f
A
y
x
f s
hb
TJ Cham
2011/12 S1
30
SCSE CE7491 Digital Image Processing
Nonlinear Filtering : Order Statistics
• In order statistics filtering:
1. neighborhood input pixels are ranked by their gray-levels
2. Output pixel is the nth-ranked pixel gray-level
• e.g. median filter
3 0 5
10 21 14
17 6 0


















21
17
14
10
6
5
3
0
0
TJ Cham
2011/12 S1
31
SCSE CE7491 Digital Image Processing
Median Filtering
• Median filter is a 50 percentile order statistics filter
• Useful for removing impulse noise, also known as speckle or salt-
and-pepper noise

More Related Content

Similar to SpatialEnhancement of course CE7491 of NTU

Similar to SpatialEnhancement of course CE7491 of NTU (20)

Digital Image Fundamentals - II
Digital Image Fundamentals - IIDigital Image Fundamentals - II
Digital Image Fundamentals - II
 
Module 2
Module 2Module 2
Module 2
 
JPEG Image Compression
JPEG Image CompressionJPEG Image Compression
JPEG Image Compression
 
h.pdf
h.pdfh.pdf
h.pdf
 
COM2304: Intensity Transformation and Spatial Filtering – I (Intensity Transf...
COM2304: Intensity Transformation and Spatial Filtering – I (Intensity Transf...COM2304: Intensity Transformation and Spatial Filtering – I (Intensity Transf...
COM2304: Intensity Transformation and Spatial Filtering – I (Intensity Transf...
 
Histogram processing
Histogram processingHistogram processing
Histogram processing
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
4 image enhancement in spatial domain
4 image enhancement in spatial domain4 image enhancement in spatial domain
4 image enhancement in spatial domain
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Image enhancement lecture
Image enhancement lectureImage enhancement lecture
Image enhancement lecture
 
Histogram based Enhancement
Histogram based Enhancement Histogram based Enhancement
Histogram based Enhancement
 
Histogram based enhancement
Histogram based enhancementHistogram based enhancement
Histogram based enhancement
 
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
 
Image Enhancement - Point Processing
Image Enhancement - Point ProcessingImage Enhancement - Point Processing
Image Enhancement - Point Processing
 
Digital Image Processing_ ch2 enhancement spatial-domain
Digital Image Processing_ ch2 enhancement spatial-domainDigital Image Processing_ ch2 enhancement spatial-domain
Digital Image Processing_ ch2 enhancement spatial-domain
 
Image Enhancement
Image Enhancement Image Enhancement
Image Enhancement
 
Chap5 imange enhancemet
Chap5 imange enhancemetChap5 imange enhancemet
Chap5 imange enhancemet
 
Lec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdfLec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdf
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 

SpatialEnhancement of course CE7491 of NTU

  • 1. TJ Cham 2011/12 S1 Image Intensity Transformations and Filtering Cham Tat Jen SCSE CE7491 Digital Image Processing 1
  • 2. TJ Cham 2011/12 S1 Contents • Point Processing – Gray-level transformations – Contrast stretching – Histogram equalization • Arithmetic / Logic Operations • Spatial filtering – Convolution – Smoothing filters – Sharpening filters – Order statistics filter SCSE CE7491 Digital Image Processing 2
  • 3. TJ Cham 2011/12 S1 Two classes of processing in the spatial domain • Point Processing – Each pixel’s new gray-level does not depend on other pixel’s gray- level • Spatial Filtering – Each pixel’s new gray-level depends on current gray-level of neighbouring pixels SCSE CE7491 Digital Image Processing 3
  • 4. TJ Cham 2011/12 S1 Point Processing • Pixel gray-level transformation expressed as a function • Some transformations may be dependent on global statistics, e.g. – Maximum and minimum pixel gray-levels present in the image – Histogram of pixel gray-levels ) (r T s = SCSE CE7491 Digital Image Processing 4
  • 5. TJ Cham 2011/12 S1 Pixel Intensity Transformation Original gray-levels New gray-levels 0 255 0 255 r s SCSE CE7491 Digital Image Processing 5
  • 6. TJ Cham 2011/12 S1 6 SCSE CE7491 Digital Image Processing Image Negatives • Inverting gray-levels produced equivalent of photographic negatives • For image with gray-levels in the range [0, L-1], transformation is 0 255 0 255 r s r L s − − = 1
  • 7. TJ Cham 2011/12 S1 7 SCSE CE7491 Digital Image Processing Contrast Stretching • Increase contrast of images captured under poor illumination, wrong camera setting, etc. – Maximizes dynamic range • rmax = max gray-level present in image • rmin = min gray-level present in image 0 255 0 255 r s           − −  = max max min min max min min 255 255 0 r r r r r r r r r r r s rmax rmin
  • 8. TJ Cham 2011/12 S1 8 SCSE CE7491 Digital Image Processing Contrast Stretching • Min present gray-level ➔ 0 • Max present gray-level ➔ 255 • Linear scale in-between
  • 9. TJ Cham 2011/12 S1 9 SCSE CE7491 Digital Image Processing Gray-Level Histograms of Images • A gray-level histogram of an image shows how frequently different gray- levels appear in the image • Can be represented as bin counts, or probability distributions if divided by total number of pixels in the image • Example: Pixel gray levels Frequency / probability
  • 10. TJ Cham 2011/12 S1 10 SCSE CE7491 Digital Image Processing Histogram Equalization • Histogram equalization attempts to flatten the gray-level histogram through a gray-level transformation • Q: What is this gray-level transformation? Pixel gray levels Frequency / probability Pixel gray levels Frequency / probability ?
  • 11. TJ Cham 2011/12 S1 11 SCSE CE7491 Digital Image Processing Histogram Equalization • Can be used improve contrast of details in images containing very light and dark regions • E.g.
  • 12. TJ Cham 2011/12 S1 12 SCSE CE7491 Digital Image Processing Histogram Equalization • Consider pixel gray-levels normalized to [0,1], i.e. 0 ≤ r ≤ 1, 0 ≤ s ≤ 1 • The transformation s = T(r) for histogram equalization must satisfy the following: – T(r) is single-valued and monotonically increasing in the interval 0 ≤ r ≤ 1 – 0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1 • In continuous domain, histogram equalized by: – Transformation same as cumulative distribution function for gray-levels!  = = r r d p r T s 0 ) ( ) (  
  • 13. TJ Cham 2011/12 S1 r r s s pr(r) ps(s) Conservation of histogram count dr r p ds s p r s ) ( ) ( = SCSE CE7491 Digital Image Processing 13
  • 14. TJ Cham 2011/12 S1 Histogram Equalization r r s s pr(r) ps(s)  = r r dr r p s ) ( dr r p ds r ) ( 1 =  1 SCSE CE7491 Digital Image Processing 14
  • 15. TJ Cham 2011/12 S1 15 SCSE CE7491 Digital Image Processing Histogram Equalization • Note derivation is only for continuous gray-levels • Need to adapt to discrete gray levels in digital images – Cumulative sum of histogram bins • See recommended text and Matlab help for details of discrete algorithms
  • 16. TJ Cham 2011/12 S1 16 SCSE CE7491 Digital Image Processing Arithmetic / Logic Operations • An image is also an array of numbers • We can carry out arithmetic and logic operations with other images, e.g. – Image masking – Image subtraction – Image averaging
  • 17. TJ Cham 2011/12 S1 17 SCSE CE7491 Digital Image Processing Image Masking • Regions of interest in an image can be selected by AND or OR operations with image masks, e.g. ) , ( & ) , ( ) , ( y x m y x f y x g =
  • 18. TJ Cham 2011/12 S1 18 SCSE CE7491 Digital Image Processing Image Subtraction • Image subtraction can be used to detect changes from one image to the next ) , ( ) , ( ) , ( y x h y x f y x g − =
  • 19. TJ Cham 2011/12 S1 19 SCSE CE7491 Digital Image Processing Image Averaging • For series of static images, image averaging can be used to suppress additive noise • Best performance under i.i.d. zero- mean assumptions – f(x,y) is the ideal but unknown image – η is an additive zero-mean, uncorrelated noise  + = ) , ( ) , ( y x f y x g
  • 20. TJ Cham 2011/12 S1 20 SCSE CE7491 Digital Image Processing Spatial Filtering • Spatial filtering computes each pixel new gray-level based on the existing gray-levels of neighboring pixels • Linear spatial filtering involves convolving a normal (large) image with a small image known as a filter, mask, kernel, template or window
  • 21. TJ Cham 2011/12 S1 21 SCSE CE7491 Digital Image Processing Discrete 2D Convolution • Images are finite – assume pixel values to be zero outside image boundaries • Consider a filter h(x,y) – size: width = 2a+1, height = 2b+1 – usually treat centre pixel as origin (0,0) • Discrete 2D convolution expressed as     − = − = − = − = − − + + = − − = a a u b b v a a u b b v v u h v y u x f v u h v y u x f y x g ) , ( ) , ( ) , ( ) , ( ) , (
  • 22. TJ Cham 2011/12 S1 22 SCSE CE7491 Digital Image Processing 2D Spatial Filtering Steps • To compute output value at a specific pixel location (x’,y’): 1. Rotate filter h(u,v) 180° around to get h(-u,-v) 2. Overlay filter centre pixel at input image location (x’,y’) 3. Multiply overlapping image and filter pixels, and sum 4. Put sum in output image (x’,y’) location.
  • 23. TJ Cham 2011/12 S1 23 SCSE CE7491 Digital Image Processing 2D Spatial Filtering Example • For g = I * h, compute g(5,3), g(6,3), … 1 8 6 5 7 5 3 9 4 7 5 4 4 7 5 5 3 1 0 6 6 2 0 8 0 2 10 5 5 4 8 2 2 10 6 8 9 1 7 1 6 9 2 9 1 7 9 9 4 6 9 0 1 2 8 3 1 5 0 8 1 8 0 -0.3 -0.2 0.1 -0.3 -0.4 0.1 0.4 0.3 0.3 I = h = g(5,3) = (0.3)(0) + (0.3)(8) + (0.4)(0) + (0.1)(2) + (-0.4)(2) + (-0.3)(10) + (0.1)(6) + (-0.2)(9) + (-0.3)(2) = -3 g(6,3)= (0.3)(8) + (0.3)(0) + (0.4)(2) + (0.1)(2) + (-0.4)(10) + (-0.3)(6) + (0.1)(9) + (-0.2)(2) + (-0.3)(9) } = -4.6 -0.3 -0.2 0.1 -0.3 -0.4 0.1 0.4 0.3 0.3
  • 24. TJ Cham 2011/12 S1 24 SCSE CE7491 Digital Image Processing Impulse Response and Point-Spread Function • The filter h(x,y) may also be considered as the impulse response of the filter system • With an impulse input (i.e. f =  ) • Sometimes, h(x,y) is also known as the Point-Spread Function (PSF), since an input impulse becomes ‘spread out’ ) , ( ) , ( ) , ( ) , ( y x h v u h v y u x y x g a a u b b v = − − =   − = − = 
  • 25. TJ Cham 2011/12 S1 25 SCSE CE7491 Digital Image Processing Averaging Filter • Also known as a box filter • Different filter sizes may also be used 1 1 1 1 1 1 1 1 1 1 9 ×
  • 26. TJ Cham 2011/12 S1 26 SCSE CE7491 Digital Image Processing Gaussian Smoothing • Gaussian smoothing filters have the shape of a 2D uniform variate Normal density function • Compute at discrete values for different size spatial filters, and normalize sum of filter coefficients to 1 – E.g. 3x3 filter 2 2 2 2 2 2 1 ) , (   y x e y x h + − = 0.075114 0.123841 0.075114 0.123841 0.20418 0.123841 0.075114 0.123841 0.075114
  • 27. TJ Cham 2011/12 S1 27 SCSE CE7491 Digital Image Processing Sharpening Linear Filters • Averaging ≈ integration ➔ image blurring • Therefore, differentiation ➔ image sharpening • Applying filters that enhance image derivatives will sharpen images
  • 28. TJ Cham 2011/12 S1 28 SCSE CE7491 Digital Image Processing Laplacian Filter • The Laplacian of a 2D function f is defined by • A discrete approximation of the operator is represented by the filter 2 2 2 2 2 y f x f f   +   =  1 1 1 1 -8 1 1 1 1
  • 29. TJ Cham 2011/12 S1 29 SCSE CE7491 Digital Image Processing High Boost Filtering • Laplacian filter enhances edges only – eliminates slowly varying image regions – may not be desirable • High boost filtering – mix original image f(x,y) and Laplacian filtered image fs(x,y) 1 ), , ( ) , ( ) 1 ( ) , (  + − = A y x f y x f A y x f s hb
  • 30. TJ Cham 2011/12 S1 30 SCSE CE7491 Digital Image Processing Nonlinear Filtering : Order Statistics • In order statistics filtering: 1. neighborhood input pixels are ranked by their gray-levels 2. Output pixel is the nth-ranked pixel gray-level • e.g. median filter 3 0 5 10 21 14 17 6 0                   21 17 14 10 6 5 3 0 0
  • 31. TJ Cham 2011/12 S1 31 SCSE CE7491 Digital Image Processing Median Filtering • Median filter is a 50 percentile order statistics filter • Useful for removing impulse noise, also known as speckle or salt- and-pepper noise