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()

输入图片:
InputImage

输出图片:
OutputImage

参考资料:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值