[Insight-users] Resampler filter giving blank output
Luis Ibanez
luis.ibanez at kitware.com
Thu Oct 8 14:22:19 EDT 2009
Hi Andrea,
Thanks for the additional information.
About Item (5) : I don't think you can use zraw as an extention.
You are probably using .mhd with the compression option turned
ON, which will generate two files:
a) filename.mhd
b) filename.zraw
Is that the case ?
---
Looking back at your code, you are trying to do manually,
something that the AffineTransform will do for you:
Managing a center of rotation.
It seems that you want to rotate the image around its central
pixel.
What you can do then, is to call SetCenter() and pass to it
the physical coordinates of the image center:
affine->SetCenter( imageCenter );
then set the desired rotation:
affine->Rotate3D( vers, - angle , false );
There is no need for you to deal with the translations
before and after. The Affine transform will compute
that for you.
Please give it a try,
and if you find any problem, please add:
affine->Print( std::cout );
and post to the list the output of this command.
Thanks
Luis
--------------------------------------------------
On Thu, Oct 8, 2009 at 2:12 PM, darkflame2000 at libero.it
<darkflame2000 at libero.it> wrote:
>
> 1) The origin is 0 0 0.
> 2) The number of pixels is 181 x 217 x181.
> 3) The spacing is 1.0 1.0 1.0.
> 4) I work with an MRI image modality.
> 5) The file is saved with a .ZRAW extension.
> 6) I use the program itksnap. When I try to visualize the rotated image, loading the .ZRAW file, I don't see anything...
>
> Bye
>
> Andrea
>
>
>
>
>
>> 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