Skip to content

Commit 02f3fc0

Browse files
authored
Create blog11-image01.py
1 parent dd5b4b5 commit 02f3fc0

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

blog11-hist/blog11-image01.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#encoding:utf-8
2+
import cv2
3+
import numpy as np
4+
import matplotlib.pyplot as plt
5+
6+
src = cv2.imread('Lena.png')
7+
8+
histb = cv2.calcHist([src], [0], None, [256], [0,255])
9+
histg = cv2.calcHist([src], [1], None, [256], [0,255])
10+
histr = cv2.calcHist([src], [2], None, [256], [0,255])
11+
12+
cv2.imshow("src", src)
13+
cv2.waitKey(0)
14+
cv2.destroyAllWindows()
15+
16+
plt.plot(histb, color='b')
17+
plt.plot(histg, color='g')
18+
plt.plot(histr, color='r')
19+
plt.show()

0 commit comments

Comments
 (0)