[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> </DIV>
<DIV><FONT face=3DArial size=3D2> I have been using the =
ResampleImageFilter of=20
ITK to resample an image (source/input) with the following=20
properties<BR> Width =3D 128 VoxelWidth =3D=20
4.296875<BR> Height =3D 128 VoxelHeight =3D=20
4.296875<BR> Depth =3D 35 VoxelDepth =3D =
4.25</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> into an image =
(destination/output) with the=20
following properties<BR> Width =3D 512 VoxelWidth =3D=20
0.976562<BR> Height =3D 512 VoxelHeight =3D=20
0.976562<BR> Depth =3D 35 VoxelDepth =3D =
4.25</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> I have set the other values for =
the filter as=20
follows:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> typedef=20
itk::ResampleImageFilter<InputImageType,OutputImageType=20
> =
ResampleFilterType;<BR> ResampleFilterType::Pointer=20
resampler =3D ResampleFilterType::New();<BR> <BR> typedef=20
itk::AffineTransform<double,3>=20
TransformType;<BR> TransformType::Pointer transform =3D=20
TransformType::New();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial=20
size=3D2> transform->SetIdentity();<BR> resampler->SetTra=
nsform(=20
transform );<BR> resampler->SetInput( Mask ); // Mask is=20
InputImageType</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> // Output image spacing : =
(0.976562,=20
0.976562, 4.25)<BR> double Spacing[ 3 ] =3D { voxelWidth, =
voxelHeight,=20
voxelDepth };</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> // Output image size : (512, 512, =
35)<BR> int fSize[ 3 ] =3D { width, height, depth };</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> double Origin[ 3 ] =3D { 0, 0, 0=20
};</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> InputImageType::SizeType=20
Size;<BR> Size[0] =3D fSize[0];<BR> Size[1] =3D =
fSize[1];<BR> Size[2]=20
=3D fSize[2];</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> typedef=20
itk::NearestNeighborInterpolateImageFunction<=20
<BR> &nb=
sp; =20
InputImageType, double> =20
InterpolatorType;<BR> InterpolatorType::Pointer interpolator =3D=20
InterpolatorType::New();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> resampler->SetSize( Size=20
);<BR> resampler->SetOutputOrigin( Origin=20
);<BR> resampler->SetDefaultPixelValue( 0=20
);<BR> resampler->SetOutputSpacing( Spacing=20
);<BR> resampler->SetInterpolator(interpolator);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> After executing the above code, =
the mask=20
appears to have shifted down and right.<BR> What could the reason =
be? Is it=20
the pixel spacing?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> I tried giving the values 1 and =
0.8 for the=20
spacing values in the above code.<BR> 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> </DIV>
<DIV><FONT face=3DArial size=3D2> The same code has given an output =
of our=20
satisfaction for the following<BR> Input =
Image:<BR> Width =3D=20
128 VoxelWidth =3D 3.90625<BR> Height =3D =
128 VoxelHeight =3D=20
3.90625<BR> Depth =3D 35 VoxelDepth =3D =
4.25 </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> Output =
Image:<BR> Width =3D=20
512 VoxelWidth =3D 0.976562<BR> Height =3D =
512 VoxelHeight =3D=20
0.976562<BR> Depth =3D 35 VoxelDepth =3D=20
4.25 <BR> <BR> In both the above cases the data type of =
input and=20
output images is "short".<BR> Please help me out with this =
situation=20
sir.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>bye,<BR> Rama=20
Krishna.</FONT></DIV></BODY></HTML>
------=_NextPart_000_000B_01C3E698.53D8F210--