Created
May 29, 2019 14:57
-
-
Save taikomatsu/7d82a1cdbaeaee9b693e5984574eb50c to your computer and use it in GitHub Desktop.
Display hdr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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