Image Enhancement 129
(a)
After histogram hy-
(b)
Histogram after histogram
perbolisation
hyperboliaation
1w
200
Gray Levels
l
(c)
After histogram hy-
(d)
Histogram after histogram
perbolization with ran-
hyperbolization with random
dom
additions additions
Figure 4.3: Histogram hyperbolization with
a
=
0.5
applied to the image
of
Figure
4.2a
with value
31
and give them value
32.
The result will be
a
perfectly
flat
histogram.
An example of applying this method can be seen in
Figures
4.2e and 4.3~.
What if we do not wish to have an image with a flat histogram?
We may define
p,(s)
to be any function we wish. Then:
LSP"(")dY
=
/kz)dz
0
where in order to avoid confusion we have used
z
and
y
as the dummy variables
of
integration. This equation defines
S
directly in terms of
T.
Since
ps(y)
is known (the
desired histogram), one can solve the integral on the left hand side to find
a
function
130
Image Processing: The Fundamentals
f~
of
S.
Similarly, the integral on the right hand side can be performed to yield a
function
f2
of
r;
i.e.
fl(S)
=
f2(7-)
*
S
=
fL1f2(r)
(4.3)
In practice, one may define an intermediate transformation by:
W
E
i'Pr(x)dx
(4.4)
This transformation gives the values
W
of the equalized histogram of the given image.
Clearly:
I"
PdYPY
=
W
(4.5)
This defines another transformation such that
W
=
Tz(s)
while we actually need
S
in
terms of
W.
So
this is
a
three-step process:
1.
Equalize the histogram of the given image.
2. Specify the desired histogram and obtain the transformation
W
=
T~(s).
3.
Apply the inverse of the above transformation to the equalized histogram.
An example of applying this method to image 4.2a can be seen in
Figures
4.3a and
4.3b. This histogram has been produced by setting
p,(s)
=
ae-"'
where
Q!
is some
positive constant. The effect is to give more emphasis to low grey level values and
less to the high ones. This effect is barely visible in
Figure
4.3b because it is masked
by the discretization effect. However, in
Figure
4.3d it can be seen clearly because
the method of random additions was used.
Why should one wish to perform something other than histogram
equalization?
One may wish to emphasize certain grey values more than others, in order to com-
pensate for
a
certain effect; for example, to compensate for the way the human eye
responds to the different degrees of brightness. This is
a
reason for doing histogram
hyperbolization: it produces
a
more pleasing picture.
Example
4.1
The histogram of an image can be approximated by the probability
density function
p'(.)
=
Ae-'
where
r
is the grey-level variable taking values between
0
and
b,
and
A
is a normalizing factor. Calculate the transformation
S
=
T(r),
where
S
is the grey level value in the transformed image, such that the trans-
formed image has probability density function
Image Enhancement
131
p,(s)
=
Bse-"
where
S
takes values between
0
and
b,
and
B
is some normalizing factor.
The transformation
S
=
T(r)
can be calculated using equation
(4.1).
BsePs2ds
=
AeC'dr
We integrate both sides
of
this equation to obtain the relationship between the
distribution functions
of
variables
S
and
r.
To avoid confusion we use as dummy
variables
of
integration y on the left hand side and
X
on the
right
hand side:
B
ye-Y2dy
=
A
e-"dx
LT
The left hand side
of
(4.6) is:
The
right
hand side
of
(4.6) is:
We substitute from (4.7) and (4.8) into (4.6) to obtain:
1
-
e-s2
A
2
B
B
=
-(l
-
e-')
+
e-s2
- -
1
-
-(l
2A
-e-')
+
What if the image has inhomogeneous contrast?
The approach described above is global, i.e. we modify the histogram which refers
to the whole image. However, the image may have variable quality
at
various parts.
For example, it may have
a
wide shadow band right in the middle, with its top and
bottom parts being adequately visible. In that case we can apply the above techniques
locally: We
scan
the image with
a
window inside which we modify the histogram but
132
Image Processing: The Fundamentals
we alter only the value of the grey level of the central pixel. Clearly such a method
is costly and various algorithms have been devised to make it more efficient.
Figure
4.4a shows
a
classical example of an image that requires local enhancement.
The picture was taken indoors looking towards windows with plenty
of
ambient light
coming through. All outdoor sections are fine, but in the indoor part the film was
under-exposed. The result of global histogram equalization shown in
Figure
4.4b is
not bad, but it makes the outdoor parts over-exposed in order to allow
us
to see
the details of the interior. The result of the local histogram equalization on the other
hand, shown in
Figure
4.4c, is overall
a
much more balanced picture. The window size
used for this was 40
X
40, with the original image being of size 400
X
400. Notice that
no part of the picture gives the impression of being over-exposed or under-exposed.
There are parts of the image, however, that look damaged:
at
the bottom of the
picture and
a
little
at
the top. They correspond to parts of the original film which
received too little light to record anything. They correspond to flat black patches,
and by trying to enhance them we simply enhance the film grain or the instrument
noise. This effect is more prominent in the picture
of
the hanging train
of
Wupertal
shown in
Figure
4.5. Local histogram equalization (the result
of
which is shown in
Figure
4.5~) attempts to improve parts of the picture that are totally black, in effect
trying to amplify non-existing information. However, those parts
of
the image with
some information content are enhanced in
a
pleasing way.
A
totally different effect becomes evident in
Figure
4.6~ which shows the local
histogram enhancement of
a
picture taken
at
Karlstejn castle in the Czech Republic,
shown in
Figure
4.6a. The castle
at
the back consists
of
flat
grey walls. The process
of local histogram equalization amplifies every small variation
of
the wall to such a
degree that the wall looks like the rough surface of
a
rock. Further, on the left
of
the
picture we observe again the effect of trying to enhance a totally black area. In this
case, the result of global histogram equalization looks much more acceptable, in spite
of the fact that if we were to judge from the original image, we would have thought
that local histogram equalization would produce
a
better result.
Is there an alternative to histogram manipulation?
Yes, one may use the mean and standard deviation
of
the distribution of pixels inside
a
window. Let
us
say that the mean grey value inside a window centred
at
(X,
y)
is
m(z,
g),
the variance of the pixels inside the window is
O(X,
y),
and the value of pixel
(X,
y)
is
f
(X,
y).
We can enhance the variance inside each such window by using a
transformation of the form:
where
A
is some scalar.
So
we choose the amplification factor
A
inversely proportional to
O(X,
y):
We would like areas which have low variance to have their variance amplified most.
Image Enhancement
133
where
k
is
a
constant, and
M
is the average grey value
of
the image.
Figure
4.4d shows the results
of
applying this process to image 4.4a with
k
=
3
and window size 5
X
5. Note that although details in the image have become explicit,
the picture overall is too dark and not particularly pleasing.
Figures
4.5d and 4.6d
show the results
of
applying the same process to the images 4.5a and 4.6a respectively,
with the additional post-processing
of
histogram equalization.
U
(a)
Original image
(b)
After global histogram equalization
(c) After local histogram equalization
(d)
After local enhancement
Figure
4.4:
Enhancing the image
of
a young train driver.
134
Image Processing: The Fundamentals
c
l
.
.
(a) Original image
(b)
After global histogram equalization
(c) After local histogram equalization
(d)
After local enhancement
Figure
4.5:
Enhancing the image
of
the hanging train
of
Wupertal.
Image Enhancement
135
(a)
Original image
(b)
After global histogram equalization
(c) After local histogram equalization
(d)
After local enhancement
Figure
4.6:
Enhancing the image at the Karlstejn castle.
How can we improve the contrast
of
a multispectral image?
A
multispectral
or
multiband
or colour image consists
of
several arrays
of
the same
scene, one for each spectral component. Each of these bands is
a
grey level image
giving the intensity of light
at
the particular spectral component
at
the position of each
136
Image Processing: The Fundamentals
pixel. Suppose for simplicity that we have three spectral bands, Red, Green and Blue.
Then each picture consists of three bands, three grey level images. Alternatively, we
may say that each pixel carries three values, one for each spectral band. We can
plot these triplets in
a
3D
coordinate space, called RGB because we measure the grey
value of
a
pixel in each of the three bands along the three axes. The pixels of the
colour image plotted in this space form
a
cluster.
If
we were to use only one of these bands, we would like to choose the one that
shows the most detail; i.e. the one with the maximum contrast, the one in which the
values of the pixels are most spread.
It
is possible that the maximum spread of the values of the pixels is not along any
of the axes, but along another line (see
Figure
4.7a). To identify this line we must
perform
principal component analysis
or take the
Karhunen-Loeve transformation
of
the image.
B
R
/
0 0
e/.
B
G
>
R
/
Figure
4.7:
The pixels of a colour image form a cluster in the colour space.
The maximum spread of this cluster may be along a line not parallel with
any of the colour axes.
What is principal component analysis?
Principal component analysis (or Karhunen-Loeve transformation) identifies
a
linear
transformation of the coordinate system such that the three axes of the new coor-
dinate system coincide with the directions of the three largest spreads of the point
distribution. In this new set of axes the data are uncorrelated. This means that if
we form
a
grey image by using the values of the first co-ordinate of each pixel, it will
contain totally uncorrelated information from the information that will be contained
in the grey image formed by the second coordinate of each pixel and the information
contained in the image formed by the third coordinate of each pixel.
Image Enhancement
137
What is the relationship of the Karhunen-Loeve transformation discussed
here and the one discussed in Chapter
3?
They both analyse an ensemble of random outcomes into their uncorrelated compo-
nents. However, in Chapter
3
the whole image was considered as the outcome of
a
random experiment, with the other random outcomes in the ensemble not available.
Their lack of availability was compensated by the assumed ergodicity.
So,
although
the ensemble statistics were computed over the single available image using spatial
statistics, they were assumed to be averages computed over all random outcomes, i.e.
all versions of the image. Here the values of
a
single
pixel are considered to be the
outcomes of
a
random experiment and we have
at
our disposal the whole ensemble
of
random outcomes made up from all the image pixels.
How can we perform principal component analysis?
To perform principal component analysis we must diagonalize the covariance matrix
of our data. The autocovariance function of the outputs of the assumed random
experiment is:
C(i,j)
=
E(("i(h1)
-
"io)("j(k,l)
-
"jo))
where
zi(k,
1)
is the value of pixel
(k,
1)
at
band
i,
zio
is the mean of band
i,
xj
(k,
1)
is
the value of the same pixel in band
j,
xjo
is the mean of band
j,
and the expectation
value is over all outcomes of the random experiment, i.e. over all pixels of the image:
(4.10)
b=l
k1
Since we have three bands, variables
i
and
j
take only three values to indicate
R,G
and
B
and the covariance matrix is
a
3
X
3
matrix. For data that are uncorrelated,
C
is diagonal; i.e.
C(i,j)
=
0
for
i
#
j.
To achieve this we must transform our data
using the transformation matrix
A
made up from the eigenvectors of the covariance
matrix of the untransformed data. The process is as follows:
1.
Find the mean of the distribution of points in the colour space, say point
(Ro,
Go, Bo).
2.
Subtract the mean grey level value from each corresponding band. This is
equivalent to translating the
RGB
coordinate system to be centred
at
the centre
of the pixel distribution (see axes
R'G'B'
in
Figure
4.7b).
j
take the values
R,
G
and
B).
3.
Find the autocorrelation matrix
C(i,
j)
of the initial distribution (where
i
and
4. Find the eigenvalues of
C(i,
j)
and arrange them in
decreasing
order. Form
the eigenvector matrix
A,
having the eigenvectors as rows.
138
Image Processing: The Fundamentals
5.
Transform the distribution using matrix
A.
Each triplet
X
=
K)
is
trans-
formed into
y
=
(2)
by:
y
=
Ax;
i.e.
~k
=
xi
akixi.
p3
This is
a
linear transformation. The new “colours” are linear combinations of the
intensity values of the initial colours, arranged
so
that the first principal component
contains most of the information for the image (see
Figure
4.7b).
What are the advantages
of
using principal components to express an
image?
The advantages of using principal components are:
1.
The information conveyed by each band is maximal for the number of bits used
because the bands are uncorrelated and no information contained in one band
can be predicted by the knowledge of the other bands.
2.
If
we want to use
a
monochrome version of the image, we can restrict ourselves
to the first principal component only and be sure that it has the maximum
contrast and contains the maximum possible information conveyed by
a
single
band of the image.
An example of principal component analysis is shown in
Figure
4.8. Although
at
first glance not much difference is observed between
Figures
4.8a, 4.8b, 4.8~ and
4.8d,
at a
more careful examination, we can see that the first principal component
combines the best parts of all three bands: For example, the face of the boy has more
contrast in 4.8b and 4.8~ than in 4.8a, while his right leg has more contrast with his
trousers in 4.8a and 4.8b than in 4.8~. In 4.8d we have good contrast in both these
places. Similarly, the contrast between the trousers and the ground is non-existent in
4.8a and 4.8b but it is obvious in 4.8~. Image 4.8d shows it as well.
What are the disadvantages
of
principal component analysis?
The grey values in the bands created from principal component analysis have no
physical meaning, as they do not correspond to any physical colours.
As
a
result, the
grey value of
a
pixel cannot be used for the classification of
a
pixel. This is particularly
relevant to remote sensing applications, where often pixels are classified according to
their grey values. In
a
principal component band,
pixels that represent water, for
example, may appear darker or brighter than other pixels in the image depending on
the image content, while the degree of greyness of water pixels in the various
spectral
bands
is always consistent, well understood by remote sensing scientists, and often
used to identify them.
Không có nhận xét nào:
Đăng nhận xét