Digital Image Processing 19 Histogram Equalization Histogram Matching Local Histogram Processing Using Histogram Statistics for Image Enhancement III... We can do it by adjusti
Trang 1Digital Image Processing
Lecture 3 – Intensity Transformation& Spatial Filtering
Lecturer: Ha Dai DuongFaculty of Information Technology
Process the transform coefficients, not directly process the
intensity values of the image plane
Trang 2Digital Image Processing 3
Trang 3Digital Image Processing 5
Intensity transformation function
s T r = ( )
II Intensity transformation function
Functions
Trang 4Digital Image Processing 7
Trang 5Digital Image Processing 9
Log Transformations log(1 )
II.2 Log Transform
Trang 6Digital Image Processing 11
II.3 Power – Law
Trang 7Digital Image Processing 13
II.4 Piecewise-Linear Transform
Contrast Stretching
Expands the range of intensity levels in an image so
that it spans the full intensity range of the recording
medium or display device
Intensity-level Slicing
Highlighting a specific range of intensities in an image
often is of interest
Trang 8Digital Image Processing 15
Trang 9Digital Image Processing 17
II.5 Bit – Plane Slicing
Trang 10Digital Image Processing 19
Histogram Equalization
Histogram Matching
Local Histogram Processing
Using Histogram Statistics for Image
Enhancement
III Histogram processing
Histogram ( )
is the intensity value
is the number of pixels in the image with intensity
k k th
: the number of pixels in the image of
size M N with intensity
k k
r
=
×
Trang 11Digital Image Processing 21
Trang 12Digital Image Processing 23
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 equally
III.1 Histogram Equalization
s = T(r)
Where 0 ≤ r ≤ 1
T(r) satisfies
(a) T(r) is single-valued and monotonically increasingly in the interval
0 ≤ r ≤ 1
(b) 0 ≤ T(r) ≤ 1 for
0 ≤ r ≤ 1
Trang 13Digital Image Processing 25
2 conditions of T(r)
Single-valued (one-to-one relationship) guarantees that
the inverse transformation will exist
Monotonicity condition preserves the increasing order from
black to white in the output image thus it won’t cause a
negative image
0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1 guarantees that the output gray
levels will be in the same range as the input levels
The inverse transformation from s back to r is
r = T -1 (s) ; 0 ≤s ≤1
III.1 Histogram Equalization
Let
p r (r) denote the PDF of random variable r (r)
p s (s) ) denote the PDF of random variable s
If pr(r) (r) and T(r) are known and T(r) T-1(s) satisfies (s)
condition (a) then ps(s) ) can be obtained using a
formula :
ds
dr (r) p (s)
ps = r
Trang 14Digital Image Processing 27
function (CDF) of random variable r :
CDF is an integral of a probability function (always positive) is the
area under the function
Thus, CDF is always single valued and monotonically increasing
Thus, CDF satisfies the condition (a)
We can use CDF as a transformation function
p
dw ) w ( p dr
d
dr
) r ( dT
dr
ds
r
r r
where 1
ds
dr ) r ( p ) s ( p
r r
r s
Substitute and yield
Trang 15Digital Image Processing 29
Ps(s):
As p s (s) is a probability function, it must be zero outside
the interval [0,1] in this case because its integral over all
values of s must equal 1.
Called p s (s) as a uniform probability density function
p s (s) is always a uniform, independent of the form of
p r (r)
III.1 Histogram Equalization
Discrete Transformation Function
The probability of occurrence of gray level in an image
k j
j r k
k
, , ,
where k n
n
) r ( p )
r ( T s
0
11
0
11
0 where k , , , L- n
n ) r (
k
Trang 16Digital Image Processing 31
Thus, an output image is obtained by mapping
each pixel with level rk in the input image into a
corresponding pixel with level sk in the output
image
In discrete space, it cannot be proved in general
that this discrete transformation will produce the
discrete equivalent of a uniform probability density
function, which would be a uniform histogram
III.1 Histogram Equalization
Example before after Histogram
equalization
Trang 17Digital Image Processing 33
Example
equalization
The quality is not improved much because the original image already has a broaden gray-level scale
III Histogram processing
Trang 18Digital Image Processing 35
Trang 19Digital Image Processing 37
Generate a processed image that has a specified
histogram
Let ( ) and ( ) denote the continous probability
density functions of the variables and ( ) is the
specified probability density function
Let be the random variable with the prob
z
r z p z s
0
0
ability ( ) ( 1) ( )
Define a random variable with the probability
( ) ( 1) ( )
r r
z z
Trang 20Digital Image Processing 39
1 Obtain pr(r) from the input image and then obtain the values of s
2 Use the specified PDF and obtain the transformation function
1r
;0 2
2 r
) r (
Trang 21Digital Image Processing 41
Example
We would like to apply the histogram specification with the
desired probability density function pz(z) as shown
1 z
;0
2 z )
z (
dw ) w (
dw ) w ( p ) r ( T s
r r
r r
2 2
2 2
2
0 2
Trang 22Digital Image Processing 43
Example
2 0
2 0
( )
2 Obtain the transformation function G(z)
III.2 Histogram Matching
Example
2
2 2
2 2
) ( )
(
r r z
r r
z
r T z
3 Obtain the inversed transformation function G-1
We can guarantee that 0 ≤ z ≤1 when 0 ≤ r ≤1
Trang 23Digital Image Processing 45
Procedure in discrete cases
1 Obtain pr(rj) from the input image and then obtain the values of
sk, round the value to the integer range [0, L-1]
2 Use the specified PDF and obtain the transformation function
G(zq), round the value to the integer range [0, L-1].
III.2 Histogram Matching
Example Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity distribution shown in the following
table (on the left) Get the histogram transformation function and make the output image with the specified histogram, listed
in the table on the right.
Trang 24Digital Image Processing 47
Example
Obtain the scaled histogram-equalized values,
Compute all the values of the transformation function G,
→7
Trang 25Digital Image Processing 49
Example
III.2 Histogram Matching
Example
Trang 26Digital Image Processing 51
Define a neighborhood and move its center from pixel to pixel
At each location, the histogram of the points in the
neighborhood is computed Either histogram equalization or
histogram specification transformation function is obtained
Map the intensity of the pixel centered in the neighborhood
Move to the next location and repeat the procedure
III.3 Local Histogram Processing
Trang 27Digital Image Processing 53
1 0( )
L
i i i
=
1 0
Local average intensity
( ) denotes a neighborhood
L
i xy
Trang 28Digital Image Processing 55
( , ), if and ( , )
Arithmetic/Logic operations perform on pixel by
pixel basis between two or more images, except
NOT operation which perform only on a single
image
Logic operation performs on gray-level images,
the pixel values are processed as binary
numbers:
Light represents a binary 1, and
Dark represents a binary 0
Trang 29Digital Image Processing 57
IV.2 Image Subtraction
g(x,y) = f(x,y) – h(x,y)
Extraction of the differences between images
Trang 30Digital Image Processing 59
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
) ,
K different noisy images
y x
g
1
) , (
1 ) , (
IV.3 Image Averaging
),(
2)
,(
y x y
x g
= variances of g and η)
,(
2)
,(
2g x y , σ η x y
σ
if K increase, it indicates that the variability (noise) of the pixel at
each location (x,y) decreases
Trang 31Digital Image Processing 61
) , ( )}
, (
)}
, (
(output after averaging)
= original image f(x,y)
V Spatial Filtering
A spatial filter consists of (a) a neighborhood, and (b) a predefined
operation
Linear spatial filtering of an image of size MxN with a filter of size
mxn is given by the expression
Trang 32Digital Image Processing 63
Smoothing filters are used for blurring and for noise reduction
Blurring is used in removal of small details and bridging of small
gaps in lines or curves
Smoothing spatial filters include linear filters and nonlinear filters.
Trang 33Digital Image Processing 65
The general implementation for filtering an M N image
with a weighted averaging filter of size m n is given
( , )
( , ) where 2 1
V.1 Smoothing Filters
Averaging Filter Masks
Trang 34Digital Image Processing 67
Averaging Filter Masks
a) original image 500x500 pixel
b) - f) results of smoothing with
square averaging filter masks of
The size of the mask establishes the
relative size of the objects that will be
blended with the background.
V.1 Smoothing Filters
original image result after smoothing with
15x15 averaging mask result of thresholding
we can see that the result after smoothing and thresholding, the
remains are the largest and brightest objects in the image
Trang 35Digital Image Processing 69
Order-Statistics Filters (Nonlinear Filters)
The response is based on ordering (ranking) the pixels
contained in the image area encompassed by the filter
Median filter : R = median{zk |k = 1,2,…,n x n}
Max filter : R = max{zk |k = 1,2,…,n x n}
Min filter : R = min{zk |k = 1,2,…,n x n}
Note: n x n is the size of the mask
V.1 Smoothing Filters
Median Filter
Median: X= {x1,x2,…, x2b+1}, x is called the median of X if x
greater than or equal b elements and less than or equal b other
elements in X;
For example: X={3,2,3,2,3,4,5,6,5} (b=4) -> Median is 3
Peplaces 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 ( impulse
noise > salt and pepper noise ) , they provide excellent
noise-reduction capabilities , with considering less blurring than linear
smoothing filters of similar size
Trang 36Digital Image Processing 71
Unsharp Masking and Highboost Filtering
Using First-Order Derivatives for Nonlinear Image
Sharpening - The Gradient
Trang 37Digital Image Processing 73
The first-order derivative of a one-dimensional function f(x) is the
Trang 38Digital Image Processing 75
Laplace Operator
The second-order isotropic derivative operator is the Laplacian
for a function (image) f(x,y)
Trang 39Digital Image Processing 77
Image sharpening in the way of using the
Trang 40Digital Image Processing 79
Filtering
V.4 Unsharp Masking and Highboost
Filtering
Trang 41Digital Image Processing 81
Filtering
V.4 Unsharp Masking and Highboost
Filtering
Trang 42Digital Image Processing 83
Trang 43Digital Image Processing 85
Trang 44Digital Image Processing 87
Derivatives (Gradient)
V.5 Method based on First-Order
Derivatives (Gradient)
Example
Trang 45Digital Image Processing 89
Methods
dynamic range of gray levels
V.6 Combining Spatial Enhancement
Methods
Trang 46Digital Image Processing 91
Methods