


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Title: Histogram Equalization
In this lab, you will implement a function that performs histogram equalization on a grayscale image. You can assume all images are grayscale and have values from 0 to 255.
a) Write the function compute_histogram that takes a grayscale image as input and returns a length 256 vector h which is the normalized histogram of the values in the image. h should have values from 0 to 1 and its components should sum to 1.
b) Write the function plot_histogram that takes as input a histogram (as returned from compute_histogram) and plots it similar to the plots shown below. The x-axis should range from 0 to 255 and be labeled “intensity value”. The y-axis should range from 0 to the maximum value of the histogram and should be labeled “PMF” (for probability mass function).
c) Write the function histogram_transform which takes as input a histogram (as returned from compute_histogram) and returns a length 256 vector T which represents the transformation function for histogram equalization. That is, when you index into T using a pixel value from an input image (offset by 1), you get the value of the pixel in the output image. Thus T is a look-up-table for the transformation. T should be computed using equation 3.3-8 in the text.
d) Write the function equalize which takes as input a grayscale image and returns the grayscale image which is the histogram equalized version of the input. This function should:
Apply your equalize to the following two images available at the course website (on the schedule page):
For each image, turn in:
In your results section, simply discuss if you think the histogram equalized versions are improvements over the light and dark images. Also discuss whether the equalized versions look as good as the original image (that you’ve used before in your lab) and why or why not.
Histogram of equalized image
Original image: mean= 60.65, standard deviation= 46.
Equalized image: mean= 129.04, standard deviation= 72.74 (note that your results may not be exactly the same as mine)