-
-
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
Improved gaussian filter and convert_to_float(#5195) #5281
Improved gaussian filter and convert_to_float(#5195) #5281
Conversation
skimage/filters/_gaussian.py
Outdated
@@ -10,7 +10,7 @@ | |||
|
|||
|
|||
def gaussian(image, sigma=1, output=None, mode='nearest', cval=0, | |||
multichannel=None, preserve_range=False, truncate=4.0): | |||
multichannel=None, preserve_range=True, truncate=4.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.
When updating a function's signature, please update its docstring as well (and 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 quite didn't see point of doing that here. See part of current docstring:
preserve_range : bool, optional
Whether to keep the original range of values. Otherwise, the input
image is converted according to the conventions of ``img_as_float``.
Also see
https://scikit-image.org/docs/dev/user_guide/data_types.html
But maybe it should be rewritten to be more specific. If you consider that as necessery - I may do that
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.
Yes, I think it is a good opportunity to rewrite it in a clearer way: "Whether to keep the original range of values. Default is True. If False, the input image is converted according to the conventions of img_as_float
, i.e., renormalised based on the range of the assumed data type: https://scikit-image.org/docs/dev/user_guide/data_types.html"
Hello @michalkrawczyk! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-06-19 21:28:59 UTC |
A bit changed conversion at dtype since according to Direct3D most negative value should be not calculated by formula, but just changed to -1.0f. That made test to fail (Also added few more tests) |
It seems like some test just failed because some functions are basing at gaussian with preserve_range=False. |
skimage/filters/_gaussian.py
Outdated
@@ -10,7 +10,7 @@ | |||
|
|||
|
|||
def gaussian(image, sigma=1, output=None, mode='nearest', cval=0, | |||
multichannel=None, preserve_range=False, truncate=4.0): | |||
multichannel=None, preserve_range=True, truncate=4.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.
Yes, I think it is a good opportunity to rewrite it in a clearer way: "Whether to keep the original range of values. Default is True. If False, the input image is converted according to the conventions of img_as_float
, i.e., renormalised based on the range of the assumed data type: https://scikit-image.org/docs/dev/user_guide/data_types.html"
Since this PR changes the default value of a function's parameter, it will affect existing code. I guess we need some kind of warning message referring to the next release version, right? @scikit-image/core |
Hi @michalkrawczyk @mkcor, please refer to our deprecation cycle policy in this case. |
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
…ikit-image into gaussian_issue
Done. @mkcor May I ask you to have a look now? |
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Hi all, sorry to jump in really late here but I don't think we should take this leap. In short, although I do support setting preserve_range=True everywhere, it should be done as a concerted effort in the road to 1.0, not as a piecemeal, whatever is most convenient for a specific function at a specific time approach. |
@jni Yeah I do see that actually almost all your current libraries use |
Indeed! As I said above I think we should make the change eventually. But when we move to 1.0 we have a chance to do it without the noise. Unfortunately we can't just change the output of the function without warning as that would break many, many users' existing code. |
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 requested a minor change to use an existing decorator to handle the deprecation. Otherwise this looks good to me.
Module cannot be found: 'skimage.restoration._inpaint' after merge with main |
I think this is because we recently added a new Cython function for inpainting. After you merged main, you would have had to rebuild scikit-image in order to avoid this error. I went ahead and ran this locally and fixed up some issues related to warnings in 528a88f. This is basically just either providing the The cosmetic changes in 0fe4242 are just for consistency with the style @rfezzani and I had been using in several other recent PRs. |
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 @michalkrawczyk, this looks good to me now
The CI errors seen here are unrelated to this PR (I saw them in a few other cases recently as well) |
Thank you @michalkrawczyk! |
Hi everyone, I'm really sorry about this, but I think we should revert this. I probably should have been more explicit in my comment above: I don't think we should have this in 0.19. I think 1.0 should Since @stefanv has also expressed concerns about some of the deprecations we're making, I think we should probably have a focused meeting soon about our upcoming API choices and how we will go about making the changes. |
Thanks for bringing this up, Juan. Would you be willing to set up that meeting and write up a paragraph or two about the challenge faced to bring everyone up to speed? |
I just opened #5439 to summarize some of the things I am aware of. Many are relatively easy to implement once we have a decision on the desired direction. |
Description
Propositon of fix #5195.
Since one point of problem, which is with not handling 1D array, was already resolved - This is mostly fix of normalizing in img_to_float() from int types according to Data Conversion Rules
Also changed preserve_range from filters.gaussian to True. The values in Gaussian Filter shoudn't be normalized by default - It will only give misleading results (Like in Issue #5195 itself)
For reviewers