<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>
<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. I woul dvery much appreciate it if someone could 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>
<BR>
Code: <BR>
<BR>
#include "itkImage.h"<BR>#include "itkImageFileReader.h"<BR>#include "itkImageFileWriter.h"<BR>#include "itkResampleImageFilter.h"<BR>#include "itkLinearInterpolateImageFunction.h"<BR>
<BR>
int main( int argc, char * argv[] )<BR>{<BR> if( argc < 3 )<BR> {<BR> std::cerr << "Usage: " << std::endl;<BR> std::cerr << argv[0] << " Resampleto.mhd currentcontour.mhd " << std::endl; <BR> return EXIT_FAILURE;<BR> }<BR>
<BR>
const unsigned int Dimension = 3;<BR> typedef unsigned short PixelType;<BR>
<BR>
typedef itk::Image< PixelType, Dimension > FixedImageType;<BR> typedef itk::Image< PixelType, Dimension > MovingImageType;<BR> typedef itk::Image< PixelType, Dimension > OutputImageType;<BR>
<BR> typedef itk::ImageFileReader< FixedImageType > ReaderType;<BR> typedef itk::ImageFileReader< MovingImageType > ReaderType;<BR> typedef itk::ImageFileWriter< OutputImageType > WriterType;<BR>
<BR>
ReaderType::Pointer fixedreader = ReaderType::New();<BR> ReaderType::Pointer movingreader = ReaderType::New();<BR> WriterType::Pointer writer = WriterType::New();<BR>
fixedreader->SetFileName( argv[1] );<BR> movingreader->SetFileName( argv[2] );<BR> writer->SetFileName( "Resampledcontours.mhd" );<BR>
fixedreader->Update();<BR>
<BR>
typedef itk::ResampleImageFilter<<BR> MovingImageType, OutputImageType > FilterType;<BR> FilterType::Pointer filter = FilterType::New();<BR> <BR> typedef itk::IdentityTransform< double, Dimension > TransformType;<BR> TransformType::Pointer transform = TransformType::New();<BR> transform->SetIdentity();<BR> filter->SetTransform( transform );<BR>
<BR>
typedef itk::LinearInterpolateImageFunction< <BR> MovingImageType, double > InterpolatorType;<BR> InterpolatorType::Pointer interpolator = InterpolatorType::New();<BR> filter->SetInterpolator( interpolator );<BR>
filter->SetDefaultPixelValue( 0 );<BR>
<BR>
double spacing[ Dimension ];<BR>
spacing[0] = fixedreader->GetOutput()->GetSpacing()[0];<BR> spacing[1] = fixedreader->GetOutput()->GetSpacing()[1];<BR> spacing[2] = fixedreader->GetOutput()->GetSpacing()[2];<BR> filter->SetOutputSpacing( spacing );<BR>
<BR>
double origin[ Dimension ];<BR> origin[0] = fixedreader->GetOutput()->GetOrigin()[0];<BR> origin[1] = fixedreader->GetOutput()->GetOrigin()[1];<BR> origin[2] = fixedreader->GetOutput()->GetOrigin()[2];<BR> filter->SetOutputOrigin( origin );<BR>
<BR>
filter->SetSize( fixedreader->GetOutput()->GetLargestPossibleRegion().GetSize() );<BR>
<BR>
filter->SetInput( movingreader->GetOutput() );<BR> <BR> writer->SetInput( filter->GetOutput() );<BR> <BR> try <BR> {<BR> writer->Update();<BR> }<BR> catch( itk::ExceptionObject & excep )<BR> {<BR> std::cerr << "Exception catched !" << std::endl;<BR> std::cerr << excep << std::endl;<BR> }<BR>
return EXIT_SUCCESS;<BR>}<BR>
<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>