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

No imread() in 2020's Scipy v1.5.x. How to read image to feed to cpbd.compute() ? #2

Open
RubinXnibu opened this issue Oct 24, 2020 · 3 comments

Comments

@RubinXnibu
Copy link

I am unable to read an image for cpbd.compute() to process. The example usage in README is broken.

This code:
from scipy import ndimage
input_image = ndimage.imread('/tmp/LIVE_Images_GBlur/img4.bmp', mode='L')

Results in:
AttributeError: module 'scipy.ndimage' has no attribute 'imread'

The docs for Scipy say imread was removed in version 1.2,
"imread is deprecated in SciPy 1.0. 0, and will be removed in 1.2."
https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.misc.imread.html

I have found a StackOverflow page that recommends using image.io:
https://stackoverflow.com/questions/15345790/scipy-misc-module-has-no-attribute-imread

However, there is no mode="L" parameter, just a format param, which overrides the image format guess from the extension (ie format="JPEG").

 import imageio
 iio_image = imageio.imread(inputpath)
 cpbd_focus1 = cpbd.compute(iio_image)

However, using plain imageio.imread results in cpbd complaining about the input shape, because its in RGB.
ValueError: The parameter image must be a 2-dimensional array

If I convert the image to grayscale, it works.

import cpbd
import cv2
import imageio
iio_image = imageio.imread('testimg.jpg')
grey_iio_image = cv2.cvtColor(iio_image, cv2.COLOR_BGR2GRAY)
cpbd.compute(grey_iio_image)
0.25540727105384264

Please update your README to address this change in modern scipy.

Thank you!!

@NeelKanwal
Copy link

After installing, there is error in CPBD, tried to reduce the version of scipy but did not work for me.

ImportError Traceback (most recent call last)
in ()
----> 1 import cpbd
2 cpbd.compute(img)

1 frames
/usr/local/lib/python3.7/dist-packages/cpbd/compute.py in ()
12
13 import numpy as np
---> 14 from scipy.ndimage import imread
15 from skimage.feature import canny
16

ImportError: cannot import name 'imread' from 'scipy.ndimage' (/usr/local/lib/python3.7/dist-packages/scipy/ndimage/init.py)


NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.

@mahtabbigverdi
Copy link

I have the same problem!

@ajlok3
Copy link

ajlok3 commented Oct 7, 2022

You can replace the corresponding line with:
from matplotlib.pyplot import imread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants