chapter-5 image histogram and morphological...
TRANSCRIPT
�
�
���
�
CHAPTER-5
IMAGE HISTOGRAM AND MORPHOLOGICAL
OPERATIONS
5.1 Image Histogram
The histogram of a digital image with intensity levels in the range ��� � �
�� is a discrete function� ��� ��, where � is the ��� intensity value and �� is
the number of pixels in the image with intensity� �. It is a common practice to
normalize a histogram by dividing each of its components by total number of
pixels in the image, denoted by a matrix�� � �, where M and N are the row and
column dimension of the image. Thus a normalized histogram is given by the
following equation [36].
��� ����� ����� ���� � � � � � �
Where ��� is an estimate of the probability of the occurrence of intensity
level, � in an image. The sum of all components in a normalized histogram is
equal to 1. The above equation is called probability density function [36]. A
histogram represents the intensity level using X-coordinates going from the darkest
(on the left) to lightest (on the right). Thus, the histogram of an image with 256
levels of grey will be represented by a graph having 256 values on the X-axis and
the number of image pixels on the Y-axis.
�
�
���
�
Figure 5.1: A gray level image and its histogram
Figure 5.2: The gray-level histogram for different contrast scenes
Figure 5.2 shows the different characteristics of histogram for different
contrast scene. It is seen that in the dark image the components of the histogram
are concentrated on the low (dark) side of the intensity scale. Similarly, the
components of histogram of the lighter image are biased towards the high side of
the scale. An image with low contrast has a narrow histogram located typically
toward the middle of the intensity scale. For a monochrome image this implies a
�
�
���
�
dull, washed-out gray look. The components of histogram of the high contrast
image cover a wide range of the intensity scale. Further, that the distribution of the
pixels is not too far from uniform.
The histogram provides information about the contrast and overall intensity
distribution of an image. Histogram manipulation can be used for image
enhancement, image segmentation, and image registration and image compression.
5.2 Histogram as a tool for image enhancement
There are two primary methods of histogram manipulation for image
enhancement: Histogram Equalization and Histogram Matching.
Histogram Equalization is a technique that generates a gray map which
changes the histogram of an image and redistributing all pixels values [136]. It
allows for areas of lower local contrast to gain a higher contrast. Histogram
equalization automatically determines a transformation function seeking to
produce an output image with a uniform histogram. This method normally
increases the global contrast of images, especially when the functional data of the
image is represented by close contrast values. Through this adjustment, the
intensities can be distributed on the histogram in a better way. Histogram
equalization fulfills this by effectively spreading out the most frequent intensity
values. The probability density function of an image given by [36]
��� ��� �� ����� ����� � � � � �
Based on the probability density function, the cumulative density function
is defined as [36]
�
�
���
�
�� �!��
!"#
Histogram equalization is a scheme that maps the input image into the
entire dynamic range,��#� $%&� by using the cumulative density function as a
transform function. The transform function '� is defined as [36]
'� # ( $%& � #���
The resulting image has a well distributed histogram with better contrast.
There are two ways of implementing histogram equalization method: non-
adaptive methods, where the transform function remains constant throughout the
image; and adaptive method, where the transform function changes with a
moving window over the pixels.
The second method is the generalization of histogram equalization
technique. Histogram equalization does not allow interactive image enhancement
and generates only one result: an approximation to a uniform histogram. The
method used to generate a processed image that has a specified histogram is called
histogram matching or histogram specification. The procedure can be summarized
as following:
(a) Obtain the histogram of the given image
(b) Apply histogram equalization for the original image.
(c) For the specified histogram, calculate the transform to equalize it. Map the
original histogram to specified histogram by following mapping function:
�
�
���
�
))((z 1 rtG −=
Where G-1 is an inverse function.
There are many literatures available suggesting various types of histogram
equalization and matching techniques [136]-[142].
5.3 Histogram based Image Features
Several features of an image can be computed from its histogram. The
image histogram supplies many insights on the character of the image. For
example, a narrowly distributed histogram indicates a low-contrast image. The
following measures have been formulated as quantitative shape descriptions of a
first-order histogram [143]. Some of the typical features are described below:
Mean: The mean value of a set of numbers is simply the average of all of
those values. For a monochrome image, the mean value of the average image is
approximately the middle gray, because the “correct” exposure is assumed to be
one where the dark values balance the bright values, on an average scale. Mean of
an image is defined as [143]
) ����$%&
�"#
Central Moment: An image moment is a certain particular weighted
average of the image pixels intensities, or a function of such moments, normally
chosen to have some interesting property or interpretation. Image moment is useful
to describe objects after segmentation. Simple properties of the image which are
�
�
���
�
found via image moments include area, its centroid, and information about its
orientation. Dividing a moment by the 0th order moment, central moment is
obtained. Central moment of an image is defined as [143]
*+� � �)����$%&
�"#���
Entropy: The image entropy specifies the uncertainty in the image values.
It measures the averaged amount of information required to encode the image
values. It is a statistical measure of randomness that can be used to characterize the
texture of the input image. An image that is perfectly flat will have an entropy of
zero. Consequently, they can be compressed to a relatively small size. On the other
hand, high entropy images cannot be compressed as much as low entropy images.
It is defined as [143]
, � ���-�./����$%&
�"#
Energy: In Signal Processing, "energy" corresponds to the mean squared
value of the signal. This concept is usually associated with the notion that allows to
think of the total frequency as distributed along "frequencies" and so one can say,
for example, that an image has most of its energy concentrated in low frequencies.
Energy of an image defined as [143]
0 �����/$%&
�"#
�
�
��
�
5.4 Histogram based Image Segmentation
Histogram-based image segmentation is one of the simplest and most
oftenly used segmentation techniques. It uses the histogram to select the gray
levels for grouping pixels into regions. In a simple image there are two entities: the
background and the object. The background is generally one gray level and
occupies most of the image. Therefore, its gray level is a large peak in the
histogram. The object or subject of the image is another gray level, and its gray
level is another, smaller peak in the histogram [144].
The basic principle of histogram based segmentation is depicted by the
Figures 5.3 below. Figure 5.3 shows an image, its histogram and the segmented
image. The tall peak at gray level 2 indicates the primary gray level for the
background of the image. The secondary peak in the histogram at gray level 8
indicates the primary gray level for the object in the image. The segmented image
consists of pixels of value 8 only, others blanked out. The object is a happy face
emoticon.
�
�
���
�
Figure 5.3: Illustration of histogram segmentation
The largest peak represents the background and the next largest peak
represents the object. We choose a threshold point in the valley between the two
peaks and threshold the image. Thresholding takes any pixel whose value is on the
object side of the point and sets it to one; setting all others to zero. The histogram
peaks and the valleys between them are the keys.
The idea of histogram-based segmentation is simple, but there can be
problems in the determination of threshold point. If the point mid-way between the
two peaks (threshold point = 5), is chosen it produces the image of Figure 5.4. This
is not the happy face object desired. Choosing the valley floor values of 4 or 5 as
�
�
��
�
the threshold point also produces a poor result. The best threshold point would be
7, but this could be known only by trial and error. This example is comparatively
easy because there are only ten gray levels and the object (happy face) is small.
Figure 5.4: Erroneous segmentation due to wrong threshold
One simple way is to preprocess the image histogram. Histogram
equalization or histogram matching can be used for this purpose. There are three
primary methods for using histogram as a tool for image segmentation. A
technique, which is rarely used, is manual the method of histogram thresholding. In
the manual technique the user inspects an image and its histogram manually. Trial
and error come into play and the result is as good as the user wants it to be Manual
segmentation is good for fine tuning and understanding the operation. Its trial-and-
error nature, however, makes it time consuming and impractical for many
applications [145]. The three methods are discussed below.
�
�
��
�
5.4.1 Histogram Peak Technique
This technique finds the two peaks in the histogram corresponding to the
background and object of the image. It sets the threshold halfway between the two
peaks. When the histograms are searched for peaks, peak spacing should be used to
ensure the highest peaks are separated. Another item to watch carefully is to
determine which peak corresponds to the background and which corresponds to the
object [145].
5.4.2 Histogram Valley Technique
The second automatic technique uses the peaks of the histogram, but
concentrates on the valley between them. Instead of setting the mid-point
arbitrarily half way between the two peaks, the valley technique searches between
the two peaks to find the lowest valley [145].
5.4.3 Adaptive Histogram Technique
The final technique uses the peaks of the histogram in first pass and adapts
itself to the objects found in the image in a second pass. In the first pass, the
adaptive technique calculates the histogram for the entire image. It smoothen the
histogram and uses the peak technique to find the high and low threshold values. In
the second pass, the technique segments an image using the high and low values
found during the first pass. Then, it calculates the mean value for all the pixels
segmented into background and object. It uses these means as new peaks and
calculates new high and low threshold values. Now, it segments that area again
using the new values [145].
�
�
��
�
5.5 Mathematical Morphology of Image
Mathematical morphology is a well-founded theory of image processing
[146], [147]. Its geometry oriented nature provides an efficient framework for
analyzing object shape characteristics such as size and connectivity, which are not
easily accessed by linear approaches. Morphological operations take into
consideration the geometrical shape of the image objects to be analyzed. The initial
form of mathematical morphology is applied to binary images and usually referred
to as standard mathematical morphology in the literature in order to be
discriminated by its later extensions such as the gray-scale and the soft
mathematical morphology.
Mathematical morphology is theoretically based on set theory. It provides a
wide range of operations to image processing, based on a few simple mathematical
theories. The operators are particularly useful for the analysis of boundary
detection, binary images, image enhancement, noise removal, and image
segmentation. The advantages of morphological operations over linear operations
are straight-forward geometric interpretation, efficiency and simplicity in hardware
implementation. This direct geometric description of set theory makes
morphological approach more suitable for image processing. Mathematical
morphology regards an image as a set and uses another smaller set which is called
as structuring element to probe image. Morphological operations on an image are
defined with regard to a structuring element.
The structuring element consists of a pattern specified as the coordinates of
a number of discrete points relative to some origin. Normally, Cartesian
�
�
��
coordinates are used and so a convenient way of representing the element is as a
small image on a rectangular grid. The origin is marked by a ring around that point.
Figure 5.5: Some structuring elements
Figure 5.5 shows a number of different structuring elements of various
sizes. In each case the origin is marked by a ring around that point. The origin does
not have to be in the center of the structuring element, but often it is. As suggested
by the figure, structuring elements that fit into a 3×3 grid with its origin at the
center are the most commonly seen type. Morphological operations are based on
basic set theoretic operations. Two set operations translation and reflection of set
are defined before discussing the morphological operations.
5.5.1 Set Operations
Now some definitions of simple set operations are given. The translation
of the set A by the point 1 is defined, in set notation, as:
{ }Aa,acc)A( x ∈−==
For example, if x were at (1, 2) then the first (upper left) pixel in (A)x would
be (3,3) + (1,2) = (4,5); all of the pixels in A shift down by one row and right by
�
�
��
�
two columns in this case. This is a translation in the same sense that it seen in
computer graphics, a change in position by specified amount. The reflection of a
set A is defined as:
{ }Aa,acA ∈−==�
Now, the morphological operations are described below.
5.5.2 Dilation
Dilation adds pixels to the object boundary of an image. Let A be a set of
pixels and let B be a structuring element. Dilation is defined as [148]
{ }Bb,Aa,baccBA ∈∈+==⊕
Dilation operation is illustrated by the following example. Let A be the set
of Figure 4.5(a), and let B be the set of {(0, 0) (0, 1)}. The pixels in the set C = A +
B is computed using the last equation which can be rewritten in this case as:
( ) ( )(0,1)A(0,0)A +∪+=⊕ BA
There are four pixels in the set A, and since any pixel translated by (0, 0)
does not change, those four will also be in the resulting set C after computing
C = A + {(0, 1)}:
(3,3) + (0,0) = (3,3) (3,4) + (0,0) = (3,4)
(4,3) + (0,0) = (4,3) (4,4) + (0,0) = (4,3)
The result of A + {(0, 1)} is
(3,3) + (0,1) = (3,4) (3,4) + (0,1) = (3,5)
�
�
��
�
(4,3) + (0,1) = (4,4) (4,4) + (0,1) = (4,5)
The set C is the result of the dilation of A using structuring B, and consists
of all of the pixels above (some of which are duplicates). Figure 5.6 illustrates this
operation, showing graphically the effect of the dilation. The pixels marked with
an "X," either white or black, represent the origin of each image. The location of
the origin is important. In this example, if the origin of B were the rightmost of the
two pixels the effect of the dilation would be to add pixels to the left of A, rather
than to the right. The set B in this case would be {(0, −1) (0,0)}
Figure 5.6: Dilation of set A of by set B; (a) Set A (b) the set obtained by adding
(0, 0) to all elements of A; (c) The set obtained by adding (0, 1) to all elements of
A; (d) The union of the two sets is the result of the dilation
5.5.3 Erosion
If dilation can be said to add pixels to an object, or to make it bigger, then
erosion will make an image smaller. In the simplest case, binary erosion will
remove the outer layer of pixels from an object. It is defined as [148]
�
�
��
�
( ){ }ABcBA c ⊆=Θ
Figure 5.7: Erosion of A by structuring element B
5.5.4 Opening and Closing
The application of erosion immediately followed by a dilation using the
same structuring element is defined as an opening operation. The name opening is
a descriptive one, describing the observation that the operation tends to "open"
small gaps or spaces between touching objects in an image. This effect is most
easily observed when using the simple structuring element. Figure 5.8 shows
image having a collection of small objects, some of them touching each other.
After an opening using simple the objects are better isolated, and might now
counted or classified [148]
Figure 5.8: Opening: (a) Image with many connected objects, (b) Objects isolated
by opening using simple structuring element, (c) Image with noise (d) The noisy
image after opening.
�
When a noisy gray
above the threshold value,
erosion step in an opening will remove isolated pixels as well as boundaries of
objects, and the dilation step will restore most of the boundary pixels without
restoring the noise.
A closing is similar to an op
followed by an erosion using the same structuring element. If an opening creates
small gaps in the image, a closing will fill them, or "close" the gaps.
(a) (b) (c)
Figure: 5.9 (a) Original image
Closing can also be used for smoothing the outline of objects in an image.
Sometimes digitization followed by thresholding can give a jagged appearance to
boundaries; in other cases the objects are naturally rough, and it may be necessary
to determine how rough the outline is. In either case, closing can be used.
However, more than one structuring element may be needed, since the simple
structuring element is only useful for removing or smoothing single pixel
irregularities.
��
When a noisy gray-level image is threshold, some of the noise
above the threshold value, and results in isolated pixels in random locations. The
erosion step in an opening will remove isolated pixels as well as boundaries of
objects, and the dilation step will restore most of the boundary pixels without
A closing is similar to an opening except that the dilation is performed first,
followed by an erosion using the same structuring element. If an opening creates
small gaps in the image, a closing will fill them, or "close" the gaps.
(a) (b) (c)
Original image (b) Opening operation (c) Closing operation
Closing can also be used for smoothing the outline of objects in an image.
Sometimes digitization followed by thresholding can give a jagged appearance to
boundaries; in other cases the objects are naturally rough, and it may be necessary
rough the outline is. In either case, closing can be used.
However, more than one structuring element may be needed, since the simple
structuring element is only useful for removing or smoothing single pixel
�
pixels are
in isolated pixels in random locations. The
erosion step in an opening will remove isolated pixels as well as boundaries of
objects, and the dilation step will restore most of the boundary pixels without
ening except that the dilation is performed first,
followed by an erosion using the same structuring element. If an opening creates
Closing operation
Closing can also be used for smoothing the outline of objects in an image.
Sometimes digitization followed by thresholding can give a jagged appearance to
boundaries; in other cases the objects are naturally rough, and it may be necessary
rough the outline is. In either case, closing can be used.
However, more than one structuring element may be needed, since the simple
structuring element is only useful for removing or smoothing single pixel
�
�
�
�
5.5.5 Filling
For grayscale images, filling operation brings the intensity values of dark
areas that are surrounded by lighter areas up to the same intensity level as
surrounding pixels. Figure 5.10 depicts the filling operation.
Figure 5.10: Pixels of blue dotted area are changed to match the background
pixels.
5.5.6 Hit or Miss Transform
Hit-or-miss Transform is a powerful tool to detect shapes. It is defined as
the set of matches of structuring element B in image A [148]
234 25 4&�62754/�
Where 4& is the shape to detect and 4/ is the set of element associated with
the corresponding background. The hit-and-miss transform is a general binary
morphological operation that can be used to look for particular patterns of
foreground and background pixels in an image. It is actually the basic operation of
binary morphology since almost all the other binary morphological operators can
be derived from it. The structuring element used in the hit-and-miss is a slight
extension to the type that has been introduced for erosion and dilation, in that it can
�
�
��
�
contain both foreground and background pixels, rather than just foreground pixels,
i.e. both ones and zeros. The hit-and-miss operation is performed in much the same
way as other morphological operators, by translating the origin of the structuring
element to all points in the image, and then comparing the structuring element with
the underlying image pixels. If the foreground and background pixels in the
structuring element exactly match foreground and background pixels in the image,
then the pixel underneath the origin of the structuring element is set to the
foreground color. If it doesn't match, then that pixel is set to the background.
5.6 Colour Image Morphology
The extension of mathematical morphology to colour images is not
straightforward. There are two ways representing the morphology of colour image
[149] [150]. The images in consideration are in RGB colour space.
The first approach considers all the colour components of RGB image. In
this component-wise approach, the grayscale morphological operator is applied to
each channel of the color image. The component-wise color dilation of �1� 8� ��91� 8��:1� 8��;1� 8��<�by structuring element
�1� 8� ��91� 8��:1� 8��;1� 8��< in RGB colour space is defined as [149]
�=7��1� 8� ��9=�9�1� 8��:=�:�1� 8��;=�;�1� 8��<
The sign >7 is the component-wise dilation and the sign > on the right
side is gray level dilation. Component-wise color erosion, opening, and closing can
be defined in the same way.
�
�
�
�
The second way of computing colour morphology is to consider each pixel
as a vector. Vector-based color morphology makes use of the multivariate ranking
concept. First, reduced ordering is performed. Each multivariate sample is mapped
to a scalar value based on reduced ordering function and then the samples are
ordered according to the mapped scalar value. Given the reduced ordering function
? and the set�,, the value of vector color dilation of � by , at the point 1� 8� is
defined as [149]
�=@��1� 8� A����=@�?B��'BC�DB�'��?E-A'E���
F�BB�A G H�� C�I � C� G ,J
A�?�?A� K ?L�� C�M�����A--�� C� G ,N�O�
Similarly, other morphological operations are also defined. Histogram
based features and morphological operations are very useful in image
segmentation. Histogram provides global information of an image as a whole.
Apart from the conventional methods described earlier, there are hosts of
segmentation method based on histogram [151], [152], [153], [154].
Morphological features provide ample opportunities for image
segmentation. The shape information of objects in an image is a very useful aid for
designing a segmentation algorithm. Various segmentation methods exist based on
morphological operations such the Watershed algorithm. Sarkar et al. [155]
proposed a method where region based segmentation is modified with
morphological operations and watershed preprocessing and post-processing to
segment images. A powerful morphological tool for image segmentation is
�
�
����
�
watershed transformation [156]. Applying watershed transformation on gradient
image could obtain an initial segmentation, but usually yields an over-segmented
result. Thus, region merging can be performed as the post-processing, and efficient
algorithms have been proposed [157].
Mathematical morphology plays an important role in microscopic medial
images. Morphological cell analysis has been integrated in new methods for
biomedical applications, such as automatic segmentation and analysis of
histological tumour sections [158]. Morphological characteristics analysis of
specific biomedical cells [159], identifying cell morphogenesis in different cell
cycle progression [160] are some examples of morphological operation based cell
image segmentation. Morphological feature quantification for grading cancerous or
precancerous cells is especially widely researched in the literature, such as nuclei
segmentation based on marker-controlled watershed transform, carcinoma feature
extraction and classification, which is important for prognosis and treatment
planning [161], nuclei feature quantification for cancer cell cycle analysis [162],
and using feature extraction including morphological analysis, wavelet analysis,
and texture analysis for automated classification of renal cell [163].