forked from InsightSoftwareConsortium/ITK
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PERF: itk::Image::GetPixel() performance improvment.
itk::Image<>::GetPixel() calls itk::ImageBase<>::ComputeOffset() which in turn calls itk::ImageBase<>::GetBufferredRegion() which is ... a virtual function. AFAIK, this function is overridden only in itk::ImageAdaptator<>, it doesn't seem to be overridden anywhere else (like in otb::Image<>). So, unless the variation point needs to stay in case a child of itk::Image or otb::Image will require to specialize the behaviour of GetBufferredRegion(), it'll be best that itk::Image<>::GetPixel() relies on a non virtual version of GetBufferredRegion(). Why not calling a virtual function from a function which is already known as inefficient will matters ? Well, first the function will be less inefficient. Then, some algorithms (like BSplineInterpolateImageFunction) need to use this GetPixel function. Any improvement on GetPixel will benefit to these algorithms. We have benchmarked, with callgrind, the number of cycles spent in the function BSplineInterpolateImageFunction::EvaluateAtContinousIndex. The function is called 117290070 times. Before the patch, the function took 212546 million cycles. After the patch, the function takes 133417 million cycles. EDIT: Before going further in this direction, we (you?) need to be sure that there is no plausible scenario where GetBufferredRegion() would be overridden in a class that inherits from itk::Image. Then, please note this is a quick and dirty patch. A better refactorization may be preferred. Change-Id: Iea7b8da0560e59f9a021fc0a50bfaa57f12939a7
- Loading branch information
1 parent
4bcaa24
commit 7998610
Showing
4 changed files
with
58 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters