Project Two

Wei Liu

weiliu@sci.utah.edu

All the functions are called by a main function 'portal.m' with image, and some parameters as input.

Histogram Equalization

  1. Implement histogram routine: The file for this routine is histogram.m. This is same with project one. This function take image as input and return a relative frequency of each greyscale.

  2. Histogram equalization function: the code is in histoeq.m. This function first calls histogram function to get the histogram of the image, then by adding previous frequency for each greyscale value, it get a cumulative mapping table. Then the routine have a two level loop for each pixel and assign each pixel a value according to the CDF mapping table.

  3. Test on the standard image. The following image are obtained by setting number of bin as 255 (to get maximum information, and the experiments on # of bin over 255 didn't make any difference), minimal and maximal pixel value to equalize as 0 and 255. So each pixel in the image is mapped to a new pixel intensity by looking up cumulative function of original image.

For crowd.tif image







We can see the original image has many area at low intensity, as indicated by the histogram. After the equalization the image have more contrast and looks better. The histogram doesnt looks like purely flat, because we can see in the histogram of the output image there are many gray levels unoccupied. If these high occupancy gray levels were to be averaged with their low occupancy neighbors, the histogram for the output image would be more close to uniform.

One thing is people's eyes are enhanced too much. This is probably because in original image the eyes already have hight intensity.

'University.tif' image:







We can see the histogram equalization addressed this image pretty well.







For the 'people' image, the equalization did good work by adding contrast, but also introduced some noise in some flat area, I.e. those area with not much information. Because the output image was mapped to (0~255), some noise also be highlighted.







For this 'portal' image, the equalization didnt improve the imag quality much. This is because the original image already has a nearly flat hstgoram, except for the large low intensity backgound. By equalization we only end up with adding more intensity to both foreground and background but the contrast on the forground didnt improve much. This problem may be addresed by adaptive hsitogram equalization or CLAHE.

My own test image one:







mytest2 image







We can see for mytest2 image, the background window( on the right side of the image) gets better view after equalization. But unfortunately the area on the left got too much enhancement, and also the human face looks unnatural. Despite that the overall image quality is improved.

  1. Image equalization with linear blending. The code for this part can be found at histoeq2.m, and this routine take 'alpha' as one argument. Basically change alpha from 0 to 1 results the output image change from original image to 'full equalized' image. When alpha is zero, the image remains unchanged, and when alpha as one, the output image is same as the output by histogram equalization without linear blending.









We can see the parameter alpha gives the weight that the original and new image blends. a greater alpha means the output image is more like the histogram equalized one.

Adaptive Histogram Equalization

I used tiling for this routine. The code for this part is in ahe2.m. This routine take the image, max and miv value as input and return equalized image. The window size is basically image size * 005. So for a 500x500 image size, the window size would be 25. The window size has to be odd number, so the program check it and if it's even, it will be add by one before it is used.

A cumulative function map is created for each tile. the cumuMap is a MxN cell array, with each cell is the cumulative funciton mapping table for each tile. The M and N is the row number and column number of tile, so the total number of tiles is MxN.

Then for each pixel, I look for four neighbour tiles ( and that also include the tile that this pixel belong to), and also have the four tile's cumulative funciton mapping table CDF1, CDF2, CDF3 and CDF4 (the code use a different name). Then for current pixel's intensity value x, I compute the CDF1(x), CDF2(x), CDF3(x) and CDF4(x), and interpolate them to get the final CDF output of current pixel. Bilinear interpolation is used here. This CDF output is then multiplied by (max – min) and plus the min value to get the final intensity value.

The test images result will be combined with CLAHE for convenience of comparison.

Clipped Local Adaptive Histogram Equalization

The program for this part is clahe.m. The only difference of CLAHE and AHE is when computing the histogram, some bin tends to have too many pixels in it. If that happens, I check it the number of bins exceed certain threshhold (the 'limit' argument in the code). And if that's the case, I'll put this pixel in other bins with little or no pixels. In this way the cdf will no have too steep edge so the output image will be smoothed.

Below is the test result for both AHE and CLAHE.

crowd image











For image quality it looks like CLAHE is better than AHE. And when window size is 35 the CLAHE looks best among all other CLAHE images with different window size. For the border of the image, as I didn't get time to do interpolation it looks not that good. Actually this can be done by just interpolating two or three neighbors, if on the border the tile can not have all four neighbors. The other 'dummy' nieghbor can have same value as one of the other three tiles, as a method of padding.

For window Size 18: AHE – 2.4 s. CLAHE – 6.1 s.

For window Size 9: AHE – 3.2 s. CLAHE – 9.8 s.

For windows size 36: AHE – 2.2 s. CLAHE – 5.6 s.

Window size 70: AHE – 1.8 s. CLAHE – 7.3 s.

University.tif image











window Size 4: AHE 1.37 s. CLAHE: 3.17 s.

Window Size 9: AHE: 0.97 s. CLAHE: 2.81 s.

Window size 18: AHE: 0.8 s. CLAHE: 2.5 s.

35: AHE: 0.67 s. CLAHE 2.37 s.

Basically I can see AHE and CLAHE is very sensitive to noise. This is because in a local tile, the gray level scope is often not big, but as we use a min and max value from global image, it's quite probable that the noise is highlighted. One method to address this problem is to use the local max and min value when doing histogram equalization in the local tile. And in this way, the tile with 'flat' intensity will remain flat.

For the computation cost of AHE and CLAHE, I just gave a rough cpu time on Matlab. No accurate time is given because even executing the same program 2nd time, the CPU time will change dramatically (e.g. from 2.5 s to 2 s). This is probably because of the cache of the operating system. Despite of that, we can still see CLAHE take longer time than AHE, because it need to deal with the flatting the pdf. For sure the tiling method is much faster than moving window( I.e. compute the center pixel output for each window and move to next window, which overlap with previous window in most part).

Theoretically AHE and CLAHE should be better than global histogram equalization method. But unfortunately this is not obvious in my test result, probably because some engineering issue. Further effort may be on how to enhancing the contrast while keep the noise level low.