Assignment 3

 

Description: Calculating the histogram of an input image and its graphical representation.


Additional description.


  1. - Calculate and visualise the histogram of an image

  2. - Histogram represents the number of times an intensity value is present on an image

  3. - It can be calculated either for each of the three channels separately or in a integrated way for the 3 channels (RGB histogram)

  4. - RGB histogram can be calculated as follows:

  5. - Open the image

  6. - Convert it to grayscale. You can use filter() method: im.filter(GRAY), that modifies the image (im) transforming it to grayscale (1 channel). This only channel will now be accessible at the RED one: red(im.get(x, y)) returns the gray value of the pixel after the transformation carried out by filter()

  7. - Create an array histogram: int[] histogram = new int[256]

  8. - Traverse all image pixels, RED channel, increasing its counter in the histogram: histogram[red(im.get(x, y))]++. With that, we count the number of times each value is present in the image. It is also convenient to calculate the maximum value of all saved in the histogram.