Skip to content

Commit 33d5065

Browse files
authored
Add files via upload
1 parent 2fdb6f2 commit 33d5065

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
# By:Eastmount CSDN 2021-03-12
3+
import cv2
4+
import numpy as np
5+
import matplotlib.pyplot as plt
6+
7+
#读取图片
8+
img = cv2.imread('lena.bmp')
9+
10+
#灰度转换
11+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
12+
13+
#直方图均衡化处理
14+
result = cv2.equalizeHist(gray)
15+
16+
#显示图像
17+
plt.subplot(221)
18+
plt.imshow(gray, cmap=plt.cm.gray), plt.axis("off"), plt.title('(a)')
19+
plt.subplot(222)
20+
plt.imshow(result, cmap=plt.cm.gray), plt.axis("off"), plt.title('(b)')
21+
plt.subplot(223)
22+
plt.hist(img.ravel(), 256), plt.title('(c)')
23+
plt.subplot(224)
24+
plt.hist(result.ravel(), 256), plt.title('(d)')
25+
plt.show()

0 commit comments

Comments
 (0)