[Insight-developers] down sampling

kevin cavin beibeiwen2003 at yahoo.com
Fri Jul 10 09:19:48 EDT 2009


Hello, 
 
   I am using Resamplefilter to downsampling my 3D volume in order to register two volumes.  Without downsampling and with less slices , I get two volume registered. With downsampling, the registered result is non sense (empty image). I am woderning where goes wrong? Maybe somepeople can help me. Thanks!
 
wen 
 
 I attach part of code 
 
factorX = 2
factorY = 2
factorZ = 1
inputSpacing1 = windowing1.GetOutput().GetSpacing()
inputSpacing2 = windowing2.GetOutput().GetSpacing()
resampler1 =itk.ResampleImageFilter.IF3IF3.New()
resampler2 =itk.ResampleImageFilter.IF3IF3.New()
transform=itk.IdentityTransform.D3.New()
transform.SetIdentity()
resampler1.SetTransform( transform.GetPointer() )
resampler2.SetTransform( transform.GetPointer() )
interpolator1=itk.LinearInterpolateImageFunction.IF3D.New()
resampler1.SetInterpolator( interpolator1.GetPointer() )
resampler1.SetDefaultPixelValue( 0 )

interpolator2=itk.LinearInterpolateImageFunction.IF3D.New()
resampler2.SetInterpolator( interpolator2.GetPointer() )
resampler2.SetDefaultPixelValue( 0 )

spacing1=itk.Vector.D3()
spacing2=itk.Vector.D3()

spacing1.SetElement(0,inputSpacing1.GetElement(0) * factorX)
spacing1.SetElement(1,inputSpacing1.GetElement(1) * factorY)
spacing1.SetElement(2,inputSpacing1.GetElement(2) * factorZ)
spacing2.SetElement(0,inputSpacing2.GetElement(0) * factorX)
spacing2.SetElement(1,inputSpacing2.GetElement(1) * factorY)
spacing2.SetElement(2,inputSpacing2.GetElement(2) * factorZ)

resampler1.SetOutputSpacing( spacing1 )
resampler1.SetOutputOrigin( windowing1.GetOutput().GetOrigin() )
resampler1.SetOutputDirection( windowing1.GetOutput().GetDirection() )
resampler2.SetOutputSpacing( spacing2 )
resampler2.SetOutputOrigin( windowing2.GetOutput().GetOrigin() )
resampler2.SetOutputDirection( windowing2.GetOutput().GetDirection() )

inputSize= windowing1.GetOutput().GetLargestPossibleRegion().GetSize()
print "X size : %f" % (inputSize.GetElement(0), )
print "Y size : %f" % (inputSize.GetElement(1), )
print "Z size : %f" % (inputSize.GetElement(2), )
size=itk.FixedArray.D3()
new_x=inputSize.GetElement(0)/factorX
new_y=inputSize.GetElement(1)/factorY
new_z=inputSize.GetElement(2)/factorZ 

inputSize.SetElement(0,  int(new_x))
inputSize.SetElement(1,  int(new_y))
inputSize.SetElement(2,  int(new_z))
resampler1.SetSize( inputSize  )
resampler1.SetInput( windowing1.GetOutput() )
resampler2.SetSize( inputSize  )
resampler2.SetInput( windowing2.GetOutput() )



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20090710/9cf92743/attachment.htm>


More information about the Insight-developers mailing list