7

我想阅读 *.hdr 文件格式的环境地图。似乎非常流行的库不支持.hdr文件读取,例如OpenCV,PIL等。那么如何将.hdr文件读入numpy数组?

4

2 回答 2

6

我发现ImageIO非常有用。它可以处理许多图像文件格式,包括 .hdr 图像。这是列表:ImageIO 格式

它可以使用 easy_install 或 pip 轻松安装。

于 2015-09-25T18:29:37.787 回答
0

出于某种原因,当我尝试使用 .hdr 格式加载 MRI 图像时,format='HDR-FI'它正在返回Could not load bitmap <path to image>: : RGBE read error

但是,如果您键入imageio.show_formats()它会返回一个格式列表,包括“ITK - Insight Segmentation and Registration Toolkit”,它表明它也可以处理 .hdr 图像。

所以我的替代方法是使用:

pip install itk

hdr_path = "<path to image>"
img = imageio.imread(hdr_path, 'ITK') # returns a tuple

img = np.array(img) # transforms to numpy array
于 2021-10-25T15:27:43.570 回答