我正在使用以下函數來調整形狀爲(samples, 1, image_row, image_column)
的圖像集的大小。我正在使用skimage
庫。使用skimage python庫調整圖像大小後丟失信息
from skimage import io
from skimage.transform import resize
def preprocess(imgs):
imgs_p = np.ndarray((imgs.shape[0], imgs.shape[1], img_rows, img_cols), dtype=np.uint8)
for i in range(imgs.shape[0]):
imgs_p[i, 0] = resize(imgs[i, 0], (img_rows, img_cols))
return imgs_p
然而,我注意到,縮放後的圖像樣變成0-1陣列。以下是一些測試結果。我們可以看到調整大小的圖像只包含0-1值。我不知道我的調整大小功能有什麼問題。
print(image[0,0].shape)
(420, 580)
print(image[0,0])
[[ 0 155 152 ..., 87 91 90]
[ 0 255 255 ..., 140 141 141]
[ 0 255 255 ..., 157 156 158]
...,
[ 0 77 63 ..., 137 133 122]
[ 0 77 63 ..., 139 136 127]
[ 0 77 64 ..., 149 144 137]]
print(resized_image[0,0].shape)
(96, 128)
print(resized_image[0,0])
[[1 1 0 ..., 0 0 0]
[0 0 0 ..., 0 0 0]
[0 0 0 ..., 0 0 0]
...,
[0 0 0 ..., 0 0 0]
[0 0 0 ..., 0 0 0]
[0 0 0 ..., 0 0 0]]