我只是想将 EXR 转换为 jpg 图像,但结果却很暗。有谁知道我在这里做错了什么?我正在标准化图像值,然后将它们放入 0-255 色彩空间。它仍然看起来不正确。
用于测试 exr 图像的 Dropbox 链接:https ://www.dropbox.com/s/9a5z6fjsyth7w98/torus.exr?dl=0
import sys, os
import imageio
def convert_exr_to_jpg(exr_file, jpg_file):
if not os.path.isfile(exr_file):
return False
filename, extension = os.path.splitext(exr_file)
if not extension.lower().endswith('.exr'):
return False
# imageio.plugins.freeimage.download() #DOWNLOAD IT
image = imageio.imread(exr_file, format='EXR-FI')
# remove alpha channel for jpg conversion
image = image[:,:,:3]
# normalize the image
data = image.astype(image.dtype) / image.max() # normalize the data to 0 - 1
data = 255 * data # Now scale by 255
rgb_image = data.astype('uint8')
# rgb_image = imageio.core.image_as_uint(rgb_image, bitdepth=8)
imageio.imwrite(jpg_file, rgb_image, format='jpeg')
return True
if __name__ == '__main__':
exr = "C:/Users/John/images/torus.exr"
jpg = "C:/Users/John/images/torus.jpg"
convert_exr_to_jpg(exr, jpg)