2
$\begingroup$

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?

$\endgroup$
2
$\begingroup$

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.

$\endgroup$
  • 2
    $\begingroup$ +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. $\endgroup$ – Niki Estner Jul 27 '15 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.