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

基于图像处理的盲文页面凸起与凹陷检测技术问询

基于图像处理的盲文页面凸起与凹陷检测技术问询

我现在遇到了一个盲文页面凸起和凹陷检测的难题,想请教大家怎么解决。问题的核心在于光源位置会严重影响检测效果:如果光源在页面右侧,凸起会在左侧形成阴影;反之光源在左侧的话,阴影就会出现在右侧。而且光源还可能来自页面周围任意方向,这就让检测变得更棘手了。我已经尝试了几种方法,但都没达到理想效果(附相关效果参考图)。

我试过通过识别并移除朝左的轮廓来处理,但这种方法只有在光源从右侧照射时才管用。以下是我实现的代码:

import cv2
import numpy as np

def remove_left_facing_dots(image, intensity_ratio_threshold=1.2):

    blurred = cv2.GaussianBlur(image, (3, 3), 0)
    
    edges = cv2.Canny(blurred, 50, 150)

    contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)


    filtered_contours = []
    for contour in contours:
        x, y, w, h = cv2.boundingRect(contour)
        
        roi = image[y:y+h, x:x+w]
        left_half = roi[:, :w//2].sum()
        right_half = roi[:, w//2:].sum()

        if right_half > left_half * intensity_ratio_threshold:
            filtered_contours.append(contour)

    
    mask = np.zeros_like(image)
    cv2.drawContours(mask, filtered_contours, -1, 255, thickness=cv2.FILLED)

    cleaned_image = cv2.bitwise_and(image, mask)

    return cleaned_image

备注:内容来源于stack exchange,提问作者meheru

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.14 12:39:29