-
-
Save Praveen76/7de750d4872182239890f162d89eb30d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img=cv.imread('D:\cats.jpg') | |
cv.imshow('img','img) | |
gray=cv.cvtColor(img,cv.COLOR_BGR2GRAY) | |
cv.imshow('gray',gray) | |
#gray hist | |
gray_hist=cv.calcHist([gray],[0],None,[256],[0,256]) | |
fig,axs=plt.subplots(2) | |
axs[0].plot(gray_hist) | |
axs.flat[0].set(xlabel='Bins',ylabel='no. of pixels') | |
plt.xlim(0,256) | |
#Color Histogram | |
colors=('b','g','r') | |
for i,col in enumerate(colors): | |
hist=cv.calcHist([img],[i],None,[256],[0,256]) | |
axs[1].plot(hist,olor=color) | |
axs.flat[1].set(xlabel='Bins',ylabel='no. of pixels') | |
plt.xlim(0,256) | |
plt.show() | |
cv.waitKey(0) | |
cv.destroyAllWindows() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment