-
-
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
Border fix #1952
base: main
Are you sure you want to change the base?
Border fix #1952
Conversation
How about |
skimage/transform/_warps.py
Outdated
@@ -332,6 +332,8 @@ def _swirl_mapping(xy, center, rotation, strength, radius): | |||
# Ensure that the transformation decays to approximately 1/1000-th | |||
# within the specified radius. | |||
radius = radius / 5 * np.log(2) | |||
if radius == 0: | |||
radius = np.power(10.0, -500) |
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.
np.finfo(float).eps
Let's also add a test to ensure that this remains fixed in the future. |
@stefanv I'm confused about your comment to use |
Ah, I thought some other small numbers would also trigger the error. Have
|
@akuchibotla can you also add a test to check that the issue of #1669 is solved? Thanks! |
Not 100% sure if this is the kind of test you're looking for |
swirled = tf.swirl(image, strength=10, **swirl_params) | ||
unswirled = tf.swirl(swirled, strength=-10, **swirl_params) | ||
|
||
assert np.mean(np.abs(image - unswirled)) < 0.01 |
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.
np.allclose
?
@akuchibotla @emmanuelle What do you think about this? :
|
Addressing issue #1669 and looking for feedback
In particular, I made sure there were no NaNs in the swirl mapping as well as no numbers less than 0. The arithmetic seemed to work incorrectly when radius was 0 (DivideByZero) but I feel as though my patch for that is still a little hacky. Is there a Numpy number abstraction that works as a "very small number"?