As we’ve talked in the previous topics about sensors and pixels, each photo is composed of a number of pixels. Each of these pixels have a certain level of brightness, ranging from 0 (black) to 255 (white). A histogram is a graphical representation of these levels of brightness for the entire photo.
On the X-axis we have the values of brightness from 0 to 255. On the Y-axis it is represented the actual number of pixels that have a certain level of brightness. Representation is in the form of a line, longer or shorter depending on the number of pixels that brightness. There is no space between these lines, so the form above is created.
The histogram described above is for the grayscale correspondent of the original photo. In a color photograph, the color of each pixel is given by the combination of Red, Green and Blue (RGB) levels. A basic algorithm that converts a color photo into its grayscale correspondent is by summing the RGB values of each pixel and divide the result by 3. The result will be the grayscale equivalent of the pixel. There are also histograms for each Read, Green and Blue component of the photo, but these are less used.
Histograms offer valuable information regarding the exposure of an image. For example a left shifted histogram (all the values are in the first two thirds of the scale) means that the photo is underexposed. A right shifted one means that the photo is overexposed. A correct exposed photo will have an approximately even distributed histogram.