[Insight-users] Image assignment does not work

Matt McCormick matt at mmmccormick.com
Thu Sep 2 09:42:40 EDT 2010


Hi Dzenan,

> 
> void applyFilter(InternalImageType::Pointer image, 
itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer filter)

How about changing the signature to use references, i.e.

void applyFilter(InternalImageType::Pointer& image, 
itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer& filter)

> 
> {
> 
> 	if (!checkImageLoaded())
> 
> 		return;
> 
> 	statusbar->showMessage("Applying filter: "+QString(filter-
>GetNameOfClass()));
> 
> 
> 	filter->SetInput( image );
> 
> 	filter->Update();
> 
> 	image=filter->GetOutput();
> 
> 
> 	updateVisualizing();
> 
> 	resetVisualization();
> 
> 	statusbar->showMessage("Ready");
> 
> }
> 
> 
> and it is invoked like this:
> 
> 
> typedef itk::SmoothingRecursiveGaussianImageFilter < InternalImageType, 
InternalImageType> FilterType;
> FilterType::Pointer filter = FilterType::New();
> 
> filter->SetSigmaArray(myImage->GetSpacing());

I would not expect much of a change with such a small sigma.

> applyFilter(myImage, 
(itk::ImageToImageFilter<InternalImageType,InternalImageType>::Pointer)filter);

I am surprised this cast works given the recent discussions of smart pointer 
casting on the ITK developers list.  If there is intention to cast to base 
classes, then using raw pointers may be better.

Regards,
Matt



More information about the Insight-users mailing list