DEP: deprecate misc.pilutil functions#7869
Conversation
cf32f0f to
4836516
Compare
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.
larsoner
left a comment
There was a problem hiding this comment.
Otherwise LGTM, thanks for tackling this.
That is the most beautiful "closes" list I've ever seen :)
scipy/misc/pilutil.py
Outdated
|
|
||
|
|
||
| # Returns a byte-scaled image | ||
| @numpy.deprecate(message="`bytescale` is deprecated in SciPy 1.0.0.") |
There was a problem hiding this comment.
I think two releases is reasonable. So how about "... and will be removed in 1.2.0", assuming others agree.
There was a problem hiding this comment.
Two releases is our default policy, so sounds reasonable to me to start stating that explicitly for all deprecations.
scipy/misc/pilutil.py
Outdated
|
|
||
| This function is only available if Python Imaging Library (PIL) is installed. | ||
|
|
||
| **Warning**: this function uses `bytescale` under the hood to rescale |
There was a problem hiding this comment.
Can use the .. warning:: directive
|
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. |
|
Good point @stefanv. I'll just add a reference now. If we decide we need |
|
@stefanv wrote:
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. |
|
Comments addressed. Also added a commit that removes |
| @@ -55,7 +60,6 @@ | |||
| __all__ = ['who', 'source', 'info', 'doccer', 'pade', | |||
There was a problem hiding this comment.
If we're not importing doccer, we should also remove it from __all__.
There was a problem hiding this comment.
Good catch, I got tricked by my pyflakes checker. Restored.
50dbdb5 to
b6cd8d6
Compare
|
OK in it goes, thanks all. |
The reasons for these deprecations are:
Summary of issues:
imsaverescales images (Wrong image scaling in scipy/misc/pilutil.py with misc.imsave? #5305)imresizerescales images (scipy.misc.imresize changes image range #4458) and casts to different dtype (scipy.misc.imresize converts images to uint8 #6417)toimageis the root cause of casting and scaling issues, one more separate bug report at scipy.misc.toimage (and therefore imresize) converts to uint32 when it should convert to int32 (Trac #1781) #2300imfilter,imrotateandimshowdon't have a bug reported against them, but suffer from casting/rescaling as well.The functions that seem sort of OK:
imread. Exposed also asndimage.imread. Want to move toscipy.io. Also note the discussion in Inconsistency / duplication for imread and imshow, imsave #6242 (comment) aboutimsave. Want to rename toimwriteand move toscipy.io(or write a new one without the rescaling issues and put that inio).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.