Python 迭代高光谱图像中的行
我有显示高光谱图像(立方体)的代码 我必须: 图1:具有N行数和N列数的高光谱图像。 图2:只有一行但列数与图1相同的高光谱图像 我想创建迭代: 对于图1中的每一行,我想减去 图2中的值。 因此,例如,如果在第1列中,图像1中的值为10,而图像2中的值为4,则新图像将具有值为6的像素 问题是我不知道如何遍历图像中的行 这就是我到目前为止所尝试的:Python 迭代高光谱图像中的行,python,image,iteration,spectral,Python,Image,Iteration,Spectral,我有显示高光谱图像(立方体)的代码 我必须: 图1:具有N行数和N列数的高光谱图像。 图2:只有一行但列数与图1相同的高光谱图像 我想创建迭代: 对于图1中的每一行,我想减去 图2中的值。 因此,例如,如果在第1列中,图像1中的值为10,而图像2中的值为4,则新图像将具有值为6的像素 问题是我不知道如何遍历图像中的行 这就是我到目前为止所尝试的: import spectral.io.envi as envi import matplotlib.pyplot as plt import os f
import spectral.io.envi as envi
import matplotlib.pyplot as plt
import os
from spectral import *
import numpy as np
#Create the image path
#the path
img_path = r'N:\this\is\path\emptyname_2019-08-13_11-05-46\capture'
cali_path=r'N:\more\path'
#the specific file
img_file = 'emptyname_2019-08-13_11-05-46.hdr'
img_dark= 'DARKREF_emptyname_2019-08-13_11-05-46.hdr'
cali_hdr= 'Radiometric_1x1.hdr'
cali_img = 'Radiometric_1x1.cal'
#load the images
img= envi.open(os.path.join(img_path,img_file)).load()
img_dark= envi.open(os.path.join(img_path,img_dark)).load()
img_cali= envi.open(os.path.join(cali_path,cali_hdr), image = os.path.join(cali_path,cali_img)).load()
wavelength=[float(i) for i in img.metadata['wavelength']]
#here I have created image 2- the image with the 1 row
dark_1024=img_dark.mean(axis=0)
#bad attempt to iterate through each row.
for index, row in img.iterrows():
img-img_dark
AttributeError:“ImageArray”对象没有属性“ItErrors”
你知道我如何只“抓取”行并用新值创建新图像吗?使用
iterrows
只能使用熊猫数据帧,对吗?img
的形状是什么?你能用itertools.product(范围(n_行),范围(n_列)):img[pixel]…中像素的循环每个像素吗?图像的sape是13000行1024列。图像2的形状是1行1024列。图像中的行和列是什么?您是否将三维立方体图像重塑为二维阵列?使用iterrows
仅适用于熊猫数据帧,对吗?img
的形状是什么?你能用itertools.product(范围(n_行),范围(n_列)):img[pixel]…
中像素的循环每个像素吗?图像的sape是13000行1024列。图像2的形状是1行1024列。图像中的行和列是什么?您是否将三维立方体图像重塑为二维阵列?