我不知道我是否会明确,但我会尽力的。我有不同日期的图像,其中有14个波段对应于不同的索引。对于第一个波段,即NDVI,我将其分配给较高的0.6值,即图像的NDVI最小值。我希望我的代码为每个频段应用此蒙版。我尝试了几种方法,但我认为我做错了……我的面具只适用于我的第一支乐队,我不能将其应用于其他乐队。你对我有什么建议吗?
我的代码中起作用的部分是:
for image in rasters:
print(image)
name, ext = os.path.splitext(image)
if ext == '.hdr':
img = sp.open_image(ssrc_directory + image)
print(image)
im_HS = img[:,:,0]
cols = im_HS.shape[0] # Number of column
rows = im_HS.shape[1] # Number of lines
bands = im_HS.shape[2] # Number of bands
names = []
##mask NDVI
names.append('maskNDVI')
for i in range(0,cols):
for j in range(0,rows):
if im_HS[i,j] >= 0.6 :
im_HS[i,j] = np.min(im_HS)
我尝试过:
img = sp.open_image(ssrc_directory + image)
print(image)
im_HS = img[:,:,:]
cols = im_HS.shape[0] # Number of column
rows = im_HS.shape[1] # Number of lines
bands = im_HS.shape[2] # Number of bands
names = []
##mask NDVI
names.append('mask')
for h in range(0,bands):
for i in range(0,cols):
for j in range(0,rows):
if im_HS[i,j,0] >= 0.6 :
im_HS[i,j,h] = np.min(im_HS)
我还考虑过使用numpy.where,但是我无法将其集成。