title: MATLAB how to calculate elongation of a BW image
body: <p>I am trying to extract features for a leaf recognition application in MATLAB. I need to get <strong>elongation</strong> value which is described as the following:</p>
  
  <blockquote>
    <p>Compute the maximum escape distance <em>d<sub>max</sub> = max<sub>X ∈ I</sub> d(X,∂I)</em>. Elongation is obtained as <em>1 - 2d<sub>max</sub> / D(I)</em> and ranges from 0 to 1. The minimum is achieved for a circular region. Note that the ratio 2d<sub>max</sub>/D(I) is the quotient between the diameter of the largest inscribed circle and the diameter of the smallest circumscribed circle.</p>
  </blockquote>
  
  <p><strong>D(I)</strong> is the diameter of the image <strong>I</strong>. <strong>∂I</strong> is border of <strong>I</strong>.</p>
  
  <p>Pretend a circular shaped image. The furthest point to the border of this shape is the center. This is called as <strong>maximum escape distance</strong>. </p>
  
  <pre><code>Elongation = 1 - (interior ellipse radius/surrounding ellipse raidus)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/eydRA.png" alt="enter image description here"></p>
  
  <p>regionprops result for the image is below:</p>
  
  <pre><code> Area: 352085
   Centroid: [311.2075 492.9844]
   BoundingBox: [2.5000 2.5000 586 1139]
   SubarrayIdx: {1x2 cell}
   MajorAxisLength: 869.2058
   MinorAxisLength: 535.2340
   Eccentricity: 0.7879
   Orientation: -85.2073
   ConvexHull: [99x2 double]
   ConvexImage: [1139x586 logical]
   ConvexArea: 403293
   Image: [1139x586 logical]
   FilledImage: [1139x586 logical]
   FilledArea: 352085
   EulerNumber: 1
   Extrema: [8x2 double]
   EquivDiameter: 669.5435
   Solidity: 0.8730
   Extent: 0.5275
   PixelIdxList: [352085x1 double]
   PixelList: [352085x2 double]
   Perimeter: 3.2466e+03
  </code></pre>