【问题标题】:How to delete (noisy and short) lines?如何删除(嘈杂和短)行?
【发布时间】:2019-04-24 04:37:58
【问题描述】:

将 OpenCV 与 Python 结合使用,我试图在图像中找到水平线和垂直线。

这是我的输出:

垂直线

水平线

好吧,我正在尝试仅检测长线并删除短(嘈杂)线。

我希望我的输出看起来像这个修改后的图像:

Final_Horizo​​ntal_lines

如果需要,我可以为您提供我的代码。

【问题讨论】:

  • 我使用了 HoughlinesP (minLineLength) 但仍然没有 -_-
  • 是的,显示您的代码。还显示输入图像。

标签: python opencv image-processing line noise


【解决方案1】:

您可以通过使用轮廓来解决这个问题。

im2, contours, hierarchy = cv2.findContours(gray, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
for contour in contours:
    (x, y, w, h) = cv2.boundingRect(contour)
    # if h<500: # check the length of verical lines 
    if w<500: # check the length of horizontal lines
        cv2.fillConvexPoly(gray,contour,0) #fill the contour with black color

【讨论】:

    猜你喜欢
    • 2013-11-02
    • 1970-01-01
    • 1970-01-01
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 2013-04-19
    • 2022-06-17
    • 2016-05-31
    相关资源
    最近更新 更多