-
-
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
restoration.denoise_bilateral and negative value image #1679
Conversation
@odebeir, @emmanuelle mentions that we could just offset the image values and back if there are any negative values. This seems easy enough to do? What do you think? |
skimage/restoration/_denoise.py
Outdated
@@ -23,7 +23,7 @@ def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1, | |||
Parameters | |||
---------- | |||
image : ndarray | |||
Input image. | |||
Input image (image minimum must be >0). |
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.
It's not completely true: values must be >= 0, it's the maximum that has to be >0.
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.
in fact is one value is <0 it breaks as well
What I suggest is
|
@jni would you agree? |
skimage/restoration/_denoise.py
Outdated
@@ -23,7 +23,7 @@ def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1, | |||
Parameters | |||
---------- | |||
image : ndarray | |||
Input image. | |||
Input image (image must be >= 0 with at least one > 0 value). |
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.
How about: "Input image whose minimum value is greater than 0."
I added three tests for the function:
the modified python wrapper _denoise pass these tests |
it is amaizing: |
skimage/restoration/_denoise.py
Outdated
# if all value identical, returns the same image | ||
return image | ||
else: | ||
return _denoise_bilateral(offset_img+1, win_size, sigma_range, sigma_spatial, |
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.
why the +1 and -1? I don't understand.
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.
well, it was related to a previous correction (commit 8d6ba04),
now, with the offset in the python wrapper it is indeed not needed anymore, so I reverted the .pyx to its initial state and removed the +1/-1
yeah, coveralls is doing strange things these days. Nevermind, your new tests are indeed useful. I just added a couple of comments. |
# if all value identical, returns the same image | ||
return image | ||
else: | ||
return _denoise_bilateral(offset_img, win_size, sigma_range, sigma_spatial, |
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.
This is changing the existing behavior and I don't see a reason why to subtract the min from the image. If you want to test for uniqueness, do a image.min() - image.max() == 0
test.
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.
basically the idea was to enable the process on image having <0 values...
using the offset ensures it as suggested by @emmanuelle
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 agree that negative values should be supported, but we shouldn't mess with the range of values in the image. This should be easily possible by changing the Cython implementation accordingly.
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 guess so, the solution was only a (quick) fix.
Oops, this one fell through the cracks... @odebeir do you think you could rebase on the current master? Then we can, hopefully, do a quick final review and get it merged! |
@jni, I am a bit confused here, I am not sure to be able to do the suggested maneuver ... |
deleted |
@soupault No, that fixed the case of single-value images. This fixes the case of negative-valued images. |
Hello @odebeir! Thanks for updating the PR.
|
I updated the first message and the title to avoid confusion |
This PR seems like a useful, straightforward addition that never quite got merged. I fixed the merge conflicts and have revived it in #5527 |
Here is a fix for #1677 regarding the case of negative-valued images, not fixed in #2533
basically change the test inside .pyx and adjusted docstring