HOME

TheInfoList



OR:

Histogram equalization is a method in
image processing An image or picture is a visual representation. An image can be two-dimensional, such as a drawing, painting, or photograph, or three-dimensional, such as a carving or sculpture. Images may be displayed through other media, including a pr ...
of contrast adjustment using the image's histogram. Histogram equalization is a specific case of the more general class of histogram remapping methods. These methods seek to adjust the image to make it easier to analyze or improve visual quality (e.g., retinex).


Overview

This method usually increases the global contrast of many images, especially when the image is represented by a narrow range of intensity values. Through this adjustment, the intensities can be better distributed on the histogram utilizing the full range of intensities evenly. This allows for areas of lower local contrast to gain a higher contrast. Histogram equalization accomplishes this by effectively spreading out the highly populated intensity values, which tend to degrade image contrast. The method is useful in images with backgrounds and foregrounds that are both bright or both dark. In particular, the method can lead to better views of
bone A bone is a rigid organ that constitutes part of the skeleton in most vertebrate animals. Bones protect the various other organs of the body, produce red and white blood cells, store minerals, provide structure and support for the body, ...
structure in
x-ray An X-ray (also known in many languages as Röntgen radiation) is a form of high-energy electromagnetic radiation with a wavelength shorter than those of ultraviolet rays and longer than those of gamma rays. Roughly, X-rays have a wavelength ran ...
images and to better detail in
photograph A photograph (also known as a photo, or more generically referred to as an ''image'' or ''picture'') is an image created by light falling on a photosensitivity, photosensitive surface, usually photographic film or an electronic image sensor. Th ...
s that are either over or under-exposed. A key advantage of the method is that it is a fairly straightforward technique adaptive to the input image and an invertible operation. So, in theory, if the histogram equalization function is known, then the original histogram can be recovered. The calculation is not
computation A computation is any type of arithmetic or non-arithmetic calculation that is well-defined. Common examples of computation are mathematical equation solving and the execution of computer algorithms. Mechanical or electronic devices (or, hist ...
ally intensive. A disadvantage of the method is that it is indiscriminate. It may increase the contrast of background
noise Noise is sound, chiefly unwanted, unintentional, or harmful sound considered unpleasant, loud, or disruptive to mental or hearing faculties. From a physics standpoint, there is no distinction between noise and desired sound, as both are vibrat ...
, while decreasing the usable
signal A signal is both the process and the result of transmission of data over some media accomplished by embedding some variation. Signals are important in multiple subject fields including signal processing, information theory and biology. In ...
. In scientific imaging where spatial correlation is more important than intensity of signal (such as separating
DNA Deoxyribonucleic acid (; DNA) is a polymer composed of two polynucleotide chains that coil around each other to form a double helix. The polymer carries genetic instructions for the development, functioning, growth and reproduction of al ...
fragments of quantized length), the small
signal-to-noise ratio Signal-to-noise ratio (SNR or S/N) is a measure used in science and engineering that compares the level of a desired signal to the level of background noise. SNR is defined as the ratio of signal power to noise power, often expressed in deci ...
usually hampers visual detections. Histogram equalization often produces unrealistic effects in photographs; however it is very useful for scientific images like
thermal A thermal column (or thermal) is a rising mass of buoyant air, a convective current in the atmosphere, that transfers heat energy vertically. Thermals are created by the uneven heating of Earth's surface from solar radiation, and are an example ...
,
satellite A satellite or an artificial satellite is an object, typically a spacecraft, placed into orbit around a celestial body. They have a variety of uses, including communication relay, weather forecasting, navigation ( GPS), broadcasting, scient ...
or
x-ray An X-ray (also known in many languages as Röntgen radiation) is a form of high-energy electromagnetic radiation with a wavelength shorter than those of ultraviolet rays and longer than those of gamma rays. Roughly, X-rays have a wavelength ran ...
images, often the same class of images to which one would apply false-color. Also histogram equalization can produce undesirable effects (like visible
image gradient An image gradient is a directional change in the intensity or color in an image. The gradient of the image is one of the fundamental building blocks in image processing. For example, the Canny edge detector uses image gradient for edge detection. ...
) when applied to images with low
color depth Color depth, also known as bit depth, is either the number of bits used to indicate the color of a single pixel, or the number of bits used for each color component of a single pixel. When referring to a pixel, the concept can be defined as bit ...
. For example, if applied to 8-bit image displayed with 8-bit gray-scale palette it will further reduce
color depth Color depth, also known as bit depth, is either the number of bits used to indicate the color of a single pixel, or the number of bits used for each color component of a single pixel. When referring to a pixel, the concept can be defined as bit ...
(number of unique shades of gray) of the image. Histogram equalization will work the best when applied to images with much higher
color depth Color depth, also known as bit depth, is either the number of bits used to indicate the color of a single pixel, or the number of bits used for each color component of a single pixel. When referring to a pixel, the concept can be defined as bit ...
than palette size, like continuous data or 16-bit gray-scale images. There are two ways to think about and implement histogram equalization, either as image change or as palette change. The operation can be expressed as P(M( I )) where I is the original image, M is histogram equalization mapping operation and P is a palette. If we define a new palette as P' = P(M) and leave image ''I'' unchanged then histogram equalization is implemented as palette change or mapping change. On the other hand, if palette P remains unchanged and image is modified to I ' = M(I) then the implementation is accomplished by image change. In most cases palette change is preferred as it preserves the original data. Modifications of this method use multiple histograms, called subhistograms, to emphasize local contrast rather than overall global contrast. Examples of such methods include adaptive histogram equalization and variations including, contrast limited adaptive histogram equalization, multipeak histogram equalization, and multipurpose beta-optimized bihistogram equalization (MBOBHE). The goal of these methods, especially MBOBHE, is to modifying the algorithm to improve the contrast without producing brightness mean-shift and detail loss artifacts. A signal transform equivalent to histogram equalization also seems to happen in biological neural networks so as to maximize the output firing rate of the neuron as a function of the input statistics. This has been proved in particular in the fly
retina The retina (; or retinas) is the innermost, photosensitivity, light-sensitive layer of tissue (biology), tissue of the eye of most vertebrates and some Mollusca, molluscs. The optics of the eye create a focus (optics), focused two-dimensional ...
.


Back projection

The ''back projection'' of a histogrammed image is the re-application of the modified histogram to the original image, functioning as a look-up table for pixel brightness values. For each group of pixels taken from the same position from all input single-channel images, the function puts the histogram bin value to the destination image, where the coordinates of the bin are determined by the values of pixels in this input group. In terms of statistics, the value of each output image pixel characterizes the probability that the corresponding input pixel group belongs to the object whose histogram is used.


Implementation

Consider a discrete
grayscale image In digital photography, computer-generated imagery, and colorimetry, a greyscale (more common in Commonwealth English) or grayscale (more common in American English) image is one in which the value of each pixel is a single sample (signal), s ...
X and let n_i be the number of occurrences of gray level i. The probability of a pixel value chosen uniformly randomly from image X being ''i'', is :\ p_X(i) = \frac,\quad 0 \le i < L L being the total number of gray levels in the image, ''n_i'' being the number of pixels in the image with value ''i'', and n being the total number of pixels in the image. Then p_X(i) is the image's histogram value for ''i'', with the histogram normalized to have a total area of 1. Let us then define the ''
cumulative distribution function In probability theory and statistics, the cumulative distribution function (CDF) of a real-valued random variable X, or just distribution function of X, evaluated at x, is the probability that X will take a value less than or equal to x. Ever ...
'' of pixels in image ''X''. For value ''i'' it is :\operatorname_X(i) = \sum_^i p_X(j), which is also the image's accumulated normalized histogram. We would like to create a transformation T: ,L-1\rightarrow ,L-1/math> to produce a new image y, with a flat histogram. Such an image would have a linearized cumulative distribution function (CDF) across the value range, i.e. :\operatorname_Y(i) = (i+1) K for 0 \le i < L for some constant K. The properties of the CDF allow us to perform such a transform (see Inverse distribution function). It is defined as :\ T(i) = \operatorname_X(i) where \ i is in the range ,L-1. Notice that \ T maps the levels into the range ,1/math>, since we used a normalized histogram of X. In order to map the values back into their original range, the following simple transformation needs to be applied to each transformed image value k: :\ k^\prime = k \cdot(\max(i) - \min(i)) + \min(i)= k \cdot(L- 1) k is a real value while\ k^\prime has to be an integer. An intuitive and popular method is applying the round operation: :\ k^\prime = \operatorname (k \cdot(L- 1)). However, detailed analysis results in slightly different formulation. The mapped value k^\prime should be 0 for the range of 0. And k^\prime =1 for 1/L < k \leq 2/L, k^\prime = 2 for 2/L < k \leq 3/L, ...., and finally k^\prime =L-1 for (L-1)/L < k \leq 1. Then the quantization formula from k to k^\prime should be k^\prime=\operatorname(L \cdot k)-1 . (Note: k^\prime=-1 when k=0 , however, it does not happen just because k=0 means that there is no pixel corresponding to that value.)


On color images

The above describes histogram equalization on a grayscale image. It can also be used on color images by applying the same method separately to the red, green and blue components of the RGB color values of the image, which may however yield dramatic changes in the image's color balance since the relative distributions of the color channels change as a result of applying the algorithm. If the image is first converted to another color space, Lab, or HSL/HSV in particular, then the algorithm can be applied to the
luminance Luminance is a photometric measure of the luminous intensity per unit area of light travelling in a given direction. It describes the amount of light that passes through, is emitted from, or is reflected from a particular area, and falls wit ...
or value channel without resulting in changes to the hue and saturation of the image. There are several histogram equalization methods in 3D space which result in "whitening" where the probability of bright pixels are higher than that of dark ones. Han et al. proposed to use a new CDF defined by the ISO-luminance plane, which results in uniform gray distribution.


Examples

For consistency with
statistical Statistics (from German language, German: ', "description of a State (polity), state, a country") is the discipline that concerns the collection, organization, analysis, interpretation, and presentation of data. In applying statistics to a s ...
usage, "CDF" (i.e. Cumulative distribution function) should be replaced by "cumulative histogram", especially since the article links to
cumulative distribution function In probability theory and statistics, the cumulative distribution function (CDF) of a real-valued random variable X, or just distribution function of X, evaluated at x, is the probability that X will take a value less than or equal to x. Ever ...
which is derived by dividing values in the cumulative histogram by the overall amount of pixels. The equalized CDF is defined in terms of rank as rank/pixelcount.


Small image

The 8-bit grayscale image shown has the following values: The histogram for this image is shown in the following table. Pixel values that have a zero count are excluded for the sake of brevity. : The
cumulative distribution function In probability theory and statistics, the cumulative distribution function (CDF) of a real-valued random variable X, or just distribution function of X, evaluated at x, is the probability that X will take a value less than or equal to x. Ever ...
(CDF) is shown below. Again, pixel values that do not contribute to an increase in the function are excluded for brevity. : (Please note that h(v)=\operatorname(\operatorname(v))-1 version is not illustrated yet.) This CDF shows that the minimum value in the subimage is 52 and the maximum value is 154. The CDF of 64 for value 154 coincides with the number of pixels in the image. The CDF must be normalized to ,255/math>. The general histogram equalization formula is: : h(v) = \mathrm \left( \frac \times (L - 1) \right) where \operatorname_ is the minimum non-zero value of the cumulative distribution function (in this case 1), M \times N gives the image's number of pixels (for the example above 64, where M is width and N the height) and L is the number of grey levels used (in most cases, like this one, 256). ''Note that to scale values in the original data that are above 0 to the range 1 to'' L-1'', inclusive, the above equation would instead be:'' : h(v) = \mathrm \left( \frac \times (L - 2) \right) + 1 ''where cdf(v) > 0. Scaling from 1 to 255 preserves the non-zero-ness of the minimum value.'' The equalization formula for the example scaling data from 0 to 255, inclusive, is: : h(v) = \mathrm \left( \frac \times 255 \right) For example, the CDF of 78 is 46. (The value of 78 is used in the bottom row of the 7th column.) The normalized value becomes: : h(78) = \mathrm \left( \frac \times 255 \right) = \mathrm \left( 0.714286 \times 255 \right) = 182 Once this is done then the values of the equalized image are directly taken from the normalized CDF to yield the equalized values: Notice that the minimum value 52 is now 0 and the maximum value 154 is now 255. : :


Full-sized image


See also

*
Histogram matching In image processing, histogram matching or histogram specification is the transformation of an image so that its image histogram, histogram matches a specified histogram. The well-known histogram equalization method is a special case in which the s ...
* Adaptive histogram equalization *
Normalization (image processing) In image processing, normalization is a process that changes the range of pixel intensity values. Applications include photographs with poor contrast (vision), contrast due to glare, for example. Normalization is sometimes called contrast stretchin ...
*
Digital image processing Digital image processing is the use of a digital computer to process digital images through an algorithm. As a subcategory or field of digital signal processing, digital image processing has many advantages over analog image processing. It allo ...
*
Image segmentation In digital image processing and computer vision, image segmentation is the process of partitioning a digital image into multiple image segments, also known as image regions or image objects (Set (mathematics), sets of pixels). The goal of segmen ...


References

*Acharya and Ray, ''Image Processing: Principles and Applications'', Wiley-Interscience 2005 *Russ, ''The Image Processing Handbook: Fourth Edition'', CRC 2002
"Histogram Equalization" at Generation5
'
archive
'' {{refend Image processing