In this activity, you will create a \"luminance (grey) histogram\" for a picture # chosen by the user.
A luminance histogram is created by counting how many # pixels are there for each level of luminance and then by drawing a chart (typically # a bar chart) showing \"how popular\" each luminance value was in the image. # Please check Google Images for examples. #
There are many ways to approach this. Here\'s the suggested approach (feel free to # follow your own as long as yours is functionally the same or better): #
1. Create a list of 256 integers as follows: # histogramData=[0]*256 #
2. Go through each pixel of the image and at each pixel:
# 2.1: Calculate the luminance \"lum\" of that pixel (i.e. the average of RGB # vaues). This value would be an integer between 0-255. #
2.2: Increment the value in the list at position \"lum\" by 1.
# 3. The previous step will generate the data necessary for the histogram. You # must now create an empty image for the histogram.
It should be 256 pixels # wide as there are only 256 unique levels. The height of the histogram should # be tall enough to fit the largest value in the histogramData list.
You can # manually estimate what the height at first but later you can think about # making the height dynamic to different pictures\' histograms. #
4. Go through the histogram list and for each item, draw a line (i.e. a bar # in the bar chart) whose height corresponds to the value of the item # in the list. # The lines should start from the bottom of the image. The x coordinates of # each line will correspond to the list element\'s position.
E.g. list item at # position zero will have its line drawn at x zero in the histogram