Skip to content

Improve performance of Advanced, ParzenWindowHistogram, ParzenWindowMutualInformation ImageToImageMetric#1444

Merged
N-Dekker merged 2 commits into
mainfrom
PERF-CostFunctions
May 15, 2026
Merged

Improve performance of Advanced, ParzenWindowHistogram, ParzenWindowMutualInformation ImageToImageMetric#1444
N-Dekker merged 2 commits into
mainfrom
PERF-CostFunctions

Conversation

@N-Dekker

Copy link
Copy Markdown
Member
  • Preallocated the memory for Parzen PDF values outside of for-each-sample loops
  • Used the most specific derived interpolator type in AdvancedImageToImageMetric::EvaluateMovingImageValueAndDerivative

The registration test case of the benchmark by Nicolas Chiaruttini (@NicoKiaru) at https://discourse.itk.org/t/8x-slower-registration-with-itk-elastix-python-api-vs-elastix-cli-minimal-reproducible-example/7736 appears to run more than 5 % faster with the CLI (elastix executable) on Window 11, at "my" LKEB/LUMC pc (AMD Threadripper, 32-Cores, 4 GHz, 64 logical processors), when using the default number of work units for the metric (ITK_MAX_THREADS, which is 128 for the executable), so without specifying "-threads".

N-Dekker added 2 commits May 15, 2026 13:59
Used the most specific derived interpolator type in `AdvancedImageToImageMetric::EvaluateMovingImageValueAndDerivativeWithOptionalThreadId`, and optionally add the threadId to EvaluateAtContinuousIndex calls.

ITK's `BSplineInterpolateImageFunction::EvaluateAtContinuousIndex` should be much faster with the threadId parameter.
Preallocated the memory for Parzen PDF values outside of for-each-sample loops. Passed the memory buffer as extra parameter to `ParzenWindowHistogramImageToImageMetric::UpdateJointPDFAndDerivatives` and `ParzenWindowMutualInformationImageToImageMetric::UpdateDerivativeLowMemory`.

A small performance improvement (~5%) was observed, running elastix.exe on Windows 11 as part of the benchmark by Nicolas Chiaruttini (https://discourse.itk.org/t/8x-slower-registration-with-itk-elastix-python-api-vs-elastix-cli-minimal-reproducible-example/7736)
@N-Dekker N-Dekker merged commit 77c726a into main May 15, 2026
7 of 8 checks passed
@N-Dekker N-Dekker deleted the PERF-CostFunctions branch May 15, 2026 12:35
N-Dekker added a commit to N-Dekker/ITKElastix that referenced this pull request May 15, 2026
Included elastix pull requests:

SuperElastix/elastix#1444
"Improve performance of Advanced, ParzenWindowHistogram,
ParzenWindowMutualInformation ImageToImageMetric"

SuperElastix/elastix#1440
"PERF: Use ImageBufferRange in AfterThreadedComputePDFs"

SuperElastix/elastix#1431
"ENH: Print a warning for each unused parameter of the ParameterMap"

All included new commits:

SuperElastix/elastix@5.3.1...77c726a
N-Dekker added a commit to N-Dekker/ITKElastix that referenced this pull request May 15, 2026
Included elastix pull requests:

SuperElastix/elastix#1444
"Improve performance of Advanced, ParzenWindowHistogram,
ParzenWindowMutualInformation ImageToImageMetric"

SuperElastix/elastix#1440
"PERF: Use ImageBufferRange in AfterThreadedComputePDFs"

SuperElastix/elastix#1431
"ENH: Print a warning for each unused parameter of the ParameterMap"

All included new commits:

SuperElastix/elastix@5.3.1...77c726a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant