Longest line inside of 3D object I have a 3D object which I have segmented and represented as a 3D binary array. I need to find the longest line which fits inside of the object in three dimensional space. What would be an efficient method I could use to approach this problem.



The following is an example of what I am trying to do but in 2 dimensions. The black part of the image is the background and the white is a segmented object. The red line is the longest line which can be drawn inside the object. I would like to find the length of this line.



I could do this by calculating the distance between each pair of two points on the surface of the object and taking the longest distance as my result, but this seems horribly inefficient particularity when solving the problem in 3 dimensions.

Is there a better way to solve this problem.

Thanks
These are very computationally expensive problems and it also depends if your polygons are convex. Also in your case you don't have any extra constraints and it can be any line within. I think that the best read for you is the following publication:


  Hall-Holt O., et al. - Finding large sticks and potatoes in polygons


You will definitely find few algorithms among ones they described (computational complexities are given). Here is some brief presentation concerning their work: click