图片数据读取性能比较

图片数据读取速度比较

import time
import cv2
import os
import numpy as np


# opencv
N = 100
tic = time.time()
for i in range(N):
    img=cv2.imread(r'D:\code\testAndExperiment\py\Gluon\test1\1.jpeg',1)
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
print(N/(time.time()-tic), 'images decoded per second with opencv')


from scipy.misc import imread
N = 100
tic = time.time()
for i in range(N):
    img = imread(r'D:\code\testAndExperiment\py\Gluon\test1\1.jpeg')
print(N/(time.time()-tic), 'images decoded per second with scipy.misc')

from skimage import io
N = 100
tic = time.time()
for i in range(N):
    img = io.imread(r'D:\code\testAndExperiment\py\Gluon\test1\1.jpeg')
print(N/(time.time()-tic), 'images decoded per second with skimage')

# # pillow
from PIL import Image
N = 100
tic = time.time()
for i in range(N):
    img = Image.open(r'D:\code\testAndExperiment\py\Gluon\test1\1.jpeg')
    img = np.array(img)
print(N/(time.time()-tic), 'images decoded per second with pillow')

# mx.image
import mxnet as mx
N = 100
tic = time.time()
for i in range(N):
    img = mx.image.imdecode(open(r'D:\code\testAndExperiment\py\Gluon\test1\1.jpeg','rb').read())
mx.nd.waitall()
print(N/(time.time()-tic), 'images decoded per second with mx.image')

测试可能受环境影响,结果据说mx是OpenCV的5倍
https://www.lizenghai.com/archives/49800.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值