Digital Image Processing
Chapter 3
Image Enhancement
Part III
Enhancement using
Arithmetic/Logic Operations
Arithmetic/Logic operations operate on a pixel-
by-pixel basis
NOT operator performs as the negative
transformation
AND and OR operators are used for masking
Masking sometimes is referred to as region of
interest (ROI) processing
Mask is used primary to isolate an area for
processing
-/+ are the most useful for image enhancement
Arithmetic/Logic Operations
Image Subtraction
Subtraction is the enhancement of differences between images
g(x,y) = f(x,y) – h(x,y)
mask mode radiography
h(x,y) : mask → X-ray image of a region of a patient’s body captured
by an intensified TV camera located opposite an X-ray source
f(x,y) : the series of incoming images after injection of the
contrast medium
This procedure gives a movie showing how the contrast medium
propagates through the various arteries
Image Subtraction
adjustment [-255, 255]
Method 1 : adds 255 to every pixel and then
divides the result by 2
Full range of the display may not be utilized
Method 2 : adds minus minimum value and
then multiplies each pixel by 255/maximum
value
Max is the max pixel value in the modified difference
Method 3 : calculates the absolute value of
each pixel
Image Averaging
Consider a noisy image
Noise is uncorrelated at every pixel
Zero average value
Image Averaging
Image Averaging
•Reduction in the visual
appearance of noise take place as
a function of increasing K
•In the histogram the mean and
the standard deviation of the
difference images decreases as K
increases
•As K increases, the average
image should approach the
original.
Spatial Linear Filtering Systems
• Linear Shift-Invariant System
input output
image LSI System image
– Linearity: “things can be added”
– Shift-invariance: “things do not change over space”
• Filtering with LSI System
– Spatial domain Convolution
– Frequency domain Multiplication (convolution theorem)
Impulse Response
• The response of an LSI system to an impulse input
impulse
impulse LSI System response
• KEY: An LSI system can be completely characterized
by its impulse response
– Given the impulse response of an LSI system, together with
the input to the system, the output is uniquely determined
Spatial Neighborhood
From [Gonzalez
& Woods]
choices of
neighborhood:
……
Basics of Spatial Filtering
mask x
f ( x − 1, y − 1) f ( x, y − 1) f ( x + 1, y − 1)
mask coefficient
w(−1,−1) w(0,−1) w(1,−1) f ( x − 1, y ) f ( x, y ) f ( x + 1, y )
y w(−1,0) w(0,0) w(1,0)
f ( x − 1, y + 1) f ( x, y + 1) f ( x + 1, y + 1)
w(−1,1) w(0,1) w(1,1)
Masks, Windows, Filters
and the Impulse Responses
• Spatial LSI Filter:
impulse response
constrained within a
local neighborhood
• “Filter”
“Mask”
“Window”
”Impulse
Response”
often used
interchangeably for LSI
From [Gonzalez & Woods]
2D Convolution
x(m,n) h(m,n) y(m,n)
∞
y (m, n) = ∑ h(k , l ) x(m − k , n − l ) = h(m, n) ⊗ x(m, n)
k ,l = −∞
∞
y (m, n) = ∑ h(m − k , n − l ) x(k , l ) = x(m, n) ⊗ h(m, n)
k ,l = −∞
h(m, n) impulse response (spatial linear filter)
x(m, n) input image
y(m, n) output image
Applications
• Image Smoothing
• Image Enhancement
• Image Restoration
– Image denoising
– Image deblurring
• Edge Detection
• Filter Bank
– Image transformation
– Frequency analysis
• ……
Image Smoothing: Average Filters
• Average Filter 1 ... 1 N: filter size
h(m, n) = 2
1
N
1 ... 1
noisy smoothed smoothed
PSNR=20.2dB PSNR=23.8dB PSNR=22.0dB
noise std = 25 3x3 window 5x5 window
From Prof. Xin Li
Image Smoothing: Average Filters
Original image size: 500x500
Average filtered images.
Filter sizes: 3, 5, 9, 15 and 35
• Effects
– Smoothing noise
– Blurring edges
From [Gonzalez & Woods]
Image Smoothing: Gaussian Filters
1
• Gaussian Filter h(m, n) = exp − m 2
+ n 2
Z 2 σ 2
− N ≤ m, n ≤ N
noisy smoothed smoothed
PSNR=20.2dB PSNR=24.4dB PSNR=22.8dB
noise std = 25 σ=1 σ=1.5
From Prof. Xin Li
Image Smoothing Filter Example
0 1 0
• Filter 1 1 8 6 6
1 2 1
6
0 1 0 6 3 11 8
8 8 9 10
• Input image: A 4x4, 4 bits/pixel
9 10 10 7
• Preprocessing: Zero-padding 0 0 0 0 0 0
1 8 6 6 0 1 8 6 6 0
6 3 11 8 0 6 3 11 8 0
8 8 9 10 0 8 8 9 10 0
9 10 10 7 0 9 10 10 7 0
0 0 0 0 0 0
Image Smoothing Filter Example
• Move mask across the 0 0 0 0 0 0
zero-padded image 0 1 0
0 1 8 6 6 0
1
1 2 1
6 0 6 3 11 8 0
0 1 0
0 8 8 9 10 0
• Compute weighted sum 0 9 10 10 7 0
0 0 0 0 0 0
• Result:
2.6 4.3 6.2 4.3 3 4 6 4
4.0 6.5 8.0 7.2
round 4 7 8 7
6.5 7.7 9.5 7.3 7 8 10 7
6.0 7.8 7.7 5.7 6 8 8 6
Sharpening Linear Filters
• Laplacian ∂ 2
f ∂ 2
f - Zero at smooth regions
∇ f = 2 + 2
2
- Sensitive to image details
∂x ∂y
• Discrete approximation of Laplacian:
0 -1 0 -1 -1 -1
-1 4 -1 -1 8 -1
0 -1 0 -1 -1 -1
0 1 0 1 1 1
1 -4 1 1 -8 1
0 1 0 1 1 1
Sharpening Linear Filters
From [Gonzalez & Woods]
Sharpening Linear Filters
• Image Sharpening Idea:
combining Laplacian with the image itself
– Case 1: Center coefficient of the Laplacian mask is positive
0 -1 0 -1 -1 -1
g ( x, y ) = f ( x, y ) + ∇ 2 f ( x, y ) -1 4 -1 -1 8 -1
0 -1 0 -1 -1 -1
– Case 2: Center coefficient of the Laplacian mask is negative
0 1 0 1 1 1
g ( x, y ) = f ( x, y ) − ∇ 2 f ( x, y ) 1 -4 1 1 -8 1
0 1 0 1 1 1
Sharpening Linear Filters
• Combined sharpening filters
0 0 0 0 -1 0
g ( x, y ) = 0 1 0 ⊗ f ( x, y ) + -1 4 -1 ⊗ f ( x, y )
0 0 0 0 -1 0
0 -1 0
= -1 5 -1 ⊗ f ( x, y )
0 -1 0
0 0 0 -1 -1 -1
g ( x, y ) = 0 1 0 ⊗ f ( x, y ) + -1 8 -1 ⊗ f ( x, y )
0 0 0 -1 -1 -1
-1 -1 -1
= -1 9 -1 ⊗ f ( x, y )
-1 -1 -1
Sharpening Linear Filters
From [Gonzalez & Woods]