OpenCV-从图表中提取箭头 [英] OpenCV - Extracting arrows from chart
问题描述
我正在尝试在流程图上执行OpenCV以提取结构(图1).所有图像都是计算机生成的.我可以很好地提取块,然后将其从图像中删除,以便我们只剩下箭头(图3).
I'm trying to perform OpenCV on a flow chart to extract the structure (image 1). All images are computer generated. I can extract the blocks fine, and remove them from the image so we are just left with the arrows (image 3).
问题是我不确定如何提取连接. IE.当我应用HoughLinesP时,每个箭头都会生成大量的行(图2).有谁知道一种提取线的方法,这样我提取的每个箭头只会得到一条线"?
The issue is I'm unsure how to extract the connections. I.e. when I apply HoughLinesP there is large number of lines generated for each arrow (image 2). Does anyone know a method of extracting the lines such that I only get one 'line' for each arrow extracted?
推荐答案
由于图像没有噪点,因此使用霍夫变换并不是最佳选择.
Since the image has no noise, using Hough transform is not optimal.
我将对图像进行二值化处理,以便从图像中获得所有非白色像素. 然后,使用匹配的滤波器,我将找到垂直和水平线段. 可以以类似的方式找到四个方向中的任何一个箭头.
I would binarize the image so that I get all non-white pixels from the image. Then, using a matched filter, I would find vertical and horizontal line segments. Arrows in any of the four directions can be found in a similar fashion.
过滤2像素厚的行可能是这样的:
Filter for a line of 2 pixels thickness can be something like:
0 0 0 0 0 0
0 0 0 0 0 0
1 1 1 1 1 1
1 1 1 1 1 1
0 0 0 0 0 0
0 0 0 0 0 0
这篇关于OpenCV-从图表中提取箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!