# \[SOLVED\]TransformIndexToPhysicalPoint manually

**URL:** <https://discourse.itk.org/t/solved-transformindextophysicalpoint-manually/1031>\
**Category:** Beginner Questions\
**Created:** [June 25, 2018, 5:28pm UTC](https://discourse.itk.org/t/solved-transformindextophysicalpoint-manually/1031 "2018-06-25T17:28:37Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![rolof](https://discourse.itk.org/letter_avatar_proxy/v4/letter/r/41988e/32.png) [@rolof](https://discourse.itk.org/u/rolof)\
**Post date:** [June 29, 2018, 10:10am UTC](https://discourse.itk.org/t/solved-transformindextophysicalpoint-manually/1031/9 "2018-06-29T10:10:26Z")

</div>

Thanks a lots @phcerdan and @blowekamp for the answers, so In C low level language programming it should be for 3D image the following Code If I didn’t make a mistake, With O(Origin), D(Direction), S(Spacing), I(index) and DxS(product between DxS):

```
float DxS11, DxS12, DxS13, DxS21, DxS22, DxS23, DxS31, DxS32, DxS33; 
float Ox, Oy, Oz;
float D11, D12, D13, D21, D22, D23, D31, D32, D33;
float S11, S22, S33;
float Ix, Iy, Iz;
float Px, Py, Pz;

const ImageType::PointType & origin = image->GetOrigin();
Ox=origin[0];
Oy=origin[1];
Oz=origin[2];

const ImageType::SpacingType & ImageSpacing = image->GetSpacing();
S11 = ImageSpacing[0];
S22 = ImageSpacing[1];
S33 = ImageSpacing[2];

const ImageType::DirectionType& direct = image->GetDirection();
D11 = direct[0][0];
D12 = direct[0][1];
D13 = direct[0][2];
D21 = direct[1][0];
D22 = direct[1][1];
D23 = direct[1][2];
D31 = direct[2][0];
D32 = direct[2][1];
D33 = direct[2][2];

DxS11= (D11*S11);
DxS12= (D12*S22);
DxS13= (D13*S33);
DxS21= (D21*S11);
DxS22= (D22*S22);
DxS23= (D23*S33);
DxS31= (D31*S11);
DxS32= (D32*S33);
DxS33= (D33*S33);

for (inputImageIterator.GoToBegin(); !inputImageIterator.IsAtEnd(); ++inputImageIterator)
{
  Ix=(inputImageIterator.GetIndex())[0];
  Iy=(inputImageIterator.GetIndex())[1];
  Iz=(inputImageIterator.GetIndex())[2];

  Px = Ox + ((DxS11*Ix) + (DxS12*Iy) + (DxS13*Iz));
  Py = Oy + ((DxS21*Ix) + (DxS22*Iy) + (DxS33*Iz));
  Pz = Oz + ((DxS31*Ix) + (DxS32*Iy) + (DxS33*Iz));
  ...
}

```

It could be improved with vectors instead of variables, but I do not have much time, and I wanted to test if it works and thanks to let me know how to get it working.

---

_[View the full topic](https://discourse.itk.org/t/solved-transformindextophysicalpoint-manually/1031)._
