在python中将多维数组保存到图像

2024-04-26 04:36:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我在python中有一个包含10个光谱带的数组,我想将它导出到一个tiff图像中,其中10个光谱带在同一个文件中分开。在

我尝试了skimage,但问题是我用正确的组件(x,y,bands nb)获得想要的图像,但只有当我用python读取图像时,我无法获得正确的组件,因为y组件已经不存在了。在

多光谱图像中的mu参数从多光谱图像中获取:

from sys import argv
import numpy as np
from scipy import ndimage
from skimage.io import imread, imsave
import os

def bindImage(*argv):
    # Open multiple images and bind them all
    k = 0
    exported_img = np.zeros((imread(argv[1]).shape[0], imread(argv[1]).shape[1], len(argv)))
    print exported_img.shape #in my case it gives me (2100, 2100, 10)
    while(k < len(argv)):
         img = imread(argv[k])
         exported_img[:,:,k] = labeled[:,:]
         k+=1
    imsave("binded_and_labled_image.tiff", exported_img[:,:,:], plugin="tifffile")

def main():
    bindImage(*argv[1:])

if __name__ == "__main__":
     main()

因此,如何保存图像文件,以获得多光谱波段的图像,并继续使用多种编程语言。在


Tags: from图像importimgmainnp组件光谱