How to define camera perspective of 3D view window

Hello

I am trying to control the perspective of an X-ray-like image generated from CT data. E.g., I would like to define the distance between the focal point and a specific anatomical feature and control the viewing angle so that the perspective (distortion) of the X-ray-like image is equal to an actual X-ray.

I am able to generate an image that looks quite similar to an x-ray (using volume rendering - CT-X-Ray properties) and I am able to zoom, rotate the viewing angle and change the focal axis with my mouse, however I am unable to quantify or define these values.

Is there a way to access this perspective information and to actively control them?

Thank you for your help

Best
deferd

Here is how I was able to do it:

viewNode = slicer.mrmlScene.GetSingletonNode("1", "vtkMRMLViewNode")
cameraNode = slicer.modules.cameras.logic().GetViewActiveCameraNode(viewNode)
position = [0,0,0]
focalPoint = [20,20,20]
viewUpDirection = [0,1,0]
cameraNode.SetPosition(position)
cameraNode.SetFocalPoint(focalPoint)
cameraNode.SetViewUp(viewUpDirection)
1 Like

Hello Mauro,

thank you for your fast response, your solution is extremely useful. I could further define the camera angle with:
cameraNode.SetViewAngle().

Am I correct in assuming that the coordinates are global coordinates? And do you know if there is a simple way to transform these coordinates into metric measures?

Also, is there a way to access the coordinates of the camera position, focal point etc. after manual manipulation?

Best

From what I know this coordinates are in RAS and longitudes are measured in mm.

You can change “Set” by “Get” in the previous methods to get the information you want. I think you have to provide a list of lenght equal 3 as parameter of the function