Skip to content

Commit 36e1f62

Browse files
authored
Add files via upload
1 parent 0b43edf commit 36e1f62

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
clahe = cv2.createCLAHE(clipLimit=2, tileGridSize=(10,10))
15+
16+
#将灰度图像和局部直方图相关联, 把直方图均衡化应用到灰度图
17+
result = clahe.apply(gray)
18+
19+
#显示图像
20+
plt.subplot(221)
21+
plt.imshow(gray, cmap=plt.cm.gray), plt.axis("off"), plt.title('(a)')
22+
plt.subplot(222)
23+
plt.imshow(result, cmap=plt.cm.gray), plt.axis("off"), plt.title('(b)')
24+
plt.subplot(223)
25+
plt.hist(img.ravel(), 256), plt.title('(c)')
26+
plt.subplot(224)
27+
plt.hist(result.ravel(), 256), plt.title('(d)')
28+
plt.show()

0 commit comments

Comments
 (0)