title: Detect correct number of CORNER coordinates from a Polygon image in MATLAB
body: <p>I have a number of polygon images like a hexagon, a pentagon, any quadrilateral etc.. i need to generalize the detection technique to detect the RIGHT number of Corner coordinates.. no extra coordinates should be generated.</p>
  
  <p>for eg:- the code should detect only 4 for a quadrilateral, 3 for triangle, 5 for pentagon and so on..</p>
  
  <p>I used HARRIS corner detection to detect right corners by specifying the number of corners value but i cant use the same code for an image with different number of edges.</p>
  
  <p>Reason for using the same code is i am trying to bulk process image -> Detect corners and print them... i cant change the code for each image.</p>
  
  <p><strong>Sample Images:-</strong>  </p>
  
  <p><strong>Octagon:</strong> </p>
  
  <p><img src="https://i.stack.imgur.com/FtSFZ.jpg" alt="enter image description here"></p>
  
  <p><strong>Pentagon:</strong> </p>
  
  <p><img src="https://i.stack.imgur.com/1RdSD.jpg" alt="enter image description here"></p>