Ch03 IntensityTransformations
Ch03 IntensityTransformations
Intensity Transformation
Background
Histogram processing
s = T (r ). (3)
s =L−1−r (4)
particularly suited for enhancing white or gray detail embedded in
dark regions.
Log transformations
s = c log(1 + r ), (5)
Contrast stretching
Process that expands the range of intensity levels in an image so
that it spans the full intensity range of the recording medium or
display device.
Picewise-linear transformation.
I r1 = s1 and r2 = s2 → linear
transformation, i. e., no
change.
I r1 = r2 , s1 = 0 and
s2 = L − 1 → thresholding.
I In general, r1 ≤ r2 and
s1 ≤ s2 , preserving the order
of intensity levels and
preventing the creation of
intensity artifacts.
Scanning electron microscope image of pollen ×700.
1. (r1 , s1 ) = (rmin , 0) and (r2 , s2 ) = (rmax , L − 1).
2. (r1 , s1 ) = (m, 0) and (r2 , s2 ) = (m, L − 1).
Intensity-level slicing
s = T (r ) 0 ≤ r ≤ L − 1. (7)
Assume:
1. T (r ) is monotonically
increasing in the interval
0 ≤ r ≤ L − 1, and;
2. 0 ≤ T (r ) ≤ L − 1 for
0 ≤ r ≤ L − 1.
Considering the inverse
r = T −1 (s) (8)
I Intensity levels in an image may be viewed as random
variables in the interval [0, L − 1].
I Let pr (r ) and ps (s) denote the Probability Density Functions
(PDFs) of r and s.
I From probability theory, if pr (r ) and T (r ) are known, and
T (r ) is continuous and differentiable over the range of values
of interest, then the PDF of the transformed variable s can be
obtained using
dr
ps (s) = pr (r ) . (9)
ds
Consider the transformation function
Z r
s = T (r ) = (L − 1) pr (w )dw , (10)
0
dr
Substituting this result in ps (s) = pr (r ) yields. . .
ds
dr
ps (s) = pr (r )
ds
1
pr (r )
(L − 1)pr (r )
1
ps (s) = , 0 ≤ s ≤ L − 1. (12)
L−1
which is a uniform probability density function.
In other words, using the transformation
Z r
s = T (r ) = (L − 1) pr (w )dw ,
0
k
(L − 1) X
sk = nj , k = 0, 1, . . . , L − 1. (13)
n
j=0
where
n = MN
Each input intensity rk is mapped into a level sk in the output
image, using Eq. (13).
Example: Hypothetical 64 × 64 = 4096 image with L = 8 intensity
levels.
rk nk nk /n sk sk
0 790 0.19 1.35 1
1 1023 0.25 3.10 3
2 850 0.21 4.55 5
3 656 0.16 5.67 6
4 329 0.08 6.23 6
5 245 0.06 6.65 7
6 122 0.03 6.86 7
7 81 0.02 7.00 7
Illustration of histogram equalization:
Notice
Histogram equalization has the tendency to wider the range of the
intensity values, enhancing the contrast.
Figure: Original (left) and histogram equalized image (right).
Figure: Transformations (1) through
(4) were obtained from the
histograms of the images
(top-bottom) in the left column of
Pk
using sk = (L − 1/MN) j=0 nj , j =
0, 1, . . . , L − 1.
Histogram matching
Histogram equalization:
I Automatically determines a transformation function that seeks
to produce an output image that has a uniform histogram.
I If automatic enhancement is desired, this is a good approach
because;
I the results from this technique are predictable, and;
I the method is simple to implement.
I However:
Histogram matching
Sometimes it is useful to be able to specify the shape of the
histogram that we wish the processed image to have.
Histogram matching is:
I A trial-and-error process.
I Sometimes, the user might know what an “average”
histogram should look like.
I There are no general rules to specifying histograms, varying
between different cases.
Local histogram processing
X n
µnSxy = rs,t − mSxy p (rs,t ) (18)
(s,t)∈Sxy
Where:
I a = (m − 1)/2 and b = (n − 1)/2 form the window dimension
m × n (both odd numbers).
I Also called convolution.
I Note: the result of the operation does not change the original
image.
The basic procedure consists in summing the products between the
mask coefficients and the gray levels at the local image region.
R = w1 z1 + w2 z2 + . . . + w9 z9 .
In general;
R = w1 z1 + w2 z2 + . . . + wmn zmn
mn
X
R= wk zk
k=1
R = wT z (21)
Smoothing filters
Median filter:
I Useful for elimination of salt-and-pepper (or impulse) noise.
I The median ξ of a set of values is such that half the values in
the set are less than or equal to ξ and half are greater than or
equal to ξ.
I I. e., its main function is to force points with distinct intensity
levels to be more like their neighbors.
Salt and pepper noise removal using the median filter:
Sharpening spatial filters
∂2f ∂2f
∇2 f = + . (24)
∂x 2 ∂y 2
Since:
∂2f
= f (x + 1) + f (x − 1) − 2f (x)
∂x 2
and
∂2f
= f (y + 1) + f (y − 1) − 2f (y ).
∂y 2
We have
1
Independent of orientation
∇2 f = f (x + 1, y ) + f (x − 1, y ) + f (x, y + 1) + f (x, y − 1) − 4f (x, y )
Because the Laplacian is a derivative operator:
I It highlights intensity discontinuities in an image.
I De-emphasizes regions with slowly varying intensity levels.
The basic way to use the Laplacian for image sharpening is:
where:
I f (x, y ) and g (x, y ) are the input and sharpened images.
I c is −1 or +1 if the center of the filter is negative or positive,
respectively.
High-boost2 filtering
2
“Alto reforço”
More formally:
∂f
gx = = (z7 + 2z8 + z9 ) − (z1 + 2z2 + z3 ) (31)
∂x
and
∂f
gy = = (z3 + 2z6 + z9 ) − (z1 + 2z4 + z7 ) (32)
∂y
The Sobel operators:
Notes:
I The weight of 2 in the center coefficient is to achieve some
smoothing by giving more importance to the center point.
I The magnitude of the gradient is obtained with:
Definition
A fuzzy set in Z is characterized by a membership function µA (z),
that associates with each element of Z a real number in the
interval [0, 1].
I The value of µA (z) represents the grade of membership of z
in A.
An element z is;
I A full member of A if µA (z) = 1.
I Not a member of A if µA (z) = 0.
I A partial member of A if 0 < µA (z) < 1.
I Crispy sets are a particular case of Fuzzy sets.
Basic definitions:
I Empty set: A fuzzy set is empty if and only if its
membership function is identically zero in Z .
I Equality: Two fuzzy sets A and B are equal, written A = B,
if and only if µA (z) = µB (z) for all z ∈ Z .
I Complement: The complement (NOT) of a fuzzy set A,
denoted by Ā, or NOT(A), is defined as the set whose
membership function is