T-shaped polygons

184 Views Asked by At

Is there any coefficient that can indicate T-shaped polygons ?

Examples of T-shaped polygons:

enter image description here

1

There are 1 best solutions below

1
On BEST ANSWER

Brainstorming answer to a brainstorming question… I'm not happy with this answer myself, and hope that me posting this answer doesn't prevent someone likely to give a better answer from reading your question in the first place.

You could start by identifying two points with maximal distance from one another, which you can obtain in linear time from the convex hull. Then look for a third point which is a maximal distance away from the line spanned by these two. If it is a T, you should have the three endpoints of its lines. Try all possible ways to connect one of the three points to the midpoint of the other two, then check how close your polygon is to the resulting shape by e.g. integrating some simple cost function or some such. It should be possible to adapt the shoelace formula to compute such integrals in reasonable time. This approach will however be rather sensitive to curls at the ends of the lines, like depicted in your right image.

To avoid that, perhaps don't use the extremal points, but instead try to find a best fit to the shape as a whole. Unfortunately, I can see no way to turn this into a linear problem, so instead of a simple least squares approximation or something like this you'd be in the domain of non-linear optimization. So you might look for the best-fitting set of T-describing parameters (orientation angle, size, aspect ratio, bar width) using some common non-linear optimization technique, with all the trouble about local optima that usually entails.

I also know that Hough transform and its generalizations are sometimes used to detect shapes in images. At some other point, I've heard about a thing called a chamfer matching, though that appears to be rather pixel-oriented. None of this sounds like an easy to implement solution.