Imagine I have the two dimensional image of a hotdog. I can draw a straight line on the hotdog between its two ends. Call this the midline. One of its properties is that it is the axis about which the (2D) hotdog has the lowest moment of inertia.
Now if I bend the hotdog in an arc, this midline will also distort.
Given a picture of the bent hotdog, how can I determine this bent midline? The algorithm should tolerate a modest amount of noise in the image.
If I understand your question, you want a line through your object where every point is in the middle of the object, i.e. if you start from any point on the midline and walk in a direction perpendicular to the midline, you have to walk the same distance in both directions until you meet the border of the object:
(this is just an illustration - probably not the geometrically correct midline!)
My quick&dirty solution would be to start with a middle axis (that can easily be calculated from first and second-order moments) and refine it by taking each point on this line and find the nearest border points on a line perpendicular to the current direction at that point, and move the point to the geometric center of these two points:
If you do this for every point, you should get a better approximation for the midline.
I said this was quick&dirty, because I'm not sure if simply repeating this procedure always converges to a stable solution. It probably depends on how you calculate the perpendicular direction of the midline in the presence of bends and kinks.
One way around this is to use a more physically-inspired model:
To find this line, I would use an algorithm similar to active contours/snakes:
You'll need to adjust a few parameters for these smoothness of the curve (as always with active contours), but your chances to get a well-defined and well-behaved approximation are far better than with the simple approach above.
Maybe you can skeletonize your bent hotdog.
You first have to thresold it, then use a thinning algorithm.
Here are some cool links:
http://xphilipp.developpez.com/contribuez/Skeleton-Algorithm.pdf http://www-prima.inrialpes.fr/perso/Tran/Draft/gateway.cfm.pdf http://www.geometrictools.com/Documentation/Skeletons.pdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With