我试图确定下图的主要部分。我希望找到突出显示的6个部分。 我尝试使用模糊/扩张/侵蚀的组合并应用findCountures(),但无法将这些主要部分作为单个单元
有人能建议最好的方法吗。我包括代码,可以产生图像以及
import cv2
import numpy as np
def createImage():
points = [
[(0, 8), (5, 8)], [(5, 8), (10, 12)], [(10, 12), (15, 26)],
[(15, 26), (20, 56)], [(20, 56), (25, 82)], [(25, 82), (30, 102)],
[(30, 102), (35, 129)], [(35, 129), (40, 100)], [(40, 100), (45, 81)],
[(45, 81), (50, 80)], [(50, 80), (55, 81)], [(55, 81), (60, 84)],
[(60, 84), (65, 104)], [(65, 104), (70, 151)], [(70, 151), (75, 151)],
[(75, 151), (80, 159)], [(80, 159), (85, 191)], [(85, 191), (90, 193)],
[(90, 193), (95, 230)], [(95, 230), (100, 230)], [(100, 230), (105, 248)],
[(105, 248), (110, 224)], [(110, 224), (115, 199)], [(115, 199), (120, 170)],
[(120, 170), (125, 130)], [(125, 130), (130, 101)], [(130, 101), (135, 69)],
[(135, 69), (140, 61)], [(140, 61), (145, 59)], [(145, 59), (150, 62)],
[(150, 62), (155, 85)], [(155, 85), (160, 104)], [(160, 104), (165, 117)],
[(165, 117), (170, 89)],[(170, 89), (175, 71)],[(175, 71), (180, 43)],[(180, 43), (185, 21)]
]
img = np.zeros([256,256],dtype=np.uint8)
for p in points:
cv2.line(img,p[0],p[1],255,1)
cv2.imwrite("sample.png",img)
return img
img =createImage()
cv2.imshow("sample",img)
cv2.waitKey(0)
一种方法是使用
FastLineDetector
如果对输入图像应用
FastLineDetector
,结果将是:让我们看看我们是如何得到结果的:
FastLineDetector
但是如果我们分析,图像上有20条线
步骤:
相关问题 更多 >
编程相关推荐