[Insight-users] Boundary problem when resampling?

Bill Lorensen bill.lorensen at gmail.com
Fri Nov 13 11:12:42 EST 2009


Statring in 3.16 we made the default for
ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY to be ON.

In 3.14 the default was OFF. If you have not turned this on in your
build, can you try that.

Bill

On Fri, Nov 13, 2009 at 11:02 AM, stan <stan.oubel at gmail.com> wrote:
> I'm using itk 3.14 ...
>
>
> Le vendredi 13 novembre 2009 à 10:52 -0500, Bill Lorensen a écrit :
>> What version of itk are you using?
>>
>> On Fri, Nov 13, 2009 at 10:13 AM, stan <stan.oubel at gmail.com> wrote:
>> > Dear all,
>> >
>> > I'm using the ITK resampling filter to upscale 3D images
>> > (BSplineInterpolateImageFunction).
>> >
>> > I encountered two problems with this filter:
>> >
>> > - there is a misregistration between high-resolution images and
>> > resampled low-resolution images. To correct that, I modified the origin
>> > ( origin = origin - spacing/2). Now images are well registered,
>> >
>> > - but now, there is a problem at image boundaries. All voxels close to
>> > the boundary (less than spacing/2 in all directions) are set to zero.
>> > This is incorrect since the size of the low-resolution have been setup
>> > to be exactly a multiple of the high-resolution image size.
>> >
>> > Here a screenshot and some code I use.
>> >
>> > Thank you
>> >
>> > stan
>> >
>> >
>> >
>> >  typedef short      PixelType;
>> >  const   unsigned int        Dimension = 3;
>> >  typedef itk::Image< PixelType, Dimension >    ImageType;
>> >  typedef itk::ImageFileReader< ImageType >  ReaderType;
>> >  typedef itk::ImageFileWriter< ImageType >  WriterType;
>> >  ReaderType::Pointer reader = ReaderType::New();
>> >  ReaderType::Pointer reader_input = ReaderType::New();
>> >  WriterType::Pointer writer = WriterType::New();
>> >
>> >  //Reading reference image
>> >  reader->SetFileName( reference_file  );
>> >  reader->Update();
>> >  ImageType::Pointer referenceImage = reader->GetOutput();
>> >
>> >  //Reading input image
>> >  reader_input->SetFileName( input_file  );
>> >  reader_input->Update();
>> >  ImageType::Pointer inputImage = reader_input->GetOutput();
>> >
>> >  typedef itk::ResampleImageFilter<ImageType,ImageType> FilterType;
>> >  FilterType::Pointer filter = FilterType::New();
>> >
>> >  typedef itk::AffineTransform< double, Dimension >  TransformType;
>> >  TransformType::Pointer transform = TransformType::New();
>> >  transform -> SetIdentity();
>> >  filter->SetTransform( transform );
>> >
>> >  typedef itk::BSplineInterpolateImageFunction< ImageType, double, int
>> >  >  InterpolatorType;
>> >
>> >  InterpolatorType::Pointer interpolator = InterpolatorType::New();
>> >  interpolator->SetSplineOrder(interp);
>> >  filter->SetInterpolator( interpolator );
>> >
>> >  filter->SetDefaultPixelValue( 0 );
>> >
>> >  //Initialize with reference image information
>> >  filter->SetOutputSpacing( referenceImage->GetSpacing() );
>> >
>> >  ImageType::SpacingType spacing = inputImage->GetSpacing();
>> >  ImageType::PointType origin = inputImage->GetOrigin();
>> >  origin[0] -= spacing[0]/2;
>> >  origin[1] -= spacing[1]/2;
>> >  origin[2] -= spacing[2]/2;
>> >
>> >  filter->SetOutputOrigin( origin );
>> >
>> >  filter->SetSize( referenceImage->GetLargestPossibleRegion().GetSize() );
>> >
>> >  //Do the resampling
>> >  filter->SetInput( inputImage );
>> >  filter->Update();
>> >  ImageType::Pointer outputImage = filter->GetOutput();
>> >
>> >  //Saving the result
>> >  writer->SetFileName( output_file );
>> >  writer->SetInput( outputImage );
>> >  writer->Update();
>> >
>> >
>> > _____________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Kitware offers ITK Training Courses, for more information visit:
>> > http://www.kitware.com/products/protraining.html
>> >
>> > Please keep messages on-topic and check the ITK FAQ at:
>> > http://www.itk.org/Wiki/ITK_FAQ
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.itk.org/mailman/listinfo/insight-users
>> >
>> >
>
>


More information about the Insight-users mailing list