Positioning of CT volume for DRR generation

Hello, I’m trying to generate DRR images from CT slices at certain angles (0°, 45°, 90°…). I’m using this C++ DRR example rewrote in Python: https://github.com/Vojtech-Benda/DRR_generation/blob/main/drrGen.py

I managed to get a reasonable result for AP view (0° rotation around z-axis (head to feet)), however I feel like one or more geometry parameters are wrong (volume center and origin, output image origin etc.).

Also, changing the rotation around z-axis moves the CT volume outside x-ray source’s “view”, which is most likely caused by the transformation’s center not being in the volume’s center.

I tried changing various parameters with similar or no results. Following on that, can I choose arbitrary size of the output DRR image or is it dependent on the distances between x-ray source, CT volume and its size and output image.

Thanks in advance.

@simon.rit might have some advice.

I believe I fixed the issue. The transformation’s center of rotation and input CT volume’s origin was set to the same location, causing the above misalignment. Removing the line that sets input volume’s origin fixes it. I’ve updated drrGen.py for anyone with similar problem.



I also found out that changing the size of output DRR image enlarges/shrinks the result, technically padding or cropping the image. I believe getting the correct size should be a simple trigonometry task, provided both source to detector and source to patient are known.

1 Like