opencv-python 中对PPT图象进行图象文字增强
话不多说直接上代码:
import cv2
import numpy as np
img = cv2.imread('D:\picture\dabo\goal.png')
img = cv2.resize(img, None, fx=0.5, fy=0.5)
b, g, r = cv2.split(img)
bH = cv2.equalizeHist(b)
gH = cv2.equalizeHist(g)
rH = cv2.equalizeHist(r)
result = cv2.merge([bH, gH, rH])
res = np.hstack((img, result))
cv2.imshow('dbao', res)
cv2.waitKey(0)
threshold = 20
h, w = img.shape[:2]
for i in range(0, h):
for j in range(0, w):
B = result[i, j, 0]
G = result[i, j, 1]
R = result[i, j, 2]
if B > threshold and G > threshold and R > threshold:
result[i, j, 0] = 255
result[i, j, 1] = 255
result[i, j, 2] = 255
cv2.imshow('dabo', result)
cv2.waitKey(0)