MATLAB: Determine the true length of the object – image analysis

blobsimage analysisImage Processing Toolboxobject length

Hello there!
I would like to measure the length of the object on the image. But the problem is that the object is sligthly bended, so after tresholding of the original image and applying the blobs identifying I have tried the method of determining the Feret diameter, but as I said, the object is bended so the method does not work so well. I attached images with marked Feret diameter (acc to https://blogs.mathworks.com/steve/2018/04/17/feret-properties-wrapping-up/), but the thing that I would really like to do is to "draw" the line in the middle of the object and then determine its length. By drawing a line I mean something as calculating the centroid per each row of the matix image containg the object (so something as the Ferete diameter but not going outside the object).
I would like to expand this method for bigger number of images and it could happen that "lines" will be even more bended.
I will be really thankful for any hints.

Best Answer

Try bwskel() and then, if it's too short, find the two points farthest way from each other and extend the endpoints of the skeleton to the closest endpoint. Then run along the skeleton getting the Euclidean distances between all the pixels, or just sum the image if you just want a pixel count, or use bwarea() if you want a sum that's weighted.