Você está na página 1de 2

Histogram Equalization

The goal of histogram equalization is to have a “flat” histogram, or a histogram as flat as


possible. For an image with nr rows and nc columns, the ideal histogram with N bins
nr * nc
would have b = pixels in each bin. For example, if an image has 16 rows and 16
N
columns, and 8 (0-7) possible gray levels, then each histogram bin (level) should have
16 x16
b= = 32 pixels.
8
Histogram equalization requires the following rule:
The total number of pixels having a value k or less in the image will not be less that the
ideal value of kb .
Let hist be the gray-level histogram for an image. The number of pixels in hist with
value k or less is called the cumulative sum. The cumulative sum is calculated according
to the following equation:
k <i
CS [i ] = ∑ hist[k ] (1)
k =0

for all possible values of i.

Histogram Specification
Histogram specification is a technique that transforms the histogram of one image into
the histogram of another image. This transformation can be easily accomplished by
recognizing that if instead of using an equally spaced ideal histogram (as in histogram
equalization), one is specified explicitly. In this way it is possible to impose an arbitrary
histogram on any image, subject to the constraint that single bins may not be split up.
The technique can be implemented in the following steps:
1. Provide the template histogram. This can be accomplished by specifying a
particular histogram shape, or by calculating the histogram of a target image.
2. Calculate the histogram of the image to be transformed.
3. Calculate the cumulative sum of the template histogram. This is the ideal
cumulative sum (not the linear line as in histogram equalization).
4. Calculate the cumulative sum of the histogram of the image to be changed.
5. Map pixels from one bin to another according to the rules of histogram
equalization. The primary rule is that the actual cumulative sum can be no less
than the ideal (template) cumulative sum.
Histogram specification always imposes a template histogram on an image, but the
technique works best if the template histogram is already similar to the actual one. For
example, in situations where a large number of images of the same kind are being
processed, it may be advantageous to make the histograms the same. In this way, the
same set of image operations would have the same results. This is almost always the case
when processing images from modern medical devices such as CT, MR, PET, or multi-
dimensional ultrasound.

Você também pode gostar