Skip to content
Snippets Groups Projects
Commit 99cc0134 authored by Simon Ripphausen's avatar Simon Ripphausen
Browse files

Update histequ.py

parents
Branches main
No related tags found
No related merge requests found
import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
path = "...\example1.jpeg"
img = cv.imread(path)
cv.imshow('image', img)
hist,bins = np.histogram(img.flatten(),256,[0,256])
cdf = hist.cumsum()
cdf_normalized = cdf * float(hist.max()) / cdf.max()
plt.plot(cdf_normalized, color = 'b')
plt.hist(img.flatten(),256,[0,256], color = 'r')
plt.xlim([0,256])
plt.legend(('cdf','histogram'), loc = 'upper left')
plt.show()
equ = cv.equalizeHist(img)
cv.imshow('equ.png',equ)
cv.waitKey(0)
hist,bins = np.histogram(equ.flatten(),256,[0,256])
cdf = hist.cumsum()
cdf_normalized = cdf * float(hist.max()) / cdf.max()
plt.plot(cdf_normalized, color = 'b')
plt.hist(equ.flatten(),256,[0,256], color = 'r')
plt.xlim([0,256])
plt.legend(('cdf','histogram'), loc = 'upper left')
plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment