包含多个spectrum .imshow()对象的子图



我想用sp.imshow绘制多张高光谱图像。我知道它返回R G B的可视化。我有13个HSI文件(13 .hdr和13 .img文件)。我知道如何绘制和分析单个文件,但我想在网格中概述我所有的样本。

我也知道之前创建了图,轴。然而,次要情节仍然令人困惑。这是我目前掌握的信息。

from pathlib import Path
import spectral as sp
import matplotlib.pyplot as plt
files_path = Path(r"C:dataReflectance_Calibrated")
hdr_list = list(files_path.glob('*.hdr'))
bin_list = list(files_path.glob('*.img'))
targets = list(zip(hdr_list,bin_list))
i = 0
## Here is where I tried doing a for loop, yet it did not work.
for k, target in enumerate(targets):
target_open = sp.envi.open(targets[i][0], targets[i][1])
sp.imshow(target_open)
i += 1

我正在寻找类似sp.imshow(target_open).add_subplot(ax)的东西

有人试过用谱图做子图吗?imshow对象?

如有任何帮助,不胜感激。

有几个选项可以达到您想要的效果。一种是使用plt.subplot选择每个网格单元,然后在调用sp.imshow时,传递fignum关键字。例如,要创建一个Nx1的图像网格(即,具有单列的网格):

fig = plt.figure()
for k, target in enumerate(targets):
target_open = sp.envi.open(targets[k][0], targets[k][1])
plt.subplot(len(targets), 1, k + 1)
sp.imshow(target_open, fignum=fig.number)

另一种选择是使用sp.get_rgb检索每个图像的RGB图像数据,然后使用plt.imshow而不是sp.imshow进行渲染。

相关内容

最新更新