Example of Histogram Equalization

http://en.wikipedia.org/wiki/Histogram_equalization

Examples

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.

ValueCountValueCountValueCountValueCountValueCount
5216427218521131
5536537328711221
5826627518811261
5936717619011441
6016857719411541
6146937811042 
6217047921061
6327128311091

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.

Valuecdfcdf, scaled
5210
55412
58620
59932
601036
611453
621557
631765
641973
652285
662493
672597
6830117
6933130
7037146
7139154
7240158
7342166
7543170
7644174
7745178
7846182
7948190
8349194
8551202
8752206
8853210
9054215
9455219
10457227
10658231
10959235
11360239
12261243
12662247
14463251
15464255

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 non-zero 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.

JPEG example subimage.svgJPEG example subimage - equalized.svg
OriginalEqualized

Full-sized image

An unequalized image
Corresponding histogram (red) and cumulative histogram (black)
The same image after histogram equalization
Corresponding histogram (red) and cumulative histogram (black)

Notes

Jump up^ Laughlin, S.B (1981). "A simple coding procedure enhances a neuron’s information capacity".Z. Naturforsch. 9–10(36):910–2.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值