title: Pixel chains from run length encoding
body: <p>I've been banging my head for a long time on this one</p>
  
  <p>I am doing imaging. So far I've binarized my images, meaning that from a grayscale image, every pixel under a certain value are dropped. This gives me only some regions out of the original image with a lot of "zero pixels" all around those regions.</p>
  
  <p>Next I've run length encoded my regions into "blobs". Runs are a method of compression for data. For example, suppose that you have binarized a square, the you will have only a few runs describing the whole image.
  The runs are defined by x,y coordinates and a length.</p>
  
  <p>When recreating the image, for each run, go to x,y coordinate and add pixels on the x axis for the length of the run.</p>
  
  <p>Now I have to take the runs and create a chain out of it that will describe the contour of the region.
  I don't know how to do that.</p>
  
  <p>I have a bunch of x,y,length runs and I have to "navigate" around the edges to form a <a href="http://www.ph.tn.tudelft.nl/Courses/FIP/noframes/fip-Contour.html" rel="nofollow noreferrer">chain</a>. Normally in imaging this process is done with the original image but I can't use the original image anymore here so I have to compute it with the runs.</p>
  
  <p>I know this looks like a big wall of text but I don't know how to ask this question better.</p>
  
  <p>Any hints or pointers on identical implementation would be awesome.</p>
  
  <p>EDIT</p>
  
  <p>thanks to unwind, Ill link a few images :</p>
  
  <p><a href="https://i.stack.imgur.com/6tdLQ.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6tdLQ.gif" alt="alt text"></a><br>
  <sub>(source: <a href="http://www.ph.tn.tudelft.nl/Courses/FIP/images/fip83.gif" rel="nofollow noreferrer">tudelft.nl</a>)</sub>  </p>
  
  <p>In this example, they process the image B into the contour C (which I call chain). However I'd like to generate the contour from D, the Run Lengths</p>