[Insight-developers] writing an ImageToImageFilter, problem with Requested Region...

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Fri Jul 24 17:11:22 EDT 2009


Le 24 juil. 09 à 22:57, kent williams a écrit :

> This sort of makes sense, but what I’m trying to do is fix my filter  
> so it can be called twice on different sized inputs.  Is it the  
> responsibility of users to know when they should call  
> UpdateLargestPossibleRegion instead of Update?
>

You have to call UpdateLargestPossibleRegion() inside GenerateData(),  
instead of Update(). Note that if the filter is not enlarging the  
requested region to the largest one, you may have some problem with  
that code. I may be better to force the requested region of the  
internal filter to the requested region of the output image of your  
custom filter.

Do you still have this kind of exception if you use the double  
GraftOutput()? I think that the region are copied properly by  
GraftOutput(). If your internal code fits entirely in the pipeline  
model, it may be enough to make your code work properly.

Gaëtan


>
>
> On 7/24/09 2:58 PM, "Bradley Lowekamp" <blowekamp at mail.nih.gov> wrote:
>
>> Hello Kent,
>>
>> This sounds familiar. If I recall correctly try calling:
>>
>> x->UpdateLargestPossibleRegion();
>>
>> instead of:
>>
>> x->Update();
>>
>> I think it comes down to an old RequestedRegion sticking around in  
>> the output image of the filter.
>>
>> Brad
>>
>>
>> On Jul 24, 2009, at 3:44 PM, kent williams wrote:
>>
>>> I've been working on an ITK filter that encapsulates some processing
>>> previously done in an ad hoc function -- the idea being we'd like  
>>> to be able
>>> to stick it in a pipeline, rather than run one pipeline, call the  
>>> function,
>>> and run the rest of the pipeline.
>>>
>>> The filter as I've written it works fine.  But if I try and re-use  
>>> the
>>> filter it throws an exception:
>>>
>>> terminate called after throwing an instance of
>>> 'itk::InvalidRequestedRegionError'
>>>   what():
>>> /scratch/kent/BT/BRAINS-COMPILE/Darwin/DEBUG_64-lib/Insight/Code/ 
>>> Common/itkD
>>> ataObject.cxx:397:
>>> Requested region is (at least partially) outside the largest  
>>> possible
>>> region.
>>>
>>> In other words what I'm doing is this:
>>>
>>>     itk::MyFilter::Pointer x = itk::MyFilter::New();
>>>     x->SetInput(inputImage1);
>>>     x->Update();
>>>     firstresult = x->GetOutput();
>>>     x->SetInput(inputImage2);
>>>     x->Update();  // *** EXCEPTION HERE
>>>     secondresult = x->GetOutput();
>>>
>>> The problem happens in itk::DataObject::PropogateRequestedRegion,  
>>> because
>>> VerifyRequestedRegion() fails -- the requested region is based on  
>>> the size
>>> of inputImage1. inputImage2 has a smaller volume, so it can't  
>>> satisfy the
>>> larger RequestedRegion.
>>>
>>> So the question is this:  What should I be doing in my filter to  
>>> support
>>> re-use?  How am I supposed to make the filter re-compute the  
>>> requested
>>> region based on the size of the new Input?
>>>
>>> Or I guess another question might be this: Do ITK Filters, in  
>>> general, ever
>>> support this kind of re-use?
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com <http://www.kitware.com>
>>>
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.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-developers
>>
>>
>> ========================================================
>>
>> Bradley Lowekamp
>>
>> Lockheed Martin Contractor for
>>
>> Office of High Performance Computing and Communications
>>
>> National Library of Medicine
>>
>> blowekamp at mail.nih.gov
>>
>>
>>
>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.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-developers

-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr  http://www.itk.org
http://www.mandriva.org  http://www.bepo.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 203 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20090724/1bc5af20/attachment.pgp>


More information about the Insight-developers mailing list