1
$\begingroup$

This is a question relating to grouping of components picked out using ComponentMeasurements to make a complete perimeter of a shape. My goal is to measure the perimeter of each of these worm-like particles, and to plot a histogram distribution of it.

Particles

From ComponentMeasurements, I would be able to obtain the perimeter of each particle that I need for the histogram. I used EdgeDetect and filtered out noise to obtain a relatively good result for ComponentMeasurements.

picEdge2 = RemoveBackground[DeleteBorderComponents[Image[EdgeDetect[pic, 6.6]]]];
array = ComponentMeasurements[picEdge2, {"Shape", "PerimeterLength", "Mask", 
 "MinimalBoundingBox", "BoundingBox"}, #Width > 10 && #PerimeterLength > 50 && #PerimeterLength < 1400 &] // Values;

ComponentMeasurements result

This seems to work pretty well, and I have complete perimeters for most particles. Complete Particles

However, the perimeter of some worms have been broken up into different pieces, such as in the following picture (red and yellow are different components).

Incomplete Perimeter

I have tried grouping components together by testing whether their bounding boxes or minimal bounding boxes intersect - however, this tends to group together multiple neighboring particles instead, because the particles are too close together.

IntersectQ[a_, b_] := Area[RegionIntersection[Polygon[{a[[1]], a[[2]],
a[[3]], a[[4]]}], Polygon[{b[[1]], b[[2]], b[[3]], b[[4]]}]]] > 0

Instead, I was thinking of trying to convert from the mask or shape obtained from ComponentMeasurements into a ConvexHull, and test for an intersection between ConvexHulls of each component. However, I'm not too sure how I should go about converting from a mask to points (so that I can make a ConvexHull), or if this method is feasible. What would be the best way to group components to ensure a complete perimeter, without grouping multiple particles together?

Thank you!

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.