我想知道如何通过在Python中快速高效地获取RGBE格式的像素值来读取HDR图像(.HDR)
以下是我尝试过的一些事情:
import imageio
img = imageio.imread(hdr_path, format="HDR-FI")
或者:
import cv2
img = cv2.imread(hdr_path, flags=cv2.IMREAD_ANYDEPTH)
这会读取图像,但会以RGB格式给出值
在不改变RGB值的情况下,如何获得第四个通道,即每个像素的“E”通道? 我更喜欢只涉及imageio的解决方案,因为我仅限于使用该模块
如果您更喜欢RGBE表示而不是浮点表示,则可以在两者之间进行转换
(注意:这是基于RGBE引用实现(found here),如果它实际上是瓶颈,则可以进一步优化。)
在您的评论中,您提到“如果我手动解析numpy数组并将通道拆分为E通道,这将花费太多时间…”,但如果不查看代码,很难解释为什么会出现这种情况。上面是O(高度×宽度),这对于像素级图像处理方法来说似乎是合理的
相关问题 更多 >
编程相关推荐