danforthcenter / plantcv

Plant phenotyping with image analysis
Mozilla Public License 2.0
655 stars 264 forks source link

Skeletonize Function #808

Closed RJGrove closed 3 years ago

RJGrove commented 3 years ago

When extracting segmented leaf angles from an image I am faced with gaps in the skeleton where the leaf is which then reads misrepresented angles.

Is there a way to adjust the thickness of the skeleton instead of having it one pixel wide?

I at first thought my issue was rooted when I convert the image to a binary and then blur but this was not the case.

HaleySchuhl commented 3 years ago

Hi @RGROVE1232 thanks for opening an issue!

The thickness of a skeleton must be just one pixel wide in order for those algorithms to work properly, so any adjustments to increase the robustness of the plants' structure should take place before skeletonization. I usually suggest using functions to clean up and refine the binary mask with steps such as pcv.fill_holes and pcv.dilate. If the binary mask has disconnected structure then the skeleton will reflect this as well. I've also had higher success when creating a binary mask that is a combination of two or more colorspaces so additionally reduce any missing portions of object in the binary mask.

RJGrove commented 3 years ago

Thank you @HaleySchuhl - works great!

HaleySchuhl commented 3 years ago

Great to hear it! I'm going to close this issue for now, but feel welcome to reopen with any further comments/questions :D