首页 文章

tf.image.convert_image_dtype之后的困惑图像(image,dtype = tf.uint8)

提问于
浏览
0

我已经读过灰度图像并且看起来很正常,但是在通过tf.image.convert_image_dtype()转换数据类型后,图像看起来很奇怪 . 我不知道发生了什么,感谢任何帮助 .

... ...
uint_inputs = tf.image.convert_image_dtype(inputs, dtype=tf.uint8, saturate=False)
... ...
with sv.managed_session() as sess:
    inputs, uint_inputs = sess.run([inputs, uint_inputs])
    f ,axis = plt.subplots(1, 2, figsize=(4, 2))
    axis[0].imshow(np.squeeze(inputs), cmap='gray')
    axis[1].imshow(np.squeeze(uint_inputs), cmap='gray')
    plt.show()

运行后的结果如下,

1 回答

  • 0

    经过长时间的斗争,我发现输入必须在[0,1]中,如果它们是 tf.image.convert_image_dtype(inputs, dtype=tf.uint8, saturate=False) 中的浮点类型 . 因此,我只是将输入按 inputs = inputs/255 缩放,然后输入 tf.image.convert_image_dtype pipline .

相关问题