opencv-python 去除图片文字
opencv-python 去除图片文字 思路: 原图增强后提取增强后图片的轮廓进行闭运算,闭运算后的图像当掩码来修复原图即可去除文字 图像增强代码链接 import numpy as np import cv2 def replaceZeroes(data): min_nonzero = min(data[np.nonzero(data)]) data[data == 0] = min_nonzero return data def SSR(src_img, size): L_blur = cv2.GaussianBlur(src_img, (size, size), 0) img = replaceZeroes(src_img) L_blur = replaceZeroes(L_blur) dst_Img = cv2.log(img / 255.0) dst_Lblur = cv2.log(L_blur / 255.0) dst_IxL = cv2.multiply(dst_Img, dst_Lblur) log_R = cv2.subtract(dst_Img, dst_IxL) dst_R = cv2.normalize(log_R, None, 0, 255, cv2.NORM_MINMAX) log_uint8 = cv2.convertScaleAbs(dst_R)