Skip to content
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

Use imageio instead of deprecated scipy functions to read and write images. #2088

Conversation

ericpre
Copy link
Member

@ericpre ericpre commented Nov 3, 2018

See https://docs.scipy.org/doc/scipy/reference/release.1.0.0.html#deprecated-features
Reading and saving images will break with the coming scipy 1.2 release.

Progress of the PR

  • replace imread and imsave functions from scipy with imageio imread and imwrite,
  • add imageio dependency,
  • add support for saving color image,
  • add tests,
  • ready for review.

Add tests for reading and writing images (png, jpeg, gif, bmp).
@sem-geologist
Copy link
Contributor

so imageio is getting to be used in hyperspy... As I can understand it is used only for non-electron microscopy formats?

@ericpre
Copy link
Member Author

ericpre commented Nov 8, 2018

Yes, because this is the most simple and what scipy recommend. See scipy/scipy#7869 for more details on the motivations.

For information on transitioning from scipy’s imread, this can be relevant:
https://imageio.readthedocs.io/en/stable/scipy.html

@sem-geologist
Copy link
Contributor

would not be better to make imageio optional library instead of hard requirement? The dependancy list of hyperspy is already so long. And imageio does not add any microscopy formats.`

@ericpre
Copy link
Member Author

ericpre commented Nov 14, 2018

would not be better to make imageio optional library instead of hard requirement? The dependancy list of hyperspy is already so long. And imageio does not add any microscopy formats.

imageio add quite a few formats and I personally use hyperspy very often to convert data to jpg so that I can browse my data very easily. imageio is a pure python library, so it is installed without any problem.

@sem-geologist
Copy link
Contributor

@ericpre , you just identified the problem I have with hyperspy using matplotlib instead of i.e. pyqtgraph. And that is sad, that we need one another library just to browse the data (as matplotlib is slow as hell) out from hyperspy.

@francisco-dlp
Copy link
Member

LGTM.

Regarding the dependency debate, in Rnp we should leave things as they are. I agree with @ericpre that adding this dependency costs very little as it's going to be a requirement of multiple packages that we depend on. However, it's true that it is not necessary to run hyperspy itself, so, after the split, this should be an optional dependency.

@sem-geologist, regarding matplotlib being slow at browsing images, as you probably know, the situation improves when disabling the axes, scale bar etc. But, anyway, it's certainly still slow for big images and it'll be good to implement a different alternative backend even if only for images.

@francisco-dlp francisco-dlp merged commit cf2e23b into hyperspy:RELEASE_next_patch Dec 5, 2018
@ericpre ericpre deleted the fix_deprecated_functions_scipy branch December 5, 2018 16:14
@francisco-dlp francisco-dlp added this to the v1.4.2 milestone May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants