[Insight-users] ImageSource->GetOutput() type

Luis Ibanez luis . ibanez at kitware . com
Fri, 29 Aug 2003 19:41:29 -0400


Hi Benjamin,

You must invoke Update() in the filter inside the
function.

The output of a filter is invalid until you call Update()
since it is the call that triggers the execution of the
filter.


> template <class ImageType>
> typename ImageType::Pointer someFunction(ImageType* image) {
>   typedef itk::ThresholdImageFilter<ImageType> TresholdType;
>   typename TresholdType::Pointer threshold = TresholdType::New();
> 
>   threshold->SetInput(image);


HERE ADD:      thershold->Update()


>   return threshold->GetOutput();
> }
> 


--------

About the other case you mention, in which you get
compilation errors.... please post the error messages
and the relevant piece of code.


Regards,



    Luis


----------------





Benjamin King wrote:
> Hi all,
> 
> I want to wrap a part of my pipeline in a function, but I'm troubled by 
> the difference between itk::Image::Pointer and itk::Image*.
> My function looks like (also see the attached code):
> 
>  ImageType::Pointer someFunction(ImageType* image);
> 
> I chose the argument's type like that because according to the
> documentation all itk::ImageSources return a plain pointer with
> GetOutput(). The return value's type is used in accordance to a previous 
> post by Bill (http://www . itk . org/pipermail/insight-users/2003- 
> June/004124.html).
> 
> When I run the attached code, the image returned by someFunction
> is an empty image, even after I Update()d it.
> 
> In a related context, I have functions like
>  double returnSomeFeature(ImageType* image);
> that work fine for filter outputs but not for "handcrafted" images:
>  // Compiles
>  double feature1 = returnSomeFeature(imageReader->GetOutput);
> 
>  // Doesn't compile
>  ImageType::Pointer image = ImageType::New();
>  image->SetLargetsPossibleRegion(....)
>  image->SetBufferedRegion(....)
>  image->Allocate(....)
>  double feature2 = returnSomeFeature(image);
> The attached code doesn't demonstrate this, but I guess the problems
> are related in some way.
> 
> Can someone point out the problem or reproduce the error?
> 
> 
> Best regards,
>  Benjamin
>