Python 实现OpenCV格式和PIL.Image格式互转
2020-02-13 11:32
901 查看
OpenCV转换成PIL.Image格式:
import cv2 from PIL import Image import numpy img = cv2.imread("plane.jpg") cv2.imshow("OpenCV",img) image = Image.fromarray(cv2.cvtColor(img,cv2.COLOR_BGR2RGB)) image.show() cv2.waitKey()
PIL.Image转换成OpenCV格式:
import cv2 from PIL import Image import numpy image = Image.open("plane.jpg") image.show() img = cv2.cvtColor(numpy.asarray(image),cv2.COLOR_RGB2BGR) cv2.imshow("OpenCV",img) cv2.waitKey()
以上这篇Python 实现OpenCV格式和PIL.Image格式互转就是小编分享给大家的全部内容了,希望能给大家一个参考
您可能感兴趣的文章:
相关文章推荐
- python中PIL.Image和OpenCV图像格式相互转换
- python中PIL.Image和OpenCV图像格式相互转换
- Python实现批量修改图片格式和大小的方法【opencv库与PIL库】
- python中PIL.Image和OpenCV图像格式相互转换
- python+OpenCV 实现image-stitching 图像拼接
- python深度学习库pytorch::transforms练习:opencv,scikit-image,PIL图像处理库比较
- Python 图片Base64解码 还原PIL.Image或Opencv
- Python3实现转换Image图片格式
- python实现通过pil模块对图片格式进行转换的方法
- python3读取图片并灰度化图片的四种方法(OpenCV、PIL.Image、TensorFlow方法)总结
- 图像处理之PIL.Image与numpy.array之间的相互转换 (Python-OpenCV)
- Python图像处理库:PIL中Image,ImageDraw等基本模块介绍
- Ubuntu下给Python2安装PIL(Python_Image_Library)
- python处理文本文件实现生成指定格式文件的方法
- 【转】OpenCV与CxImage转换(IplImage)、IplImage QImage Mat 格式互转
- python 借助opencv实现Gabor滤波特征提取
- Python的PIL库实现验证码图片
- C++ budilder 使用ImageOle.dll 实现richedit显示任意格式图片和连接 gif
- Python实现批量把SVG格式转成png、pdf格式的代码分享
- Python中使用PIL库实现图片高斯模糊实例