[Insight-users] Re: Background after Registration
Luis Ibanez
luis.ibanez at kitware.com
Sun May 14 18:09:38 EDT 2006
Hi Balaji,
Thanks for sending the code of your resampling program.
Unfortunately you did not send the declaration of types
for MovingImageType and FixedImageType.
From the code it seems that you settings for the
DefaultPixelValue are fine. Although, this is under
the assumpttion that the pixel type of the FixedImage
is "unsigned char".
Is that the case ?
Why are you casting the output image to be "unsigned short" ?
A misuse of pixel types is likely the source of your problem
with the default pixel value.
Please let us know about the pixel type definitions,
Thanks
Luis
======================
Balaji Gandhi wrote:
> Here is resampling code and the resampled image:-
>
> /****************************************************************************************************/
>
> typedef itk::ResampleImageFilter< MovingImageType,
> FixedImageType > ResampleFilterType;
>
> TransformType::Pointer finalTransform = TransformType::New();
>
> finalTransform->SetParameters( finalParameters );
>
> ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>
> resampler->SetTransform( finalTransform );
> resampler->SetInput( movingImageReader->GetOutput() );
>
> FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();
>
> resampler->SetSize(
> fixedImage->GetLargestPossibleRegion().GetSize() );
> resampler->SetOutputOrigin( fixedImage->GetOrigin() );
> resampler->SetOutputSpacing( fixedImage->GetSpacing() );
> resampler->SetDefaultPixelValue( 255 );
>
> typedef unsigned short OutputPixelType;
>
> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>
> typedef itk::CastImageFilter< FixedImageType, OutputImageType >
> CastFilterType;
>
> typedef itk::ImageFileWriter< OutputImageType > WriterType;
>
>
> WriterType::Pointer writer = WriterType::New();
> CastFilterType::Pointer caster = CastFilterType::New();
>
>
> writer->SetFileName( outputImageFile );
>
>
> caster->SetInput( resampler->GetOutput() );
> writer->SetInput( caster->GetOutput() );
> writer->Update();
>
>
> typedef itk::SubtractImageFilter<
> FixedImageType,
> FixedImageType,
> FixedImageType > DifferenceFilterType;
>
> DifferenceFilterType::Pointer difference = DifferenceFilterType::New();
>
>
> typedef itk::RescaleIntensityImageFilter<
> FixedImageType,
> OutputImageType > RescalerType;
>
> RescalerType::Pointer intensityRescaler = RescalerType::New();
>
> intensityRescaler->SetInput( difference->GetOutput() );
> intensityRescaler->SetOutputMinimum( 0 );
> intensityRescaler->SetOutputMaximum( 255 );
>
> difference->SetInput1( fixedImageReader->GetOutput() );
> difference->SetInput2( resampler->GetOutput() );
>
> resampler->SetDefaultPixelValue( 255 );
>
> WriterType::Pointer writer2 = WriterType::New();
> writer2->SetInput( intensityRescaler->GetOutput() );
>
> if( argc > 5 )
> {
> writer2->SetFileName( differenceAfterRegistration );
> writer2->Update();
> }
>
> typedef itk::IdentityTransform< double, Dimension > IdentityTransformType;
> IdentityTransformType::Pointer identity = IdentityTransformType::New();
>
> if( argc > 4 )
> {
> resampler->SetTransform( identity );
> writer2->SetFileName( differenceBeforeRegistration );
> writer2->Update();
> }
>
> /****************************************************************************************************/
>
>
> --
> ===============================
> Balaji Gandhi
> Research Associate
> Biomolecular Science Center
> University of Central Florida
> Phone: 407-823-3387
> Fax: 407-823-0956
> Project: imgem.ucf.edu <http://imgem.ucf.edu>
> ===============================
More information about the Insight-users
mailing list