matplotlib库

matplotlib.pyplot =plt

一.介绍

二.方法

1.plt.imread(“图片的路径”),输出是数组,三行三列,每个数字都是rgb颜色值。

(1).plt.imread(‘D:\learning\jupyter work\zhaoliying.jpg’)

输出:array([[[167, 180, 163], [168, 181, 164], [171, 184, 167], …, [177, 185, 172], [178, 186, 173], [178, 186, 173]], [[171, 184, 167], [164, 177, 160], [168, 181, 164], …, [177, 185, 172], [178, 186, 173], [178, 186, 173]], [[171, 184, 167], [165, 178, 161], [168, 181, 164], …, [175, 183, 170], [178, 186, 173], [181, 189, 176]], …, [[182, 188, 174], [185, 191, 177], [187, 193, 179], …, [235, 240, 234], [235, 240, 234], [236, 241, 235]], [[185, 191, 177], [183, 189, 175], [182, 188, 174], …, [235, 240, 234], [235, 240, 234], [236, 241, 235]], [[183, 192, 175], [181, 190, 173], [183, 192, 175], …, [237, 242, 236], [237, 242, 236], [238, 243, 237]]], dtype=uint8)

(2).zhaoliying = plt.imread(‘zhaoliying.jpg’)

type(zhaoliying)

输出:numpy.ndarray,说明这是一个ndarray类型。

2.plt.imshow(zhaoliying)

输出:<matplotlib.image.AxesImage at 0x261ae7029e8>

3.plt.show(zhaoliying)

显示图片

4.zhaoliying1=zhaoliying-500

显示图片颜色有变化

5.zhaoliying.shape

输出:(1105, 1108, 3) #1105是长,1108是宽,3表示颜色,任何一个二维图片转换成三维数组

猜你喜欢

转载自blog.csdn.net/MingZier_/article/details/83049821
今日推荐