Skip to content

DEP: deprecate misc.pilutil functions#7869

Merged
rgommers merged 4 commits intoscipy:masterfrom
rgommers:imresize-issues
Sep 17, 2017
Merged

DEP: deprecate misc.pilutil functions#7869
rgommers merged 4 commits intoscipy:masterfrom
rgommers:imresize-issues

Conversation

@rgommers
Copy link
Copy Markdown
Member

The reasons for these deprecations are:

  1. Many of the functions have bugs and unexpected behavior.
  2. There are better alternatives for pretty much every function.

Summary of issues:

The functions that seem sort of OK:

  • imread. Exposed also as ndimage.imread. Want to move to scipy.io. Also note the discussion in Inconsistency / duplication for imread and imshow, imsave #6242 (comment) about
    imsave. Want to rename to imwrite and move to scipy.io (or write a new one without the rescaling issues and put that in io).
  • fromimage. Changes PIL image to ndarray.
  • bytescale. Does some simple scaling of range of an array.

Closes gh-2347
Closes gh-2300
Closes gh-2442
Closes gh-3154
Closes gh-4458
Closes gh-4893
Closes gh-5305
Closes gh-6242
Closes gh-6417
Closes gh-7259
Closes gh-7458

See discussion about introducing scipy.io.imread/imwrite in http://thread.gmane.org/gmane.comp.python.scientific.devel/20063. I didn't actually do that here, seems duplicate with matplotlib, scikit-image, etc. Can always be done separately if deemed a good idea. See also PR gh-5458, which makes an attempt at this.

@rgommers rgommers added maintenance Items related to regular maintenance tasks scipy.misc labels Sep 16, 2017
@rgommers rgommers added this to the 1.0.0 milestone Sep 16, 2017
The reasons for these deprecations are:
  1. Many of the functions have bugs and unexpected behavior.
  2. There are better alternatives for pretty much every function.

Summary of issues:

- ``imsave`` rescales images (scipygh-5305)
- ``imresize`` rescales images (scipygh-4458) and casts to different dtype (scipygh-6417)
- Many functions suffer from a shape handling bug for (3, 100, 3) RGB and
  (4, 100, 4) RGBA images (scipygh-2347)
- ``toimage`` is the root cause of casting and scaling issues, one more
  separate bug report at scipygh-2300
- ``imfilter``, ``imrotate`` and ``imshow`` don't have a bug reported against
  them, but suffer from casting/rescaling as well.

The functions that seem sort of OK:
- ``imread``. Exposed also as ``ndimage.imread``.  Want to move to ``scipy.io``
  Also note the discussion in
  scipy#6242 (comment) about
  ``imsave``. Want to rename to ``imwrite`` and move to ``scipy.io`` (or write
  a new one without the rescaling issues and put that in ``io``).
- ``fromimage``.  Changes PIL image to ndarray.
- ``bytescale``.  Does some simple scaling of range of an array.

Closes scipygh-2347
Closes scipygh-2300
Closes scipygh-2442
Closes scipygh-3154
Closes scipygh-4458
Closes scipygh-4893
Closes scipygh-5305
Closes scipygh-6242
Closes scipygh-6417
Closes scipygh-7259
Closes scipygh-7458

See discussion about introducing scipy.io.imread/imwrite in
http://thread.gmane.org/gmane.comp.python.scientific.devel/20063
I didn't actually do that here, seems duplicate with matplotlib,
scikit-image, etc.  Can always be done separately if deemed a good
idea.  See also PR scipygh-5458 that make an attempt at this.
Copy link
Copy Markdown
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM, thanks for tackling this.

That is the most beautiful "closes" list I've ever seen :)



# Returns a byte-scaled image
@numpy.deprecate(message="`bytescale` is deprecated in SciPy 1.0.0.")
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 two releases is reasonable. So how about "... and will be removed in 1.2.0", assuming others agree.

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.

Two releases is our default policy, so sounds reasonable to me to start stating that explicitly for all deprecations.


This function is only available if Python Imaging Library (PIL) is installed.

**Warning**: this function uses `bytescale` under the hood to rescale
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.

Can use the .. warning:: directive

@stefanv
Copy link
Copy Markdown
Member

stefanv commented Sep 16, 2017

I'd suggest either adding imageio as a dependency, and exposing their versions of these functions, or referring users to that packages. Our aim with skimage is to eventually do the same.

@rgommers
Copy link
Copy Markdown
Member Author

Good point @stefanv. I'll just add a reference now. If we decide we need scipy.io.imread/imwrite after all, then we should indeed implement that as an imageio dependency.

@WarrenWeckesser
Copy link
Copy Markdown
Member

WarrenWeckesser commented Sep 16, 2017

@stefanv wrote:

I'd suggest either adding imageio as a dependency, and exposing their versions of these functions, or referring users to that packages.

I think the latter option is better. Wrapping an existing python package that appears to have a solid reputation, works with numpy arrays, and is under active development seems like a waste of effort on our part. It makes much more sense for us to just point users to imageio.

@rgommers
Copy link
Copy Markdown
Member Author

Comments addressed. Also added a commit that removes lena, which has been generating RuntimeErrors for the past 3 releases already.

@@ -55,7 +60,6 @@
__all__ = ['who', 'source', 'info', 'doccer', 'pade',
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.

If we're not importing doccer, we should also remove it from __all__.

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.

Good catch, I got tricked by my pyflakes checker. Restored.

@rgommers
Copy link
Copy Markdown
Member Author

OK in it goes, thanks all.

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

Labels

maintenance Items related to regular maintenance tasks scipy.misc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants