[Rtk-users] RTK-user

Simon Rit simon.rit at creatis.insa-lyon.fr
Mon Apr 17 09:08:25 CEST 2017


Hi,
GetImageFromArray seems to be the good solution. Can you give the code that
doesn't work (instead of copy pasting what works from the wiki)?
Simon

On Sun, Apr 16, 2017 at 10:27 PM, sare Borhani <sareh.borhani at gmail.com>
wrote:

> Dear RTK.User,
>
> I'm using python wrapped version of RTK.
>
> I used the only example of that for reconstruction.It works perfectly.
> The problem is that I need to simulate an artifact on projection 2D
> images, so first I got each 2D images of stack reiImage by
> *srtk.GetArrayFromImage(reiImage) *and then I applied a polynomial on
> that to simulate an artifact.NOW need to extract these artifacted-images
> again to the simpleRTK image to be able to reconstruct it at the end. I
> thought maybe *srtk.GetImageFromArray* works, but it doesn't.Can you pls
> help me.I'm really hopeless.
>
> Here is the Example;
>
> from __future__ import print_functionimport SimpleRTK as srtkimport sysimport osimport matplotlib.pyplot as pltimport matplotlib.cm as cm
>  if len ( sys.argv ) < 2:
>     print( "Usage: RTKFirstReconstruction <output>" )
>     sys.exit ( 1 )
>  # Defines the RTK geometry object
> geometry = srtk.ThreeDCircularProjectionGeometry()
> numberOfProjections = 360
> firstAngle = 0
> angularArc = 360
> sid = 600 # source to isocenter distance in mm
> sdd = 1200 # source to detector distance in mm
> isox = 0 # X coordinate on the projection image of isocenter
> isoy = 0 # Y coordinate on the projection image of isocenterfor x in range(0,numberOfProjections):
>   angle = firstAngle + x * angularArc / numberOfProjections
>   geometry.AddProjection(sid,sdd,angle,isox,isoy)
>
> constantImageSource = srtk.ConstantImageSource()
> origin = [ -127.5, -127.5, 0. ]
> sizeOutput = [ 256, 256,  numberOfProjections ]
> spacing = [ 1.0, 1.0, 1.0 ]
> constantImageSource.SetOrigin( origin )
> constantImageSource.SetSpacing( spacing )
> constantImageSource.SetSize( sizeOutput )
> constantImageSource.SetConstant(0.0)
> source = constantImageSource.Execute()
>
> rei = srtk.RayEllipsoidIntersectionImageFilter()
> semiprincipalaxis = [ 50, 50, 50]
> center = [ 0, 0, 0]# Set GrayScale value, axes, center...
> rei.SetDensity(20)
> rei.SetAngle(0)
> rei.SetCenter(center)
> rei.SetAxis(semiprincipalaxis)
> rei.SetGeometry( geometry )
> reiImage = rei.Execute(source)
>  # Create reconstructed image
> constantImageSource2 = srtk.ConstantImageSource()
> origin = [ -63.5, -63.5, -63.5 ]
> sizeOutput = [ 128, 128, 128 ]
> constantImageSource2.SetOrigin( origin )
> constantImageSource2.SetSpacing( spacing )
> constantImageSource2.SetSize( sizeOutput )
> constantImageSource2.SetConstant(0.0)
> source2 = constantImageSource2.Execute()
>  print("Performing reconstruction")
> feldkamp = srtk.FDKConeBeamReconstructionFilter()
> feldkamp.SetGeometry( geometry );
> feldkamp.SetTruncationCorrection(0.0);
> feldkamp.SetHannCutFrequency(0.0);
> image = feldkamp.Execute(source2,reiImage)
>  print("Masking field-of-view")
> fov = srtk.FieldOfViewImageFilter()
> fov.SetGeometry(geometry)
> fov.SetProjectionsStack(reiImage)
> image = fov.Execute(image)
>
> plt.imshow(srtk.GetArrayFromImage(image[:,64,:]), cmap = cm.Greys_r)
> plt.show()
>
> writer = srtk.ImageFileWriter()
> writer.SetFileName ( sys.argv[1] )
> writer.Execute ( image );
>
> http://wiki.openrtk.org/index.php/SimpleRTK
>
>
> Thank you in advance.
>
>
> Best regards,
> Sareh Borhani
>
> _______________________________________________
> Rtk-users mailing list
> Rtk-users at public.kitware.com
> http://public.kitware.com/mailman/listinfo/rtk-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.creatis.insa-lyon.fr/pipermail/rtk-users/attachments/20170417/024b8773/attachment.htm>


More information about the Rtk-users mailing list