# Understanding “IntensityData” coordinates

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.

componentOneArray={{4.1209,2.39237},{72.5,250.5},{73.1307,250.376}}
componentTwoArray={{4.10345,2.51433},{208.5,246.5},{208.993,246.415}}
componentThreeArray={{2.74777,11.3037},{18.5,229.5},{16.6019,229.926}}
componentFourArray={{3.75292,2.4059},{92.5,228.5},{93.1028,228.757}}
componentFiveArray={{3.74452,3.1833},{109.5,224.5},{109.302,224.697}}
componentSixArray={{3.76436,2.40024},{137.5,223.5},{138.098,223.743}}
componentSevenArray={{3.52801,2.6132},{221.5,221.5},{221.89,221.992}}
componentEightArray={{4.10626,2.43366},{64.5,209.5},{65.0603,209.391}}
componentNineArray={{4.08676,3.06379},{98.5,208.5},{98.4326,208.419}}
componentTenArray={{3.90224,3.10008},{30.5,205.5},{30.3848,205.606}}


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?

-
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