1. 程式人生 > >python 中opencv, PIL, skimage, scipy matplotlib中的細節說明

python 中opencv, PIL, skimage, scipy matplotlib中的細節說明

0. 寫作目的

好記性不如爛筆頭。、

1. 有關size返回的說明

tensorflow中需要的tensor型別為: (N, H, W, C)其中N是batch 大小,H是height, W是width,C是通道的數目。

PIL中  pil_img.size 函式返回的是 tuple型別的(width, height),如果怕出錯,可以pil_img.width 或者pil_img.height獲取影象的大小。影象的畫素值是[0, 255]。

Opencv中 cv_img.shape() 函式返回的是 tuple型別的(height, width, channel)。但是opencv中的通道順序不是RGB,而是GBR。影象的畫素值是[0, 255]。

matplotlib中 import matplotlib.pyplot as plt 

plt_img = plt.imread( imgDir )

plt_img.shape() 函式返回的tuple型別的(height, width, channel),但是通道的是順序為RGB。影象畫素值為[0, 255]。