【发布时间】:2017-01-06 02:59:01
【问题描述】:
我正在使用以下函数来调整形状为(samples, 1, image_row, image_column) 的图像集的大小。我正在使用skimage 库。
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]]
【问题讨论】:
标签: python image-processing scipy scikit-image