[Insight-users] "In place" filtering

David Doria daviddoria at gmail.com
Mon Oct 25 15:50:25 EDT 2010


>
> Hi David,
>
> You must get the output and pass it back.
> If you want to disconnect the output from the pipeline use
> image->DisconnectPipeline();
>
> Try this:
>
> void ApplyThresholding(ImageType::Pointer &image)
> {
>  typedef itk::BinaryThresholdImageFilter <ImageType, ImageType>
>          BinaryThresholdImageFilterType;
>
>  BinaryThresholdImageFilterType::Pointer thresholdFilter
>          = BinaryThresholdImageFilterType::New();
>  thresholdFilter->SetInput(image);
>  thresholdFilter->SetLowerThreshold(10);
>  thresholdFilter->SetUpperThreshold(50);
>  thresholdFilter->SetInsideValue(255);
>  thresholdFilter->SetOutsideValue(0);
>  thresholdFilter->InPlaceOn();
>  thresholdFilter->Update();
>  image = thresholdFilter->GetOutput();
>  // OPTIONAL:
>  // image->DisconnectPipeline();
> }
>
> PS: I am not 100% sure if this is the "best practice".
>
> Hope that helps,
> Markus
>

Hi Markus,

You are right, if I change the function signature to pass the 'image'
pointer by reference:

void ApplyThresholding(ImageType::Pointer &image)

and then assign 'image' to the pointer that is the output of the filter:

image = thresholdFilter->GetOutput();

the thresholded image is displayed. However, this works whether or not
InPlaceOn has been called. What this has done is simply change 'image' in
the calling function to point to a different image, rather than modify the
image that 'image' was pointing to originally.

Can anyone clarify the idea/usage of the InPlaceOn option?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101025/facaefa1/attachment-0001.htm>


More information about the Insight-users mailing list