<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Good morning,<BR>
&nbsp;<BR>
I am trying to resample contours and am running into a bit of a problem. The method I am using is as follows: I create a matrix of zeros which is as big as the image set I am looking at. If a contour is present on a particular voxel, I set that voxel's value to 1000. I then use the code below to resample the matrix. The first case I tried was to scale all axial images by 1/2 (keeping offsets constant). When I use the NearestNeighborInterpolateImageFunction, I get the results I expect, with the occasional breaks in the contour. When I switch to the LinearInterpolateImageFunction, my instincts tell me I should get the same contour as before, except with the value of 500 instead of 1000. However, I get the exact same results as with the nearest neighbor method. Same for the BSplineInterpolateImageFunction, which incidentally does take much longer to run.&nbsp;I woul dvery much appreciate it if someone could&nbsp;point me to the mistake I am making, either with the code or with my thought process... Thank you for your help. <BR>
<BR>Vik<BR>
&nbsp;<BR>
Code: <BR>
&nbsp;<BR>
#include "itkImage.h"<BR>#include "itkImageFileReader.h"<BR>#include "itkImageFileWriter.h"<BR>#include "itkResampleImageFilter.h"<BR>#include "itkLinearInterpolateImageFunction.h"<BR>
&nbsp;<BR>
int main( int argc, char * argv[] )<BR>{<BR>&nbsp; if( argc &lt; 3 )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Usage: " &lt;&lt; std::endl;<BR>&nbsp;std::cerr &lt;&lt; argv[0] &lt;&lt; "&nbsp;&nbsp;Resampleto.mhd&nbsp;currentcontour.mhd " &lt;&lt; std::endl; <BR>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<BR>&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;<BR>
&nbsp; const&nbsp;&nbsp;&nbsp;&nbsp; unsigned int&nbsp;&nbsp; Dimension = 3;<BR>&nbsp; typedef&nbsp;&nbsp; unsigned short&nbsp;&nbsp; PixelType;<BR>
&nbsp;<BR>
&nbsp; typedef itk::Image&lt; PixelType,&nbsp; Dimension &gt;&nbsp;&nbsp; FixedImageType;<BR>&nbsp; typedef itk::Image&lt; PixelType,&nbsp; Dimension &gt;&nbsp;&nbsp; MovingImageType;<BR>&nbsp; typedef itk::Image&lt; PixelType,&nbsp; Dimension &gt;&nbsp;&nbsp; OutputImageType;<BR>
<BR>&nbsp; typedef itk::ImageFileReader&lt; FixedImageType&nbsp; &gt;&nbsp; ReaderType;<BR>&nbsp; typedef itk::ImageFileReader&lt; MovingImageType&nbsp; &gt;&nbsp; ReaderType;<BR>&nbsp; typedef itk::ImageFileWriter&lt; OutputImageType &gt;&nbsp; WriterType;<BR>
&nbsp;<BR>
&nbsp; ReaderType::Pointer fixedreader = ReaderType::New();<BR>&nbsp; ReaderType::Pointer movingreader = ReaderType::New();<BR>&nbsp; WriterType::Pointer writer = WriterType::New();<BR>
&nbsp; fixedreader-&gt;SetFileName( argv[1] );<BR>&nbsp; movingreader-&gt;SetFileName( argv[2] );<BR>&nbsp; writer-&gt;SetFileName( "Resampledcontours.mhd" );<BR>
&nbsp; fixedreader-&gt;Update();<BR>
&nbsp;<BR>
&nbsp; typedef itk::ResampleImageFilter&lt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MovingImageType, OutputImageType &gt;&nbsp; FilterType;<BR>&nbsp; FilterType::Pointer filter = FilterType::New();<BR>&nbsp; <BR>&nbsp; typedef itk::IdentityTransform&lt; double, Dimension &gt; TransformType;<BR>&nbsp; TransformType::Pointer transform = TransformType::New();<BR>&nbsp; transform-&gt;SetIdentity();<BR>&nbsp; filter-&gt;SetTransform( transform );<BR>
&nbsp;<BR>
&nbsp; typedef itk::LinearInterpolateImageFunction&lt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MovingImageType, double &gt;&nbsp; InterpolatorType;<BR>&nbsp; InterpolatorType::Pointer interpolator = InterpolatorType::New();<BR>&nbsp; filter-&gt;SetInterpolator( interpolator );<BR>
&nbsp; filter-&gt;SetDefaultPixelValue( 0 );<BR>
&nbsp;<BR>
&nbsp; double spacing[ Dimension ];<BR>
&nbsp; spacing[0] = fixedreader-&gt;GetOutput()-&gt;GetSpacing()[0];<BR>&nbsp; spacing[1] = fixedreader-&gt;GetOutput()-&gt;GetSpacing()[1];<BR>&nbsp; spacing[2] = fixedreader-&gt;GetOutput()-&gt;GetSpacing()[2];<BR>&nbsp; filter-&gt;SetOutputSpacing( spacing );<BR>
&nbsp; <BR>
&nbsp; double origin[ Dimension ];<BR>&nbsp; origin[0] = fixedreader-&gt;GetOutput()-&gt;GetOrigin()[0];<BR>&nbsp; origin[1] = fixedreader-&gt;GetOutput()-&gt;GetOrigin()[1];<BR>&nbsp; origin[2] = fixedreader-&gt;GetOutput()-&gt;GetOrigin()[2];<BR>&nbsp; filter-&gt;SetOutputOrigin( origin );<BR>
&nbsp;<BR>
&nbsp; filter-&gt;SetSize( fixedreader-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize() );<BR>
&nbsp;<BR>
&nbsp; filter-&gt;SetInput( movingreader-&gt;GetOutput() );<BR>&nbsp; <BR>&nbsp; writer-&gt;SetInput( filter-&gt;GetOutput() );<BR>&nbsp;<BR>&nbsp; try <BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; writer-&gt;Update();<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; catch( itk::ExceptionObject &amp; excep )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Exception catched !" &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; excep &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;return EXIT_SUCCESS;<BR>}<BR>
&nbsp;<BR><br /><hr />Stay up to date on your PC, the Web, and your mobile phone with Windows Live. <a href='http://clk.atdmt.com/MRT/go/msnnkwxp1020093185mrt/direct/01/' target='_new'>See Now</a></body>
</html>