Talk:Histogram equalization

Example added
I have created an example. But it seems a little awkwardly placed. Feel free to re-arrange it or put it in a different location in the article.--Konstable 05:56, 11 June 2006 (UTC)
 * Excellent! I love the example. Wilson Harron 21:55, 22 October 2006 (UTC)
 * Thanks!--Konst.ableTalk 22:45, 22 October 2006 (UTC)

Superscript link
Added a section on back project with a citation and footnote reference, but couldn't figure out how to get the superscript to link properly. kostmo 20:40, 18 August 2006 (UTC)

Philosophy project
Sorry, but I don't understand why is this page into philosophy's project. It seems better suited to optics, computer science or something like this, is not?--Patillotes (talk) 07:47, 31 January 2008 (UTC)

Incorrect image
Isn't the example pictogram of the histograms wrong !? Histogram equalization should transfrom an image such that it's histogram becomes (approximately) uniform, i.e. "flat" -- the shown pictogram looks more like it's just about contrast and brightness change, i.e. linear transformation. -Seb.Haase —Preceding unsigned comment added by Sebhaase (talk • contribs) 08:40, 5 September 2008 (UTC)


 * That is not the point at all. The point is is that the cumulative histogram is linear:


 * [[Image:Equalized Histogram.svg|200px]]


 * H.eq. spreads out the histogram which is a form of contrast adjustment. The more "probable" a given intensity is in the original image that intensity has more local contrast.  The maximum in the above image (~52) has the largest step to the previous and next intensity.


 * Flattening the histogram would result in global contrast change and a drastic change in the image. What transformation are you thinking of that would yield a flat histogram?  Cburnett (talk) 20:07, 5 September 2008 (UTC)


 * The histogram would be flat only if histograms were continuous functions. Since they are discrete, it's not possible to guarantee a flat histogram. But you can still make the cumulative histogram quasi-linear. 89.214.104.88 (talk) 11:38, 12 March 2009 (UTC)


 * For the cumulative histogram to be linear, each step must contribute the same number of occurrences as every other step of the same size, and the histogram must therefore be constant...unless the x-axis is non-linear or not fully populated. —Preceding unsigned comment added by 128.170.116.22 (talk) 21:48, 31 July 2009 (UTC)


 * I came to the talk page because I was going to make the same observation, but of the image:
 * [[Image:Histogrammspreizung.png|200px]]
 * Is it possible that this is the image Seb was referring to? It seems to show histogram stretching, not equalization. Actually, as the graph shows a continuous histogram, the equalized version should be a rather boring flat line. I may be missing something here, but I think that a) that image is histogram stretching, not equalization, and b) showing stretching on the equalization page may confuse people, particularly as they are related.
 * Timbo76 (talk) 00:38, 9 November 2011 (UTC)

Isn't the image of the scaled image also incorrect? If you compare the bitmap against the matrix above it, you can see the lower left corner is 146 and the pixel to the right is 206, yet in the image the left pixel is brighter (whiter) than the right. Same in the upper right corner: corner is 53, pixel to left is 174, yet the left pixel is clearly blacker. What am I missing here? — Preceding unsigned comment added by Bnehring (talk • contribs) 18:39, 19 July 2018 (UTC)

Error in formula
The formula in the example is not correct: it says "cdf(v) = round[cdf(v)..." when it should be something like "vnew(vold) = round[cdf(vold)...", as the formula gives us the new value that a certain gray level in the original image will assume in the equalized image. Gazilion (talk) 12:10, 12 March 2009 (UTC)

Histogram Matching and Histogram Hyperbolization
Maybe it makes sense to mention Histogram Matching (match histogram to a distribution of a 2nd source). Even more important is Histogram Equalization in log-log-domain (Histogram Hyperbolization). Hyperbolization is achieved by using the power function for the cdf. This leads to more "natural" results, since many quantities in nature are roughly linear in log-log domain (including light as perceived by the human visual system). -- 92.225.71.216 (talk) 09:50, 30 November 2009 (UTC)

Overview is bad
The overview is not an overview if it starts giving mathematical jargon and talks about DNA stuff. Applications of this technique shouldn't be discussed in that much detail. There are also a few grammatical mistakes in the overview. The discussion of when the equalization should be used is also simplifying it too much. The section is just bad; the main person to blame is whoever added that stuff about DNA.Owen214 (talk) 04:38, 13 June 2010 (UTC)

Invertible?
This article talks about the equalization being invertible, yet the german wikipedia (and my image processing course notes) say that is is explicitly NOT invertible. Which also makes sense to me, since this process can map multiple (infrequent) grey levels in the source image to the same grey level in the resulting image. --77.176.232.123 (talk) 21:04, 20 December 2010 (UTC)

bad formula?
The formula for histogram equalization icludes CDF values(Commulative Distribution Function) which are probabilities.

So, when the formula

$$ h(v) = \mathrm{round} \left(  \frac {cdf(v) - cdf_{min}} {(M \times N) - cdf_{min}}   \times (L - 1) \right) $$

mentions cdf, thats incorrect. I think it should read like

$$ h(v) = \mathrm{round} \left(  \frac {N_ k - N_{kmin}} {(M \times N) - N_{kmin}}   \times (L - 1) \right) $$ where Nk= the sum of all the appearances of values N1,N2...Nk —Preceding unsigned comment added by 94.67.130.221 (talk) 12:49, 5 February 2011 (UTC)

Small image
The following is the same 8x8 subimage as used in JPEG. The 8-bit greyscale image shown has the following values:

\begin{bmatrix} 52 & 55 & 61 & 66 & 70 & 61 & 64 & 73 \\ 63 & 59 & 55 & 90 & 109 & 85 & 69 & 72 \\ 62 & 59 & 68 & 113 & 144 & 104 & 66 & 73 \\ 63 & 58 & 71 & 122 & 154 & 106 & 70 & 69 \\ 67 & 61 & 68 & 104 & 126 & 88 & 68 & 70 \\ 79 & 65 & 60 & 70 & 77 & 68 & 58 & 75 \\ 85 & 71 & 64 & 59 & 55 & 61 & 65 & 83 \\ 87 & 79 & 69 & 68 & 65 & 76 & 78 & 94 \end{bmatrix} $$

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.
 * {| class="wikitable"

! Value !! Count ! Value !! Count ! Value !! Count ! Value !! Count ! Value !! Count
 * 52 || 1
 * 64 || 2
 * 72 || 1
 * 85 || 2
 * 113 || 1
 * 55 || 3
 * 65 || 3
 * 73 || 2
 * 87 || 1
 * 122 || 1
 * 58 || 2
 * 66 || 2
 * 75 || 1
 * 88 || 1
 * 126 || 1
 * 59 || 3
 * 67 || 1
 * 76 || 1
 * 90 || 1
 * 144 || 1
 * 60 || 1
 * 68 || 5
 * 77 || 1
 * 94 || 1
 * 154 || 1
 * 61 || 4
 * 69 || 3
 * 78 || 1
 * 104 || 2
 * rowspan="3" colspan="2"|
 * 62 || 1
 * 70 || 4
 * 79 || 2
 * 106 || 1
 * 63 || 2
 * 71 || 2
 * 83 || 1
 * 109 || 1
 * }
 * 79 || 2
 * 106 || 1
 * 63 || 2
 * 71 || 2
 * 83 || 1
 * 109 || 1
 * }
 * }

The cumulative distribution function (cdf) is shown below. Again, pixel values that do not contribute to an increase in the cdf are excluded for brevity.
 * {| class="wikitable"

! Value !! cdf ! Value !! cdf ! Value !! cdf ! Value !! cdf ! Value !! cdf
 * 52 || 1
 * 64 || 19
 * 72 || 40
 * 85 || 51
 * 113 || 60
 * 55 || 4
 * 65 || 22
 * 73 || 42
 * 87 || 52
 * 122 || 61
 * 58 || 6
 * 66 || 24
 * 75 || 43
 * 88 || 53
 * 126 || 62
 * 59 || 9
 * 67 || 25
 * 76 || 44
 * 90 || 54
 * 144 || 63
 * 60 || 10
 * 68 || 30
 * 77 || 45
 * 94 || 55
 * 154 || 64
 * 61 || 14
 * 69 || 33
 * 78 || 46
 * 104 || 57
 * rowspan="3" colspan="2"|
 * 62 || 15
 * 70 || 37
 * 79 || 48
 * 106 || 58
 * 63 || 17
 * 71 || 39
 * 83 || 49
 * 109 || 59
 * }
 * 79 || 48
 * 106 || 58
 * 63 || 17
 * 71 || 39
 * 83 || 49
 * 109 || 59
 * }
 * }

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 $$[0,255]$$. The general histogram equalization formula is:



h(v) = \mathrm{round} \left(  \frac {cdf(v) - cdf_{min}} {(M \times N) - cdf_{min}}   \times (L - 1) \right) $$

Where cdfmin is the minimum value of the cumulative distribution function (in this case 1), M × 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). The equalization formula for this particular example is:



h(v) = \mathrm{round} \left(  \frac {cdf(v) - 1} {63}   \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{round} \left(  \frac {46 - 1} {63}   \times 255 \right) = \mathrm{round} \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:



\begin{bmatrix} 0 & 12 &  53 &  93 & 146 &  53 &  73 & 166 \\  65 &  32 &  12 & 215 & 235 & 202 & 130 & 158 \\  57 &  32 & 117 & 239 & 251 & 227 &  93 & 166 \\  65 &  20 & 154 & 243 & 255 & 231 & 146 & 130 \\  97 &  53 & 117 & 227 & 247 & 210 & 117 & 146 \\ 190 &  85 &  36 & 146 & 178 & 117 &  20 & 170 \\ 202 & 154 &  73 &  32 &  12 &  53 &  85 & 194 \\ 206 & 190 & 130 & 117 &  85 & 174 & 182 & 219 \end{bmatrix} $$

Notice that the minimum value (52) is now 0 and the maximum value (154) is now 255.

Code the message “ANDHRA” using arithmetic coding algorithm. — Preceding unsigned comment added by 106.51.243.6 (talk) 14:25, 16 November 2013 (UTC)

Histogram-equalized 8x8 example image has errors (possibly due to JPEG loss?)
The current histogram-equalized version of the 8x8 example image has errors, or at least doesn't match the matrix generated in the example.

For example, this image should be significantly lighter at pixel position [1, 3] (Coordinates counted from 0 starting at top left corner) to match this the final histogram-equalized matrix. I think the problem is with the image, not the matrix because when I was reproducing the 8x8 example, my results matched the matrix rather than the image.

I generated my own image with the correct greyscale values, but Wikipedia isn't accepting my upload.

— Preceding unsigned comment added by Isears (talk • contribs) 14:16, 31 December 2020 (UTC)

Update: was able to upload my corrected image to commons: https://commons.wikimedia.org/wiki/File:Small_example_hist_equalized.png

Isears (talk) 14:24, 31 December 2020 (UTC)

The notations are wrong
The notation h(v) is incorectly used several times. h(v) would be the new values of the histogram for that specific pixel value, but it is used when calculating the actual new pixel value of the transformed image resulted from the process of histogram equalization. A.Roman2104 (talk) 02:20, 27 January 2023 (UTC)