Skip to content

Instantly share code, notes, and snippets.

@taikomatsu
Created May 29, 2019 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taikomatsu/7d82a1cdbaeaee9b693e5984574eb50c to your computer and use it in GitHub Desktop.
Save taikomatsu/7d82a1cdbaeaee9b693e5984574eb50c to your computer and use it in GitHub Desktop.
Display hdr
import numpy as np
import imageio
from PIL import Image
import matplotlib.pyplot as plt
# imageioで画像を読み込み
imgpath = 'myhdri.hdr'
imageio.plugins.freeimage.download()
img = imageio.imread(imgpath)
# ガンマ補正
img = np.power(img, 1/2.2)
# float32からuint8に変更
img = np.clip(np.floor(img*255), 0, 255).astype(np.uint8)
# 表示方法その1
# Imageオブジェクトにしてリサイズしてデフォルトのビューワーで表示
image = Image.fromarray(img)
image.thumbnail((320, 320), Image.ANTIALIAS)
image.show()
# 表示方法その2
# jupyterの場合はそのままndarray食わせても表示してくれた
plt.imshow(img)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment