Image Histogram

Photogrammetry-1

Talha Hanif Butt
1 min readJul 9, 2023

I am taking the Photogrammetry-1 course by Prof. Cyrill Stachniss which is available here:

I have recently worked on Image Histogram as an assignment. Today, I will be talking about the same.

A histogram is basically a graph with intensity values on x-axis while the number of pixels having that intensity value on y-axis.

It can also be defined as an array having indexes equal to the number of unique intensity values in an image while having the number of pixels having that intensity value as the value at that index.

The following function returns a histogram given an input image.

def histogram(image):

"""The function takes as input an image [np.array] and returns its histogram [np.array]"""

histogram = np.zeros((256,1))

for i in range(256):

histogram[i] = len(image[image == i])

return histogram

My work on the course is available in this repository:

That’s it for now. See you later.

--

--