[Insight-users] howto reuse pipeline with another image

Andreas Schuh andreas.schuh.84 at googlemail.com
Sat Jan 9 16:29:02 EST 2010


Hi Maquette,


Here are just some idea's regarding your problem while I was looking through the sources of the relevant filters.

Your problem may be that the itk::RegionOfInterestImageFilter still uses the previous ROI and/or that the reader reuses the previous requested region.

In itk::RegionOfInterestImageFilter::GenerateInputRequestedRegion(), the requested region of the input is set to m_RegionOfInterest. Thus, you have to set the region of interest properly before updating the pipeline, i.e. by setting it to reader->GetOutput()->GetLargestPossibleRegion(), as you suggested, after you have done an update of the reader first.

You may also want to use reader->UpdateLargestPossibleRegion() instead of reader->Update() to ensure that the reader does not use any previous requested region, but reads in the whole image. Or you set the requested region of the output image of the reader to the ROI. In case that the reader supports streaming, it may even just read in the ROI, but not the whole image. You can do this by reader->GetOutput()->SetRequestedRegion(). On the other side, the region of interest image filter should set the requested region of the reader's output to the ROI you've set. already.

As long as you don't set the IO region of the writer, it will always propagate the largest possible region as requested region up the pipeline. Thus, your problem should not be that the writer uses a wrong requested region. However, you may want to consider setting the ROI by writer0->SetIORegion() instead of using the itk::RegionOfInterestImageFilter, as this filter actually makes a copy of the ROI.

In order to be able to tell which filter actually throws the exception, you could update each filter one by another manually, instead of just calling writer0->Update(). Then you can see at which point in the pipeline the exception occurs.

Andreas

On Jan 9, 2010, at 1:34 PM, Maquette wrote:

> hi all,
> 
> Sorry in advance, that this might be a rather frequent question. But I didn't find out much about whether/how an image pipeline can be reused after the first Image has been read, and Update() has been called on a concluding writer. The purpose is to build an interactive tool, where new image Files can be read and processed, and a smaller Region of Interest can be selected/changed to have a quick preview written as .mha. After a new file has been selected the ROI should default to that files whole extend. (
> 
> I try to achieve this by a pipeline connected like that:
> 
>   itk::ImageFileReader<I>               reader
>   ->
>   itk::RegionOfInterestImageFilter<I,I> roi
>   ->
>   itk::FancyFilter1<I,I>                filter1
>   ->
>   ...
>   ->
>   itk::FancyFilterN<I,I>                filterN
>   ->
>   itk::ImageFileWriter<I>               writer0
> 
> 
> How can it be reused (let writer0 write out the new result) after one of the follwing events:
> 
> - The first Image loaded with
>   reader->SetFileName("first.mha");
>   writer0->Update();
> always works fine. The whole pipeline seems to adjust to the extends of first.mha One can nicely adjust Filter parameters in an interactive program and by one call to writer0->Update() gets the new result.
> 
> - What do I have to do after setting reader->SetFileName("second.mha") in order to have the pipeline process the new image in its probably new extends. writer0->Update() throws some    "requested region out of possible region". Of course! but how to tell writer0 what to request next?
> 
> - What is to be done to change the region of interest? Would
>   roi->SetRegionOfInterest();
> be sufficient? Lets say the new ROI is kept within the bounds given by reader->GetOutput()->GetLargestPossibleRegion(). Changing roi leads to the same exception by writer0->Update(). Perhaps RegionOfInterestImageFilter is not even needed, and one has to tell writer0 what subregion to request/use. (meaning one has to tell it to each leaf in the pipeline jungle)
> 
> I hope the issue can be discussed on that rather abstract level. The sources have already grown > 1200 LOCs when I tried to make it "reloadable" and "ROI selectable".
> _____________________________________
> 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