我正在尝试显示浮点数组中的图像,该图像应该是灰度数字。但图像远非如此

问题描述 投票:0回答:0

X_train 的形状为 (32,32),有 32 个浮点数图像

X_train[0] 是

数组([115.1609, 114.161, 113.1611, 112.7482, 112.5633, 114.6771, 115.3781、115.0792、115.0792、114.0793、112.9654、110.9656、 110.0797、112.9654、114.8512、111.4386、109.1507、109.5636、 113.1503、116.623、111.9332、106.1187、100.5923、102.2932、 106.8197、107.8196、108.8195、110.9333、111.6882、112.0302、 112.6711, 112.7851], dtype=float32)

x = (X_train[1]).reshape(4,8).astype(np.uint8)
img = Image.fromarray(x,'1')

n_img = img.resize((100,100))

n_img

我正在调整它的大小,因为它太小了,图像应该是灰度图像。 我试图在将图像输入神经网络模型之前将其可视化

显示的图像远不及数字。我试过 顺便说一句,我正在做的是谷歌colab。我是否使用了错误的图像格式(unit8)。

python deep-learning python-imaging-library
© www.soinside.com 2019 - 2024. All rights reserved.