title: Algorithm to find the longest fully-internal line of a non-regular 2D-shape?
body: <p>I've been doing some image processing recently, and am looking for an algorithm to determine the longest line segment that is entirely within a non-regular shape. In other words, the line segment should be the longest line segment that touches the shape elusively at its endpoints. </p>
  
  <p>The shape can be represented as a set of (x,y) coordinates or as a binary-array. The outermost layer of pixels (the edge), have already been determined. 
  A simple example would be an ellipse, to which the solution is the major axis. A more complex example would be a equilateral triangle, which would result in a line between two pixels which are immediately adjacent to two separate corners. Most of my shapes are ellipse-like or 'worm-like' (long and wavy).</p>
  
  <p>Ultimately I wish to use this as a method to divide the 'worm-like' shapes into their segments, using a series of 'cuts' approximately perpendicular to this line. I am hoping that the line formed by this message will be better suited for this task than one determined by a regression. It should be noted that these shapes are high resolution, and therefore may consist of up to 1000 edge-pixels, which is why I'm trying to avoid a simple iterative/brute force approach.</p>
  
  <p>Thank you for any and all suggestions!</p>
  
  <p>Here are some visualizations:</p>
  
  <p><img src="https://i.stack.imgur.com/fW3Hs.png" alt="Example 1"> <img src="https://i.stack.imgur.com/maq6h.png" alt="Example 2"></p>