24 lines
489 B
Python
24 lines
489 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)
|
|
imgEq = cv2.equalizeHist(img)
|
|
|
|
cv2.imshow('in',img)
|
|
cv2.imshow('out',imgEq)
|
|
|
|
hist = cv2.calcHist([img], [0], None, [256], [0,256])
|
|
histEq = cv2.calcHist([imgEq], [0], None, [256], [0,256])
|
|
|
|
|
|
# show the plotting graph of an image
|
|
plt.plot(hist)
|
|
plt.plot(histEq)
|
|
plt.show()
|
|
|
|
cv2.waitKey(0)
|
|
cv2.destroyAllWindows()
|