title: Algorithm to detect curved lines from list of 2D points
body: <p>I am trying to extract horizontal lines from a set of 2D points generated from the photo of the model of a human torso:</p>
  
  <p><a href="https://i.stack.imgur.com/Csdqa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Csdqa.png" alt="overal view of torso point cloud"></a></p>
  
  <p>The points "mostly" form horizontal(ish) lines in a more or less regular way, but with possible gaps/missing-points:</p>
  
  <p><a href="https://i.stack.imgur.com/PRNht.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PRNht.png" alt="some missing points"></a></p>
  
  <p>There can be regions where the lines deform a bit:</p>
  
  <p><a href="https://i.stack.imgur.com/4wSO8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4wSO8.png" alt="enter image description here"></a></p>
  
  <p>And regions with background noise:<a href="https://i.stack.imgur.com/10xTb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/10xTb.png" alt="enter image description here"></a></p>
  
  <p>Of course I would need to tune things so I exclude those parts with defects. What I am looking for with this question is a suggested algorithm to find lines where they are well-behaved, filling eventual gaps and avoiding eventual noise, and also terminating the lines properly upon some discontinuity condition.</p>
  
  <p>I believe there could be some optimizing or voting "flood fill" variant that would score line candidates and yield only well-formed lines, but I am not experienced with this and cannot figure anything by myself.</p>
  
  <p>This dataset is <a href="https://gist.github.com/heltonbiker/3468362c7dc0fd069be0cda2a2737805" rel="nofollow noreferrer">in a gist here</a>, and it is important to note that X coordinates are integers, so points are aligned vertically. The Y coordinates though are decimal numbers.</p>