2

I need to separate lines from each other and make an array of coordinates for each graphic. The problem is (see the red circled section on the pic) some graphics overlap, and i don't know how to write a program that will find this overlaps and separate them. (Now we think that lines only touch each other not cross.)

Squiggly lines

@Rethunk i maked thinning and got this result. after thinning

4

1 回答 1

1

如果您知道这些行最初是分开的,则可以从左到右跟踪它们。对于每条线,顶部和底部 y 坐标逐渐变化,而 x 坐标增加。对于向右移动的每个像素,您可以从平均 y 坐标开始并上下移动以找到每条线的新顶部和底部 y 坐标。

当两条线接触时,它们的顶部和底部 y 坐标将相同。这可以通过比较彼此相邻的线的坐标来检测。例如,假设第 4 行和第 5 行在某个点重叠。对于这些行,您知道哪一行是较高的行 (4) 和较低的行 (5)。假设 yTopOverlap = 130 和 yBottomOverlap = 160。我们可以在两条线之间划分像素。在这种情况下,为第 4 行设置 yTop 130 和 yBottom 145,为第 5 行设置 yTop 146 和 yBottom 160。当行再次分开时,不再需要修改它们的 y 坐标。

于 2013-01-27T15:58:03.843 回答