没有合适的资源?快使用搜索试试~ 我知道了~
首页详解python opencv、scikit-image和PIL图像处理库比较
详解python opencv、scikit-image和PIL图像处理库比较
1.8k 浏览量
更新于2023-03-16
评论 1
收藏 160KB PDF 举报
主要介绍了详解python opencv、scikit-image和PIL图像处理库比较,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
资源详情
资源评论
资源推荐

详解详解python opencv、、scikit-image和和PIL图像处理库比较图像处理库比较
主要介绍了详解python opencv、scikit-image和PIL图像处理库比较,文中通过示例代码介绍的非常详细,对大
家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
进行深度学习时,对图像进行预处理的过程是非常重要的,使用pytorch或者TensorFlow时需要对图像进行预处理以及展示来
观看处理效果,因此对python中的图像处理框架进行图像的读取和基本变换的掌握是必要的,接下来python中几个基本的图像
处理库进行纵向对比。
项目地址:https://github.com/Oldpan/Pytorch-Learn/tree/master/Image-Processing
比较的图像处理框架:
PIL
scikit-image
opencv-python
PIL::
由于PIL仅支持到Python 2.7,加上年久失修,于是一群志愿者在PIL的基础上创建了兼容的版本,名字叫Pillow,支持最新
Python 3.x,又加入了许多新特性,因此,我们可以直接安装使用Pillow。
摘自廖雪峰的官方网站
scikit-image
scikit-image is a collection of algorithms for image processing. It is available free of charge and free of restriction. We pride
ourselves on high-quality, peer-reviewed code, written by an active community of volunteers.
摘自官网的介绍,scikit-image的更新还是比较频繁的,代码质量也很好。
opencv-python
opencv的大名就不要多说了,这个是opencv的python版
# Compare Image-Processing Modules
# Use Transforms Module of torchvision
# &&&
# 对比python中不同的图像处理模块
# 并且使用torchvision中的transforms模块进行图像处理
# packages
from PIL import Image
from skimage import io, transform
import cv2
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
%matplotlib inline
img_PIL = Image.open('./images/dancing.jpg')
img_skimage = io.imread('./images/dancing.jpg')
img_opencv = cv2.imread('./images/dancing.jpg')
img_plt = plt.imread('./images/dancing.jpg')
loader = transforms.Compose([
transforms.ToTensor()]) # 转换为torch.tensor格式
print('The shape of img_skimage is {} img_opencv is {} img_plt is {}'.format(img_skimage.shape, img_opencv.shape, img_plt.shape))
print('The type of img_skimage is {}\n img_opencv is {} img_plt is {}'.format(type(img_skimage), type(img_opencv), type(img_plt)))
The shape of
img_skimage is (444, 444, 3)
img_opencv is (444, 444, 3)
img_plt is (444, 444, 3)
The size of
img_PIL is (444, 444)
The mode of
img_PIL is RGB
The type of
img_skimage is <class 'numpy.ndarray'>
img_opencv is <class 'numpy.ndarray'>
img_plt is <class 'numpy.ndarray'>
img_PIL if <class 'PIL.JpegImagePlugin.JpegImageFile'>
# 定义一个图像显示函数


















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0