# Are the vectors defining the Direction of a SimpleITK image normalized?

**URL:** <https://discourse.itk.org/t/are-the-vectors-defining-the-direction-of-a-simpleitk-image-normalized/810>\
**Category:** Beginner Questions\
**Tags:** doxygen, simpleitk\
**Created:** [March 29, 2018, 8:47pm UTC](https://discourse.itk.org/t/are-the-vectors-defining-the-direction-of-a-simpleitk-image-normalized/810 "2018-03-29T20:47:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diego\_C](https://discourse.itk.org/user_avatar/discourse.itk.org/diego_c/32/279_2.png) [@Diego\_C](https://discourse.itk.org/u/Diego_C)\
**Post date:** [March 29, 2018, 8:47pm UTC](https://discourse.itk.org/t/are-the-vectors-defining-the-direction-of-a-simpleitk-image-normalized/810/1 "2018-03-29T20:47:48Z")

</div>

HI!

I would like to know if the vectors that define the Direction of a SimpleITK image are normalized or not. I am trying to use the method SetDirection but the documentation is not clear about this:

 ![image](https://discourse.itk.org/uploads/default/original/1X/fcbfcd6617a57dddbb3f5162319fdaf504231269.png)

Whereas in NRRD, the space directions tag is not normalized and the vectors of this basis are scaled in such a way that the basis also encodes the spacing. So that’s why I am confused.

Thanks,

Diego

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [March 30, 2018, 1:15pm UTC](https://discourse.itk.org/t/are-the-vectors-defining-the-direction-of-a-simpleitk-image-normalized/810/2 "2018-03-30T13:15:58Z")

</div>

The basis are not normalized, though I would use normalized basis to separate the effect of the spacing parameter from the axis direction. In practice if you provide non-normalized vectors the actual spacing will be a combination of the scale from the basis vectors and the image spacing. See code example below:

```auto
import SimpleITK as sitk

img = sitk.Image([2,4], sitk.sitkUInt8)

# non-normalized basis matrix columns are (2,0), (0,3)
img.SetDirection([2,0,0,3])
print("direction: "+ str(img.GetDirection())) 
print("spacing: " + str(img.GetSpacing()))
print("point coordinates for index [1,1]: " + str(img.TransformIndexToPhysicalPoint([1,1])))

# change spacing to see combination of basis and spacing
img.SetSpacing([0.5,0.5])
print("direction: "+ str(img.GetDirection())) 
print("spacing: " + str(img.GetSpacing()))
print("point coordinates for index [1,1]: " + str(img.TransformIndexToPhysicalPoint([1,1])))

```
