Chap 22
Chap 22
com
Objectives of Enhancement
Background Infomation
Chapter 3
Image Enhancement in the
Spatial Domain
where
f ( x, y) is the input image
g ( x, y) is the processed image
T is an operator on f defined over
some neighborhood of ( x, y)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Point Processing
s T (r )
Where
r =gray level of f ( x, y)
s=gray level of g ( x, y)
Contrast Stretching
and
Thresholding
3 basic gray-level
transformation functions
Linear function
Negative and identity
transformation
Logarithm function
Log and inverse-log
transformation
Power-low function
Additional Source:
nth power and nth root [Link]
transformation el_transformations.htm
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Identity function
Image Negatives
Log Transformations
s c log(1 r )
c is a contrast and r≥0
Log curve maps a narrow
range of low gray-level
values in the input image
into a wider range of
output levels.
Used to expand the values
of dark pixels in an image
Additional source: while compressing the
[Link] higher-level values.
transformation-of-an-image-using-
python-and-opencv/
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Power-Law Transformations
s cr
c and are positive constants
Power-low curves with fractional
values of r map a narrow range of
dark input values with the opposite
being true for higher values of input
levels.
c= =1 → Identity function
Gamma correction
=2.5
Gamma correction is
done by preprocessing
the image before
inputting it to the
1/
monitor with s cr
=1/2.5=4
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Another example
Another example
Piecewise-Linear
Transformation Functions
Advantage :
The form of piecewise function can be arbitrarily
complex
Disadvantage:
Their specification requires considerably more user
input
a b
Contrast Stretching (1/2) c d
Increase the dynamic range of
the gray levels in the image
(b) a low-contrast image: result
from poor illumination, lack of
dynamic range in the imaging
sensor, or even wrong setting of a
lens aperture of image acquisition
(c) result of contrast stretching :
( r1 , s1 ) ( rmin , 0) and (r2 , s2 ) (rmax , L 1)
(d) result of thresholding
a b
Contrast Stretching (2/2) c d
r
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Gray-level slicing
Bit-plane slicing
Example
8 bit planes
Bit-plane 7 Bit-plane 6
h(rk ) nk
Where
rk : the kth gray level
nk : the number of pixels in the image having gray level rk
h(rk ) : histogram of digital image with gray levels
Normalized Histogram
Histogram Processing
Example
rk
Dark image
components of histogram
are concentrated on the low
side of the gray scale
Bright image
components of histogram
are concentrated on the high
side of the gray scale
Example
Low-contrast image
histogram is narrow and
centered toward the middle of
the gray scale
High-contrast image
histogram covers broad
range of the gray scale and the
distribution of pixels is not too
far from uniform
Histogram Transformation
s T (r )
Where 0 ≤ r ≤ 1
T(r) satisfies [condition (a)]
T(r) is single-valued and
monotonically increasing in the
interval 0 ≤ r ≤ 1
0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Discrete Transformation
Function
The probability of occurrence of gray level in an image is
approximated by
, where k = 0, 1, …, L-1
, where k = 0, …, L-1
Histogram Equalization
As the low-contrast image’s histogram is narrow and
centered toward the middle of the gray scale, if we
distribute the histogram to a wider range, the quality
of the image will be improved.
We can do it by adjusting the probability density
function of the original histogram of the image so that
the probability spread equality
Equalization can be achieved by the following
transformation function
Example
Example-Transformation
Example-Result
Example
Example
Image is dominated by
large, dark areas,
resulting in a histogram
characterized by a large
concentration of pixels in
pixels in the dark end of
the gray scale
Image Equalization
Histogram Specification
Histogram Specification
Histogram Equalization
Histogram Equalization
using Desired Histogram of
of input image, S.
output image, Z.
vk
zk
1 4 6 13 15 20 24 25 1 8 13 18 20 23 25 25
Accumulative distribution of input Accumulative distribution of output
- S R’ mapping R Z
- In continuous space, the two
-Construct LUT as follows: equalize images (R and R’)
+ Map rk to sk using T(r) should be the same.
LUT 0 0 1 2 2 4 5 6
Histogram Specification
(1) the transformation
function G(z) obtained
from
k
G ( zk ) pz ( zi ) sk
i 0
k 0,1, 2,...L 1
(2) the inverse
transformation G 1 ( s )
Note
Histogram specification is s trial-and-error
process
There are no rules for specifying histograms, and
one must resort to analysis on a case-by-case basis
for any given enhancement task.
Histograms processing methods are global
processing, in the sense that pixels are modified by
a transformation function based in the gray-level
content of an entire image.
Sometimes, we may need to enhance details over
small areas in an image, which in called a local
enhancement.
Local Enhancement
define a square or rectangular neighborhood and move the center of this area
from pixel to pixel.
at each location, the histogram of the points in the neighborhood is computed
and either histogram equalization or histogram specification transformation
function is obtained.
another approach used to reduce computation is to utilize nonoverlapping
regions, but it usually produces an undesirable checkerboard effect.
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Enhancement using
Arithmetic/Logic Operations
Logic Operations
Image Subtraction
g ( x, y) f ( x, y) h( x, y)
Enhancement of the
differences between images
Note
We may have to adjust the gray-scale of the
subtracted image to be [0,255] (if 8-bit is used)
first, find the minimum gray value of the subtracted
image
second, find the maximum gray value of the subtracted
image
Set the minimum value to be zero and the maximum to
be 255
While the rest are adjusted according to the interval
[0,255], by timing each value with 255/max
Subtraction is also used in segmentation of moving
pictures to track the changes
After subtract the sequenced images, what is left should
be the moving elements in the image, plus noise
Image Averaging
consider a noisy image g(x,y) formed by the
addition of noise η(x,y) to an original image f(x,y)
g ( x, y) f ( x, y) ( x, y)
if noise has zero mean and be uncorrelated then it
can be shown that if
g ( x, y ) image formed by averaging
K different noisy images
K
1
g ( x, y )
K
g ( x, y )
i 1
i
Image Averaging
then
1 2
g2( x , y ) ( x, y )
K
g2( x , y ) , 2( x , y ) var iances of g and
if K increases, it indicates that the variability (noise) of the pixel at each location
(x,y) decreases.
thus
E{g ( x, y)} f ( x, y)
E{g ( x, y )} = expected value of g
(output after averaging)
= original image f ( x, y )
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Example
-Image corrupted by
additive Gaussian
noise with zero mean
-Results of averaging
k=8, 16, 64, 128
Chapter 3
Image Enhancement in the
Spatial Domain
Spatial Filtering
w7 w8 w9
i 1
Linear Filtering
Linear Filtering of an image f of size M x N filter
mask of size m x n is defined as
𝑎 𝑏
𝑔 𝑥, 𝑦 = 𝑤 𝑠, 𝑡 𝑓(𝑥 + 𝑠, 𝑦 + 𝑡)
𝑠=−𝑎 𝑡=−𝑏
Example
Note:
Big mask is used to
eliminate small objects
from an image
The size of the mask
establishes that relative size
of the objects that will be
blended with the
background.
Example
Order-Statistics Filters
(Nonlinear Filters)
The response is based on ordering (ranking) the
pixels contained in the image area encompassed by
the filter
example
median filter : R=median{Zk | k=1,2,…,nxn}
max filter : R=max{Zk | k=1,2,…,nxn}
min filter : R=min{Zk | k=1,2,…,nxn}
note : nxn is the size of the mask
Median Filters
Replaces the value of a pixel by the median of the
gray levels in the neighborhood of that pixel ( the
original value of the pixel is included in the
computation of the median)
Quite popular because for certain types of random
noise such as impulse noise(or salt and pepper
noise), they provide excellent noise-reduction
capabilities, with considering less blurring than linear
smoothing filters of similar size.
Median Filters
Forces the points with distinct gray levels to be
more like their neighbors.
Isolated clusters of pixels that are light or dark
with respect to their neighbors, and whose area
is less than one-half the filter area, are
eliminated by an n x n median filter.
Forced to have the value equal the median
intensity of the neighbors.
Larger clusters are affected considerably less
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. [Link]
Derivative operator
The response of a derivative operator is
proportional to the degree of discontinuity of the
image at the point at which the operator is
applied.
Thus, image differentiation
enhances edges and other discontinuities (noise)
deemphasizes area with slowly varying gray-level
values.
Example
Laplacian masks
Example
Example
Sharpening
f s ( x, y) f ( x, y) f ( x, y)
High-pass image = original image – blurred image
High-boost filtering
High-boost filtering
High-boost Masks
Example
Gradient Operator
Gradient Mask
Gradient Mask
Gradient Mask
Sobel operators, 3x3
Note
The summation of coefficients in all
masks equals 0, which means that
they would give a response of 0 in an
area of constant gray level.
Edge Masks
Example
solution :
1. Laplacian to highlight fine detail
2. gradient to enhance prominent edges
3. gray-level transformation to increase the dynamic
range of gray levels
Thank You