Voronoi lines
I'm trying to have an image with the voronoi line (the point on the image which are at an equal distance of at least to 0-value pixel). I know of distanceTransform
and for now I'm using this to return either the distance Mat or the label. I've tried using line detector to find the line but, if I use the label, I don't have all the line, if I use the distances, the image gets rather messy.
Using delaunay here isn't really an option because I have only an image with lines and no points to give to Subdiv2D
. Plus subdiv doesn't give me an image as a result.
Is there any "easy way" to get all those point at equal distance of 0-value pixel ? If I could not have to reimplement a Voronoi less efficient than the one implemented I'll be really glad.
Here is a (bad) image made under GIMP. If the red lines are the 0-values point, then the black line would be my Voronoi lines :
Sorry for the very badly drawn drawing !
What I tried for now :
- Doing distanceTransform and then
- Using Laplace/Sobel to get the lines directly on the Vronoi diagram
- Using Laplace/Sobel on the label from CCOMP. That wasn't to bad but I missed some line. Especially, when There is a square (like in the figure) all the line are considered as 1element and I have no lines anymore.
- Using Delaunay.
- Calculating local maximum value . That gave quite good results but the lines are often disconnected.
For exemple, here are my results with Laplace and Sobel using the label. The Laplace one here is perfect because non of the lines are connected. If I were to put a "dead-end" (connect the two line on top for example), my top line would disappear. And I don't want that :)
Thanks !