二值化图像中的单独交叉口线段 [英] Separate crossings segments in binarised image

查看:180
本文介绍了二值化图像中的单独交叉口线段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行了一些图像处理,使我可以提取包含较厚片段的二进制图像,而且我面临着这些片段可能彼此交叉的问题.因此,我需要找到一种有效的方法来将它们分开,我必须在C ++中实现此方法,以便基于OpenCV的任何内容都可以提供帮助.
这是一个示例输入图像,两个斑点"都需要分成3个不同的部分.

I have some image processing that allows me to extract a binary image containing thick segments and i'm facing the issue that these segments may cross each other. Hence I need to find an efficient way to separate them, i'll have to implement this in C++ so anything OpenCV-based would help.
Here is a sample input image, both "blobs" would need to be split in 3 different segments.

到目前为止,我已经尝试了2个想法,但我都坚持使用这两个想法,这就是为什么我在这里询问是否存在针对这个看似简单的问题的最先进的"解决方案.

I have tried 2 ideas until now, I'm stuck with both of them and that's why I'm asking here if there are any "state of the art" solution to this apparently simple problem.

  1. 我的第一个想法是计算斑点的骨架,找到相交点.这部分很简单.然后,我计划从端点开始,遍历线段,直到到达一个交叉点并穿过交叉点".如果您查看底部的Blob,则即使预期会出现"T"形,骨骼也会产生怪异的"Y"形,从而无法决定如何遍历相交.

  1. My first idea was to compute the skeleton of the blobs, find intersection points. This part was easy. Then I planned to start with an end-point, traverse the segment until I reach an intersection and "cross the intersection". If you look at the bottom blob, the skeleton can produce weird "Y" shapes even when a "T" shape was expected, making it impossible to decide how to traverse an intersection.

第二个想法是计算距离变换,然后计算渐变方向,然后我仍然需要一种方法来合并方向相似的像素并处理端点/交叉点.

Second idea was to compute the distance transform, followed by the gradient direction, and then I still need a way to merge pixels with similar direction and a way to handle endpoints / intersections.

推荐答案

使用骨架是一个好主意,因为这将使处理不受笔划宽度的影响.在交汇点附近,骨骼会受到干扰,因此方向会发生局部变化.

It is a good idea to use a skeleton, as this will make the processing independent of the stroke width. Near a junction, the skeleton is perturbed so that the direction locally changes.

您可以考虑骨架并在连接点处分割(连接到两个以上独立曲线).您将构建一个图形,其中边缘是交接点之间的弧线.确保保留连接性.

You can consider a skeleton and split at the junction points (connected to more than two independent curves). You will build a graph where the edges are arcs between the junction points. Make sure to preserve connexity.

然后,您可以通过查找离结点一到两个厚度的点来估计圆弧的方向.您将对边缘进行配对,以使(绿色)点形成最佳对齐方式.您可以用贪​​婪的方式(最适合的方式)进行此操作,直到用尽所有可能的匹配项,或者直到角度被认为太大为止.

Then you can estimate the direction of an arc by finding points that are one and two thicknesses away from the junction. You will pair the edges such that the (green) points form the best alignment. You can do this in a greedy way (best fit first), until you exhaust all possible matchings or until the angle is considered too large.

具有广角的交叉点具有挑战性,因为它们将形成具有两个遥远连接点的骨架.当将一条曲线与另一条曲线匹配时,您可以考虑与远处的曲线进行匹配,前提是它们之间有一条路径,这样它就可以适合与笔触一样大的条纹.

The crossings with a wide angle are challenging because they will form a skeleton with two distant junctions. When matching a curve to another, you might consider matchings with distant curves, provided there is a path in between, such that it fits inside a stripe as large as the strokes.

这篇关于二值化图像中的单独交叉口线段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆