AttributeError:模块“ PIL”没有属性“ Image”

时间:2020-10-25 15:36:58

标签: python python-3.x opencv image-processing

这是我为opencv运行的示例代码

import cv2
from google.colab.patches import cv2_imshow

img = cv2.imread('rose.png')
print("Image Properties")
print(" - Number of Pixels:" + str(img.size))
print("-Shape/Dimensions:" + str(img.shape))

blue, green, red = cv2.split(img) # Split the image into its channels
img_gs = cv2.imread('rose.png', cv2.IMREAD_GRAYSCALE) # Convert image to grayscale
cv2_imshow(img_gs)

以下是我得到的错误。我尝试了其他解决方案,提示枕头版本等存在问题。但是,这不起作用。

cv2_imshow(img_gs)
  File "/Users/fazalshaik/.pyenv/versions/myproject/lib/python3.6/site-packages/google/colab/patches/__init__.py", line 29, in cv2_imshow
    display.display(PIL.Image.fromarray(a))
AttributeError: module 'PIL' has no attribute 'Image'

0 个答案:

没有答案