-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integral_image: promote floating point inputs to double by default #5392
Conversation
skimage/transform/integral.py
Outdated
References | ||
---------- | ||
.. [1] F.C. Crow, "Summed-area tables for texture mapping," | ||
ACM SIGGRAPH Computer Graphics, vol. 18, 1984, pp. 207-212. | ||
|
||
""" | ||
if dtype is None and image.real.dtype.kind == 'f': | ||
# default to at least double precision cumsum for accuracy | ||
dtype = np.promote_types(image.dtype, float) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think on some Windows builds, "float" will default to float32. Should we specify np.float64 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the case for int
on 32-bit, but I thought float was usually double precision? Definitely not a problem to just use np.float64 to make it unambiguous, though
I'm happy to consider it a bug fix, since the change fixes floating-point cumulative sums which used to be off. Does @rfezzani agree?
Which (larger) output dtype do |
Yes, this is correct. |
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Sorry for not being available these last weeks 🙏... 👍 I agree @mkcor, and thank you @juan for merging this 😉 and thank you again @grlee77 🎉 |
Description
This PR was split off from #5372 as it is a change in existing behavior. To avoid surprises due to poor accuracy of floating point cumulative sums, I propose we default to double precision when computing integral images. See additional details in prior comment: #5372 (comment).
The user can override the default by manually specifying the
dtype
argument.One question is whether we can consider this a bug fix or if we should introduce a deprecation cycle before making the switch. The new output should be strictly an improvement from an accuracy standpoint, but output dtype will be larger for
float16
,float32
orcomplex64
inputs.Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.