[Insight-users] "In place" filtering
Bill Lorensen
bill.lorensen at gmail.com
Mon Oct 25 20:09:55 EDT 2010
The advantage is that the operations are done in place and no output
image needs to be allocated.
On Mon, Oct 25, 2010 at 3:50 PM, David Doria <daviddoria at gmail.com> wrote:
>> 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
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list