title: Find contour of 2D object in image in matlab
body: <p>I have this problem: I have this 2D binary image and I want to extract the contour of the object in this image.
  This is the image: 
  <a href="https://i.stack.imgur.com/05T06.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/05T06.png" alt="enter image description here"></a></p>
  
  <p>I want to have the same matrix image but with ones only in the contour of the object and zeros elsewhere.
  Is there a solution?
  If so, is there any implementation to do the same thing also for a 3D object?</p>
  
  <p>Thank you very much</p>