
因为格式都是压缩格式的数据,并不是说总像素相同两个图像就相同。一张内容丰富的个一张纯白色占用的空间是不一样的。也就是说opencv在解压图像时需要处理的数据量和计算量是不同的。所以,依据图像的不同,加载图像的时间也是不一样的。
经测试,同一张,使用 PIL 和 OpenCv 库读取的数据是一样的(经过BGR转成RGB):
执行结果:
建议:可以尝试更新 PIL 或是 OpenCv 库。
本机测试环境: Python 37+Pillow 62 +opencv-python 41
参数不对。
imread(const string& filename, int flags=1 )
filename – Name of file to be loaded
flags –
Flags specifying the color type of a loaded image:
In the current implementation the alpha channel, if any, is stripped from the output image Use negative value if you need the alpha channel
CV_LOAD_IMAGE_ANYDEPTH - If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit
CV_LOAD_IMAGE_COLOR - If set, always convert image to the color one
CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one
Note:
>0 Return a 3-channel color image
=0 Return a grayscale image
<0 Return the loaded image as is (with alpha channel)
以上就是关于opencv 用imread读取多张图片(图片大小相同)时,读取时间不同全部的内容,包括:opencv 用imread读取多张图片(图片大小相同)时,读取时间不同、为什么用Python的openCV读取图片与PIL读取的图片像素值会不一样、用OpenCV中的imread读取图像,图是彩色图,而为什么dims是2呢!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)