[Insight-developers] TransformIndexToPhysicalPoint/TransformPhysicalPointToIndex seem slow
Bill Lorensen
bill.lorensen at gmail.com
Tue Jun 2 19:31:22 EDT 2009
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
>
More information about the Insight-developers
mailing list