[Insight-developers] ImageRegion bounds caching

M Stauffer (V) mstauff at verizon.net
Tue Mar 1 15:27:47 EST 2011


Luis,

We noticed this in while looking at ImageFunction::IsInsideBuffer( point
), which calls Image::TransformPhysicalPointToIndex, which calls
ImageRegion::IsInside. 

We figured it's used very often, but haven't profiled, so no, we're not
sure it's so critical to optimize it. We'd have to be careful to check
the cache is never updated while threading.

So on second thought we'll leave this as-is, in the interest of getting
other, probalby more important, things done.

I will however add to ImageRegionTest to make sure that IsInside(
ContinuousIndex ) returns false for NaN and Inf values, as I did
recently for ImageFunction::IsInsideBuffer. Currently
ImageRegion::IsInside ContinousIndex ) does return false for NaN, but
only because NaN is cast to integer which yields a massive negative
number that is out of bounds. The test will make sure this works on all
platforms and remains this way in the future.

Cheers,
Michael 

>-----Original Message-----
>From: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
>Sent: Tuesday, March 01, 2011 9:26 AM
>To: M Stauffer (V)
>Cc: ITK
>Subject: Re: [Insight-developers] ImageRegion bounds caching
>
>Hi Michael,
>
>Are you using an image region in an inner loop ?
>
>The bounds computation only takes one addition per dimension,...
>
>Is the operation so critical that it is worth the pain
>of maintained a cached variable synchronized ?
>
>Have we run any profiling that points at this operation
>as a critical one ?
>
>
>     Luis
>
>
>--------------------------------
>On Wed, Feb 23, 2011 at 4:48 PM, M Stauffer (V) 
><mstauff at verizon.net> wrote:
>> Hi,
>>
>> I'd like to change ImageRegion to cache its bounds when its members
>> m_Size and/or m_Index are set, then compute 
>ImageRegion::IsInside more
>> quickly by simple comparison against the bounds. As a 
>reference, bounds
>> caching is done in itkImageFunction::SetInputImage, and used in
>> itkImageFunction::IsInside routines.
>>
>> Since this is such a fundamental method, I'd like to check first if
>> there's something I'm missing?
>>
>> Cheers,
>> Michael
>>
>> _______________________________________________
>> 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://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-developers
>>



More information about the Insight-developers mailing list