RTK icon indicating copy to clipboard operation
RTK copied to clipboard

Python joseph_forward_projection_image_filter does not behave as expected

Open SimonRit opened this issue 3 years ago • 2 comments

The following code works

import itk
from itk import RTK as rtk

ImageType = itk.Image[itk.F,3]
emptyVol = rtk.constant_image_source(origin=[-63.5]*3, size=[128]*3,spacing=[1.]*3,ttype=ImageType)
sl = rtk.draw_shepp_logan_filter(emptyVol)
geometry = rtk.ThreeDCircularProjectionGeometry.New()
geometry.AddProjection(600,1200,0.)
emptyProj = rtk.constant_image_source(origin=[-127,-127,0.], size=[128,128,1],spacing=[2.]*3,ttype=ImageType)

projector = rtk.JosephForwardProjectionImageFilter[ImageType,ImageType].New()
projector.SetInput(0,emptyProj)                                                                                                                                                                                                               
projector.SetInput(1,sl)
projector.SetGeometry(geometry)
projector.Update()

itk.imwrite(projector.GetOutput(), 'projections.mha')

If I also want to use the same syntax for the projector

import itk
from itk import RTK as rtk

ImageType = itk.Image[itk.F,3]
emptyVol = rtk.constant_image_source(origin=[-63.5]*3, size=[128]*3,spacing=[1.]*3,ttype=ImageType)
sl = rtk.draw_shepp_logan_filter(emptyVol)
geometry = rtk.ThreeDCircularProjectionGeometry.New()
geometry.AddProjection(600,1200,0.)
emptyProj = rtk.constant_image_source(origin=[-127,-127,0.], size=[128,128,1],spacing=[2.]*3,ttype=ImageType)
projections = rtk.joseph_forward_projection_image_filter(emptyProj,sl,geometry=geometry)
itk.imwrite(projections, 'projections.mha')

I obtain a seg fault. If I look at help(rtk.joseph_forward_projection_image_filter), I see it is a Proxy of C++ rtkJosephForwardProjectionImageFilterIF3IF3SWMFDFIPC class. (defined in rtkJosephForwardAttenuatedProjectionImageFilter.wrap) which is wrong. I want it to be a proxy for rtkJosephForwardProjectionImageFilterIF3IF3 (defined in rtkJosephForwardProjectionImageFilter.wrap). No clue how to solve this...

SimonRit avatar Oct 28 '21 06:10 SimonRit

@LucasGandel @thewtex, any ideas?

SimonRit avatar Oct 28 '21 06:10 SimonRit

Hi,

I'm facing the same issue with the last version on the Python wrapping.

arobert01 avatar Jun 08 '22 07:06 arobert01