title: Find contour/edge in pcolor in Matlab
body: <p>I'm trying to make a contour that follows the edges of the 'pixels' in a <code>pcolor</code> plot in Matlab. This is probably best explained in pictures. Here is a plot of my data. There is a distinct boundary between the yellow data (data==1) and the blue data (data==0):</p>
  
  <p><a href="https://i.stack.imgur.com/V0Lro.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V0Lro.png" alt="Pcolor plot"></a></p>
  
  <p>Note that this is a <code>pcolor</code> plot so each 'square' is essentially a pixel. I want to return a contour that follows the <em>faces</em> of the yellow data <em>pixels</em>, <strong>not</strong> just the edge of the yellow data. </p>
  
  <p><a href="https://i.stack.imgur.com/zrhof.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zrhof.png" alt="i want this output"></a></p>
  
  <p>So the output contour (green line) passes through the mid-points of the face (red dots) of the pixels.</p>
  
  <p>Note that I don't want the contour to follow the centre points of the data (black dots), which would do something like this green line. This could be achieved easily with <code>contour</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/p2apw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p2apw.png" alt="I don&#39;t want this outcome"></a></p>
  
  <p>Also, if it's any help, I have a few grids which may be useful. I have the points in the middle of the pixels (obviously, as that's what I've plotted here), I also have the points on the corners, AND I have the points on the west/east faces and the north/south faces. IF you're familiar with <a href="https://en.wikipedia.org/wiki/Arakawa_grids" rel="nofollow noreferrer">Arakawa grids</a>, this is an Arakawa-C grid, so I have the rho-, u-, v- and psi- points.</p>
  
  <p>I've tried interpolation, interweaving grids, and a few other things but I'm not having any luck. Any help would be HUGELY appreciated and would stop me going crazy.</p>
  
  <p>Cheers, Dave</p>
  
  <p>EDIT:</p>
  
  <p>Sorry, I simplified the images to make what I was trying to explain more obvious, but here is a larger (zoomed out) image of the region I'm trying to separate:
  <a href="https://i.stack.imgur.com/dpsvn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dpsvn.png" alt="zoomed out image"></a></p>
  
  <p>As you can see, it's a complex outline which heads in a "southwest" direction before wrapping around and moving back "northeast". And here is the red line that I'd like to draw, through the black points:</p>
  
  <p><a href="https://i.stack.imgur.com/gqJjs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gqJjs.png" alt="intended output line"></a></p>