Skip to content

Commit e01bc21

Browse files
authored
Create blog37-01.py
1 parent 38a0e96 commit e01bc21

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

blog37-histogram/blog37-01.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
# By:Eastmount CSDN 2021-02-05
3+
import cv2
4+
import numpy as np
5+
import matplotlib.pyplot as plt
6+
7+
#读取图像
8+
src = cv2.imread('lena.bmp')
9+
10+
#绘制直方图
11+
#plt.hist(src.ravel(), 256)
12+
plt.hist(src.ravel(), bins=256, density=1, facecolor='green', alpha=0.75)
13+
plt.xlabel("x")
14+
plt.ylabel("y")
15+
plt.show()
16+
17+
#显示原始图像
18+
cv2.imshow("src", src)
19+
cv2.waitKey(0)
20+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)