[Insight-users] WG: Problem with the warp image filter

Merrem, Andreas andreas.merrem at medma.uni-heidelberg.de
Thu Jun 10 08:41:43 EDT 2010


 Hi, 

I solved my problem by setting the parameter "direction" in addition to the others, I hadn't done that before. 
Sorry for bothering you with all those emails,

Andreas

-----Ursprüngliche Nachricht-----
Von: Merrem, Andreas 
Gesendet: Mittwoch, 9. Juni 2010 20:42
An: 'Luis Ibanez'; 'insight-users at itk.org'
Betreff: AW: Problem with the warp image filter

Well, please think of the code without those format problems...
One more try: 

typedef itk::WarpImageFilter <ImageType,ImageType,DeformationFieldType> ResamplerType; typedef itk::LinearInterpolateImageFunction <ImageType, ouble> LinearInterpolatorType;

LinearInterpolatorType::Pointer LinearInterpolator=LinearInterpolatorType::New();
ResamplerType::Pointer resampler=ResamplerType::New(); ImageType::Pointer ResampledImage=ImageType::New();
 
resampler->SetInterpolator(LinearInterpolator);
resampler->SetOutputSpacing (InputImage->GetSpacing()); 
resampler->SetOutputOrigin(InputImage->GetOrigin());
resampler->SetDeformationField (DeformationField); SetInput(InputImage); 
resampler->Update();
ResampledImage=resampler->GetOutput();

-----Ursprüngliche Nachricht-----
Von: Merrem, Andreas
Gesendet: Mittwoch, 9. Juni 2010 20:34
An: 'Luis Ibanez'; insight-users at itk.org
Betreff: WG: Problem with the warp image filter

 
Sorry, I guess I had a little format problem in the code. It should be: 

typedef itk::WarpImageFilter <ImageType, ImageType, DeformationFieldType> ResamplerType; typedef itk::LinearInterpolateImageFunction <ImageType, double> LinearInterpolatorType;

LinearInterpolatorType::Pointer LinearInterpolator = LinearInterpolatorType::New(); ResamplerType::Pointer resampler = ResamplerType::New(); ImageType::Pointer ResampledImage = ImageType::New(); 

resampler-> SetInterpolator(LinearInterpolator);
resampler-> SetOutputSpacing (InputImage->GetSpacing()); 
resampler-> SetOutputOrigin(InputImage->GetOrigin());
resampler-> SetDeformationField (DeformationField); SetInput 
resampler-> (InputImage); Update();

ResampledImage = resampler-> GetOutput();

Anyway, those typos were not the problem in my program. 

Thanks, 

Andreas



-----Ursprüngliche Nachricht-----
Von: Merrem, Andreas
Gesendet: Mittwoch, 9. Juni 2010 20:27
An: 'Luis Ibanez'; insight-users at itk.org
Betreff: Problem with the warp image filter

Hi Luis (I'm very happy about help from anyone who has an idea),

Thanks a lot for your previous help. 
I have tried to use the itk::WarpImageFilter on a 3D DICOM volume with origin [-199.071, 3.32761, 170.176] and spacing [1.5626, 1.5625, 4]. For testing, I used a deformation field filled with zero vectors to output the same image I put in.

It works perfectly for 2D png images with spacing [1,1] and origin [0,0]. However, when I try to warp the dicom volume with the exact same procedure, the resampled image contains only pixel values of 0. In both cases, I set the origin and spacing of the deformation field and of the output image equal to those of the input image. 

I have no idea what causes this problem, and I have verified that it has nothing to do with reading or writing the image files.     

I set up the filter in the following way:


typedef itk::WarpImageFilter <ImageType, ImageType, DeformationFieldType>ResamplerType;
typedef itk::LinearInterpolateImageFunction <ImageType, double> LinearInterpolatorType;

LinearInterpolatorType::Pointer LinearInterpolator = LinearInterpolatorType::New(); ResamplerType::Pointer resampler = ResamplerType::New(); ImageType::Pointer ResampledImage = ImageType::New(); 

resampler-> SetInterpolator(LinearInterpolator);
resampler-> SetOutputSpacing (InputImage->GetSpacing()); SetOutputOrigin 
resampler-> (InputImage->GetOrigin()); SetDeformationField 
resampler-> (DeformationField); SetInput (InputImage); Update();

ResampledImage = resampler-> GetOutput();

This is really a bit mysterious to me, so if you see what I am missing, that would be very helpful. 
  
Best regards, 

Andreas


More information about the Insight-users mailing list