[Insight-developers] TransformIndexToPhysicalPoint/TransformPhysicalPointToIndex seem slow
Tom Vercauteren
tom.vercauteren at gmail.com
Wed Jun 3 09:09:26 EDT 2009
Hi Kent,
You may want to try experiencing with the
ITK_USE_CENTERED_PIXEL_COORDINATES_CONSISTENTLY flag for two reasons:
1) Calling TransformIndexToPhysicalPoint followed by
TransformPhysicalPointToIndex will only be consistent with this flag
on.
2) TransformPhysicalPointToIndex should be faster with this flag on
(in release mode) since it relies on optimized floating point to
integer conversion functions.
Hope this helps,
Tom
On Wed, Jun 3, 2009 at 01:31, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> Are you building a Debug or Release build? There can be a huge
> difference in speed between the two.
>
> Bill
>
>
> On Tue, Jun 2, 2009 at 6:07 PM, kent williams
> <norman-k-williams at uiowa.edu> wrote:
>> I'll state in advance I haven't tried a release build, which I'm sure would
>> help somewhat, but...
>>
>> I'm trying to blend two images that potentially have different origins,
>> spacing and dimensions. So I am using this idiom:
>>
>> ImageType::Pointer curImage; // set elsewhere...
>> itk::ImageRegionIteratorWithIndex<ImageType>
>> curIt(accumulator,accumulator->GetLargestPossibleRegion());
>> ImageType::PointType accPoint;
>>
>> for(;!curIt.IsAtEnd(); ++curIt)
>> {
>> ImageType::IndexType index(curIt.GetIndex());
>> accumulator->TransformIndexToPhysicalPoint(index,accPoint);
>> ImageType::IndexType curIndex;
>> if(curImage->TransformPhysicalPointToIndex(accPoint,curIndex))
>> {
>> ImageType::PixelType curPixel(curImage->GetPixel(curIndex));
>> curIt.Set(Blend(curIt.Value(),curPixel));
>> }
>> }
>> }
>>
>> This sort of Index->Point->Index transformation seems unavoidable, unless
>> I'm missing something, but it's dog slow compared to (for example) stepping
>> through two images with a regular ImageRegionIterator for both images. And
>> this code doesn't even address proper interpolation of the voxels from the
>> second image.
>>
>> It would probably be quicker to resample the second image to the first
>> image's spacing, then figure out the overlapping regions and use regular
>> RegionIterators, but that seems like overkill. Certainly I could detect
>> cases where both images have the same spacing and do the simpler traversal
>> too.
>>
>> But is there a way to make this sort of idiom faster?
>>
>> _______________________________________________
>> 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
>>
> _______________________________________________
> 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