TypeError: src is not a numpy array, neither a scalar----PIL Image转成opencv Image

文章目录

  • 方法及运行结果
  • 参考资料:

方法及运行结果

#PIL Image转成opencv Image
#python-Version3.7.1
#
'''Packages&Version
numpy==1.15.3
opencv-python==3.4.2.16
opencv-contrib-python==3.4.2.16
Pillow-PIL==0.1.dev0
'''
from PIL import Image, ImageEnhance
import cv2
import numpy
pil_image = Image.open('image.jpg')
contrast_enhancer = ImageEnhance.Contrast(pil_image)
pil_enhanced_image = contrast_enhancer.enhance(2)
enhanced_image = np.asarray(pil_enhanced_image)
r, g, b = cv2.split(enhanced_image)
enhanced_image = cv2.merge([b, g, r])
cv2.imshow('Enhanced Image', enhanced_image)
cv2.waitKey()

输入图片:
TypeError: src is not a numpy array, neither a scalar----PIL Image转成opencv Image_第1张图片

输出图片:
TypeError: src is not a numpy array, neither a scalar----PIL Image转成opencv Image_第2张图片

参考资料:

1.TypeError: src is not a numpy array, neither a scalar

你可能感兴趣的:(Python)