[Insight-users] Repeat use of filter

Bradley Lowekamp blowekamp at mail.nih.gov
Fri Jul 19 08:38:02 EDT 2013


Hello,

You have created a loop in the ITK pipeline as you are reusing the output of the mean as the input of the dilate filter. It's likely easiest to just do the following for each filter:

img = prevfilter->GetOutput();
img->DisconnectPipeline()
filter->SetInput(img)
filter->Update()

The above approach will allow you to execute each filter in isolation, however I am not sure what your goals of your pipeline are. If you need to stream, then you need to create a separate filter of each execution as you initially did. If you are trying to minimize memory, then you will need to look into grafting images, and which filter can run in-place.

Brad

On Jul 19, 2013, at 4:37 AM, Jesse Ross-Jones <jesse.rj at gmail.com> wrote:

> Hello,
> 
> I am using ITK to write a method which requires the repeated use of a couple filters. Instead of having to repeat code, is it possible for the filters to work within a loop instead? 
> 
> A simplified example of the working code is here:
> 
>   dilateFilter->SetInput(this->GetInput());
>   dilateFilter->SetKernel(structuringElement);
> 
>   meanFilter->SetRadius(2);
>   meanFilter->SetInput(dilateFilter->GetOutput());
> 
>   dilateFilter2->SetInput(meanFilter->GetOutput());
>   dilateFilter2->SetKernel(structuringElement);
> 
>   meanFilter2->SetRadius(2);
>   meanFilter2->SetInput(dilateFilter->GetOutput());
> 
>   dilateFilter3->SetInput(meanFilter2->GetOutput());
>   dilateFilter3->SetKernel(structuringElement);
> 
>   meanFilter3->SetRadius(2);
>   meanFilter3->SetInput(dilateFilter3->GetOutput());
> 
> 
> I tried to replace the previous code with something the following, but the result produced only a black image. 
> 
> 
>   dilateFilter->SetInput(this->GetInput());
>   dilateFilter->SetKernel(structuringElement);
> 
>   meanFilter->SetRadius(2);
>   meanFilter->SetInput(dilateFilter->GetOutput());
> 
>   for ( int j = 0 ; j < 3 ; j = j + 1 ){
>      dilateFilter->SetInput(meanFilter->GetOutput());
>      meanFilter->SetInput(dilateFilter->GetOutput());
>      meanFilter->Update();
>   }
> 
> 
> Best Regards,
> Jesse
> 
> 
> _____________________________________
> 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.php
> 
> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130719/10be28e9/attachment.htm>


More information about the Insight-users mailing list