我正在随机调整图像的亮度、饱和度等。但经过调整后,img_data的值超过0-1,因此imshow将不起作用。
tf.InteractiveSession()
image_raw_data=tf.read_file('C:/Users/User/PycharmProjects/Neural_Network\\cat.jpg')
sess=tf.Session()
img_data=tf.image.decode_jpeg(image_raw_data,channels=3)
img_data=tf.image.convert_image_dtype(img_data,dtype=tf.float32)
img_data=tf.image.resize_images(img_data,[300,300],method=0)
img_data=tf.image.random_brightness(img_data,max_delta=32/255)
plt.imshow(img_data.eval())错误是:
ValueError: Floating point image RGB values must be in the 0..1 range.我可以知道我应该如何正确地转换图像以使其能够显示?
发布于 2018-02-27 22:02:02
我要做的纯粹是将图像可视化,将图像中的最小值相加,然后除以最大值,以如下方式将图像夹在0和1之间:
import numpy as np
img_data_np = img_data.eval()
min_val = np.min(img_data_np)
max_val = np.max(img_data_np)
img_data_clamped = (img_data_np - min_val) / (max_val - min_val)
plt.imshow(img_data_clamped)https://stackoverflow.com/questions/49007816
复制相似问题