You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何进一步优化带水印文档图片去噪效果,提升OCR识别率?

文档OCR去水印及去噪优化求助

我在实现拍摄文档自动识别时遇到问题:待识别文档文字下方存在水印,导致OCR识别难度大。目前已通过CLAHE(限制对比度自适应直方图均衡化)及直方图调整的矩阵运算提升了图像质量,代码如下,现寻求进一步去噪、提升OCR识别率的方法。

已实现的图像优化代码

import cv2
import numpy as np
import math

def enhance_document_image(gray_image, hsv_image, sharpen=True):
    # 应用CLAHE增强对比度
    clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
    gray_image = clahe.apply(gray_image)
    
    # 计算亮度并调整对比度、亮度
    height, width, channels = hsv_image.shape
    histogram = cv2.calcHist([hsv_image], [2], None, [256], [0, 256])
    brightness_value = sum([idx * value[0] for idx, value in enumerate(histogram)]) / (255 * height * width)
    brightness = contrast = int(math.log(2 - brightness_value) * 100) + 30
    
    gray_image = np.int16(gray_image)
    gray_image = gray_image * (contrast / 127 + 1) - contrast + brightness
    gray_image = np.clip(gray_image, 0, 255)
    
    # 锐化处理(可选)
    if sharpen:
        gray = np.uint8(gray_image)
        sharpening_kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]])
        gray = cv2.filter2D(gray, -1, sharpening_kernel)
        return gray
    
    return np.uint8(gray_image)

图像效果对比

原始文档图像

原始文档图片

优化后文档图像

优化后文档图片

恳请各位提供进一步优化的建议或代码!

内容的提问来源于stack exchange,提问作者wr93_

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 06:24:59