Assignment 3
Description: Calculating the histogram of an input image and its graphical representation.
Additional description.
- Calculate and visualise the histogram of an image
- Histogram represents the number of times an intensity value is present on an image
- It can be calculated either for each of the three channels separately or in a integrated way for the 3 channels (RGB histogram)
- RGB histogram can be calculated as follows:
- Open the image
- 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()
- Create an array histogram: int[] histogram = new int[256]
- 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.