AttributeError: shape | When using skimage resize with pyscreenshot.grab() as input?
AttributeError: shape | When using skimage resize with pyscreenshot.grab() as input?
我正在尝试将使用 pyscreenshot.grab() 捕获的图像调整为 28x28 像素
import pyscreenshot
from skimage.transform import resize
def captureAndSubsample():
userImage = pyscreenshot.grab(bbox=(785, 335, 1125, 675))
userImageResized = resize(userImage, (28, 28))
此代码returns:
>
File "C:\Users\brad\Desktop\Development\Code\main.py", line 178, in captureAndSubsample
userImageResized = resize(userImage, (100, 100), 3)
File "C:\Users\brad\Desktop\Development\Code\venv\lib\site-packages\skimage\transform\_warps.py", line 144, in resize
image, output_shape = _preprocess_resize_output_shape(image, output_shape)
File "C:\Users\brad\Desktop\Development\Code\venv\lib\site-packages\skimage\transform\_warps.py", line 56, in _preprocess_resize_output_shape
input_shape = image.shape
File "C:\Users\brad\Desktop\Development\Code\venv\lib\site-packages\PIL\Image.py", line 519, in __getattr__
raise AttributeError(name)
AttributeError: shape
<
我试过将输入图像更改为形状:
def captureAndSubsample():
userImage = pyscreenshot.grab(bbox=(785, 335, 1125, 675))
userImage = shape(userImage)
userImageResized = resize(userImage, (100, 100)).shape(340, 340)
但这 returns 与 returns 维度的元组相同,我们将不胜感激。
在传递给 scikit-image 函数之前将 userImage
转换为 numpy 数组就可以了。
import pyscreenshot
import numpy as np
from skimage.transform import resize
userImage = pyscreenshot.grab(bbox=(785, 335, 1125, 675))
userImage = np.array(userImage)
userImageResized = resize(userImage, (28, 28))
我正在尝试将使用 pyscreenshot.grab() 捕获的图像调整为 28x28 像素
import pyscreenshot
from skimage.transform import resize
def captureAndSubsample():
userImage = pyscreenshot.grab(bbox=(785, 335, 1125, 675))
userImageResized = resize(userImage, (28, 28))
此代码returns:
>
File "C:\Users\brad\Desktop\Development\Code\main.py", line 178, in captureAndSubsample
userImageResized = resize(userImage, (100, 100), 3)
File "C:\Users\brad\Desktop\Development\Code\venv\lib\site-packages\skimage\transform\_warps.py", line 144, in resize
image, output_shape = _preprocess_resize_output_shape(image, output_shape)
File "C:\Users\brad\Desktop\Development\Code\venv\lib\site-packages\skimage\transform\_warps.py", line 56, in _preprocess_resize_output_shape
input_shape = image.shape
File "C:\Users\brad\Desktop\Development\Code\venv\lib\site-packages\PIL\Image.py", line 519, in __getattr__
raise AttributeError(name)
AttributeError: shape
<
我试过将输入图像更改为形状:
def captureAndSubsample():
userImage = pyscreenshot.grab(bbox=(785, 335, 1125, 675))
userImage = shape(userImage)
userImageResized = resize(userImage, (100, 100)).shape(340, 340)
但这 returns 与 returns 维度的元组相同,我们将不胜感激。
在传递给 scikit-image 函数之前将 userImage
转换为 numpy 数组就可以了。
import pyscreenshot
import numpy as np
from skimage.transform import resize
userImage = pyscreenshot.grab(bbox=(785, 335, 1125, 675))
userImage = np.array(userImage)
userImageResized = resize(userImage, (28, 28))