Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Update - Playing around a bit, is it true that we need to process the list of "IntensityData" values $r$ as follows:

r = Partition[r,k];
r = Transpose@r;

And then apply:

vmapped= c + {v[[1]] - k/2 - 0.5, k/2 - v[[2]] + 0.5}

It looks like this properly maps the point $v$ to the larger image containing the morphological component with "IntensityData" $r$, however, it's difficult to tell if there's a small error here?


I would like to ask a follow-up to a previous question - Understanding the computation of IntensityCentroid? - since this question was answered well, but I am still a bit confused about the coordinates for "IntensityData".

Let $m$ be a square morphological component with $k \times k$ pixels. Let $c$ be the output of ComponentMeasurements[{m,img},"Centroid"], let $r$ be the output of ComponentMeasurements[{m,img},"IntensityData"]. For an example, we can set:

k = 7;
c = {157.5, 92.5};
r = {0.509752, 0.958211, 0.177492, 0.679586, 0.651634, 0.159438, 0.249294,      
     0.840233, 0.403427, 0.706836, 0.0924188, 0.523653, 0.907517, 0.219175, 
     0.134596, 0.599349, 0.320155, 0.417359, 0.767355, 0.280942, 0.960531, 
     0.332421, 0.756754, 0.186532, 0.188323, 0.457144, 0.80254, 0.252036, 0.66885, 
     0.0437862, 0.674661, 0.125856, 0.134035, 0.62525, 0.328863, 0.84693, 
     0.644811, 0.877901, 0.0685183, 0.307649, 0.481993, 0.695101};

We then partition $r$ in the following way to structure the data in the form of ImageData:

r = Partition[r,k];

I then do "something" to calculate a coordinate with respect to the coordinate frame in Image[r]. Call this coordinate $v$, where we might have, for example, v = {4.232,7.827} (perhaps this is an intensity centroid in the the coordinate system for $r$).

Using image coordinates rather than indices, i.e. the coordinate system used when outputting a value for ComponentMeasurements[{m,img},"IntensityCentroid"], how can I use only the component centroid $c$ to map $v$ to my original image, img? Note that I only provide you with $k$, $c$, and $v$ for this mapping, not the original image.

Ok, let's provide a small example using ten morphological components. Here, the first set of coordinates in each three-element array represents $v$, which is something similar to an intensity centroid computed with the output of r = Partition[r,7]; where $r$ is the "IntensityData" output for some box-like morphological component with a 7-pixel edge-length. The second set of coordinates in each array ({72.5,250.5}, {208.5,246.5}, etc.) represents the output of ComponentMeasurements[{m,img},"Centroid"] for the morphological component used to grab $r$. The final set of coordinates is the output of ComponentMeasurements[{m,img},"IntensityCentroid"] for the particular morphological component.


How can we use use the second element of each list, $c$, to map the first element of each list, $v$, to the coordinate system used for the computed intensity centroid of the morphological component?

share|improve this question
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Dr. belisarius Aug 14 '13 at 20:01
@belisarius Thanks for the welcome belisarius. – Ynv Aug 14 '13 at 20:32
@belisarius I appreciate your last answer, I'm just still getting a bit tripped up by the relevant coordinate systems used for images and morphological components. I put some thought into this question, and I think an answer should really help my intuition. – Ynv Aug 14 '13 at 20:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.