[Insight-users] Resampler filter giving blank output

darkflame2000 at libero.it darkflame2000 at libero.it
Thu Oct 8 05:42:06 EDT 2009


Hi all,

I'm tryng to resample a 3d image with unsigned short pixel type, but the output results a blank image. I'm sure that it's not a visualization problem because I've tried to read the image with a viewer that it's able to read images like this.
My code is something like that:


typedef itk::Image<unsigned short, 3> AtlasImageType;
typedef itk::ResampleImageFilter<AtlasImageType, AtlasImageType> ResamplerType;
typedef itk::AffineTransform<double, 3> TransformType;
typedef itk::NearestNeighborInterpolateImageFunction<AtlasImageType, double> InterpolatorType;



ResamplerType::Pointer resampler1 = ResamplerType::New();
TransformType::Pointer transform1 = TransformType::New();
InterpolatorType::Pointer interpolator1 = InterpolatorType::New();
 
resampler1->SetInterpolator( interpolator1 );

	
const AtlasImageType::SpacingType& spacing1 = InputImage -> GetSpacing();
	
const AtlasImageType::PointType& origin1 = InputImage -> GetOrigin();
	
const AtlasImageType::SizeType& size1 = InputImage -> GetLargestPossibleRegion().GetSize();
	
resampler1 -> SetOutputDirection ( InputImage -> GetDirection () );
resampler1 -> SetOutputSpacing ( spacing1 );
resampler1 -> SetOutputOrigin ( origin1 );
resampler1 -> SetSize ( size1 ); 
resampler1 -> SetInput ( InputImage );

const double imageCenterX = origin1[0] + spacing1[0] * size1[0] / 2.0;
const double imageCenterY = origin1[1] + spacing1[1] * size1[1] / 2.0;
const double imageCenterZ = origin1[2] + spacing1[2] * size1[2] / 2.0;
	
TransformType::OutputVectorType translation1;

translation1[0] = - imageCenterX;
translation1[1] = - imageCenterY;
translation1[2] = - imageCenterZ;

transform1 ->Translate ( translation1 );

TransformType :: OutputVectorType vers;
vers[0] = 0;
vers[1] = 0;
vers[2] = 1;

double angleInDegrees = 180;  
const double degreesToRadians = vcl_atan(1.0) / 45.0;
const double angle = angleInDegrees * degreesToRadians;
transform1 -> Rotate3D( vers, - angle , false );
 
TransformType::OutputVectorType translation2;

translation2[0] = imageCenterX;
translation2[1] = imageCenterY;
translation2[2] = imageCenterZ;
	
transform1 -> Translate ( translation2 , false );

resampler1 -> SetTransform ( transform1 );





Any hints???

Andrea

    
	

    	



More information about the Insight-users mailing list