gpt4 book ai didi

python - OpenCV:像素数与行数*列数

转载 作者:行者123 更新时间:2023-12-02 17:12:44 28 4
gpt4 key购买 nike

我运行以下代码:

import cv2
import numpy as np

img_file='pokemon.jpg'
img=cv2.imread(img_file)

# print total number of rows, columns and channels that are provided in the picture
print 'Image shape: ',img.shape # rows = 630, columns = 900

# now let us print the total number of pixels that the picture has
print 'Number of pixels: ', img.size # 1701000
print 630*900 # 56700

为什么最后两个输出不同?代表像素矩阵内组织的像素数量的列数和行数不是吗?

最佳答案

感谢@beaker的评论,答案是:

For multichannel images the columns contain as many sub columns as the number of channels. For example in case of an RGB color system:



Documentation.

关于python - OpenCV:像素数与行数*列数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28324125/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com