[Insight-users] Sub sampling

cspl affable@hd2.dot.net.in
Sat, 26 Apr 2003 11:14:51 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C30BE5.0E5ABDB0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Luis,

    I have worked on subsampling the 2d-image. But i didn't get the =
subsampled output but a part of the image with given dimensions. I am =
using "ResampleImageFilter" to resample the image. If i give the size of =
the image to the half of the original image, it is giving the left top =
half part of the image but it is not actually shrinking the image. I =
even tried with by decreasing the spacing to its half.=20

    I have gone through the examples on resampleimagefilter in =
..\Examples\Filtering\ path.

   My code is...

 finalTransform->SetIdentity();
 resample->SetTransform( finalTransform );
 resample->SetInput(FixedImage);
 unsigned long ss[2] =3D {pInput.width / 2, pInput.height / 2};
 ImageType::SizeType Size =3D =
FixedImage->GetLargestPossibleRegion().GetSize();
 Size[0] =3D ss[0];
 Size[1] =3D ss[1];
 resample->SetSize( Size );
 resample->SetOutputOrigin(  FixedImage->GetOrigin() );
 double * spacing =3D new double [ Dimension ];
 spacing =3D (double *)FixedImage->GetSpacing();
 spacing[0] /=3D 2;=20
 spacing[1] /=3D 2;
 resample->SetOutputSpacing( spacing );
 resample->SetInterpolator( interpolator );
 resample->SetDefaultPixelValue( 0 );
 resample->Update();

     I am using NearestNeighbout interpolator and Centered affine =
transform.

    What else i have to add to my code to subsample the image.

    Please help me in this regard.

    Thanks in advance.

-Regards,
   Sateesh.
   =20


------=_NextPart_000_000D_01C30BE5.0E5ABDB0
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 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Luis,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; I have worked on =
subsampling the=20
2d-image. But i didn't get the subsampled output but a part of the image =
with=20
given dimensions. I am using "ResampleImageFi</FONT><FONT face=3DArial=20
size=3D2>lter" to resample the image. If i give the size of the image to =
the half=20
of the original image, it is giving the left top half part of the image =
but it=20
is not actually shrinking the image. I even tried with by decreasing the =
spacing=20
to its half. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; I have gone through =
the examples=20
on resampleimagefilter in ..\Examples\Filtering\ path.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; My code is...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;finalTransform-&gt;SetIdentity();<BR>&nbsp;resample-&gt;Se=
tTransform(=20
finalTransform =
);<BR>&nbsp;resample-&gt;SetInput(FixedImage);<BR>&nbsp;unsigned=20
long ss[2] =3D {pInput.width / 2, pInput.height / =
2};<BR>&nbsp;ImageType::SizeType=20
Size =3D =
FixedImage-&gt;GetLargestPossibleRegion().GetSize();<BR>&nbsp;Size[0] =
=3D=20
ss[0];<BR>&nbsp;Size[1] =3D ss[1];<BR>&nbsp;resample-&gt;SetSize( Size=20
);<BR>&nbsp;resample-&gt;SetOutputOrigin(&nbsp; =
FixedImage-&gt;GetOrigin()=20
);<BR>&nbsp;double * spacing =3D new double [ Dimension =
];<BR>&nbsp;spacing =3D=20
(double *)FixedImage-&gt;GetSpacing();<BR>&nbsp;spacing[0] /=3D 2;=20
<BR>&nbsp;spacing[1] /=3D 2;<BR>&nbsp;resample-&gt;SetOutputSpacing( =
spacing=20
);<BR>&nbsp;resample-&gt;SetInterpolator( interpolator=20
);<BR>&nbsp;resample-&gt;SetDefaultPixelValue( 0=20
);<BR>&nbsp;resample-&gt;Update();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp; I am using=20
NearestNeighbout interpolator and Centered affine =
transform.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; What else i have to =
add to my=20
code to subsample the image.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Please help me in =
this=20
regard.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; Thanks in =
advance.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-Regards,<BR>&nbsp;&nbsp;=20
Sateesh.<BR>&nbsp;&nbsp;&nbsp; <BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_000D_01C30BE5.0E5ABDB0--