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
single precision support in skimage.metrics module #5220
Conversation
85e15ed
to
c72ce6f
Compare
c72ce6f
to
6d3d024
Compare
add float32 support for structural similarity Metrics give float64 scalar outputs. Array outputs preserve the precision of the input.
ab6f25f
to
c5bdcf4
Compare
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 just left some minor comments, otherwise, everything is fine 😉 thank you @grlee77.
@@ -226,8 +227,8 @@ def structural_similarity(im1, im2, | |||
# to avoid edge effects will ignore filter radius strip around edges | |||
pad = (win_size - 1) // 2 | |||
|
|||
# compute (weighted) mean of ssim | |||
mssim = crop(S, pad).mean() | |||
# compute (weighted) mean of ssim. Use float64 for accuracy. |
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.
👍
Co-authored-by: Riadh Fezzani <rfezzani@gmail.com>
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.
Thanks, @grlee77: I'm only this far (tiny gesture) from approving/merging!
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
set dtype properly in test_nmi_random Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Weird... at b94bce2 diff --git a/skimage/metrics/tests/test_simple_metrics.py b/skimage/metrics/tests/test_simple_metrics.py
index a69b9abb3..edcb28fd4 100644
--- a/skimage/metrics/tests/test_simple_metrics.py
+++ b/skimage/metrics/tests/test_simple_metrics.py
@@ -66,7 +66,7 @@ def test_PSNR_float(dtype):
with expected_warnings(['Inputs have mismatched dtype']):
p_mixed = peak_signal_noise_ratio(cam / 255.,
np.float32(cam_noisy / 255.))
- assert_almost_equal(p_mixed, p_float64, decimal=5)
+ assert_almost_equal(p_mixed, p_float64, decimal=decimal) But here on GitHub line 69 reads |
Although GitHub would display otherwise, the code base definitely had |
Description
#5219 should be reviewed first since this PR is built on top of that one (to reuse the same
_float_dtype
utility).Computations of means as in
mse
were intentionally set to usedtype=float64
and that is preserved here to keep good accuracy on larger images. Similarly, forstructural_similarity
, I added single precision support in most of the function, but kept the final mean computation to generatemssim
in double precision.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
.