<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Histogram_equalization</id>
	<title>Histogram equalization - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Histogram_equalization"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Histogram_equalization&amp;action=history"/>
	<updated>2026-05-05T23:14:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Histogram_equalization&amp;diff=2601797&amp;oldid=prev</id>
		<title>imported&gt;Kvng: review: simplify link. format ref.</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Histogram_equalization&amp;diff=2601797&amp;oldid=prev"/>
		<updated>2025-06-16T15:54:32Z</updated>

		<summary type="html">&lt;p&gt;review: simplify link. format ref.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Method in image processing of contrast adjustment using the image&amp;#039;s histogram}}&lt;br /&gt;
{{Lead too short|date=November 2023}}&lt;br /&gt;
{{Use American English|date=March 2021}}&lt;br /&gt;
{{Use mdy dates|date=March 2021}}&lt;br /&gt;
[[Image:Histogrammeinebnung.png|thumb|right|300px|alt=A histogram which is zero apart from a central area containing strong peaks is transformed by stretching the peaked area to fill the entire x-axis.|Histograms of an image before and after equalization.]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Histogram equalization&amp;#039;&amp;#039;&amp;#039; is a method in [[image processing]] of [[contrast (vision)|contrast]] adjustment using the [[Image histogram|image&amp;#039;s histogram]]. &lt;br /&gt;
&lt;br /&gt;
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]]).&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
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 [[luminous intensity|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.&lt;br /&gt;
&lt;br /&gt;
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]] structure in [[x-ray]] images and to better detail in [[photograph]]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 (mathematics)|function]] is known, then the original histogram can be recovered. The calculation is not [[computation]]ally intensive. A disadvantage of the method is that it is indiscriminate. It may increase the contrast of background [[signal noise|noise]], 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.&lt;br /&gt;
&lt;br /&gt;
Histogram equalization often produces unrealistic effects in photographs; however it is very useful for scientific images like [[Thermography|thermal]], [[satellite]] or [[x-ray]] 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]]) when applied to images with low [[color depth]]. For example, if applied to 8-bit image displayed with [[List of 8-bit computer hardware palettes|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 (computing)|palette]] size, like [[Continuous function|continuous]] data or 16-bit gray-scale images.&lt;br /&gt;
&lt;br /&gt;
There are two ways to think about and implement histogram equalization, either as image change or as [[Palette (computing)|palette]] change. The operation can be expressed as &amp;lt;math&amp;gt;P(M( I ))&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;I&amp;lt;/math&amp;gt; is the original image, &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is histogram equalization mapping operation and &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; is a palette.  If we define a new palette as &amp;lt;math&amp;gt;P&amp;#039; = P(M)&amp;lt;/math&amp;gt; and leave image &amp;#039;&amp;#039;&amp;lt;math&amp;gt;I&amp;lt;/math&amp;gt;&amp;#039;&amp;#039; unchanged then histogram equalization is implemented as [[Palette (computing)|palette]] change or mapping change. On the other hand, if palette &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; remains unchanged and image is modified to &amp;lt;math&amp;gt;I &amp;#039; = M(I)&amp;lt;/math&amp;gt; then the implementation is accomplished by image change. In most cases palette change is preferred as it preserves the original data.&lt;br /&gt;
&lt;br /&gt;
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.&amp;lt;ref&amp;gt;{{cite journal|last1=Hum|first1=Yan Chai|last2=Lai|first2=Khin Wee|last3=Mohamad Salim|first3=Maheza Irna|title=Multiobjectives bihistogram equalization for image contrast enhancement|journal=Complexity|date=11 October 2014|volume=20|issue=2|pages=22–36|doi=10.1002/cplx.21499|bibcode=2014Cmplx..20b..22H}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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]].&amp;lt;ref&amp;gt;{{cite journal|last=Laughlin|first=S.B|year=1981|title=A simple coding procedure enhances a neuron&amp;#039;s information capacity|journal=Z. Naturforsch.|volume=9–10(36):910–2}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Back projection===&lt;br /&gt;
The &amp;#039;&amp;#039;back projection&amp;#039;&amp;#039; 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.&lt;br /&gt;
&lt;br /&gt;
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.&amp;lt;ref&amp;gt;{{cite manual|year=2001|title=Open Source Computer Vision Library Reference Manual|url=http://www.cs.unc.edu/~stc/FAQs/OpenCV/OpenCVReferenceManual.pdf|archive-url=https://web.archive.org/web/20150409155114/http://www.cs.unc.edu/~stc/FAQs/OpenCV/OpenCVReferenceManual.pdf|url-status=dead|archive-date=April 9, 2015|author=Intel Corporation|access-date=2015-01-11}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Consider a discrete [[grayscale image]] &amp;lt;math&amp;gt;X&amp;lt;/math&amp;gt; and let &amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt; be the number of occurrences of gray level &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;. The probability of a pixel value chosen uniformly randomly from image &amp;lt;math&amp;gt;X&amp;lt;/math&amp;gt; being &amp;#039;&amp;#039;&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;&amp;#039;&amp;#039;, is &lt;br /&gt;
:&amp;lt;math&amp;gt;\ p_X(i) = \frac{n_i}{n},\quad 0 \le i &amp;lt; L &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; being the total number of gray levels in the image, &amp;#039;&amp;#039;&amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt;&amp;#039;&amp;#039; being the number of pixels in the image with value &amp;#039;&amp;#039;&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;&amp;#039;&amp;#039;, and &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; being the total number of pixels in the image. Then &amp;lt;math&amp;gt;p_X(i)&amp;lt;/math&amp;gt; is the image&amp;#039;s histogram value for &amp;#039;&amp;#039;&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;&amp;#039;&amp;#039;, with the histogram normalized to have a total area of 1.&lt;br /&gt;
&lt;br /&gt;
Let us then define the &amp;#039;&amp;#039;[[cumulative distribution function]]&amp;#039;&amp;#039; of pixels in image &amp;#039;&amp;#039;&amp;lt;math&amp;gt;X&amp;lt;/math&amp;gt;&amp;#039;&amp;#039;. For value &amp;#039;&amp;#039;&amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;&amp;#039;&amp;#039; it is&lt;br /&gt;
:&amp;lt;math&amp;gt;\operatorname{cdf}_X(i) = \sum_{j=0}^i p_X(j)&amp;lt;/math&amp;gt;,&lt;br /&gt;
which is also the image&amp;#039;s accumulated normalized histogram.&lt;br /&gt;
&lt;br /&gt;
We would like to create a transformation &amp;lt;math&amp;gt;T:[0,L-1] \rightarrow [0,L-1]&amp;lt;/math&amp;gt; to produce a new image &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt;, with a flat histogram. Such an image would have a linearized cumulative distribution function (CDF) across the value range, i.e.&lt;br /&gt;
:&amp;lt;math&amp;gt;\operatorname{cdf}_Y(i) = (i+1) K&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt; 0 \le i &amp;lt; L &amp;lt;/math&amp;gt;&lt;br /&gt;
for some constant &amp;lt;math&amp;gt;K&amp;lt;/math&amp;gt;. The properties of the CDF allow us to perform such a transform (see [[Cumulative distribution function#Inverse distribution function (quantile function)|Inverse distribution function]]). It is defined as&lt;br /&gt;
:&amp;lt;math&amp;gt;\ T(i) = \operatorname{cdf}_X(i)&amp;lt;/math&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;\ i &amp;lt;/math&amp;gt; is in the range &amp;lt;math&amp;gt; [0,L-1] &amp;lt;/math&amp;gt;. Notice that &amp;lt;math&amp;gt;\ T &amp;lt;/math&amp;gt; maps the levels into the range &amp;lt;math&amp;gt;[0,1]&amp;lt;/math&amp;gt;, since we used a normalized histogram of &amp;lt;math&amp;gt;X&amp;lt;/math&amp;gt;. In order to map the values back into their original range, the following simple transformation needs to be applied to each transformed image value &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;:&lt;br /&gt;
:&amp;lt;math&amp;gt;\ k^\prime = k \cdot(\max(i) - \min(i)) + \min(i)= k \cdot(L- 1)&amp;lt;/math&amp;gt;&amp;lt;ref&amp;gt;{{web archive |url=https://web.archive.org/web/20200601000000*/https://www.math.uci.edu/icamp/courses/math77c/demos/hist_eq.pdf |title=University of California, Irvine Math 77C - Histogram Equalization}}&amp;lt;/ref&amp;gt;&amp;lt;!--[[User:Kvng/RTH]]--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;k &amp;lt;/math&amp;gt; is a real value while&amp;lt;math&amp;gt;\ k^\prime &amp;lt;/math&amp;gt; has to be an integer. An intuitive and popular method&amp;lt;ref&amp;gt;{{Cite book|last=Gonzalez|first=Rafael C.|url=https://www.worldcat.org/oclc/991765590|title=Digital image processing|date=2018|publisher=Pearson|others=Richard E. Woods|isbn=978-1-292-22304-9|edition=4th|location=New York, NY|pages=138–140|oclc=991765590}}&amp;lt;/ref&amp;gt; is applying the round operation:&lt;br /&gt;
:&amp;lt;math&amp;gt;\ k^\prime = \operatorname{round} (k \cdot(L- 1))&amp;lt;/math&amp;gt;.&lt;br /&gt;
However, detailed analysis results in slightly different formulation. The mapped value &amp;lt;math&amp;gt;k^\prime &amp;lt;/math&amp;gt; should be 0 for the range of &amp;lt;math&amp;gt;0&amp;lt;k \leq1/L&amp;lt;/math&amp;gt;. And &amp;lt;math&amp;gt;k^\prime =1&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;1/L &amp;lt; k \leq 2/L&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;k^\prime = 2 &amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;2/L &amp;lt; k \leq 3/L&amp;lt;/math&amp;gt;, ...., and finally &amp;lt;math&amp;gt;k^\prime =L-1&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;(L-1)/L &amp;lt; k \leq 1&amp;lt;/math&amp;gt;. Then the quantization formula from &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;k^\prime &amp;lt;/math&amp;gt; should be&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;k^\prime=\operatorname{ceil}(L \cdot k)-1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
(Note: &amp;lt;math&amp;gt;k^\prime=-1 &amp;lt;/math&amp;gt; when &amp;lt;math&amp;gt;k=0 &amp;lt;/math&amp;gt;, however, it does not happen just because &amp;lt;math&amp;gt;k=0 &amp;lt;/math&amp;gt; means that there is no pixel corresponding to that value.)&lt;br /&gt;
&lt;br /&gt;
== On color images ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;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 color space|Lab]], or [[HSL and HSV|HSL/HSV]] in particular, then the algorithm can be applied to the [[luminance]] or value channel without resulting in changes to the hue and saturation of the image.&amp;lt;ref&amp;gt;S. Naik and C. Murthy, &amp;quot;[https://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=1257395 Hue-preserving color image enhancement without gamut problem],&amp;quot; IEEE Trans. Image Processing, vol. 12, no. 12, pp. 1591–1598, Dec. 2003&amp;lt;/ref&amp;gt; There are several histogram equalization methods in 3D space&amp;lt;ref&amp;gt;P. E. Trahanias and A. N. Venetsanopoulos, &amp;quot;[https://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=202045 Color image enhancement through 3-D histogram equalization],&amp;quot; in Proc. 15th IAPR Int. Conf. Pattern Recognition, vol. 1, pp. 545–548, Aug.-Sep. 1992.&amp;lt;/ref&amp;gt; which result in &amp;quot;whitening&amp;quot; where the probability of bright pixels are higher than that of dark ones.&amp;lt;ref&amp;gt;N. Bassiou and C. Kotropoulos, &amp;quot;[http://www.sciencedirect.com/science/article/pii/S1077314206002141 Color image histogram equalization by absolute discounting back-off],&amp;quot; Computer Vision and Image Understanding, vol. 107, no. 1-2, pp.108-122, Jul.-Aug. 2007&amp;lt;/ref&amp;gt; Han et al. proposed to use a new CDF defined by the ISO-luminance plane, which results in uniform gray distribution.&amp;lt;ref&amp;gt;{{Cite journal|doi = 10.1109/TIP.2010.2068555|title = A Novel 3-D Color Histogram Equalization Method with Uniform 1-D Gray Scale Histogram|year = 2011|last1 = Han|first1 = Ji-Hee|last2 = Yang|first2 = Sejung|last3 = Lee|first3 = Byung-Uk|journal = IEEE Transactions on Image Processing|volume = 20|issue = 2|pages = 506–512|pmid = 20801744| bibcode=2011ITIP...20..506H |s2cid = 17972519}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
For consistency with [[statistical]] usage, &amp;quot;CDF&amp;quot; (i.e. Cumulative distribution function) should be replaced by &amp;quot;cumulative histogram&amp;quot;, especially since the article links to [[cumulative distribution function]] which is derived by dividing values in the cumulative histogram by the overall amount of pixels. The equalized CDF is defined in terms of [[ranking|rank]] as &amp;lt;math&amp;gt;rank/pixelcount&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Small image===&lt;br /&gt;
[[File:JPEG example subimage.svg|thumb|256px|The 8×8 sub-image shown in 8-bit grayscale]]&lt;br /&gt;
The 8-bit grayscale image shown has the following values:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! style=&amp;quot;background-color:#343434; color:#ffffff;&amp;quot; | 52&lt;br /&gt;
! style=&amp;quot;background-color:#373737; color:#ffffff;&amp;quot; | 55&lt;br /&gt;
! style=&amp;quot;background-color:#3d3d3d; color:#ffffff;&amp;quot; | 61&lt;br /&gt;
! style=&amp;quot;background-color:#3b3b3b; color:#ffffff;&amp;quot; | 59&lt;br /&gt;
! style=&amp;quot;background-color:#464646; color:#ffffff;&amp;quot; | 79&lt;br /&gt;
! style=&amp;quot;background-color:#3d3d3d; color:#ffffff;&amp;quot; | 61&lt;br /&gt;
! style=&amp;quot;background-color:#4c4c4c; color:#ffffff;&amp;quot; | 76&lt;br /&gt;
! style=&amp;quot;background-color:#3d3d3d; color:#ffffff;&amp;quot; | 61&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color:#3e3e3e; color:#ffffff;&amp;quot; | 62&lt;br /&gt;
| style=&amp;quot;background-color:#3b3b3b; color:#ffffff;&amp;quot; | 59&lt;br /&gt;
| style=&amp;quot;background-color:#373737; color:#ffffff;&amp;quot; | 55&lt;br /&gt;
| style=&amp;quot;background-color:#686868; color:#ffffff;&amp;quot; | 104&lt;br /&gt;
| style=&amp;quot;background-color:#5e5e5e; color:#ffffff;&amp;quot; | 94&lt;br /&gt;
| style=&amp;quot;background-color:#555555; color:#ffffff;&amp;quot; | 85&lt;br /&gt;
| style=&amp;quot;background-color:#3b3b3b; color:#ffffff;&amp;quot; | 59&lt;br /&gt;
| style=&amp;quot;background-color:#474747; color:#ffffff;&amp;quot; | 71&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color:#3f3f3f; color:#ffffff;&amp;quot; | 63&lt;br /&gt;
| style=&amp;quot;background-color:#414141; color:#ffffff;&amp;quot; | 65&lt;br /&gt;
| style=&amp;quot;background-color:#424242; color:#ffffff;&amp;quot; | 66&lt;br /&gt;
| style=&amp;quot;background-color:#717171; color:#ffffff;&amp;quot; | 113&lt;br /&gt;
| style=&amp;quot;background-color:#909090; color:#000000;&amp;quot; | 144&lt;br /&gt;
| style=&amp;quot;background-color:#686868; color:#ffffff;&amp;quot; | 104&lt;br /&gt;
| style=&amp;quot;background-color:#3f3f3f; color:#ffffff;&amp;quot; | 63&lt;br /&gt;
| style=&amp;quot;background-color:#484848; color:#ffffff;&amp;quot; | 72&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color:#404040; color:#ffffff;&amp;quot; | 64&lt;br /&gt;
| style=&amp;quot;background-color:#464646; color:#ffffff;&amp;quot; | 70&lt;br /&gt;
| style=&amp;quot;background-color:#464646; color:#ffffff;&amp;quot; | 70&lt;br /&gt;
| style=&amp;quot;background-color:#7e7e7e; color:#ffffff;&amp;quot; | 126&lt;br /&gt;
| style=&amp;quot;background-color:#9a9a9a; color:#000000;&amp;quot; | 154&lt;br /&gt;
| style=&amp;quot;background-color:#6d6d6d; color:#ffffff;&amp;quot; | 109&lt;br /&gt;
| style=&amp;quot;background-color:#474747; color:#ffffff;&amp;quot; | 71&lt;br /&gt;
| style=&amp;quot;background-color:#454545; color:#ffffff;&amp;quot; | 69&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color:#434343; color:#ffffff;&amp;quot; | 67&lt;br /&gt;
| style=&amp;quot;background-color:#494949; color:#ffffff;&amp;quot; | 73&lt;br /&gt;
| style=&amp;quot;background-color:#444444; color:#ffffff;&amp;quot; | 68&lt;br /&gt;
| style=&amp;quot;background-color:#6a6a6a; color:#ffffff;&amp;quot; | 106&lt;br /&gt;
| style=&amp;quot;background-color:#7a7a7a; color:#ffffff;&amp;quot; | 122&lt;br /&gt;
| style=&amp;quot;background-color:#585858; color:#ffffff;&amp;quot; | 88&lt;br /&gt;
| style=&amp;quot;background-color:#444444; color:#ffffff;&amp;quot; | 68&lt;br /&gt;
| style=&amp;quot;background-color:#444444; color:#ffffff;&amp;quot; | 68&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color:#444444; color:#ffffff;&amp;quot; | 68&lt;br /&gt;
| style=&amp;quot;background-color:#4f4f4f; color:#ffffff;&amp;quot; | 79&lt;br /&gt;
| style=&amp;quot;background-color:#3c3c3c; color:#ffffff;&amp;quot; | 60&lt;br /&gt;
| style=&amp;quot;background-color:#464646; color:#ffffff;&amp;quot; | 70&lt;br /&gt;
| style=&amp;quot;background-color:#4d4d4d; color:#ffffff;&amp;quot; | 77&lt;br /&gt;
| style=&amp;quot;background-color:#424242; color:#ffffff;&amp;quot; | 66&lt;br /&gt;
| style=&amp;quot;background-color:#3a3a3a; color:#ffffff;&amp;quot; | 58&lt;br /&gt;
| style=&amp;quot;background-color:#4b4b4b; color:#ffffff;&amp;quot; | 75&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color:#454545; color:#ffffff;&amp;quot; | 69&lt;br /&gt;
| style=&amp;quot;background-color:#555555; color:#ffffff;&amp;quot; | 85&lt;br /&gt;
| style=&amp;quot;background-color:#404040; color:#ffffff;&amp;quot; | 64&lt;br /&gt;
| style=&amp;quot;background-color:#3a3a3a; color:#ffffff;&amp;quot; | 58&lt;br /&gt;
| style=&amp;quot;background-color:#373737; color:#ffffff;&amp;quot; | 55&lt;br /&gt;
| style=&amp;quot;background-color:#3d3d3d; color:#ffffff;&amp;quot; | 61&lt;br /&gt;
| style=&amp;quot;background-color:#414141; color:#ffffff;&amp;quot; | 65&lt;br /&gt;
| style=&amp;quot;background-color:#535353; color:#ffffff;&amp;quot; | 83&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;background-color:#464646; color:#ffffff;&amp;quot; | 70&lt;br /&gt;
| style=&amp;quot;background-color:#575757; color:#ffffff;&amp;quot; | 87&lt;br /&gt;
| style=&amp;quot;background-color:#454545; color:#ffffff;&amp;quot; | 69&lt;br /&gt;
| style=&amp;quot;background-color:#444444; color:#ffffff;&amp;quot; | 68&lt;br /&gt;
| style=&amp;quot;background-color:#414141; color:#ffffff;&amp;quot; | 65&lt;br /&gt;
| style=&amp;quot;background-color:#494949; color:#ffffff;&amp;quot; | 73&lt;br /&gt;
| style=&amp;quot;background-color:#4e4e4e; color:#ffffff;&amp;quot; | 78&lt;br /&gt;
| style=&amp;quot;background-color:#5a5a5a; color:#ffffff;&amp;quot; | 90&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value !! Count&lt;br /&gt;
! Value !! Count&lt;br /&gt;
! Value !! Count&lt;br /&gt;
! Value !! Count&lt;br /&gt;
! Value !! Count&lt;br /&gt;
|-&lt;br /&gt;
|  52 || 1&lt;br /&gt;
|  64 || 2&lt;br /&gt;
|  72 || 1&lt;br /&gt;
|  85 || 2&lt;br /&gt;
| 113 || 1&lt;br /&gt;
|-&lt;br /&gt;
|  55 || 3&lt;br /&gt;
|  65 || 3&lt;br /&gt;
|  73 || 2&lt;br /&gt;
|  87 || 1&lt;br /&gt;
| 122 || 1&lt;br /&gt;
|-&lt;br /&gt;
|  58 || 2&lt;br /&gt;
|  66 || 2&lt;br /&gt;
|  75 || 1&lt;br /&gt;
|  88 || 1&lt;br /&gt;
| 126 || 1&lt;br /&gt;
|-&lt;br /&gt;
|  59 || 3&lt;br /&gt;
|  67 || 1&lt;br /&gt;
|  76 || 1&lt;br /&gt;
|  90 || 1&lt;br /&gt;
| 144 || 1&lt;br /&gt;
|-&lt;br /&gt;
|  60 || 1&lt;br /&gt;
|  68 || 5&lt;br /&gt;
|  77 || 1&lt;br /&gt;
|  94 || 1&lt;br /&gt;
| 154 || 1&lt;br /&gt;
|-&lt;br /&gt;
|  61 || 4&lt;br /&gt;
|  69 || 3&lt;br /&gt;
|  78 || 1&lt;br /&gt;
| 104 || 2&lt;br /&gt;
|rowspan=&amp;quot;3&amp;quot; colspan=&amp;quot;2&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|  62 || 1&lt;br /&gt;
|  70 || 4&lt;br /&gt;
|  79 || 2&lt;br /&gt;
| 106 || 1&lt;br /&gt;
|-&lt;br /&gt;
|  63 || 2&lt;br /&gt;
|  71 || 2&lt;br /&gt;
|  83 || 1&lt;br /&gt;
| 109 || 1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The [[cumulative distribution function]] (CDF) is shown below. Again, pixel values that do not contribute to an increase in the function are excluded for brevity.&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;, Pixel Intensity !! &amp;lt;math&amp;gt;\operatorname{CDF}(v)&amp;lt;/math&amp;gt;!! &amp;lt;math&amp;gt;h(v)&amp;lt;/math&amp;gt;, equalized &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 52||1||0&lt;br /&gt;
|-&lt;br /&gt;
| 55||4||12&lt;br /&gt;
|-&lt;br /&gt;
| 58||6||20&lt;br /&gt;
|-&lt;br /&gt;
| 59||9||32&lt;br /&gt;
|-&lt;br /&gt;
| 60||10||36&lt;br /&gt;
|-&lt;br /&gt;
| 61||14||53&lt;br /&gt;
|-&lt;br /&gt;
| 62||15||57&lt;br /&gt;
|-&lt;br /&gt;
| 63||17||65&lt;br /&gt;
|-&lt;br /&gt;
| 64||19||73&lt;br /&gt;
|-&lt;br /&gt;
| 65||22||85&lt;br /&gt;
|-&lt;br /&gt;
| 66||24||93&lt;br /&gt;
|-&lt;br /&gt;
| 67||25||97&lt;br /&gt;
|-&lt;br /&gt;
| 68||30||117&lt;br /&gt;
|-&lt;br /&gt;
| 69||33||130&lt;br /&gt;
|-&lt;br /&gt;
| 70||37||146&lt;br /&gt;
|-&lt;br /&gt;
| 71||39||154&lt;br /&gt;
|-&lt;br /&gt;
| 72||40||158&lt;br /&gt;
|-&lt;br /&gt;
| 73||42||166&lt;br /&gt;
|-&lt;br /&gt;
| 75||43||170&lt;br /&gt;
|-&lt;br /&gt;
| 76||44||174&lt;br /&gt;
|-&lt;br /&gt;
| 77||45||178&lt;br /&gt;
|-&lt;br /&gt;
| 78||46||182&lt;br /&gt;
|-&lt;br /&gt;
| 79||48||190&lt;br /&gt;
|-&lt;br /&gt;
| 83||49||194&lt;br /&gt;
|-&lt;br /&gt;
| 85||51||202&lt;br /&gt;
|-&lt;br /&gt;
| 87||52||206&lt;br /&gt;
|-&lt;br /&gt;
| 88||53||210&lt;br /&gt;
|-&lt;br /&gt;
| 90||54||215&lt;br /&gt;
|-&lt;br /&gt;
| 94||55||219&lt;br /&gt;
|-&lt;br /&gt;
| 104||57||227&lt;br /&gt;
|-&lt;br /&gt;
| 106||58||231&lt;br /&gt;
|-&lt;br /&gt;
| 109||59||235&lt;br /&gt;
|-&lt;br /&gt;
| 113||60||239&lt;br /&gt;
|-&lt;br /&gt;
| 122||61||243&lt;br /&gt;
|-&lt;br /&gt;
| 126||62||247&lt;br /&gt;
|-&lt;br /&gt;
| 144||63||251&lt;br /&gt;
|-&lt;br /&gt;
| 154||64||255&lt;br /&gt;
|} (Please note that &amp;lt;math&amp;gt;h(v)=\operatorname{ceil}(\operatorname{CDF}(v))-1 &amp;lt;/math&amp;gt; version is not illustrated yet.)&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;math&amp;gt;[0,255]&amp;lt;/math&amp;gt;. The general histogram equalization formula is:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
h(v) =&lt;br /&gt;
 \mathrm{round}&lt;br /&gt;
 \left(&lt;br /&gt;
   \frac {\operatorname{CDF}(v) - \operatorname{CDF}_{\min}} {(M \times N) - \operatorname{CDF}_{\min}}&lt;br /&gt;
   \times (L - 1)&lt;br /&gt;
 \right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\operatorname{CDF}_{\min}&amp;lt;/math&amp;gt; is the minimum non-zero value of the cumulative distribution function (in this case 1), &amp;lt;math&amp;gt;M \times N&amp;lt;/math&amp;gt; gives the image&amp;#039;s number of pixels (for the example above 64, where &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is width and &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; the height) and &amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; is the number of grey levels used (in most cases, like this one, 256).&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Note that to scale values in the original data that are above 0 to the range 1 to&amp;#039;&amp;#039; &amp;lt;math&amp;gt;L-1&amp;lt;/math&amp;gt;&amp;#039;&amp;#039;, inclusive, the above equation would instead be:&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
h(v) =&lt;br /&gt;
 \mathrm{round}&lt;br /&gt;
 \left(&lt;br /&gt;
   \frac {\operatorname{CDF}(v) - \operatorname{CDF}_{\min}} {(M \times N) - \operatorname{CDF}_{\min}}&lt;br /&gt;
   \times (L - 2)&lt;br /&gt;
 \right) + 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;#039;&amp;#039;where cdf(v) &amp;gt; 0. Scaling from 1 to 255 preserves the non-zero-ness of the minimum value.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
The equalization formula for the example scaling data from 0 to 255, inclusive, is:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
h(v) =&lt;br /&gt;
 \mathrm{round}&lt;br /&gt;
 \left(&lt;br /&gt;
   \frac {\operatorname{cdf}(v) - 1} {63}&lt;br /&gt;
   \times 255&lt;br /&gt;
 \right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;&lt;br /&gt;
h(78) =&lt;br /&gt;
 \mathrm{round}&lt;br /&gt;
 \left(&lt;br /&gt;
   \frac {46 - 1} {63}&lt;br /&gt;
   \times 255&lt;br /&gt;
 \right)&lt;br /&gt;
=&lt;br /&gt;
 \mathrm{round}&lt;br /&gt;
 \left(&lt;br /&gt;
   0.714286&lt;br /&gt;
   \times 255&lt;br /&gt;
 \right)&lt;br /&gt;
=&lt;br /&gt;
182&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this is done then the values of the equalized image are directly taken from the normalized CDF to yield the equalized values:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! style=&amp;quot;background-color:#000000; color:#FFFFFF;&amp;quot; | 0&lt;br /&gt;
! style=&amp;quot;background-color:#0C0C0C; color:#FFFFFF;&amp;quot; | 12&lt;br /&gt;
! style=&amp;quot;background-color:#353535; color:#FFFFFF;&amp;quot; | 53&lt;br /&gt;
! style=&amp;quot;background-color:#202020; color:#FFFFFF;&amp;quot; | 32&lt;br /&gt;
! style=&amp;quot;background-color:#929292; color:#000000;&amp;quot; | 190&lt;br /&gt;
! style=&amp;quot;background-color:#353535; color:#FFFFFF;&amp;quot; | 53&lt;br /&gt;
! style=&amp;quot;background-color:#AEAEAE; color:#000000;&amp;quot; | 174&lt;br /&gt;
! style=&amp;quot;background-color:#353535; color:#FFFFFF;&amp;quot; | 53&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background-color:#393939; color:#FFFFFF;&amp;quot; | 57&lt;br /&gt;
! style=&amp;quot;background-color:#202020; color:#FFFFFF;&amp;quot; | 32&lt;br /&gt;
! style=&amp;quot;background-color:#0C0C0C; color:#FFFFFF;&amp;quot; | 12&lt;br /&gt;
! style=&amp;quot;background-color:#E3E3E3; color:#000000;&amp;quot; | 227&lt;br /&gt;
! style=&amp;quot;background-color:#DBDBDB; color:#000000;&amp;quot; | 219&lt;br /&gt;
! style=&amp;quot;background-color:#CACACA; color:#000000;&amp;quot; | 202&lt;br /&gt;
! style=&amp;quot;background-color:#202020; color:#FFFFFF;&amp;quot; | 32&lt;br /&gt;
! style=&amp;quot;background-color:#9A9A9A; color:#000000;&amp;quot; | 154&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background-color:#414141; color:#FFFFFF;&amp;quot; | 65&lt;br /&gt;
! style=&amp;quot;background-color:#555555; color:#FFFFFF;&amp;quot; | 85&lt;br /&gt;
! style=&amp;quot;background-color:#5D5D5D; color:#FFFFFF;&amp;quot; | 93&lt;br /&gt;
! style=&amp;quot;background-color:#EFEFEF; color:#000000;&amp;quot; | 239&lt;br /&gt;
! style=&amp;quot;background-color:#FBFBFB; color:#000000;&amp;quot; | 251&lt;br /&gt;
! style=&amp;quot;background-color:#E3E3E3; color:#000000;&amp;quot; | 227&lt;br /&gt;
! style=&amp;quot;background-color:#414141; color:#FFFFFF;&amp;quot; | 65&lt;br /&gt;
! style=&amp;quot;background-color:#9E9E9E; color:#000000;&amp;quot; | 158&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background-color:#494949; color:#FFFFFF;&amp;quot; | 73&lt;br /&gt;
! style=&amp;quot;background-color:#929292; color:#000000;&amp;quot; | 146&lt;br /&gt;
! style=&amp;quot;background-color:#929292; color:#000000;&amp;quot; | 146&lt;br /&gt;
! style=&amp;quot;background-color:#F7F7F7; color:#000000;&amp;quot; | 247&lt;br /&gt;
! style=&amp;quot;background-color:#FFFFFF; color:#000000;&amp;quot; | 255&lt;br /&gt;
! style=&amp;quot;background-color:#EBEBEB; color:#000000;&amp;quot; | 235&lt;br /&gt;
! style=&amp;quot;background-color:#9A9A9A; color:#000000;&amp;quot; | 154&lt;br /&gt;
! style=&amp;quot;background-color:#828282; color:#000000;&amp;quot; | 130&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background-color:#616161; color:#FFFFFF;&amp;quot; | 97&lt;br /&gt;
! style=&amp;quot;background-color:#A6A6A6; color:#000000;&amp;quot; | 166&lt;br /&gt;
! style=&amp;quot;background-color:#757575; color:#FFFFFF;&amp;quot; | 117&lt;br /&gt;
! style=&amp;quot;background-color:#E7E7E7; color:#000000;&amp;quot; | 231&lt;br /&gt;
! style=&amp;quot;background-color:#F3F3F3; color:#000000;&amp;quot; | 243&lt;br /&gt;
! style=&amp;quot;background-color:#D2D2D2; color:#000000;&amp;quot; | 210&lt;br /&gt;
! style=&amp;quot;background-color:#757575; color:#FFFFFF;&amp;quot; | 117&lt;br /&gt;
! style=&amp;quot;background-color:#757575; color:#FFFFFF;&amp;quot; | 117&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background-color:#757575; color:#FFFFFF;&amp;quot; | 117&lt;br /&gt;
! style=&amp;quot;background-color:#BEBEBE; color:#000000;&amp;quot; | 190&lt;br /&gt;
! style=&amp;quot;background-color:#242424; color:#FFFFFF;&amp;quot; | 36&lt;br /&gt;
! style=&amp;quot;background-color:#BEBEBE; color:#000000;&amp;quot; | 146&lt;br /&gt;
! style=&amp;quot;background-color:#B2B2B2; color:#000000;&amp;quot; | 178&lt;br /&gt;
! style=&amp;quot;background-color:#5D5D5D; color:#FFFFFF;&amp;quot; | 93&lt;br /&gt;
! style=&amp;quot;background-color:#141414; color:#FFFFFF;&amp;quot; | 20&lt;br /&gt;
! style=&amp;quot;background-color:#AAAAAA; color:#000000;&amp;quot; | 170&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background-color:#828282; color:#000000;&amp;quot; | 130&lt;br /&gt;
! style=&amp;quot;background-color:#CACACA; color:#000000;&amp;quot; | 202&lt;br /&gt;
! style=&amp;quot;background-color:#494949; color:#FFFFFF;&amp;quot; | 73&lt;br /&gt;
! style=&amp;quot;background-color:#141414; color:#FFFFFF;&amp;quot; | 20&lt;br /&gt;
! style=&amp;quot;background-color:#0C0C0C; color:#FFFFFF;&amp;quot; | 12&lt;br /&gt;
! style=&amp;quot;background-color:#353535; color:#FFFFFF;&amp;quot; | 53&lt;br /&gt;
! style=&amp;quot;background-color:#555555; color:#FFFFFF;&amp;quot; | 85&lt;br /&gt;
! style=&amp;quot;background-color:#C2C2C2; color:#000000;&amp;quot; | 194&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;background-color:#929292; color:#000000;&amp;quot; | 146&lt;br /&gt;
! style=&amp;quot;background-color:#CECECE; color:#000000;&amp;quot; | 206&lt;br /&gt;
! style=&amp;quot;background-color:#828282; color:#000000;&amp;quot; | 130&lt;br /&gt;
! style=&amp;quot;background-color:#757575; color:#FFFFFF;&amp;quot; | 117&lt;br /&gt;
! style=&amp;quot;background-color:#555555; color:#FFFFFF;&amp;quot; | 85&lt;br /&gt;
! style=&amp;quot;background-color:#A6A6A6; color:#000000;&amp;quot; | 166&lt;br /&gt;
! style=&amp;quot;background-color:#B6B6B6; color:#000000;&amp;quot; | 182&lt;br /&gt;
! style=&amp;quot;background-color:#D7D7D7; color:#000000;&amp;quot; | 215&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Notice that the minimum value 52 is now 0 and the maximum value 154 is now 255.&lt;br /&gt;
&lt;br /&gt;
:{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:JPEG example subimage.svg|200px]]&lt;br /&gt;
| [[File:JPEG example subimage - equalized.svg|200px]]&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| Original&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| Equalized&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
:{|&lt;br /&gt;
|-&lt;br /&gt;
| [[File:Plot for illustrating histogram equalization.svg|200px]]&lt;br /&gt;
| [[File:Histogram equalization.svg|200px]]&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| Histogram of Original image&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| Histogram of Equalized image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Full-sized image===&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;|align=&amp;quot;left&amp;quot;	 &lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; |	 &lt;br /&gt;
|[[File:Unequalized Hawkes Bay NZ.jpg|thumb|300px|Before Histogram Equalization|center]]&lt;br /&gt;
|[[File:Unequalized Histogram.svg|thumb|300px|Corresponding histogram (red) and cumulative histogram (black)|center]]&lt;br /&gt;
|- valign=&amp;quot;top&amp;quot; |	 &lt;br /&gt;
|[[File:Equalized Hawkes Bay NZ.jpg|thumb|300px|After Histogram Equalization|center]]&lt;br /&gt;
|[[File:Equalized Histogram.svg|thumb|300px|Corresponding histogram (red) and cumulative histogram (black)|center]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Histogram matching]]&lt;br /&gt;
* [[Adaptive histogram equalization]]&lt;br /&gt;
* [[Normalization (image processing)]]&lt;br /&gt;
* [[Digital image processing]]&lt;br /&gt;
* [[Image segmentation]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
{{refbegin}}&lt;br /&gt;
*Acharya and Ray, &amp;#039;&amp;#039;Image Processing: Principles and Applications&amp;#039;&amp;#039;, Wiley-Interscience 2005 {{ISBN|0-471-71998-6}}&lt;br /&gt;
*Russ, &amp;#039;&amp;#039;The Image Processing Handbook: Fourth Edition&amp;#039;&amp;#039;, CRC 2002 {{ISBN|0-8493-2532-3}}&lt;br /&gt;
* [http://www.generation5.org/content/2004/histogramEqualization.asp &amp;quot;Histogram Equalization&amp;quot; at Generation5] &amp;#039;&amp;#039;([https://archive.today/20160516012012/http://www.generation5.org/content/2004/histogramEqualization.asp archive])&amp;#039;&amp;#039;&lt;br /&gt;
{{refend}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Image processing]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Kvng</name></author>
	</entry>
</feed>