- An image histogram is a type of histogram that reflects the tonal distribution of the image. It plots the frequency (number of pixels) for each tonal value (commonly in the range of [0-255]).
- In OpenCV, we make use of the cv2.calcHist() function to calculate the histogram of images. To calculate the histogram of a grayscale image using 64 bits, the code is as follows:
hist = cv2.calcHist([gray_image], [0], None, [64], [0, 256])
- We first build the image, M, with the same shape as the grayscale image, gray_image, and we set the value, 50, for every pixel of this image. Afterwards, we add both images using cv2.add(). Finally, the histogram is computed using cv2.calcHist():
M = np.ones(gray_image.shape, dtype="uint8") * 50 added_image ...