9
Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet Singh Dhaliwal (2008CS50212) Kshiteej S. Mahajan (2008CS50214) Introduction In this assignment we have dealt with image enhancement of monochromatic (grey level) images using histogram processing. The goal of histogram equalization is to enhance the contrast of the image, which it accomplishes by making all intensities in the range of possible intensities equally likely. Global Histogram Equalization indiscriminately enhances the contrast of the whole image which won’t be required if our area of interest is much smaller than the entire image. Generating the Histogram The most basic part of the assignment was to be able to generate the Histogram given a greyscale image. An image histogram shows the frequency of occurrence each allowable pixel value has in the image. For this we have used integer values in the range [0,255], where 0 represents pure black and 255 represents pure white. Values in between are varying shades of grey. To generate a Histogram, we wrote a function which takes a 2D greyscale image as an input and returns a 1D array (say ‘arr’) such that arr*i+ (where i varies from 0 to 255) represents the frequency of occurrence of intensity ‘i’ in the input image. Global Histogram Equalization As mentioned above, Global Histogram Equalization enhances the contrast of the whole image without being locally biased at any single pixel. If in a histogram, if all the values are clumped on the same side then the problem with this image is that it is hard for the human visual system to distinguish these features due to the values being too tightly packed. If one could re-map these tightly packed values to use the whole range possible, it would be much easier to make out features. This is exactly what histogram equalization does by making all possible intensities equally likely.

Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

Digital Image Processing CSL 783

REPORT

Assignment 1: Image Enhancement using Histogram Processing

Jagjeet Singh Dhaliwal (2008CS50212)

Kshiteej S. Mahajan (2008CS50214)

Introduction

In this assignment we have dealt with image enhancement of monochromatic (grey level) images using histogram processing. The goal of histogram equalization is to enhance the contrast of the image, which it accomplishes by making all intensities in the range of possible intensities equally likely. Global Histogram Equalization indiscriminately enhances the contrast of the whole image which won’t be required if our area of interest is much smaller than the entire image.

Generating the Histogram

The most basic part of the assignment was to be able to generate the Histogram given a greyscale image. An image histogram shows the frequency of occurrence each allowable pixel value has in the image. For this we have used integer values in the range [0,255], where 0 represents pure black and 255 represents pure white. Values in between are varying shades of grey.

To generate a Histogram, we wrote a function which takes a 2D greyscale image as an input and returns a 1D array (say ‘arr’) such that arr*i+ (where i varies from 0 to 255) represents the frequency of occurrence of intensity ‘i’ in the input image.

Global Histogram Equalization

As mentioned above, Global Histogram Equalization enhances the contrast of the whole image without being locally biased at any single pixel. If in a histogram, if all the values are clumped on the same side then the problem with this image is that it is hard for the human visual system to distinguish these features due to the values being too tightly packed. If one could re-map these tightly packed values to use the whole range possible, it would be much easier to make out features. This is exactly what histogram equalization does by making all possible intensities equally likely.

Page 2: Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

Analysis of GHE

Global histogram equalization works best for images that have less noise and don't contain regions of relative brightness or darkness. Comparing the histograms of the input and output images it’s seen that histogram equalization spreads out the histogram to cover the entire range of intensities in such a way so as to make the cdf of the image to have a somewhat constant slope. Ideally histogram equalization should make the histogram of the image flat and the cdf perfectly linear, but since we are working with discrete samples the resulting histograms are not flat and the cdf has a stair-step appearance. Like in the above example, the original image of the car has poor contrast but is almost noiseless. Global histogram equalization should work very well for this image and that as we see it does.

Page 3: Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

The image above has a very poor contrast but due to enhancement the noise in the sky is more visible after histogram equalization. AHE should work better here as there is not enough contrast in the dome to make out the details.

Page 4: Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

In the above two examples, the results after histogram equalization are quite similar. In both cases, we have a corner in the original image that’s brighter than the rest (left bottom in the first one and top-right in the second one). Global contrast enhancement ends up making those places way brighter than the rest. AHE would work better for these cases than GHE.

Adaptive Histogram Equalization

For images, in which the areas of interest are much smaller than the entire image or which contain local regions of low contrast bright or dark regions global histogram equalization either won't be required or won’t work effectively. A modification of histogram equalization called the Adaptive Histogram Equalization can be used on such images for better results. Adaptive histogram equalization works by considering only small regions (defined by the neighborhood window size) and based on their local cdf, performs contrast enhancement of those regions using the same method as Global Histogram Equalization for each window.

Analysis

The size of the neighbourhood region in LHE constitutes a characteristic length scale: contrast at smaller scales is enhanced, while contrast at larger scales is reduced. Let’s see the variation with window size for the virtually noiseless yet low contrast image of the car.

Page 5: Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

Window size for above 5x5

Window size for above 15x15

Page 6: Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

Window size for above 40x40

Notice the artifacts on the bonnet of the car in this case. We can see that they lessen as the window size is increased. The result we are getting here is not as good as GHE but due to the fact that the since the original image is almost noiseless, GHE seems to be tailor-made for these kind of cases unlike AHE. The black border increases as the size of window increases due to effect of black in case of corner vertices.

AHE is better than GHE when it comes to bringing out the finer details of the dome. But GHE doesn’t produce a weird sky like AHE. Increasing the window size darkens the contrast of the dome and reduces the noise in the sky as well.

Page 7: Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

In the previous section I mentioned that this is the kind of image where AHE will perform better than GHE. After applying AHE the resulting image now has a uniform contrast throughout the image. The enhancement done by AHE in this case makes this image appear unreal. Increasing the window size has a positive effect for this image and the image appears to be more reasonable with larger window sizes. The same happens in case of the crowd image.

Histogram Specification v/s Luminance Remapping

Above image - Histogram Specification

Page 8: Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

Above Image – Luminance remapping

Clearly in histogram specification the histogram of the modified original image has taken the shape of the reference image’s histogram. Histogram specification is going to return undesirable results in case of a non-smooth mapping.

Colorization

Page 9: Digital Image Processing CSL 783 REPORTcs5080212/Dia1.pdf · 2012. 8. 29. · Digital Image Processing CSL 783 REPORT Assignment 1: Image Enhancement using Histogram Processing Jagjeet

Colorization using swatches

We have added the capability of choosing 3 pair of swatches corresponding to each other on source and target images.

Swatch selection in colored source image Corresponding swatch selection in target image

One can easily see the better colorization in case of swatching as we have more local control over the colors from the source image that we want in the target image.