[Insight-users] Problem with itk::ResampleImagefilter

Daanen Vincent daanen at koelis.com
Mon May 17 11:50:39 EDT 2010


Dear Itk users,

I'm facing to a problem to use ItkImageResampler to extract slice from a  3D
image.
The goal is to extract "AXIAL", "CORONAL" or "SAGITTAL" slice from a 3D
image, whatever is its native orientation.

I succeed in extracting Axial, coronal or sagittal slice from a Axial 3D
image but I can't with a coronal 3D image.

Here's what I'm doing.

Say I have a 3D image which is coronal (or closely). Given my input image
orientation close to 
X_Img_3D = (1,0,0), Y_Img_3D = (0,0,-1), Z_Img_3D=(0,1,0), when I want to
extract a patient "axial" image, I have to set output image orientation 
to
 * X_Slice = (1,0,0) ( -> = X_Img_3D)
 * Y_Slice = (0,1,0) ( -> = Z_Img_3D)
 * Z_Slice = (0,0,1) ( -> = -Y_Img_3D)
   

// Get first "Axial"  image
start[0] = 0;		// first index on X
start[1] = 0;		// first index on Y
start[2] = 0;		// first index on Z
		
itk::Point<double,3> l_Org;
m_pImg->TransformIndexToPhysicalPoint(start, l_Org);		// m_pImg is
the input 3D image
m_pResampler->SetOutputOrigin(l_Org);

//! output image Direction
TItkInputImage::DirectionType l_InputImgDir = m_pImg->GetDirection();
TItkInputImage::DirectionType l_SliceDir;

// vector X of slice is vector X of 3D image
l_SliceDir(0,0) = l_Inputdir(0,0);
l_SliceDir(1,0) = l_Inputdir(1,0);
l_SliceDir(2,0) = l_Inputdir(2,0);

// vector Y of slice is vector Z of 3D image
l_SliceDir(0,1) = l_Inputdir(0,2);
l_SliceDir(1,1) = l_Inputdir(1,2);
l_SliceDir(2,1) = l_Inputdir(2,2);

// vector Z of slice is vector -Y of 3D image
l_SliceDir(0,2) = -l_Inputdir(0,1);
l_SliceDir(1,2) = -l_Inputdir(1,1);
l_SliceDir(2,2) = -l_Inputdir(2,1);
m_pResampler->SetOutputDirection(l_SliceDir);

// Spacing -> use minimun scale to get a isotropic slice.
const TItkInputImage::SpacingType &l_InSpacing = m_pImg->GetSpacing();
double l_IsoSpacing =
__min(l_InSpacing[0],__min(l_InSpacing[1],l_InSpacing[2]));
		
TItkOutputImage::SpacingType l_OutSpacing;
l_OutSpacing[0] = l_IsoSpacing;
l_OutSpacing[1] = l_IsoSpacing;
l_OutSpacing[2] = l_IsoSpacing;
m_pResampler->SetOutputSpacing(l_OutSpacing);

// output image size
TItkOutputImage::SizeType l_OutputImgSize = inputRegion.GetSize();
TItkInputImage::SizeType size = inputRegion.GetSize();

l_OutputImgSize[0] = size[0];						//
width of axial image  = width of native image
l_OutputImgSize[1] = size[2]*l_InSpacing[1]/l_IsoSpacing;		//
height of axial image = Depth of native image * slicethickness/pixelsize
l_OutputImgSize[2] = 1; // size along Z

m_pResampler->SetSize( l_OutputImgSize );



Doing so, I get an image with a small part of the native image :(.
I must be missing something but i can't see what;

Is there a itk::ImageResampleFileter guru who could help me ?

Thanks

 Vince


--------------------------------------------
Vincent Daanen, PhD
D&D Manager

--------------------------------------------
KOELIS
5, avenue du Grand Sablon 38700 La Tronche
www.koelis.com  -  daanen at koelis.com
Tel .+33(0) 476637588 Fax .+33(0) 476637592
--------------------------------------------

CONFIDENTIALITY This e-mail and any attachments are confidential and may
also be privileged. If you are not the named recipient, please notify the
sender immediately and do not disclose the contents to another person, use
it for any purpose, or store or copy the information in any medium.

"Les problèmes ne peuvent être résolus par ceux dont l'horizon se limite aux
réalités quotidiennes,  mais par ceux qui rêvent de choses qui n'ont jamais
existé et qui se disent : Pourquoi Pas ?" (J-F Kennedy, 1963). 



More information about the Insight-users mailing list