我想用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:\data\Reflectance_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)这样的东西
有没有人试过用spectral.imshow对象做子图?
任何帮助都将不胜感激。
发布于 2022-06-06 01:58:08
有几个选项可以实现你想要的。一种是使用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进行呈现。
https://stackoverflow.com/questions/72470081
复制相似问题