当我读取png文件时,如何解释matplotlib的imread
函数读入的数据?
>>> img = mpimg.imread('stinkbug.png')
>>> img
array([[[ 0.40784314, 0.40784314, 0.40784314],
[ 0.40784314, 0.40784314, 0.40784314],
[ 0.40784314, 0.40784314, 0.40784314],
...,
[ 0.42745098, 0.42745098, 0.42745098],
[ 0.42745098, 0.42745098, 0.42745098],
[ 0.42745098, 0.42745098, 0.42745098]],
...,
[[ 0.44313726, 0.44313726, 0.44313726],
[ 0.4509804 , 0.4509804 , 0.4509804 ],
[ 0.4509804 , 0.4509804 , 0.4509804 ],
...,
[ 0.44705883, 0.44705883, 0.44705883],
[ 0.44705883, 0.44705883, 0.44705883],
[ 0.44313726, 0.44313726, 0.44313726]]], dtype=float32)
我知道[0.40784314, 0.40784314, 0.40784314]
的含义,但我不知道以下含义:
[[ 0.40784314, 0.40784314, 0.40784314],
[ 0.40784314, 0.40784314, 0.40784314],
[ 0.40784314, 0.40784314, 0.40784314],
...,
[ 0.42745098, 0.42745098, 0.42745098],
[ 0.42745098, 0.42745098, 0.42745098],
[ 0.42745098, 0.42745098, 0.42745098]],
来源:http://matplotlib.org/users/image_tutorial.html
PS:我已经编辑了问题以包含原始链接(从中复制的地方),这可能有助于回答问题,而且,这与在StackOverflow中发布链接有点无关,仍然没有标记,因为我我不确定它是否无关紧要。
答案 0 :(得分:0)
imread吐出一组数组数组。行列表,每行中的像素列表以及表示每个像素颜色的列表。
这只是图像中的一行像素。结果在中间截断,因此当您将其打印出来时,您只能看到该行的第一个和最后一个3个像素。
[[ 0.40784314, 0.40784314, 0.40784314],
[ 0.40784314, 0.40784314, 0.40784314],
[ 0.40784314, 0.40784314, 0.40784314],
...,
[ 0.42745098, 0.42745098, 0.42745098],
[ 0.42745098, 0.42745098, 0.42745098],
[ 0.42745098, 0.42745098, 0.42745098]],