[Insight-users] Writing Resampled Images With New Orientation

Kon Z mnkz at comp.leeds.ac.uk
Mon May 18 08:01:15 EDT 2009


Hello ALL,

When I use ResampleImageFilter to resample an 3D image with a new 
direction matrix

resampler->SetOutputDirection(directionMatrix);

the filter output shows the specified orientation (with the values I 
specify in the direction matrix):

   Direction:
0.529919 0.46188 -0.711233
0 0.838671 0.544639
0.848048 -0.288615 0.444428

However, when I pass resample filter output to a writer connected to 
GDCMImageIO, the saved volume has this orientation (the direction matrix 
is transposed!):

   Direction:
0.529919 0 0.848048
0.46188 0.838671 -0.288615
-0.711233 0.544639 0.444428

Am I doing something wrong? Or am I not doing something I'm supposed to 
do with the image before passing it to the writer? Can someone please 
explain it to me?

For the moment I use this workaround I found in the ITK Guide:
itk::EncapsulateMetaData<std::string>(
	resampler->GetOutput()->GetMetaDataDictionary(),
	"0020|0037", // Patient orientation tag.
	directionStream.str().c_str());

where directionStream contains the correct string representation of the 
directionMatrix.

Thanks.

Best regards,
Kon Z





More information about the Insight-users mailing list