Histogram Equalization


            Histogram equalization can be even better than a contrast stretch.  This method essentially optimizes the contrast stretch at every pixel through integrating over the number of pixels at each pixel value.  I implemented this by summing up the number of pixels of value 0, value 1, etc, and saving the values in "bins".  Then I took the cumulative sum of all pixel values less than or equal to the current bin.  Finally, I normalized these cumulative sums and reassigned them back to their original places in the matrix.  Here are the same images that were shown in the contrast stretch.  The top image is a very good subject for histogram equalization.  The peppers don't seem to be affected.  There are some changes in the face, but it doesn't really provide any new information.




            I compared my histogram equalization function to matlab's histeq.  The results were very similar looking.  So, I tried subtracting matlab's resultant image from mine.  It yielded an image with numbers in the range -3 to 9.  This seems reasonable, but I decided to do a contrast stretch on the resultant image is below.  Much of the information still seems to be here even though I took the difference of two similar images.