[Insight-users] Problem with ResampleImageFilter

CSPL hyd2_affable at sancharnet.in
Thu, 29 Jan 2004 18:47:21 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C3E698.53D8F210
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello Luis,

 I have been using the ResampleImageFilter of ITK to resample an image =
(source/input) with the following properties
  Width =3D 128 VoxelWidth =3D 4.296875
  Height =3D 128 VoxelHeight =3D 4.296875
  Depth =3D 35 VoxelDepth =3D 4.25

 into an image (destination/output) with the following properties
  Width =3D 512 VoxelWidth =3D 0.976562
  Height =3D 512 VoxelHeight =3D 0.976562
  Depth =3D 35 VoxelDepth =3D 4.25

 I have set the other values for the filter as follows:

 typedef itk::ResampleImageFilter<InputImageType,OutputImageType >    =
ResampleFilterType;
 ResampleFilterType::Pointer resampler =3D ResampleFilterType::New();
=20
 typedef itk::AffineTransform<double,3> TransformType;
 TransformType::Pointer transform =3D TransformType::New();

 transform->SetIdentity();
 resampler->SetTransform( transform );
 resampler->SetInput( Mask ); // Mask is InputImageType

 // Output image spacing : (0.976562, 0.976562, 4.25)
 double Spacing[ 3 ] =3D { voxelWidth, voxelHeight, voxelDepth };

 // Output image size : (512, 512, 35)
 int fSize[ 3 ] =3D { width, height, depth };

 double Origin[ 3 ] =3D { 0, 0, 0 };

 InputImageType::SizeType Size;
 Size[0] =3D fSize[0];
 Size[1] =3D fSize[1];
 Size[2] =3D fSize[2];

 typedef itk::NearestNeighborInterpolateImageFunction<=20
                       InputImageType, double>  InterpolatorType;
 InterpolatorType::Pointer interpolator =3D InterpolatorType::New();

 resampler->SetSize( Size );
 resampler->SetOutputOrigin( Origin );
 resampler->SetDefaultPixelValue( 0 );
 resampler->SetOutputSpacing( Spacing );
 resampler->SetInterpolator(interpolator);

 After executing the above code, the mask appears to have shifted down =
and right.
 What could the reason be? Is it the pixel spacing?

 I tried giving the values 1 and 0.8 for the spacing values in the above =
code.
 When I did that the mask completely disappeared from the image. That is =
why I thought pixel spacing is the reason for the shift in the output.

 The same code has given an output of our satisfaction for the following
 Input Image:
  Width =3D 128 VoxelWidth =3D 3.90625
  Height =3D 128 VoxelHeight =3D 3.90625
  Depth =3D 35 VoxelDepth =3D 4.25=20

 Output Image:
  Width =3D 512 VoxelWidth =3D 0.976562
  Height =3D 512 VoxelHeight =3D 0.976562
  Depth =3D 35 VoxelDepth =3D 4.25=20
=20
 In both the above cases the data type of input and output images is =
"short".
 Please help me out with this situation sir.

bye,
 Rama Krishna.

------=_NextPart_000_000B_01C3E698.53D8F210
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello Luis,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;I have been using the =
ResampleImageFilter of=20
ITK to resample an image (source/input) with the following=20
properties<BR>&nbsp;&nbsp;Width =3D 128&nbsp;VoxelWidth =3D=20
4.296875<BR>&nbsp;&nbsp;Height =3D 128&nbsp;VoxelHeight =3D=20
4.296875<BR>&nbsp;&nbsp;Depth =3D 35&nbsp;VoxelDepth =3D =
4.25</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;into an image =
(destination/output) with the=20
following properties<BR>&nbsp;&nbsp;Width =3D 512&nbsp;VoxelWidth =3D=20
0.976562<BR>&nbsp;&nbsp;Height =3D 512&nbsp;VoxelHeight =3D=20
0.976562<BR>&nbsp;&nbsp;Depth =3D 35&nbsp;VoxelDepth =3D =
4.25</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;I have set the other values for =
the filter as=20
follows:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;typedef=20
itk::ResampleImageFilter&lt;InputImageType,OutputImageType=20
&gt;&nbsp;&nbsp;&nbsp; =
ResampleFilterType;<BR>&nbsp;ResampleFilterType::Pointer=20
resampler =3D ResampleFilterType::New();<BR>&nbsp;<BR>&nbsp;typedef=20
itk::AffineTransform&lt;double,3&gt;=20
TransformType;<BR>&nbsp;TransformType::Pointer&nbsp;transform&nbsp;=3D=20
TransformType::New();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;transform-&gt;SetIdentity();<BR>&nbsp;resampler-&gt;SetTra=
nsform(=20
transform );<BR>&nbsp;resampler-&gt;SetInput( Mask );&nbsp;// Mask is=20
InputImageType</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;// Output image spacing : =
(0.976562,=20
0.976562, 4.25)<BR>&nbsp;double Spacing[ 3 ] =3D { voxelWidth, =
voxelHeight,=20
voxelDepth };</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;// Output image size : (512, 512, =

35)<BR>&nbsp;int fSize[ 3 ] =3D { width, height, depth };</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;double Origin[ 3 ] =3D { 0, 0, 0=20
};</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;InputImageType::SizeType=20
Size;<BR>&nbsp;Size[0] =3D fSize[0];<BR>&nbsp;Size[1] =3D =
fSize[1];<BR>&nbsp;Size[2]=20
=3D fSize[2];</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;typedef=20
itk::NearestNeighborInterpolateImageFunction&lt;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
InputImageType, double&gt;&nbsp;=20
InterpolatorType;<BR>&nbsp;InterpolatorType::Pointer interpolator =3D=20
InterpolatorType::New();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;resampler-&gt;SetSize( Size=20
);<BR>&nbsp;resampler-&gt;SetOutputOrigin( Origin=20
);<BR>&nbsp;resampler-&gt;SetDefaultPixelValue( 0=20
);<BR>&nbsp;resampler-&gt;SetOutputSpacing( Spacing=20
);<BR>&nbsp;resampler-&gt;SetInterpolator(interpolator);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;After executing the above code, =
the mask=20
appears to have shifted down and right.<BR>&nbsp;What could the reason =
be? Is it=20
the pixel spacing?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;I tried giving the values 1 and =
0.8 for the=20
spacing values in the above code.<BR>&nbsp;When I did that the mask =
completely=20
disappeared from the image. That is why I thought pixel spacing is the =
reason=20
for the shift in the output.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;The same code has given an output =
of our=20
satisfaction for the following<BR>&nbsp;Input =
Image:<BR>&nbsp;&nbsp;Width =3D=20
128&nbsp;VoxelWidth =3D 3.90625<BR>&nbsp;&nbsp;Height =3D =
128&nbsp;VoxelHeight =3D=20
3.90625<BR>&nbsp;&nbsp;Depth =3D 35&nbsp;VoxelDepth =3D =
4.25&nbsp;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;Output =
Image:<BR>&nbsp;&nbsp;Width =3D=20
512&nbsp;VoxelWidth =3D 0.976562<BR>&nbsp;&nbsp;Height =3D =
512&nbsp;VoxelHeight =3D=20
0.976562<BR>&nbsp;&nbsp;Depth =3D 35&nbsp;VoxelDepth =3D=20
4.25&nbsp;<BR>&nbsp;<BR>&nbsp;In both the above cases the data type of =
input and=20
output images is "short".<BR>&nbsp;Please help me out with this =
situation=20
sir.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>bye,<BR>&nbsp;Rama=20
Krishna.</FONT></DIV></BODY></HTML>

------=_NextPart_000_000B_01C3E698.53D8F210--