Histogram equalization is a method in
image processing
An image is a visual representation of something. It can be two-dimensional, three-dimensional, or somehow otherwise feed into the visual system to convey information. An image can be an artifact, such as a photograph or other two-dimensio ...
of
contrast adjustment using the
image
An image is a visual representation of something. It can be two-dimensional, three-dimensional, or somehow otherwise feed into the visual system to convey information. An image can be an artifact, such as a photograph or other two-dimensio ...
's
histogram
A histogram is an approximate representation of the frequency distribution, distribution of numerical data. The term was first introduced by Karl Pearson. To construct a histogram, the first step is to "Data binning, bin" (or "Data binning, buck ...
.
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 are used 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, or, much less commonly, X-radiation, is a penetrating form of high-energy electromagnetic radiation. Most X-rays have a wavelength ranging from 10 picometers to 10 nanometers, corresponding to frequencies in the range 30&nb ...
images, and to better detail in
photographs 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 operator. So in theory, if the histogram equalization
function is known, then the original histogram can be recovered. The calculation is not
computation
Computation is any type of arithmetic or non-arithmetic calculation that follows a well-defined model (e.g., an algorithm).
Mechanical or electronic devices (or, historically, people) that perform computations are known as ''computers''. An esp ...
ally intensive. A disadvantage of the method is that it is indiscriminate. It may increase the contrast of background
noise
Noise is unwanted sound considered unpleasant, loud or disruptive to hearing. From a physics standpoint, there is no distinction between noise and desired sound, as both are vibrations through a medium, such as air or water. The difference aris ...
, while decreasing the usable
signal.
In scientific imaging where spatial correlation is more important than intensity of signal (such as separating
DNA fragments of quantized length), the small
signal-to-noise ratio usually hampers visual detections.
Histogram equalization often produces unrealistic effects in photographs; however it is very useful for scientific images like
thermal,
satellite
A satellite or artificial satellite is an object intentionally placed into orbit in outer space. Except for passive satellites, most satellites have an electricity generation system for equipment on board, such as solar panels or radioiso ...
or
x-ray
An X-ray, or, much less commonly, X-radiation, is a penetrating form of high-energy electromagnetic radiation. Most X-rays have a wavelength ranging from 10 picometers to 10 nanometers, corresponding to frequencies in the range 30&nb ...
images, often the same class of images to which one would apply
false-color
False color (or pseudo color) refers to a group of color rendering methods used to display images in color which were recorded in the visible or non-visible parts of the electromagnetic spectrum. A false-color image is an image that depicts ...
. 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 detectio ...
) when applied to images with low
color depth
Color depth or colour depth (see spelling differences), 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 ...
. For example, if applied to 8-bit image displayed with
8-bit gray-scale palette it will further reduce
color depth
Color depth or colour depth (see spelling differences), 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 ...
(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 or colour depth (see spelling differences), 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 ...
than
palette
Palette may refer to:
* Cosmetic palette, an archaeological form
* Palette, another name for a color scheme
* Palette (painting), a wooden board used for mixing colors for a painting
** Palette knife, an implement for painting
* Palette (company) ...
size, like
continuous
Continuity or continuous may refer to:
Mathematics
* Continuity (mathematics), the opposing concept to discreteness; common examples include
** Continuous probability distribution or random variable in probability and statistics
** Continuous g ...
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
Palette may refer to:
* Cosmetic palette, an archaeological form
* Palette, another name for a color scheme
* Palette (painting), a wooden board used for mixing colors for a painting
** Palette knife, an implement for painting
* Palette (company) ...
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
Palette may refer to:
* Cosmetic palette, an archaeological form
* Palette, another name for a color scheme
* Palette (painting), a wooden board used for mixing colors for a painting
** Palette knife, an implement for painting
* Palette (company) ...
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 better 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
Adaptive histogram equalization (AHE) is a computer image processing technique used to improve contrast in images. It differs from ordinary histogram equalization in the respect that the adaptive method computes several histograms, each corres ...
, ''contrast limiting adaptive histogram equalization'' or
CLAHE
Adaptive histogram equalization (AHE) is a computer image processing technique used to improve contrast in images. It differs from ordinary histogram equalization in the respect that the adaptive method computes several histograms, each corres ...
, multipeak histogram equalization (MPHE), and multipurpose beta optimized bihistogram equalization (MBOBHE). The goal of these methods, especially MBOBHE, is to improve the contrast without producing brightness mean-shift and detail loss artifacts by modifying the HE algorithm.
A signal transform equivalent to histogram equalization also seems to happen in
biological neural networks
A neural circuit is a population of neurons interconnected by synapses to carry out a specific function when activated. Neural circuits interconnect to one another to form large scale brain networks.
Biological neural networks have inspired the ...
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
Flies are insects of the order Diptera, the name being derived from the Greek δι- ''di-'' "two", and πτερόν ''pteron'' "wing". Insects of this order use only a single pair of wings to fly, the hindwings having evolved into advanced ...
retina
The retina (from la, rete "net") is the innermost, light-sensitive layer of tissue of the eye of most vertebrates and some molluscs. The optics of the eye create a focused two-dimensional image of the visual world on the retina, which the ...
.
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
Color constancy is an example of subjective constancy and a feature of the human color perception system which ensures that the perceived color of objects remains relatively constant under varying illumination conditions. A green apple ...
)
Back projection
The back projection (or "project") 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 and let ''n
i'' be the number of occurrences of gray level ''i''. The probability of an occurrence of a pixel of level ''i'' in the image is
:
being the total number of gray levels in the image (typically 256), ''n'' being the total number of pixels in the image, and
being in fact the image's histogram for pixel value i, normalized to
,1
Let us also 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.
Eve ...
'' corresponding to ''i'' as
:
,
which is also the image's accumulated normalized histogram.
We would like to create a transformation of the form
to produce a new image , with a flat histogram. Such an image would have a linearized cumulative distribution function (CDF) across the value range, i.e.
:
for
for some constant
. The properties of the CDF allow us to perform such a transform (see
Inverse distribution function
In probability and statistics, the quantile function, associated with a probability distribution of a random variable, specifies the value of the random variable such that the probability of the variable being less than or equal to that value equ ...
); it is defined as
:
where
is in the range
.
Notice that
maps the levels into the range
,1 since we used a normalized histogram of . In order to map the values back into their original range, the following simple transformation needs to be applied on the result:
:
.
A more detailed derivation i
provided here
is a real value while
has to be an integer. An intuitive and popular method is applying the round operation:
:
.
However, detailed analysis results in slightly different formulation. The mapped value
should be 0 for the range of