It quantifies the number of pixels for each intensity value considered. What is Histogram Equalization? To make it clearer, from the image above, you can see that the pixels seem clustered around the middle of the available range of intensities. What Histogram Equalization does is to stretch out this range. Take a look at the figure below: The green circles indicate the underpopulated intensities.
|Published (Last):||19 August 2016|
|PDF File Size:||15.36 Mb|
|ePub File Size:||1.57 Mb|
|Price:||Free* [*Free Regsitration Required]|
For eg, brighter image will have all pixels confined to high values. But a good image will have pixels from all regions of the image. So you need to stretch this histogram to either ends as given in below image, from wikipedia and that is what Histogram Equalization does in simple words. This normally improves the contrast of the image. I would recommend you to read the wikipedia page on Histogram Equalization for more details about it. It has a very good explanation with worked out examples, so that you would understand almost everything after reading that.
Instead, here we will see its Numpy implementation. After that, we will see OpenCV function. We need the full spectrum. For that, we need a transformation function which maps the input pixels in brighter region to output pixels in full region. That is what histogram equalization does. Now we find the minimum histogram value excluding 0 and apply the histogram equalization equation as given in wiki page.
But I have used here, the masked array concept array from Numpy. For masked array, all operations are performed on non-masked elements. You can read more about it from Numpy docs on masked arrays. So we just apply the transform. This is useful in many cases. For example, in face recognition, before training the face data, the images of faces are histogram equalized to make them all with same lighting conditions.
Its input is just grayscale image and output is our histogram equalized image. Histogram equalization is good when histogram of the image is confined to a particular region. In many cases, it is not a good idea. For example, below image shows an input image and its result after global histogram equalization. It is true that the background contrast has improved after histogram equalization. But compare the face of statue in both images. We lost most of the information there due to over-brightness.
It is because its histogram is not confined to a particular region as we saw in previous cases Try to plot histogram of input image, you will get more intuition. So to solve this problem, adaptive histogram equalization is used.
Then each of these blocks are histogram equalized as usual. So in a small area, histogram would confine to a small region unless there is noise. If noise is there, it will be amplified. To avoid this, contrast limiting is applied. If any histogram bin is above the specified contrast limit by default 40 in OpenCV , those pixels are clipped and distributed uniformly to other bins before applying histogram equalization.
After equalization, to remove artifacts in tile borders, bilinear interpolation is applied.
More Histogram Equalization The process of adjusting intensity values can be done automatically using histogram equalization. Histogram equalization involves transforming the intensity values so that the histogram of the output image approximately matches a specified histogram. By default, the histogram equalization function, histeq , tries to match a flat histogram with 64 bins, but you can specify a different histogram instead. Notice how this curve reflects the histograms in the previous figure, with the input values mostly between 0.
In simple terms, it represents the number of pixels for each intensity value considered. In the above figure, X-axis represents the tonal scale black at the left and white at the right , and Y-axis represents the number of pixels in an image. Here, the histogram shows the number of pixels for each brightness level from black to white , and when there are more pixels, the peak at the certain brightness level is higher. Histogram Equalization Histogram Equalization is a computer image processing technique used to improve contrast in images. It accomplishes this by effectively spreading out the most frequent intensity values, i. This method usually increases the global contrast of images when its usable data is represented by close contrast values.
Select a Web Site
Overview[ edit ] This method usually increases the global contrast of many images, especially when the usable data of the image is represented by close contrast values. Through this adjustment, the intensities can be better distributed on the histogram. This allows for areas of lower local contrast to gain a higher contrast. Histogram equalization accomplishes this by effectively spreading out the most frequent intensity values. The method is useful in images with backgrounds and foregrounds that are both bright or both dark. In particular, the method can lead to better views of bone structure in x-ray images, and to better detail in photographs that are over or under-exposed.