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
Fix the order of return values for hessian_matrix
#6624
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For mode='rc' the 2nd derivative along axis=0 should come first. This change also makes the order consistent with that used by structure_tensor
add test cases to confirm expected behavior for order
This was referenced Nov 20, 2022
grlee77
force-pushed
the
fix-hessian-matrix
branch
from
November 20, 2022 23:54
63eacb9
to
c84280b
Compare
CI failures are unrelated and fixed by #6626 |
lagru
approved these changes
Dec 21, 2022
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.
A few nitpicks and maybe we can make a test more specific but otherwise good to go. Thanks @grlee77!
@lagru Want to make the minor adjustment to the test and merge this? |
Okay, I'll take your #6624 (comment) as an approval. |
Explanation: Each array in Hs is the result of H_elems = [np.gradient(gradients[ax0], axis=ax1) for ax0, ax1 in combinations_with_replacement(axes, 2)] Because reversing axes (due to the bug fix) doesn't affect the result of `H_elems[2]`. For index 2, `combinations_with_replacement(axes, 2)` returns either `(0, 2)` or the reversed `(2, 0)`. Both result in the same gradient. So to make the test notice this change, we test another one of H_elems arrays whose result is not the same if axes is reversed.
This was referenced Feb 24, 2023
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #5230
This fixes the reported bug where 'xy' order was returned when 'rc' was requested and vice-versa. The change here also matrix
hessian_matrix
order consistent withstructure_tensor
which has the same conventions.A second inconsistency is that
structure_tensor
only allows use of mode='xy' for 2D images and otherwise raises an error, whilehessian_matrix
did not have this restriction. I have changed thehessian_matrix
behavior here for consistency.Fortunately, the presence of this bug did not effect the use cases of this function in higher order functions within scikit-image (e.g.
blob_doh
and various ridge filters likesato
,meijering
,frangi
). The eigenvalues used by the ridge filters, for example, are the same whether or not the axes are reversed.