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-dimensiona ...
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-dimensiona ...
's
histogram.
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 Stiffness, rigid Organ (biology), organ that constitutes part of the skeleton in most vertebrate animals. Bones protect the various other organs of the body, produce red blood cell, red and white blood cells, store minerals, provid ...
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
A photograph (also known as a photo, image, or picture) is an image created by light falling on a photosensitive surface, usually photographic film or an electronic image sensor, such as a CCD or a CMOS chip. Most photographs are now created ...
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
In mathematics, the concept of an inverse element generalises the concepts of opposite () and reciprocal () of numbers.
Given an operation denoted here , and an identity element denoted , if , one says that is a left inverse of , and that is ...
operator. So in theory, if the histogram equalization
function
Function or functionality may refer to:
Computing
* Function key, a type of key on computer keyboards
* Function model, a structured representation of processes in a system
* Function object or functor or functionoid, a concept of object-oriente ...
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 es ...
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 arise ...
, while decreasing the usable
signal
In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The '' IEEE Transactions on Signal Processing' ...
.
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
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 the 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 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 radioisotope ...
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) when applied to images with low
color depth. For example, if applied to 8-bit image displayed with
8-bit gray-scale palette it will further reduce
color depth (number of unique shades of gray) of the image. Histogram equalization will work the best when applied to images with much higher
color depth than
palette 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 ...
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 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 corr ...
, ''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 corr ...
, 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 t ...
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 (biology), order Diptera, the name being derived from the Ancient Greek, Greek δι- ''di-'' "two", and πτερόν ''pteron'' "wing". Insects of this order use only a single pair of wings to fly, the hindwing ...
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 then ...
.
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
In digital photography, computer-generated imagery, and colorimetry, a grayscale image is one in which the value of each pixel is a single sample representing only an ''amount'' of light; that is, it carries only intensity information. Gray ...
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.
Ev ...
'' 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 ...
); 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