EV5_Beeldherk_Bomen/example/ex6 - histogram.py

17 lines
337 B
Python

import numpy as np
import cv2
import os
from matplotlib import pyplot as plt
# Load an color image in grayscale
img = cv2.imread(os.path.join(os.getcwd(), "./res/bwg.png"), 0)
hist = cv2.calcHist([img], [0], None, [256], [0,256])
# show the plotting graph of an image
plt.plot(hist)
plt.show()
cv2.waitKey(0)
cv2.destroyAllWindows()