【问题标题】:Best image thresholding technique that will return a high/low threshold?将返回高/低阈值的最佳图像阈值技术?
【发布时间】:2019-01-16 22:22:11
【问题描述】:

我发现很难为迷宫找到一种自适应图像阈值技术,该技术将返回一个高值或低值以确保所有路径都是相同的颜色。

到目前为止,我已经尝试了一个明显不起作用的固定阈值和 otsu 的方法,它在中间返回一个值,这意味着一些像素没有正确转换。

原图 - https://imgur.com/DqaUYfW

大津的方法——https://imgur.com/a/V5t6rqZ

期望的输出 - https://imgur.com/a/yvXuAqC

【问题讨论】:

    标签: java image-processing image-thresholding


    【解决方案1】:

    对不起,我没有java,所以我只是尝试了python中的一些方法,可以获得你想要的输出。希望对你有帮助。

    import cv2
    import numpy as np
    
    image = cv2.imread("1.png")
    
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    
    _,thresh = cv2.threshold(gray,100,255,cv2.THRESH_BINARY)
    cv2.imshow("thresh",thresh)
    
    blur = cv2.GaussianBlur(gray,(5,5),0)
    ret3,otsu = cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
    cv2.imshow("otsu",otsu)
    
    adaptive_thresh = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 29, 30)
    cv2.imshow("adaptive_thresh",adaptive_thresh)
    
    cv2.imshow("img",image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    
    • 大津法

    • 固定二进制阈值

    • 自适应阈值

    【讨论】:

      猜你喜欢
      • 2021-02-10
      • 2013-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-01
      • 1970-01-01
      • 2016-09-06
      • 2012-03-01
      相关资源
      最近更新 更多