[Insight-users] Resampler filter giving blank output

Luis Ibanez luis.ibanez at kitware.com
Thu Oct 8 08:45:59 EDT 2009


Hi Andrea,

Please post to the list the following information:

1) Origin of your input image
2) Number of pixesl along every dimension of the input image
3) Pixel spacing along every dimension of the input image
4) Image modality of the input image
5) File format that you are using for saving the image
6) Name of the program that you are using to visualize the image



BTW:

It seems that you missed to setup the Center of Rotation
of the AffineTransform....   Please note that by default, it
will be rotating around the point (0,0,0), that can easily be
far away from the physical extent of your image.



Thanks


     Luis


----------------------------------------------------------
On Thu, Oct 8, 2009 at 5:42 AM, darkflame2000 at libero.it
<darkflame2000 at libero.it> wrote:
> Hi all,
>
> I'm tryng to resample a 3d image with unsigned short pixel type, but the output results a blank image. I'm sure that it's not a visualization problem because I've tried to read the image with a viewer that it's able to read images like this.
> My code is something like that:
>
>
> typedef itk::Image<unsigned short, 3> AtlasImageType;
> typedef itk::ResampleImageFilter<AtlasImageType, AtlasImageType> ResamplerType;
> typedef itk::AffineTransform<double, 3> TransformType;
> typedef itk::NearestNeighborInterpolateImageFunction<AtlasImageType, double> InterpolatorType;
>
>
>
> ResamplerType::Pointer resampler1 = ResamplerType::New();
> TransformType::Pointer transform1 = TransformType::New();
> InterpolatorType::Pointer interpolator1 = InterpolatorType::New();
>
> resampler1->SetInterpolator( interpolator1 );
>
>
> const AtlasImageType::SpacingType& spacing1 = InputImage -> GetSpacing();
>
> const AtlasImageType::PointType& origin1 = InputImage -> GetOrigin();
>
> const AtlasImageType::SizeType& size1 = InputImage -> GetLargestPossibleRegion().GetSize();
>
> resampler1 -> SetOutputDirection ( InputImage -> GetDirection () );
> resampler1 -> SetOutputSpacing ( spacing1 );
> resampler1 -> SetOutputOrigin ( origin1 );
> resampler1 -> SetSize ( size1 );
> resampler1 -> SetInput ( InputImage );
>
> const double imageCenterX = origin1[0] + spacing1[0] * size1[0] / 2.0;
> const double imageCenterY = origin1[1] + spacing1[1] * size1[1] / 2.0;
> const double imageCenterZ = origin1[2] + spacing1[2] * size1[2] / 2.0;
>
> TransformType::OutputVectorType translation1;
>
> translation1[0] = - imageCenterX;
> translation1[1] = - imageCenterY;
> translation1[2] = - imageCenterZ;
>
> transform1 ->Translate ( translation1 );
>
> TransformType :: OutputVectorType vers;
> vers[0] = 0;
> vers[1] = 0;
> vers[2] = 1;
>
> double angleInDegrees = 180;
> const double degreesToRadians = vcl_atan(1.0) / 45.0;
> const double angle = angleInDegrees * degreesToRadians;
> transform1 -> Rotate3D( vers, - angle , false );
>
> TransformType::OutputVectorType translation2;
>
> translation2[0] = imageCenterX;
> translation2[1] = imageCenterY;
> translation2[2] = imageCenterZ;
>
> transform1 -> Translate ( translation2 , false );
>
> resampler1 -> SetTransform ( transform1 );
>
>
>
>
>
> Any hints???
>
> Andrea
>
>
>
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.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