[Insight-users] ResamplingFilter problem
Alessandro
notinmyhead at gmail.com
Mon Oct 8 09:23:34 EDT 2012
Hello,
I had it work with this small amount of code (thanks!).
ImageVolumeType::Pointer VolumeRetriever::applyResamplingFromImage (ImageVolumeType::Pointer img, ImageVolumeType::Pointer ref) {
typedef itk::ResampleImageFilter<ImageVolumeType, ImageVolumeType> ResampleImageFilterType;
typedef itk::BSplineInterpolateImageFunction<ImageVolumeType, double, double> InterpolatorType;
ResampleImageFilterType::Pointer resample = ResampleImageFilterType::New();
// Instantiate the b-spline interpolator and set it as the third order
// for bicubic.
InterpolatorType::Pointer pInterpolator = InterpolatorType::New();
pInterpolator->SetSplineOrder(3);
resample->SetInput(img);
resample->UseReferenceImageOn();
resample->SetReferenceImage(ref);
resample->SetInterpolator(pInterpolator);
resample->UpdateLargestPossibleRegion();
// resample->Update();
return resample->GetOutput();
}
It still seems to suffer of some kind of issue about slices of the volume. Even if I get this values in the dimensions:
Reference:
Origins: -79.8526, -75.5083, -92.1846
Dimensions (x): (pixel) 512, (spacing) 0.3125
Dimensions (y): (pixel) 512, (spacing) 0.3125
Dimensions (z): (pixel) 24, (spacing) 2.99998
Copied:
Origins: -79.8526, -75.5083, -92.1846
Dimensions (x): (pixel) 512, (spacing) 0.3125
Dimensions (y): (pixel) 512, (spacing) 0.3125
Dimensions (z): (pixel) 24, (spacing) 2.99998
The new volume appears not to have all original slices... There is some reason behind the code?
Ale
Il giorno 02/ott/2012, alle ore 13.34, Ariel Hernán Curiale ha scritto:
> I forgot to say that I use the interpolator only in the registration and the registration modified my transform which is a BSplineTransform.
>
> Saludos
> __________________________________
> | Ariel Hernán Curiale Ph.D Student
> | ETSI Telecomunicación
> | Universidad de Valladolid
> | Campus Miguel Delibes
> | 47011 Valladolid, Spain
> | Phone: 983-423000 ext. 5590
> | Web: www.curiale.com.ar
> |_________________________________
>
> El 02/10/2012, a las 13:25, Ariel Hernán Curiale escribió:
>
>> Hi,
>> I'm using this code and works ok for me:
>>
>> typedef itk::InterpolateImageFunction< MovingImageType,double> InterpolatorType;
>> typename InterpolatorType::Pointer interpolator;
>>
>> .....
>> .....
>>
>> interpolator = BsplineInterpolatorType::New(); //Generic interpolator type
>>
>> typedef BsplineInterpolatorType * InterpolatorPointer;
>> InterpolatorPointer int_aux = dynamic_cast< InterpolatorPointer>(interpolator.GetPointer());
>> int_aux->SetSplineOrder(3);
>>
>>
>> typedef itk::ResampleImageFilter<FixedImageType,MovingImageType >ResampleFilterType;
>>
>> typename ResampleFilterType::Pointer resample_grid = ResampleFilterType::New();
>>
>> resampleGridImages.push_back(resample_grid);
>>
>> resample_grid->SetTransform( transform );
>> resample_grid->SetInput( gridImage );
>>
>> resample_grid->SetSize( fixedImage->GetLargestPossibleRegion().GetSize() );
>> resample_grid->SetOutputOrigin( fixedImage->GetOrigin() );
>> resample_grid->SetOutputSpacing( fixedImage->GetSpacing() );
>> resample_grid->SetOutputDirection( fixedImage->GetDirection() );
>> resample_grid->SetDefaultPixelValue( 100 );
>> resample_grid->Update();
>>
>>
>> Saludos
>> __________________________________
>> | Ariel Hernán Curiale Ph.D Student
>> | ETSI Telecomunicación
>> | Universidad de Valladolid
>> | Campus Miguel Delibes
>> | 47011 Valladolid, Spain
>> | Phone: 983-423000 ext. 5590
>> | Web: www.curiale.com.ar
>> |_________________________________
>>
>> El 02/10/2012, a las 12:47, alex Dowson escribió:
>>
>>>
>>>
>>> Hi
>>>
>>> You didn’t set the Transformation anywhere. Can you show me code again with correction .
>>>
>>>
>>> -----Original Message----- From: Alessandro
>>> Sent: Tuesday, October 02, 2012 4:15 PM
>>> To: Insight User
>>> Subject: Re: [Insight-users] ResamplingFilter problem
>>>
>>> Hi,
>>>
>>> I tried but still nothing seems to come out...
>>>
>>> Ale
>>>
>>> Il giorno 02/ott/2012, alle ore 12.39, alex Dowson ha scritto:
>>>
>>>>
>>>> Hi
>>>>
>>>>
>>>> Try calling the resample->Update() before the resample->GetOutput()
>>>>
>>>>
>>>>
>>>>
>>>> -----Original Message----- From: Alessandro
>>>> Sent: Tuesday, October 02, 2012 4:07 PM
>>>> To: Insight User
>>>> Subject: [Insight-users] ResamplingFilter problem
>>>>
>>>> Hello,
>>>>
>>>> I tried to Resample a 3d Slice Volume using a reference image. I wrote the following function (inside a class) to perform the task:
>>>>
>>>> ImageVolumeType::Pointer VolumeRetriever::applyResamplingFromImage (ImageVolumeType::Pointer img, ImageVolumeType::Pointer ref) {
>>>>
>>>> typedef itk::IdentityTransform<double, 3> TransformType;
>>>> typedef itk::ResampleImageFilter<ImageVolumeType, ImageVolumeType> ResampleImageFilterType;
>>>>
>>>> ResampleImageFilterType::Pointer resample = ResampleImageFilterType::New();
>>>>
>>>> resample->SetInput(img);
>>>> resample->UseReferenceImageOn();
>>>> resample->SetReferenceImage(ref);
>>>> resample->UpdateLargestPossibleRegion();
>>>>
>>>> return resample->GetOutput();
>>>> }
>>>>
>>>> where ImageVolumeType is typedef itk::Image< InputPixelType, 3 > ImageVolumeType;
>>>>
>>>> Problem is: when I run it the return is a NULL pointer...
>>>>
>>>> What am I missing?
>>>>
>>>> Thanks,
>>>> Ale
>>>>
>>>> _____________________________________
>>>> 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.php
>>>>
>>>> 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
>>>
>>> _____________________________________
>>> 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.php
>>>
>>> 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
>>> _____________________________________
>>> 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.php
>>>
>>> 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