title: External and internal Edge Detection for ideal image
body: <p>I am looking for an algorithm that can do external and internal contour detection on an ideal image containing only two different RGB values.</p>
  
  <p>Below is a typical example of the image (first one) I want to process, next image is one I made myself showing the result I am expecting.</p>
  
  <p>The last one is a result from OpenCV Canny detection made through the demo software available at <a href="http://www.tsdconseil.fr/log/opencv/demo/index-en.htmlhttp://" rel="nofollow noreferrer">OpenCV demo Software</a>.</p>
  
  <p>The canny algorithm is not satisfying as it is smoothing too much the shapes (especially corner).</p>
  
  <p>Are there any elegant algorithm that could give the same results as in the second image?</p>
  
  <p><a href="https://i.stack.imgur.com/3aeLD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3aeLD.png" alt="Original Image"></a><br>
  <a href="https://i.stack.imgur.com/1dZBg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1dZBg.png" alt="My own brain&#39;s contour detection and expected result"></a><br>
  <a href="https://i.stack.imgur.com/C1rMZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C1rMZ.png" alt="OpenCV -&gt; Contour algorithm result"></a></p>