【发布时间】:2020-06-22 23:58:02
【问题描述】:
我有一组图像像素值,我想将其放大以输入到我的神经网络中。它是一个形状数组 (28000, 48, 48, 1)。这些是归一化的图像像素值,并且希望将它们放大到更高的分辨率以输入到我的 CNN 中。数组看起来像这样......
array([[[[-0.6098866 ],
[-0.4592209 ],
[-0.40325198],
...,
[-0.7694696 ],
[-0.90518403],
[-0.95160526]],
[[-0.66049284],
[-0.68162924],
[-0.694159 ],
我的X_train 和y_train 图像数组的形状都是(28000,48,48,1)。我想将这 28000 个图像阵列放大或调整大小为 75x75。请帮忙。我应该将数组转换回非标准化数组或图像,然后使用 cv2 进行升级吗?我该怎么做?
【问题讨论】:
-
试过
scipy.misc.imresize()或skimage.transform.resize()吗? -
也在调查这个。对于我只有数组而不是图像的用例来说很难。
-
import matplotlib.pyplot as plt import cv2 image_array = X_train[0] img = image_array.reshape(48,48) resized_width = 75 resized_height = 75 dimension = (resized_width, resized_height) resized = cv2.resize (img, 尺寸, 插值 = cv2.INTER_CUBIC) print(resized.shape) image_array = resized.flatten() print(len(image_array))
-
上面的代码在 cv2 上也能正常工作。这让我在展平后得到了一个长度为 5625(75x75)的数组。所以现在我需要对所有 28000 个图像执行此操作以获得最终大小数组 (28000, 5625) 我将如何循环并执行此操作?
标签: python computer-vision conv-neural-network object-detection image-resizing