Skip to content

Commit 0b43edf

Browse files
authored
Add files via upload
1 parent 33d5065 commit 0b43edf

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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('yxz.jpg')
9+
10+
# 彩色图像均衡化 需要分解通道 对每一个通道均衡化
11+
(b, g, r) = cv2.split(img)
12+
bH = cv2.equalizeHist(b)
13+
gH = cv2.equalizeHist(g)
14+
rH = cv2.equalizeHist(r)
15+
16+
# 合并每一个通道
17+
result = cv2.merge((bH, gH, rH))
18+
cv2.imshow("Input", img)
19+
cv2.imshow("Result", result)
20+
21+
#等待显示
22+
cv2.waitKey(0)
23+
cv2.destroyAllWindows()
24+
25+
#绘制直方图
26+
plt.figure("Hist")
27+
#蓝色分量
28+
plt.hist(bH.ravel(), bins=256, normed=1, facecolor='b', edgecolor='b')
29+
#绿色分量
30+
plt.hist(gH.ravel(), bins=256, normed=1, facecolor='g', edgecolor='g')
31+
#红色分量
32+
plt.hist(rH.ravel(), bins=256, normed=1, facecolor='r', edgecolor='r')
33+
plt.xlabel("x")
34+
plt.ylabel("y")
35+
plt.show()

0 commit comments

Comments
 (0)