Skip to content

Deprecate non gray scale image conversion in gray2rgb - #4440

Merged
emmanuelle merged 2 commits into
scikit-image:masterfrom
rfezzani:Deprecate_non_gray_scale_input_in_gray2rgb
Feb 11, 2020
Merged

emmanuelle merged 2 commits into
scikit-image:masterfrom
rfezzani:Deprecate_non_gray_scale_input_in_gray2rgb

Conversation

@rfezzani

Copy link
Copy Markdown
Member

Description

Following @hmaarrfk recommandations, this PR is a prerequisite to #4418.

Checklist

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.
  • Consider backporting the PR with @meeseeksdev backport to v0.14.x

@rfezzani rfezzani added the 🔽 Deprecation Involves deprecation label Feb 10, 2020
Comment thread skimage/color/colorconv.py Outdated
if is_rgb:
warn('Non gray scale images conversion is now deprecated. In version '
'0.19, input image will be considered as grey scale, whatever '
'is its shape.', FutureWarning, stacklevel=2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gray scale/grey scale -> grayscale, and remove "whatever is its shape". ie:

"Pass-through of possibly RGB images in gray2rgb is deprecated. In version 0.19, input arrays will always be considered grayscale, even if the last dimension has length 3 or 4. To prevent this warning and ensure compatibility with future versions, detect RGB images outside of this function."

We also need a way to silence this warning when this function is used correctly with a grayscale array with last axis shape (3,)...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that we need to add an argument (nd for example) to be set to True if the user wants effectively convert nD grayscale image to RGB?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. But nd isn't a great argument name, and anyway, in the future we would want to remove it. So I don't really know what to do here. =\

is_rgb = True

if is_rgb:
warn('Pass-through of possibly RGB images in gray2rgb is deprecated. '

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the appropriate parameter to add is one called multichannel

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multichannel is in fact well suited for this, but we all agree that in version 0.19 this parameter will be deprecated since nD will be the default behavior of gray2rgb?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah..... Maybe the best way is to ask users to import the function from a "future" module???

Definitely annoying

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the best way to go about this one

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, one thing I've been thinking about is to add a note to the next two release notes, 0.17 and 0.18, that users should pin to <1.0, because 1.0 will contain breaking changes, and then work to get 1.0 out after that, with a bunch of breaking changes. This would solve this situation and a bunch of others... But probably I should start a SKIP for this. =)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this as is.

Users that avoid this warning will have code that is correct all the way through

@emmanuelle

Copy link
Copy Markdown
Member

Thanks @rfezzani, merging!

@emmanuelle
emmanuelle merged commit f97d2e6 into scikit-image:master Feb 11, 2020
@rfezzani

Copy link
Copy Markdown
Member Author

Thank you @emmanuelle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔽 Deprecation Involves deprecation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants