Histogram equalization, there is no written formula, just look at how to count
A. Histogram equalization hand count
For example, a matrix
\ [active matrix = \ left [\ begin {matrix
} 4 & 4 & 4 & 4 & 4 & 4 & 4 & 0 \\ 4 & 5 & 5 & 5 & 5 & 5 & 4 & 0 \\ 4 & 5 & 6 & 6 & 6 & 5 & 4 & 0 \\ 4 & 5 & 6 & 7 & 6 & 5 & 4 & 0 \\ 4 & 5 & 6 & 6 & 6 & 5 & 4 & 0 \\ 4 & 5 & 5 & 5 & 5 & 5 & 4 & 0 \\ 4 & 4 & 4 & 4 & 4 & 4 & 4 & 0 \\ 4 & 4 & 4 & 4 & 4 & 4 & 4 & 0 \\ \ end {matrix} \ right] \] meaning of the questions or matrix analysis, matrix gray value range is [0,7]
now, the number of gradation values statistical calculation, probability, cumulative probability
Gradation values mapped calculated difference * = the maximum tone value of the current cumulative probability
due to the gradation value is positive, the final to rounding
grayscale value | Quantity | Probability | Cumulative probability | Gradation values mapped | ToSei |
---|---|---|---|---|---|
P(h=0) | 8 | 0.125 | 0.125 | 7*0.125=0.875 | 1 |
P(h=1) | 0 | 0 | 0.125 | 7*0.125=0.875 | 1 |
P(h=2) | 0 | 0 | 0.125 | 7*0.125=0.875 | 1 |
P(h=3) | 0 | 0 | 0.125 | 7*0.125=0.875 | 1 |
P(h=4) | 31 | 0.484375 | 0.609375 | 7*0.609375=0.4.265625 | 4 |
P(h=5) | 16 | 0.25 | 0.859375 | 7*0.859375=6.015625 | 6 |
P(h=6) | 8 | 0.125 | 0.984375 | 7*0.125=6.890625 | 7 |
P(h=7) | 1 | 0.015625 | 1 | 7*1=7 | 7 |
\[直方图均衡化后= \left[ \begin{matrix} 4&4&4&4&4&4&4&1\\ 4&6&6&6&6&6&4&1\\ 4&6&7&7&7&6&4&1\\ 4&6&7&7&7&6&4&1\\ 4&6&7&7&7&6&4&1\\ 4&6&6&6&6&6&4&1\\ 4&4&4&4&4&4&4&1\\ 4&4&4&4&4&4&4&1\\ \end{matrix} \right] \]
Two .matlab histogram equalization
method one
- histeq (mat): matrix histogram equalization
- hist (mat): histogram display matrix
imhist (mat): histogram display matrix
For hist and differences imhist not currently know, just when the custom with imhist small matrix display histogram is not successful, success can be displayed with hist
Method Two
- imadjust(img,[low_in,high_in],[low_out,high_out],gamma)
- - [low_in, high_in]: need to expand the range of the normalized value, i.e. [0,1]
- - [low_out, high_out]: to extend the range, ibid
-gamma: mapping method (coefficient)
<1 brighter;
1: darken;
= 1] Default);