带有多个频谱的子图。Imshow()objec

发布于 2025-02-03 20:00:18 字数 802 浏览 4 评论 0 原文

我想用sp.imshow绘制多个高光谱图像。我知道这返回A 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对象进行子图?

任何帮助将不胜感激。

I want to plot multiple hyperspectral images with sp.imshow. I know this returns a R,G,B visualization. I have 13 HSI files (13 .hdr and 13 .img files). I know how to plot and analyze individual files but I want an overview of all my samples in a grid.

I am also aware of creating the fig, axes previously. Yet subplots are still confusing.
This is what I have so far.

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

I am looking for something like sp.imshow(target_open).add_subplot(ax)

Has anyone tried doing subplots with spectral.imshow objects?

Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初雪 2025-02-10 20:00:19

有一些选择可以实现您想要的东西。一种是使用 plt.subplot 选择每个网格单元格,然后当您调用 sp.imshow 时,传递 fignum keyword。例如,要创建图像的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

There are a few options to achieve what you want. One is to use plt.subplot to select each grid cell, then when you call sp.imshow, pass the fignum keyword. For example, to create an Nx1 grid of images (i.e., a grid with a single column):

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)

Another option is to use sp.get_rgb to retrieve the RGB image data for each image, then use plt.imshow to do the rendering instead of sp.imshow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文