[英]How to delete (noisy and short) lines?
結合使用OpenCV和Python,我試圖在圖像中找到水平和垂直線。
這是我的輸出:
vertical_lines
horizontal_lines
好吧,我試圖僅檢測長行並刪除短(嘈雜)行。
我希望我的輸出看起來像這個修改后的圖像:
Final_Horizontal_lines
如果需要,我可以為您提供代碼。
您可以通過使用輪廓來解決該問題。
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.