title: How make endpoints of bwboundaries consistent in Matlab?
body: <p>I have an image with 2 edges</p>
  
  <p>if I then plot the boundary of the edges with the code below:</p>
  
  <pre><code>imshow(I); hold on; [B,L,N] = bwboundaries(I);
  for k=1:length(B),
      boundary = B{k};
      BL=size(boundary);
      plot(boundary(1,2), boundary(1,1), '*g','MarkerSize',15);
      for j=1:10:BL(1)
          plot(boundary(j,2), boundary(j,1), '.r','MarkerSize',5);
      end
  
  end
  </code></pre>
  
  <p>As seen in the image above, the starting point (the green star) for the left edge is at the left side of the image, which is what I expected. However, the starting point for the right edge is towards the middle</p>
  
  <p>Apparently this is because <code>bwboundaries</code> deals with tracing objects in clockwise direction, whereas the 2nd edge needs to be traced counterclockwise for it to begin and end on the right boundary of the image</p>
  
  <p>How can Matlab be able to take the positions from <code>bwboundaries</code> and correctly determine the endpoints for the edge on the right?</p>