[Insight-developers] handling different sized inputs & outputs in a filter
kent williams
norman-k-williams at uiowa.edu
Tue Mar 17 09:58:36 EDT 2009
I know what the problem is, I'm just not sure what the 'right' way to fix it
is. Or if I'm doing something I shouldn't even try to do, even though it's
a perfectly reasonable thing to want to do.
The first test of my changes to WarpImageFilter is based on a use case Hans
Johnson suggested that he'd find very useful, where the DeformationField
used with the filter is at lower resolution than the image being warped.
So, for example, you want to warp an image with spacing of 1 MM and
dimensions 128 x 128 x 128, but your deformation field covers the same space
with a spacing of 4 MM and dimensions 32 x 32 x 32.
What's causing the exception is that I've constructed a test case for
exactly this scenario; and the WarpImageFilter sets the requested region for
the input to the resolution of the input image, in
GenerateInputRequestedRegion, like this:
Deformationfieldpointer fieldPtr = this->GetDeformationField();
OutputImagePointer outputPtr = this->GetOutput();
if( this->m_OutputSize[0] == 0 && fieldPtr.IsNotNull() )
{
fieldPtr->SetRequestedRegion( outputPtr->GetRequestedRegion() );
}
The actual error occurs when WarpImageFilter::Update() is called, and
ImageBase::VerifyRequestedRegion()
The problem is pretty simple really: What I wish would happen would be for
the requested region to be verified in world coordinates, but instead, it is
being verified in IJK index space.
What I don't know is how to work around this, other than call
VerfiyRequestedRegion myself on the deformation field and if it fails set
the requested region to the DeformationField's LargestPossibleRegion. It
all comes out in the wash when the filter runs, because it's asking an
intepolator for displacements in world coordinates if the deformation field
size is not equal to the output image size.
On 3/16/09 5:20 PM, "Bradley Lowekamp" <blowekamp at mail.nih.gov> wrote:
> Which class is throwing that exception? The ImageFileWriter now
> sometimes throws that exception when it gets a 0 sized region... I
> have been meaning to look into that one. For example if you forget to
> set the input to a filter, you can get this exception... not to helpful.
>
> Also I wrote a very useful test filter in Testing/Code/IO/
> itkPipelineMonitorImageFilter.h. You can put that before or after your
> filter to peak into how the regions are being propagated, it has
> helped me a lot with the debugging of streaming. Just turn on it's
> debugging flag and it will start giving lots of info about the pipeline.
>
> Brad
>
>
> On Mar 16, 2009, at 5:40 PM, kent williams wrote:
>
>> I'm getting confused by how exactly to deal with changing the
>> itk::WarpImageFilter to allow for output image size other than the
>> deformation field size.
>>
>> The desired behavior -- I think would be this:
>>
>> 1. The input image can be any size and resolution.
>> 2. The deformation field can be any size, but ideally should be at
>> as large
>> in volume (3D) or area (2D) as the output volume/area.
>> 3. The output volume can be any size and resolution. Points in the
>> input
>> volume that warp outside the output volume are clipped, points in
>> the output
>> volume outside the deformation field volume are set to background
>> value.
>>
>> In other words interpolators are used both to get the value out of
>> the input
>> volume, and displacements from the deformation field, and the filter
>> always
>> asks for a value at a physical point in both cases.
>>
>> I thought I had this covered, but I'm getting this abort:
>>
>> terminate called after throwing an instance of
>> 'itk::InvalidRequestedRegionError'
>> what(): /scratch/kent/itktest/Insight/Code/Common/
>> itkDataObject.cxx:397:
>> Requested region is (at least partially) outside the largest possible
>> region.
>>
>> So I'm trying to figure out what I'm getting wrong. Any suggestions?
>>
>>
>>
>> Notice: This UI Health Care e-mail (including attachments) is
>> covered by the Electronic Communications Privacy Act, 18 U.S.C.
>> 2510-2521, is confidential and may be legally privileged. If you
>> are not the intended recipient, you are hereby notified that any
>> retention, dissemination, distribution, or copying of this
>> communication is strictly prohibited. Please reply to the sender
>> that you have received the message in error, then delete it. Thank
>> you.
>>
>>
>> _______________________________________________
>> 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
>
More information about the Insight-developers
mailing list