Anda di halaman 1dari 5

Histogram equalization

P. F. Lammertsma (#0305235)

Assignment Inleiding beeldverwerking

Histogram equalization
Literature Study
A histogram can represent any number of things, since its sole purpose is to graphically summarize the distribution of a single-variable set of data1 . Each specific use targets some different features of histogram graphs, and when it boils down to image analysis, histograms are the de facto standard. When viewing an image represented by a histogram, what were really doing is analyzing the number of pixels (vertically) with a certain frequency (horizontally). In essence, an equalized image is represented by an equalized histogram where the number of pixels is spread evenly over the available frequencies.
Figure 1: Well-exposed photograph

An overexposed image is defined as an image in which there are an excessive number of pixels with a high pixel frequency, while there is a shortage of low frequencies (Figure 2). The data in a histogram representing an overexposed image therefore is not spread evenly over the horizontal axis, instead skewing non-symmetrically to the absolute right edge of the graph (Figure 3) 2 . Usually, when the number of pixels with very high pixel frequencies is so high as shown in the example it means that some image Figure 2: An overexposed image data has been lost; it is then impossible to restore detail in areas where the pixel frequencies have been cropped to a maximum value. The same, of course, goes for underexposed images (Figure 4); images where the histogram is skewed non-symmetrically to the Figure 3: Histogram of Figure 2 absolute left edge of the graph (Figure 5).
1

John Chambers, William Cleveland, Beat Kleiner, and Paul Tukey, (1983), Graphical Methods for Data Analysis, Wadsworth. 2 Bob Johnson, (November 28, 2004), Your Friend, the Histogram, Earthbound Light (earthboundlight.com).

Inleiding Beeldverwerking 2006

Histogram equalization

P. F. Lammertsma (#0305235)

Figure 4: An underexposed image

Figure 5: Histogram of Figure 4

There are situations where we would want to reveal detail in an image that cannot easily be seen with the naked eye. One of the several techniques to enhance an image in such a manner is histogram equalization, which is commonly used to compare images made in entirely different circumstances. Extreme examples may include comparisons of photographs with different exposures, lighting angles and shadow casts 3 . The concept of histogram equalization is to spread otherwise cluttered frequencies more evenly over the length of the histogram. Frequencies that lie close together will dramatically be stretched out. These respective areas of the image that first had little fluctuation will appear grainy and rigid, thereby revealing otherwise unseen details. A histogram equalization algorithm will determine the ideal number of times each frequency should appear in the image and, theoretically, re-plot the histogram appropriately. However, because image data isnt stored in an analogue manner, this is usually not possible. Instead, the image data is stored digitally and limited to n bits of color depth, thus the image cannot be requantified to meet our requirement 4 . Nevertheless, by ensuring that the number of times a frequency in a certain range remains as close to the ideally equalized histogram as possible, we can work around the issue of requantification. The solution is simple and elegant. The ideal number of pixels per frequency i is the total number of pixels in the image divided by the total number of possible image frequencies N. The algorithm counts the frequencies from 0 to N and shifts as many pixel frequencies into that position as long as this number of pixels is less than or equal to a certain delimiter that increases linearly to

Ido Mildstein and Amir Fish, (June 1999), Matlab interface to video camera and Face Detection, Stanford University 4 Kenneth Spring, John Russ and Michael Davidson, Basic Properties of Digital Images, Olympus America Inc.

Inleiding Beeldverwerking 2006

Histogram equalization

P. F. Lammertsma (#0305235)

the frequency. If a pixel frequency doesnt fit, it is pushed to the right along the horizontal axis until a place is found. In the simplest scenario, histogram equalization is used on grayscale images. However, by converting a RGB image to HSV, we can equalize the Value channel without altering the Hue or Saturation. After converting the result back to RGB, a properly equalized image is produced (Figure 6 and Figure 7).

Figure 6: Histogram equalization on Figure 4

Figure 7: Histogram of Figure 6

Application Report
The included application (Figure 8), Histogram by P. F. Lammertsma, performs the cumulative histogram equalization operation described on the previous page. After starting the application, you will only see a blank screen. To display its histogram and perform operations on the histogram, you will need to load an image by pressing Open. After running an algorithm, you can view the calculations described on page 60 of Digital and Medical Image Processing, by Twan Maintz, by checking the box next to Debug info (Figure 9). Note, however, that to view the calculations the panel with debug information must already be open.

Figure 8: Histogram application, by P. F. Lammertsma

Figure 9: Histogram can display the calculation results

Inleiding Beeldverwerking 2006

Histogram equalization

P. F. Lammertsma (#0305235)

To display an equalized image, the application first determines the pixel frequencies and stores them in an array. When the user presses Cumulative Equalize, these frequencies are remapped such that they spread the histogram more evenly. Rounding errors could in some instances deliver values above 255, therefore the algorithm crops results to be equal to or above 0 and equal to or less than 255. Instead of running two loops one for building a cumulative histogram and a second for equalizing the image in accordance to it this program only runs one loop. During a loop where v = {0,,N 1}, the function g*(v) (as described on page 60 of the reader) only grabs an item from the array of the cumulative histogram c(v) for value v; it is therefore not necessary to compile c(v) beforehand as this can be done simultaneously. After execution of the algorithm, the modified image and histogram are immediately displayed on the screen (Figure 10). Note that if you have opened the panel for debug information, the histogram is not visible.

Figure 10: Histogram can cumulatively equalize histograms

Also keep in mind that you can revert to the original image at any time by pressing Reset. A second form of histogram equalization came to my attention during my literature survey: normalized histogram equalization. By calculating the normalized cumulative histogram beforehand, you can simply use it as a look-up table when performing modifications to the histogram. The Histogram application can also perform normalized equalizations, although there is hardly any difference between the normal and cumulative form visible. The application can also equalize colored images, but may display strange artifacts. Like mentioned before, instead of equalizing the RGB-channels separately, a better solution would be converting the image to HSV and equalizing the Value-channel. To equalize

Inleiding Beeldverwerking 2006

Histogram equalization

P. F. Lammertsma (#0305235)

colored images, the program gives you the alternative of simply converting the image to grayscale.

Figure 11: Histogram can equalize color images

Figure 12: Equalizing with RGB will change the color

There are several other approaches to histogram equalization, beside the discussed cumulative and normalized methods. Histogram specification allows you to specify what you want the histogram to look like, which the algorithm will use to modify the image appropriately. A much more popular but difficult to implement method is localized equalization. The algorithm performs an equalization operation per pixel. Determined by the result of this equalization on a section of x y pixels centered on that particular pixel, a new value is set.

For more detailed technical information, please refer to the application source code on the CD-ROM.

All included images are courtesy of P. F. Lammertsma.

Inleiding Beeldverwerking 2006

Anda mungkin juga menyukai