如何在tensoflow中将float32 tif图像解码为float32张量? [英] How to decode float32 tif images to float32 tensor in tensoflow?
本文介绍了如何在tensoflow中将float32 tif图像解码为float32张量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一组 tif 格式的 float32 数据类型的输入图像(rgb)和图像目标(灰度).是否可以在 tensorflow 中将它们解码为 float32 张量?
I have a sets of input images (rgb) and image targets (grayscale) in float32 data type by tif format. Is it possible to decode them into float32 tensor in tensorflow?
推荐答案
在撰写此评论时 tfio.experimental.image.decode_tiff()
.然而,输出格式是 uint8 而不是 float32.
At the time of writing this comment tfio.experimental.image.decode_tiff()
. Nevertheless the output format is uint8 rather than float32.
我建议您使用 OpenCV 或 Pillow 阅读图像.
I suggest that you read the image with OpenCV or Pillow.
例如使用 OpenCV:
E.g with OpenCV:
import cv2
import tensorflow as tf
image = cv2.imread('image.tif')
tf_tensor = tf.convert_to_tensor(image, dtype=float32)
这篇关于如何在tensoflow中将float32 tif图像解码为float32张量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文