module scipy.misc has no attribute imresize
时间: 2023-10-30 16:59:20 浏览: 127
Python各类图像库的图片读写方式总结(推荐)
The `imresize` function in the `scipy.misc` module is deprecated and no longer available in recent versions. It has been removed because it was not properly maintaining the aspect ratio of the image when resizing.
Instead, you can use the `resize` function from the `scipy.ndimage` module to resize images. Here's an example of how you can use it:
```python
from scipy import ndimage
import matplotlib.pyplot as plt
# Load the image
image = plt.imread('image.jpg')
# Resize the image to a specific size
resized_image = ndimage.zoom(image, (0.5, 0.5, 1))
# Display the original and resized images
plt.subplot(1, 2, 1)
plt.imshow(image)
plt.title('Original Image')
plt.subplot(1, 2, 2)
plt.imshow(resized_image)
plt.title('Resized Image')
plt.show()
```
This example resizes the image by a factor of 0.5 in both dimensions. You can adjust the zoom factors to achieve the desired size.
阅读全文