# ~8x slower registration with itk-elastix Python API vs elastix CLI — minimal reproducible example

**URL:** <https://discourse.itk.org/t/8x-slower-registration-with-itk-elastix-python-api-vs-elastix-cli-minimal-reproducible-example/7736>\
**Category:** Engineering\
**Tags:** performance, itk-elastix, elastix\
**Created:** [March 22, 2026, 1:48pm UTC](https://discourse.itk.org/t/8x-slower-registration-with-itk-elastix-python-api-vs-elastix-cli-minimal-reproducible-example/7736 "2026-03-22T13:48:26Z")\
**Posts on this page:** 1\
**Showing post:** 38

<div class="post-metadata">

**Author:** ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)\
**Post date:** [June 5, 2026, 12:04pm UTC](https://discourse.itk.org/t/8x-slower-registration-with-itk-elastix-python-api-vs-elastix-cli-minimal-reproducible-example/7736/38 "2026-06-05T12:04:42Z")

</div>

> [@blowekamp](#):
>
> Yes merging histograms or other data in a single threaded fashion can be quite slow. You might find the approach using in LabelStatisticImageFilter useful for reference.

Thanks for the suggestion, @blowekamp Is this what you had in mind?

> <https://github.com/SuperElastix/elastix/pull/1451>
>
> Inspired by a suggestion from Bradley Lowekamp (@blowekamp), June 2, 2026, at ht…tps://discourse.itk.org/t/8x-slower-registration-with-itk-elastix-python-api-vs-elastix-cli-minimal-reproducible-example/7736/37
> 
> \----
> A major performance improvement (10% to 40%) of elastix.exe was observed on the benchmark data set from https://discourse.itk.org/t/8x-slower-registration-with-itk-elastix-python-api-vs-elastix-cli-minimal-reproducible-example (by @NicoKiaru). However, this PR might cause slightly different results, because it may change the order of additions of floating point numbers, during accumulation.

I observed a major performance improvement (10% to 40%), when moving the accumulation of joint histograms from the “AfterThreaded” member function to the “Threaded” member function (even though it adds mutex locking).

However it _might_ yield slightly different results, each time the joint histogram is computed, because it might add floating point numbers in a different order, each time. And you know, for floating point numbers, `a + b + c` may not be _exactly_ equal to `b + c + a`. So I feel reluctant to merge this PR. 🤷

---

_[View the full topic](https://discourse.itk.org/t/8x-slower-registration-with-itk-elastix-python-api-vs-elastix-cli-minimal-reproducible-example/7736)._
