ENVI二次开发应用:遥感影像的批量(多个两幅遥感影像的)镶嵌
作者:互联网
功能:实现多个两幅遥感影像的(无缝)镶嵌
pro Batch_Mosaic_Raster_Task
compile_opt idl2
; Start the application
e = ENVI(/headless)
image_dir = DIALOG_PICKFILE(PATH='D:\IDL_workspace', /DIRECTORY, $
TITLE="选择包含镶嵌数据的文件夹")
files = FILE_SEARCH(image_dir, '*.tif')
results = FILE_BASENAME(files, '*.tif')
start = systime(1)
m = 0 ;计数
FOR i=0, n_elements(results)-1 DO BEGIN
lst = list()
date1 = strmid(results[i],11,8) ;选出日期
lst.add,results[i]
FOR j=i+1, n_elements(results)-1 DO BEGIN
date2 = strmid(results[j],11,8)
if date1 eq date2 then begin
lst.add,results[j]
;print,"List:",lst
scenes=!NULL
FOR k=0, n_elements(lst)-1 DO BEGIN
r = image_dir+'\'+lst[k]
print,"路径:",r
raster = e.OpenRaster(image_dir+'\'+lst[k])
scenes=[scenes,raster]
;print,"scene:",scenes
ENDFOR
s = systime(1)
; Create a mosaic
mosaicRaster = ENVIMosaicRaster(scenes, $
color_matching_actions = ['Reference', 'Adjust'], $ ;这里仅限两幅的镶嵌,多幅影像此处需要修正
color_matching_method = 'Histogram Matching', $
color_matching_stats = 'Entire Scene', $
feathering_method = 'Seamline', $
seamline_method = 'geometry', $
feathering_distance = 500, $
data_ignore_value = 0, $
resampling = 'Cubic')
outfile_dir = "D:\IDL_workspace\寿光镶嵌"
outFile = outfile_dir + '\' + date2 $
+'_mosaic'+'.tif'
mosaicRaster.Export, outFile, 'TIFF'
mosaictime = systime(1)-s
m = m + 1
print, FORMAT='("第 ",I0,"次镶嵌耗时:", F0.3,"秒")', m, mosaictime
endif
ENDFOR
ENDFOR
runtime = systime(1)-start
print,"总共耗时:",runtime,"秒"
end
标签:scenes,镶嵌,lst,results,print,遥感,影像,二次开发,dir 来源: https://blog.csdn.net/m0_37609748/article/details/119888242