pixel positions in every slice is not uniform

I am getting the 3d position of the pixels in every slice. I use the “TransformIndexToPhysicalPoint” to get the 3d position of pixels. I looked at the corner pixel in every slice, index (0, 0, 0), and the results are not uniform. Here are the results of the 3d position of the corner pixel in every slice

Physical coordinates of the first pixel: (-202.954, -27.6161, -60.131)
Physical coordinates of the first pixel: (-202.298, -28.3201, -51.7863)
Physical coordinates of the first pixel: (-201.642, -29.0242, -43.4416)
Physical coordinates of the first pixel: (-200.984, -29.7283, -35.097)
Physical coordinates of the first pixel: (-200.328, -30.4323, -26.7524)
Physical coordinates of the first pixel: (-199.672, -31.1364, -18.4077)
Physical coordinates of the first pixel: (-199.016, -31.8405, -10.063)
Physical coordinates of the first pixel: (-198.358, -32.5445, -1.7184)
Physical coordinates of the first pixel: (-197.702, -33.2486, 6.62633)
Physical coordinates of the first pixel: (-197.046, -33.9527, 14.971)
Physical coordinates of the first pixel: (-196.39, -34.6567, 23.3156)
Physical coordinates of the first pixel: (-195.732, -35.3609, 31.6602)
Physical coordinates of the first pixel: (-195.076, -36.0649, 40.0049)
Physical coordinates of the first pixel: (-194.42, -36.769, 48.3496)
Physical coordinates of the first pixel: (-193.764, -37.4731, 56.6942)
Physical coordinates of the first pixel: (-193.107, -38.1771, 65.0389)
Physical coordinates of the first pixel: (-192.45, -38.8812, 73.3835)
Physical coordinates of the first pixel: (-191.794, -39.5853, 81.7282)
Physical coordinates of the first pixel: (-191.138, -40.2893, 90.0728)
Physical coordinates of the first pixel: (-190.481, -40.9934, 98.4175)
Physical coordinates of the first pixel: (-189.824, -41.6975, 106.762)
Physical coordinates of the first pixel: (-189.168, -42.4015, 115.107)
Physical coordinates of the first pixel: (-188.512, -43.1056, 123.452)
Physical coordinates of the first pixel: (-187.855, -43.8097, 131.796)
Physical coordinates of the first pixel: (-187.198, -44.5137, 140.141)
Physical coordinates of the first pixel: (-186.542, -45.2179, 148.486)
Physical coordinates of the first pixel: (-185.886, -45.9219, 156.83)

Both the x and y positions are deviating, the z position(depth) is also changing as it should. The tag values values of the

Slice Thickness = 4
Pixel Spacing X = 0.3125
Pixel Spacing Y = 0.3125

the results do not reflect these values between pixels, the pixel positions are being advanced with random values.

Should I use these tag values to advance pixel positions from the corner pixel position to get a uniform result? or just go with the function given values?

Hello @jsemeda,

The results of using TransformIndexToPhysicalPoint are correct. Those are the physical coordinates of the corner pixels. The “issue” you are encountering is that the axes of the image are not the identity. To see this use the image’s GetDirection method. Non identity direction matrices often happen in CT and MR. Note that slice thickness does not play a role in determining the pixel locations, see this discussion for details.

1 Like