You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
phase_cross_correlation returns tuple instead of np.array when disambiguate=True #7083
According to its documentation, ski.registration.phase_cross_correlation returns a numpy array as a shift. However, when using the function with disambiguate=True, a tuple is returned.
Way to reproduce:
importnumpyasnpimportskimageasskiim=np.random.randint(0, 100, ((10,10)))
r1=ski.registration.phase_cross_correlation(im, im)
assert(isinstance(r1[0], np.ndarray)) # r1[0] is a numpy arrayr2=ski.registration.phase_cross_correlation(im, im, disambiguate=True)
assert(isinstance(r2[0], np.ndarray)) # r2[0] is a tuple
I was going to create a PR with a fix, but will postpone that for now as I'm getting strange ninja related errors on my M2 when trying to set up skimage testing.
Hi @m-albert! May I create a PR that closes this issue?
The bug seems to be from the _disambiguate_shift function which returns a 'tuple of floats'. One possible fix I have explored is to make _disambiguate_shift return an ndarray instead of a tuple. This is a more robust approach. Would require changes to the test suite as well.
The other would be to update the if block like this.
Activity
m-albert commentedon Aug 2, 2023
I was going to create a PR with a fix, but will postpone that for now as I'm getting strange
ninjarelated errors on my M2 when trying to set up skimage testing.jni commentedon Aug 2, 2023
😬
Well a PR would be most welcome anyway! 😅
decorouz commentedon Aug 29, 2023
Hi @m-albert! May I create a PR that closes this issue?
The bug seems to be from the
_disambiguate_shiftfunction which returns a 'tuple of floats'. One possible fix I have explored is to make_disambiguate_shiftreturn anndarrayinstead of a tuple. This is a more robust approach. Would require changes to the test suite as well.The other would be to update the
ifblock like this.The latter is an easy work around. Not sure it is the best approach. I would appreciate an input
m-albert commentedon Aug 29, 2023
Hey @decorouz, thanks for working on this :) I haven't had the time and happy to help.
I agree that that's probably the best fix, since there's no reason for a shift sometimes being a tuple and sometimes a numpy array.
Ideally the fixed return type could also be checked for in the tests.
I'd guess scikit-image would welcome your PR on this :)
Make phase_cross_correlation return ndarray when disambiguate=True (#…
lagru commentedon Sep 20, 2023
Fixed in #7112.