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

replacing deprecated imresize #103

Open
cxrodgers opened this issue Jul 1, 2019 · 4 comments
Open

replacing deprecated imresize #103

cxrodgers opened this issue Jul 1, 2019 · 4 comments

Comments

@cxrodgers
Copy link

In scipy v1.3, the scipy.misc.imread and scipy.misc.imresize functions are no longer available. These are used throughout this package, especially in loading data in pose_dataset.py.

There's an easy replacement for imread : imageio.imread

For imresize, there are several choices:

  • scipy.ndimage.zoom
  • skimage.transform.resize
  • PIL.Image.resize

These differ slightly in their implementation details (e.g., type of interpolation, anti-aliasing filters). Any preferences for which would be best?

My feeling is that scipy.ndimage.zoom is the best because it doesn't require adding a dependency (skimage or PIL). Also, the function signature is the same as the old scipy.misc.imresize, so it's a drop-in replacement.

@cxrodgers
Copy link
Author

Here is a commit in my own fork that demonstrates the change:
cxrodgers@f36d9f1

I can turn this into a PR if people like this approach

@DenisPolygalov
Copy link

My feeling is that scipy.ndimage.zoom is the best because it doesn't require adding a dependency (skimage or PIL). Also, the function signature is the same as the old scipy.misc.imresize, so it's a drop-in replacement.

not quite correct. It does not have 'interp' keyword argument which is used in util/visualize.py
But anyway, unfortunately this repository is abandoned as many others intended to have papers as outputs...

@cxrodgers
Copy link
Author

I see. I don't use util/visualize.py so I didn't know about that.

Here is the code I'm currently using in pose_dataset.py. Perhaps it will be useful for others.

        # Resize the image
        if scale == 1:
            img = image
        else:
            # Zoom each color channel separately
            img = np.array([
                scipy.ndimage.zoom(image[:, :, channel], scale, mode='reflect')
                for channel in range(image.shape[2])])
            img = np.moveaxis(img, 0, -1)

@pouryajafarzadeh
Copy link

I solve it by uninstalling scipy, and:
pip install scipy==1.21

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

3 participants