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
where
is the original image,
is histogram equalization mapping operation and
is a palette. If we define a new palette as
and leave image ''
'' unchanged then histogram equalization is implemented as
palette change or mapping change. On the other hand, if palette
remains unchanged and image is modified to
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 ...
and let
be the number of occurrences of gray level
. The probability of a pixel value chosen uniformly randomly from image
being ''
'', is
:
being the total number of gray levels in the image, ''
'' being the number of pixels in the image with value ''
'', and
being the total number of pixels in the image. Then
is the image's histogram value for ''
'', 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 ''
''. For value ''
'' it is
:
,
which is also the image's accumulated normalized histogram.
We would like to create a transformation