[Insight-users] about itkResampleImageFilter

Luis Ibanez luis.ibanez at kitware.com
Sun Jul 30 08:49:38 EDT 2006


Hi Yixun,


Thanks for letting us know that you fixed the problem.

You shouldn't expect to exploit the regions from
outside of the pipeline control.

The intent of the RequestedRegion and LargestPossibleRegion
is to provide data structure for the streaming of data inside
the ITK pipeline.

You shouldn't get the output of a filter an update
its regions manually.

Instead, probably what you need to invoke is the method


     filter->UpdateLargestPossibleRegion()



  Regards,


      Luis




----------------------
Yixun Liu wrote:
> Thank you for your reply!
> 
> I have used VTK and ITK for three years and I cannot make mistake like this.:-). I added some codes as shown below. Now everything is ok.  However, why not itk automatically change the request region when possible largest region change?
> 
> Regards,
> 
> Yixun Liu
> 
> 
> 
> typedef itk::Image<short, 3> ImageType;
> typedef itk::ResampleImageFilter<ImageType, ImageType>  ResampleFilterType;
> ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>  
> resampler->SetTransform( transform );
> // resampler->SetInterpolator(this->interpolator);
> resampler->SetInput( movingImage );
> size =  fixedImage->GetLargestPossibleRegion().GetSize();
> size[2] = 1;
> index[2] = 24;
> index[0] = index[1] = 0;
> this->resampler->SetSize(size);
> this->resampler->SetOutputStartIndex(index);
> this->resampler->SetOutputOrigin(  fixedImage->GetOrigin() );
> this->resampler->SetOutputSpacing( fixedImage->GetSpacing() );
> this->resampler->SetDefaultPixelValue( 100 );
> 
>  region.SetSize(size);//added code
>  region.SetIndex(index);//added code
>  this->resamplerZ->GetOutput()->SetRegions(region);//added code
> 
> 
> this->resampler->Update();
> 
> 
>   
> 
> 
> ----- Original Message ----- 
> From: "Luis Ibanez" <luis.ibanez at kitware.com>
> To: "Yixun Liu" <yxliu at fudan.edu.cn>
> Cc: "ITK" <insight-users at itk.org>
> Sent: Sunday, July 30, 2006 6:12 AM
> Subject: Re: [Insight-users] about itkResampleImageFilter
> 
> 
> 
>>Hi Yixun,
>>
>>It is a common mistake to get values from the Image before it has been
>>read with a reader.
>>
>>In your code you are using the methods
>>
>>  GetSpacing()
>>  GetOrigin()
>>  GetLargestPossibleRegion()
>>
>>
>>in the fixed image.
>>
>>It is very likely that you have not updated yet the reader of the
>>fixed image, and therefore the image lacks any information at the
>>moment you are invoking all these methods.
>>
>>
>>
>>  Regards,
>>
>>
>>
>>      Luis
>>
>>
>>
>>-----------------------
>>Yixun Liu wrote:
>>
>>>Hi,
>>> 
>>>The fixedImage and movingImage both are 256 x 256 x 48. I use the grid 
>>>with size 256 x 256 x 1 and start index (0,0,24) as the resample grid. I 
>>>do as below,
>>> 
>>>typedef itk::Image<short, 3> ImageType;
>>>typedef itk::ResampleImageFilter<ImageType, ImageType>  ResampleFilterType;
>>>ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>>> 
>>> resampler->SetTransform( transform );
>>>// resampler->SetInterpolator(this->interpolator);
>>> resampler->SetInput( movingImage );
>>> size =  fixedImage->GetLargestPossibleRegion().GetSize();
>>> size[2] = 1;
>>> index[2] = 24;
>>> index[0] = index[1] = 0;
>>> this->resampler->SetSize(size);
>>> this->resampler->SetOutputStartIndex(index);
>>> this->resampler->SetOutputOrigin(  fixedImage->GetOrigin() );
>>> this->resampler->SetOutputSpacing( fixedImage->GetSpacing() );
>>> this->resampler->SetDefaultPixelValue( 100 );
>>> this->resampler->Update();
>>> 
>>>After resampled I change the index from (0,0,24) to (0,0,16). However 
>>>itk exception throwed. I debug into ITK and found the 
>>>possiblelargestregion change from (0,0,24) to (0,0,16), but the 
>>>requestregion still is (0,0,24). The requestregion is not in the range 
>>>of the possiblelargestregion, so the exception throw. Why not ITK 
>>>automatically change the requestregion when the largestpossibleregion 
>>>change?
>>> 
>>> 
>>> 
>>>Regards,
>>> 
>>>Yixun Liu
>>>
>>> 
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk.org
>>>http://www.itk.org/mailman/listinfo/insight-users
>>
>>
> 
> 
	



More information about the Insight-users mailing list