import cv2
import matplotlib.pyplot as plt
import numpy as np
img = cv2.imread('./image/dog.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
gray_dark = gray - 40
gray_bright = gray + 40
hist_gray = cv2.calcHist([gray],[0],None,[256], [0,255])
hist_dark = cv2.calcHist([gray_dark],[0],None,[256], [0,255])
hist_bright = cv2.calcHist([gray_bright],[0],None,[256], [0,255])
plt.plot(hist_gray)
plt.plot(hist_dark)
plt.plot(hist_bright)
plt.show()
dark_equ = cv2.equalizeHist(gray_dark)
bright_equ = cv2.equalizeHist(gray_bright)
cv2.imshow('gray_dark',np.hstack((gray_dark,dark_equ)))
cv2.imshow('gray_bright',np.hstack((gray_bright, bright_equ)))
cv2.waitKey(0)
cv2.destroyAllWindows()