Engineering presentation
Digital Image Processing
EEE415
Lecture 5
Image Enhancement in Spatial Domain
Local enhancement using statistical parameters from histogram
Local enhancement can be based on statistical properties of the gray levels in a block instead of using full histogram
Examples:
- Mean gives the average brightness of the image
- Variance (σ2) and its square root the standard deviation gives the deviation of intensities on average from the mean value (average contrast)
Local enhancement using statistical parameters
Sxy : a neighborhood (subimage) of size NSxy; a block centered at (x,y)
: gray-level mean in Sxy
: gray-level variance in Sxy
: standard deviation, square root of variance
MG : global mean of f(x,y)
DG : global standard deviation of f(x,y)
Local enhancement using statistical parameters
The statistical parameters can be used in various ways:
- For the direct calculation of transformation function (adaptive transformation function) for example
where is the local gain factor,
- Using them in defining ranges for different transfer functions for example
where E, k0, k1, k2, are specified parameters
Local enhancement with adaptive transformation function
Original moon image
Image enhanced using adaptive transformation window size: 15x15, k = 0.5
Histogram equalized image
Local enhancement using statistical parameters
Defining ranges for different transformation functions
Local enhancement using statistical parameters
Image formed from the local means
Image formed from the local standard deviations
Image formed from the multiplication constants selected for different mean/std ranges
E = 4.0, k0 = 0.4, k1 = 0.02, and k2 = 0.4,
Local enhancement using statistical parameters
Input microscopic image
Enhanced output image
Mathematical/logical operations on images
- Addition
- Averaging images for noise removal
- Subtraction
- Removal of background from images
- Image enhancement
- Image matching
- Moving/displaced object tracking
- Multiplication
- Superimposing of texture on an image
- Convolution and correlation of images
- And and or operations
- To remove the unnecessary area of an image through mask operations
Image averaging for noise reduction
A noisy image can be represented by
where denotes the noise in the image
Since the noise is random and the content is fixed,
The noise can be removed by taking more noisy images of the same object and averaging them out
Image averaging for noise reduction
Original image Noisy image
Result of averaging using 8 noise samples
Using 16 noise samples
Using 64 noise samples
Using 128 noise samples
Image averaging for noise reduction
Noisy image
Noise reduction by averaging 256 samples
Examples of image subtraction
Original image
Image after moving one coin
Difference image after pixel by pixel subtraction of second image from first image
Examples of image subtraction
Difference of images from quality control: a missing chip in PCB is detected by subtracting the master image from image of each sample
Examples of image Multiplication
Multiplication of images can be used for superimposing texture on an image
Smooth spherical surface image
Texture to be superimposed
output image
Example of logical operations using masks
Local enhancement through spatial filtering
- The output intensity value at (x,y) depends not only on the input intensity value at (x,y) but also on the specified number of neighboring intensity values around (x,y)
- Spatial masks (also called window, filter, kernel, template) are used and convolved over the entire image for local enhancement (spatial filtering)
- The size of the masks determines the number of neighboring pixels which influence the output value at (x,y)
- The values (coefficients) of the mask determine the nature and properties of enhancing technique
Local enhancement through spatial filtering
The mechanics of spatial filtering
For an image of size M x N and a mask of size m x n
The resulting output gray level for any coordinates x and y is given by
Basics of spatial filtering
- Given the 3×3 mask with coefficients: w1, w2,…, w9
- The mask cover the pixels with gray levels: z1, z2,…, z9
- z gives the output intensity value for the processed image (to be stored in a new array) at the location of z5 in the input image
Basics of spatial filtering
Mask operation near the image border
Problem arises when part of the mask is located outside the image plane; to handle the problem:
Discard the problem pixels (e.g. 512x512input 510x510output if mask size is 3x3)
Zero padding: expand the input image by padding zeros (512x512input 514x514output)
- Zero padding is not good create artificial lines or edges on the border;
We normally use the gray levels of border pixels to fill up the expanded region (for 3x3 mask). For larger masks a border region equal to half of the mask size is mirrored on the expanded region.
Mask operation near the image border
Spatial filtering for Smoothing
- For blurring/noise reduction;
- Blurring is usually used in preprocessing steps,
e.g., to remove small details from an image prior to object extraction,
or to bridge small gaps in lines or curves
- Equivalent to Low-pass spatial filtering in frequency domain because smaller (high frequency) details are removed based on neighborhood averaging (averaging filters)
Implementation: The simplest form of the spatial filter for averaging is a square mask (assume m×m mask) with the same coefficients 1/m2 to preserve the gray levels (averaging).
Applications: Reduce noise; smooth false contours
Side effect: Edge blurring
Smoothing filters
Spatial filtering for Smoothing (example)
Spatial filtering for Smoothing (example)
Original image size: 500 x 500
Smoothed by 5 x 5 box filter
Smoothed by 15 x 15 box filter
Smoothed by 3 x 3 box filter
Smoothed by 9 x 9 box filter
Smoothed by 35 x 35 box filter
Spatial filtering for Smoothing (example)
*
*
Order-statistic (Nonlinear) Filters
— Nonlinear
— Based on ordering (ranking) the pixels contained in the filter mask
— Replacing the value of the center pixel with the value determined by the ranking result
E.g., median filter, max filter, min filter
*
*
Example: Use of Median Filtering for Noise Reduction
*
*
Sharpening Spatial Filters
Foundation
Laplacian Operator
Unsharp Masking and Highboost Filtering
Using First-Order Derivatives for Nonlinear Image Sharpening — The Gradient
*
*
Sharpening Spatial Filters: Foundation
The first-order derivative of a one-dimensional function f(x) is the difference
The second-order derivative of f(x) as the difference
*
*
*
*
Sharpening Spatial Filters: Laplace Operator
The second-order isotropic derivative operator is the Laplacian for a function (image) f(x,y)
*
*
Sharpening Spatial Filters: Laplace Operator
*
*
Sharpening Spatial Filters: Laplace Operator
Image sharpening in the way of using the Laplacian:
*
*
*
*
Unsharp Masking and Highboost Filtering
Unsharp masking
Sharpen images consists of subtracting an unsharp (smoothed) version of an image from the original image
e.g., printing and publishing industry
Steps
1. Blur the original image
2. Subtract the blurred image from the original
3. Add the mask to the original
*
*
Unsharp Masking and Highboost Filtering
*
*
Unsharp Masking: Demo
*
*
Unsharp Masking and Highboost Filtering: Example
*
*
Image Sharpening based on First-Order Derivatives
Gradient Image
*
*
Image Sharpening based on First-Order Derivatives
| z1 | z2 | z3 |
| z4 | z5 | z6 |
| z7 | z8 | z9 |
*
*
Image Sharpening based on First-Order Derivatives
| z1 | z2 | z3 |
| z4 | z5 | z6 |
| z7 | z8 | z9 |
*
*
Image Sharpening based on First-Order Derivatives
*
*
Example
*
*
Example:
Combining Spatial Enhancement Methods
Goal:
Enhance the image by sharpening it and by bringing out more of the skeletal detail
*
*
Example:
Combining Spatial Enhancement Methods
Goal:
Enhance the image by sharpening it and by bringing out more of the skeletal detail
xy
xy
xy
Sts
S
S
tsf
N
m
),(
),(
1
xy
S
m
2
xy
S
2
),(
2
),(
1
xy
xy
xy
xy
Sts
S
S
S
mtsf
N
xy
S
2
xy
S
s
,
]
)
,
(
[
)
,
(
xy
xy
xy
S
S
S
m
m
y
x
f
A
y
x
g
+
-
=
xy
S
A
1
0
,
<
<
=
k
kM
A
xy
xy
S
G
S
s
ï
þ
ï
ý
ü
ï
î
ï
í
ì
£
£
£
=
otherwise
)
,
(
AND
if
)
,
(
.
)
,
(
2
1
0
y
x
f
D
k
D
k
M
k
m
y
x
f
E
y
x
g
G
S
D
G
S
xy
xy
s
),
,
(
)
,
(
)
,
(
y
x
y
x
f
y
x
g
h
+
=
)
,
(
y
x
h
)
,
(
y
x
f
å
=
=
K
i
i
y
x
g
K
y
x
g
1
),
,
(
1
)
,
(
,
1
,......,
2
,
1
,
0
,
1
,......,
2
,
1
,
0
2
/
)
1
(
,
2
/
)
1
(
where
)
,
(
)
,
(
)
,
(
-
=
-
=
-
=
-
=
+
+
=
å
å
-
=
-
=
N
y
M
x
n
b
m
a
t
y
s
x
f
t
s
w
y
x
g
a
a
s
b
b
t
(1)()
f
fxfx
x
¶
=+-
¶
2
2
(1)(1)2()
f
fxfxfx
x
¶
=++--
¶
22
2
22
ff
f
xy
¶¶
Ñ=+
¶¶
2
2
(1,)(1,)2(,)
f
fxyfxyfxy
x
¶
=++--
¶
2
2
(,1)(,1)2(,)
f
fxyfxyfxy
y
¶
=++--
¶
2
(1,)(1,)(,1)(,1)
-4(,)
ffxyfxyfxyfxy
fxy
Ñ=++-+++-
2
2
(,)(,)(,)
where,
(,) is input image,
(,) is sharpenend images,
-1 if (,) corresponding to Fig. 3.37(a)
or (b)
and 1 if either of the other two filters
is us
gxyfxycfxy
fxy
gxy
cfxy
c
éù
=+Ñ
ëû
=Ñ
=
ed.
Let (,) denote the blurred image, unshar
p masking is
(,)(,)(,)
Then add a weighted portion of the mask
back to the original
(,)(,)*(,)
mask
mask
fxy
gxyfxyfxy
gxyfxykgxy
=-
=+
0
k
³
when 1, the process is referred to as hi
ghboost filtering.
k
>
For function (,), the gradient of at co
ordinates (,)
is defined as
grad()
x
y
fxyfxy
f
g
x
ff
f
g
y
¶
éù
êú
éù
¶
êú
Ѻº=
êú
¶
êú
ëû
êú
¶
ëû
22
The of vector , denoted as (,)
(,)mag()
xy
magnitudefMxy
Mxyfgg
Ñ
=Ñ=+
(,)||||
xy
Mxygg
»+
8565
(,)||||
Mxyzzzz
=-+-
9586
Roberts Cross-gradient Operators
(,)||||
Mxyzzzz
»-+-
789123
369147
Sobel Operators
(,)|(2)(2)|
|(2)(2)|
Mxyzzzzzz
zzzzzz
»++-++
+++-++