5

Last couple of days I spent on searching for curve reconstruction implementations, and found none - not as a library nor as a tool.

To describe my problem.

My main concern are contours with gaps: img

From papers I've read in the meantime, I guess solution will require usage of Delaunay triangulation, and the method referenced most seems to be described in 1997 paper "The Crust and the β-Skeleton: Combinatorial Curve Reconstruction "

Can someone point me to a curve reconstruction implementation, that can help me solve this problem?

theta
  • 24,593
  • 37
  • 119
  • 159
  • 1
    Although you've already selected an answer, if the problem remains of interest search for "curve completion" and "contour completion", which are likely to give you more hits. For this sort of problem Euler spirals are a good fit, as an Euler spiral curve completion algorithm can give a "natural" fit even when there are large gaps. – Rethunk Apr 07 '13 at 03:49
  • Thanks @Rethunk. I browsed some papers on the subject and it looks like it's suited for single curve reconstruction, rather then contours reconstruction. Do you perhaps know if it's implemented in some library or environment that will allow easy testing? – theta Apr 08 '13 at 03:01
  • 1
    About a year ago I found some resources, including some C++ code. I posted the links here: http://stackoverflow.com/questions/6828359/how-to-draw-clothoids-graphically-in-qt/8890013#8890013 – Rethunk Apr 09 '13 at 12:20
  • 1
    Crust algorithm gives very nice results in controlled examples, but with real data which does not conform to initial assumptions, there are some errors and missed gaps which I correct later by hand. Now I'm enhancing approach with code to close gaps based on distance and segment directions, with strait lines (with OpenCV) and I see that Euler spirals come naturally handy. Thanks! – theta Apr 09 '13 at 15:09

3 Answers3

1

Algorithm is implemented in CGAL. Example implementation can be seen in C++ in CGAL ipelets demo package. Even more compiling the demo allows user applying the algorithm in ipe GUI application:

img

In above example I selected just part of my image, as bottom lines did not meet necessary requirements, so crust can't be applied on that part until corrected. Further, image has to be sampled, as can be noticed.

If no one provides another implementation example, I'll mark my answer as correct after couple of days.

theta
  • 24,593
  • 37
  • 119
  • 159
0

Delaunay triangulation uses discretized curve, and with that loses information. That can cause strange problems where you don't expect them. In your example, probably middle part on lower boundary would cause a problem.

In this situations maybe it is good to collect relevant information from model and try to make a matching.

Something like, for each end point collect contour derivative in a neighbourhood. Than find all end points to which that end point can be connected, with approximative derivative direction and that joint doesn't cross other line. It is possible to give weight to possible connection by joint distance and deviation from local derivative. Giving weight defines weighted graph with possible end point connections. Maximal edge matching in that graph would be good solution to a problem.

Ante
  • 5,350
  • 6
  • 23
  • 46
  • Delaunay triangulation closes the contour in acceptable accuracy. Crust algorithm extracts just the missing part. As proved on paper. – theta Mar 03 '13 at 10:16
0

There are quite a few ways to solve this;

You could simply write a worm that follows the curves and when you reach the end of one, you take your current direction vector along with gradient and extrapolate it forward. Find all the other endpoints that would best fit and then score them; Reconnect up with the one with the highest score. Simple, and prone to problems if its more than a simple break up.

A hierarchical waterfall method might be interesting

There are threshold methods in waterfall (and level-set methods) that can be used to detect these gaps and fill them in.

Meirion Hughes
  • 24,994
  • 12
  • 71
  • 122
  • I've read that there are few ways to do connection, but closing it with crust algorithm is reported as most accurate for topological contours. – theta Mar 03 '13 at 10:12