Manipulation and removal of Morphological Components from an Image?

Please view the sample image below where each morphological component has been labeled with a number at its centroid.

If I wanted to programmatically remove a given component, such as 34, how would I do that?

Additionally, is it possible to perform manipulation on individual morphological components, such as rotation?

If I wanted to rotate components 2 and 3 would that be possible? Would the interior components rotate with the components they are contained within?

DeleteSmallComponent and DeleteLargeComponent functions are not general enough for my purposes, as there are a large number of images to be processed, and it is not known whether a morphological component that requires manipulation will be large or small.

It’s my 2nd day with Wolfram, I have consumed as much as the documentation as I can today, but I wanted to see if someone could help.

Thanks for your time.

Here are a few hints on how to implement your workflow:

  1. Select morphological components via SelectComponents. You can specify any kind of criteria.
  2. Remove a morphological component via Inpaint. The result of (1) would function as a mask.
  3. Rotate a morphological component via ImagePerspectiveTransformation. The “Centroid” could be the center of rotation.
  4. Insert a transformed morphological component back into the original image via morphological ImageCompose.

See attached notebook for details.

Hope this helps to get you started.

Marcus, this is very helpful, but I’m still having some issues. I think maybe I do not fully understand the “Count” criteria. Why is “Count” -1 the largest ? In a ComponentsMeasure[Image, “Count”] what is the order of the output?

Additionally, what type of value is the “Count” Property? Some of the sample output for my image is: 34 → 109, 35 → 115, 36 → 110 . But I am unsure of what the 109, 115 and 110 represent.

When I do a SelectComponents[segments, “Count”, 34] on my provided sample image It actually selects components labled 14, 25, and 27. Why is that?

Here is my workbook.

Thank you for the assistance.