# Setting camera direction of projection (position) to have slices like in 3d slicer

**URL:** https://discourse.vtk.org/t/setting-camera-direction-of-projection-position-to-have-slices-like-in-3d-slicer/2466
**Category:** Development
**Created:** [January 20, 2020, 6:16pm UTC](https://discourse.vtk.org/t/setting-camera-direction-of-projection-position-to-have-slices-like-in-3d-slicer/2466 "2020-01-20T18:16:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Andrzej\_Marciniak](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andrzej_marciniak/32/259_2.png) [@Andrzej\_Marciniak](https://discourse.vtk.org/u/Andrzej_Marciniak)
#### Post date: [January 20, 2020, 6:16pm UTC](https://discourse.vtk.org/t/setting-camera-direction-of-projection-position-to-have-slices-like-in-3d-slicer/2466/1 "2020-01-20T18:16:27Z")

</div>

Hi,

I am writing MRI browser and I am trying to set camera projection perpendicular to IJK planes in vtk-js (camera in parallel mode).  
I am using only vtkImageData direction matrix to calculate slicing modes and camera position and viewup. I would like to have exactly the same scene like in 3DSlicer, i.e. slicing in direction: L-\>R, P-\>A, I-\>S, camera viewup always for a given orientation,etc…

Let suppose that I have two images with direction matrices (using row-major order for 9-element vector) as follows:

[0, 1, 0]  
[0, 0,-1]  
[-1, 0, 0]

[0, 1, 0]  
[0, 0,-1]  
[1, 0, 0]

First, I am setting proper slicing mode in IJK,and I am checking  
anatomical orientation:

RL AP IS  
i[0, 1, 0] 1\>0 A  
j[0, 0,-1] -1\<0 S  
k[-1, 0, 0] -1\<0 L

i[0, 1, 0] 1\>0 A  
j[0, 0,-1] -1\<0 S  
k[1, 0, 0] 1\>0 R

Using ITK notation A:A-\>P, S:S-\>I etc. I confirmed in ITK-SNAP that these images are in fact in ASL and ASR orientations.

So I know that vtkImageMappers should be set as follows:

- SlicingMode.I for Coronal (reversed slicing direction in both)
- SlicingMode.J for Axial (reversed slicing direction in both)
- SlicingMode.K for Sagittal. (reversed slicing direction in ASR)

To set camera’s direction of projection I just use a given row of direction matrix.  
For example: for axial this would be [0,0,-1] in both cases.

However for ASR image, the image is flipped (Left to Right) when compared to 3DSlicer.  
If I multiply j row ([0,0,-1]) by -1, then it works for ASR, but ASL will be flipped.  
I checked with all orientations and this would work nicely if only I would know when to change direction to opposite.

I was trying to figure out with using some transformations, like described in [https://www.slideserve.com/kare/slicer-s-coordinate-systems](https://www.slideserve.com/kare/slicer-s-coordinate-systems)  
but I did not manage to find the solution.  
I also studied vtk-js ViewProxy and InteractorStyleMPRSlice but it didn’t help.  
How can set camera direction of projection, so that it will work as in 3D slicer?  
Thank you for any help  
Andrzej Marciniak
