1,彩色图像的维度、灰度图像的维度:(灰度图是2维矩阵,rgb彩色图是3维的)
彩色图像在Matlab存储的矩阵是3维的;对于BMP或JPEG图像image(h;w;z);h是图片的高,w是图片宽,z可以为1、2、3,分别对应R,G,B三原色。
2,python各类图像读写
import matplotlib.pyplot as plt
from PIL import Image
img = Image.open('N_0000001939_00054.jpg')
print(img.size)
print(img.mode)
plt.imshow(img)
plt.show()
img = Image.open('KA.AN1.39.tiff')
print(img.size)
print(img.mode)
plt.imshow(img)
plt.show()
'''
输出结果:
(128, 128)
RGB
(256, 256)
P
'''
import matplotlib.pyplot as plt
import cv2
img = cv2.imread('N_0000001939_00054.jpg')
print(img.shape)
print(type(img))
io.imshow(img)
plt.show()
img = cv2.imread('KA.AN1.39.tiff')
print(type(img))
print(img.shape)
io.imshow(img)
plt.show()
'''
输出结果:
(128, 128, 3)
(256, 256, 3)
'''
3,图像的mode=p,这是什么图像