[Rtk-users] DRR with limited FOV from 3D-CT

Isuru Suranga Wijesinghe isurusuranga.wijesinghe at gmail.com
Tue Nov 8 11:23:05 UTC 2022


Hi,

I have a 3D-CT volume and want to obtain the DRR projection by adjusting
the machine parameters as shown in the image below.

Here's my code, and I didn't get the expected DRRs with the limited FOV. Is
there anything missing from the parameter setup?

Could you please assist me in resolving this issue? Any code level
assistance or advice would be greatly appreciated.

# Loading 3D CT image
CT = itk.imread("./ct.nii.gz", pixel_type=itk.F)

# Defines the image type
Dimension_CT = 3
PixelType = itk.F
ImageType = itk.Image[PixelType, Dimension_CT]

origin_x, origin_y, origin_z = CT.GetOrigin()
space_x, space_y, space_z = CT.GetSpacing()

# Define origin, sizeOutput and spacing (still need to change these)
origin = [origin_x, origin_y, origin_z]
spacing = [space_x, space_y, space_z]

sizeOutput = [ 512, 512, 1]

# Create a stack of empty projection images
ConstantImageSourceType = rtk.ConstantImageSource[ImageType]
constantImageSource = ConstantImageSourceType.New()

constantImageSource.SetOrigin( origin )
constantImageSource.SetSpacing( spacing )
constantImageSource.SetSize( sizeOutput )
constantImageSource.SetConstant(0.)

# Defines the RTK geometry object
geometry = rtk.ThreeDCircularProjectionGeometry.New()
firstAngle = 0.
angularArc = 360.
sid = 1000 # source to isocenter distance
sdd = 1536 # source to detector distance
gantryAngle = 0. # rot around y-axis
projOffsetX = 0.
projOffsetY = 0.
outOfPlaneAngle = 90. # rot around x-axis
inPlaneAngle = 0. # rot around z-axis
sourceOffsetX = 0.
sourceOffsetY = 0.
geometry.AddProjection(sid, sdd, gantryAngle)

REIType = rtk.JosephForwardProjectionImageFilter[ImageType, ImageType]
rei = REIType.New()

rei.SetGeometry( geometry )
rei.SetInput(0, constantImageSource.GetOutput())
rei.SetInput(1, CT)
rei.Update()

Dimension = 3
OutputPixelType = itk.UC
OutputImageType = itk.Image[OutputPixelType, Dimension]

RescaleType = itk.RescaleIntensityImageFilter[ImageType, OutputImageType]
rescaler = RescaleType.New()
rescaler.SetOutputMinimum(0)
rescaler.SetOutputMaximum(255)
rescaler.SetInput(rei.GetOutput())
rescaler.Update()

WriteType = itk.ImageFileWriter[OutputImageType]
writer = WriteType.New()
writer.SetFileName('./drr_0.png')
writer.SetInput(rescaler.GetOutput())
writer.Update()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/rtk-users/attachments/20221108/9ef3f920/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: machine_Steup.png
Type: image/png
Size: 98881 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/rtk-users/attachments/20221108/9ef3f920/attachment-0001.png>


More information about the Rtk-users mailing list