CS6640 – Project 2 Assigned Sept 18, 2009 Due Oct 1 (Just before midnight)

Goals

The purpose of this assignment is to develop you understanding of image histograms and histogram equalization.

1 Histogram Equalization

1. Implement a Matlab or C++ function (you can use or build on one that already exists in the Matlab base, if you want):

histogram(I, n, min, max)

that takes a 2D array (or image) I as input and returns a 1D array of floats (length n) that give the relative frequency of the occurance of greyscale values in each of the n bins that equally divide the range of values between min and max.

2. Implement a function

histoeq(I, n, min, max)

that takes a 2D array (or image) I as input (e.g. VISImage¡float¿ in Vispack) and returns an image of the same type that has undergone histogram equalization using n bins and has a range of outputs that spans the range between min and max.

3. Use this routine to transform and enhance the following images:

(a) Crowd
(b) University
(c) People
(d) Portal

4. In addition, include in your discussion 2-3 of your own greyscale images that you think would be interesting from the point of view of this exercise. I.e. that have bad contrast characteristics and that might be improved by histogram equalization.

5. Show graphs of the histograms of the images before and after equalization and explain their appearance.

6. Discuss (briefly) why histogram equalization is or is not effective for each image.

7. Derive an algorithm that processes an image to return an image with a histogram (pdf) that has at every grey level a value that is a linear blend of the input histogram and a flat histogram. Implement a matlab function

histoeq(I, n, min, max, alpha)

where alpha is a float between 0 and 1 and every bin is (in principle) equal to αH_{eq} + (1 − α)H_{I}. Thus, for a value of alpha = 0, the output equals the input and for a value of 1 the output is the same as histoeq(I, n,). Experiment and report results on some of the images listed above. Explain the results you get.

2 Adaptive Histogram Equalization

1. Implement a function that returns the input image which has been transformed by adaptive equalized histogram equalization using square neighborhoods (allowing for boundaries). The function should be

AHE(I, n, windowsize)

You may use whichever algorithm you choose. The function should treat windowsize as an optional parameter. If windowsize is left empty (set to -1) your routine should make a reasonable choice of tile or window size based on the size of the image, etc. If you use the tiling method, then the window size parameter could be modified to fit into the image. In this case, you should make windows as square as possible. Make sure that your function is a sensibly efficient implementation (avoid obviously redundant computation) of whatever algorithm you choose.

2. For the images given in 1 above (the samples given you and the ones you bring in yourself) try adaptive histogram equalization, with different values of window size.

3. Discuss the time it takes to run and its effectiveness for each image.

4. Comment on and explain any artifacts in the results.

3 Clipped Local Adaptive Histogram Equalization

Implement a version of Clipped LAHE (CLAHE). Explain your algorithm in the report, and if you used ideas from any outside resources. The clip value should be specified as an input parameter. The function should be

CLAHE(I, n, cliplevel, windowsize)

Try your algorithm on a variety of images and compare against the unclipped version. What values of clipping are effective and why?

4 Instructions, Requirements, and Restrictions

1. Write your project code in a single directory, called project1.

2. For Matlab, each individual function (including functions you define) should be a “.m” file, and your functions should call one another as necessary. Likewise, in C++ clearly separate these different functions and document how you have organized the code.

3. Your project report will be in the form of an html file called \underline{index.html}, contained in that directory. All links from that file must be relative and all other files necessary to read your report must be in that directory (or subdirectories).

4. You should use examples of images in your report. They should be viewable in the browser when we open your html file.

5. You will submit a single tar file created from from your project directory with the unix command tar -czf project2.tgz ./project2 or something equivalent on another operating system.