# How to select components selected via SelectComponents?

I have selected the components of a "reduced" (dilated, thinned) image, now I need to go back to the original image and find the coordinates of the components I have found.

My code currently does something like this (thinnedImage is the image dilated and thinned, so that is is basically the wireframe of the original image):

components = MorphologicalComponents[ColorNegate[thinnedImage]];
selected=SelectComponents[
ColorNegate[thin], {"FilledCircularity", "Eccentricity", "Area", "Centroid"}, criteria];


At this point my code knows which are the components of my interest. How do I get the centroids (in image coordinates) of those components I have selected via SelectComponents?

Take a look at ComponentMeasurements[], in particular:

ComponentMeasurements[..., "Centroid"];


This will give you a list of the centroids in the form

{1 -> {x1, y1}, 2 -> {x2, y2}, ...}


Update As pointed out by nikie in a comment,

Also, ComponentMeasurements takes a 3rd parameter crit, that basically does the same as SelectComponents last parameter - so you don't need SelectComponents at all.

• +1. Also, ComponentMeasurements takes a 3rd parameter crit, that basically does the same as SelectComponents last parameter - so you don't need SelectComponents at all. – Niki Estner Jul 27 '15 at 17:53