FOR i=0,N_ELEMENTS(files)-1 DO BEGIN
;构建输出文件名
fileName = FILE_BASENAME(files[i])
pointPos = STRPOS(fileName,'.')
;查找文件名中点的位置
IF pointPos[0] NE -1 THEN BEGIN
fileName= STRMID(fileName,0,pointPos)
ENDIF
ENVI_OPEN_FILE, files[i], r_fid=fid
IF (fid EQ -1) THEN BEGIN
tmp = DIALOG_MESSAGE(files[i]+'文件读取错误',$
title = !sys_title, /error)
CONTINUE
ENDIF
;文件信息
ENVI_FILE_QUERY, fid, dims=dims, nb=nb,bnames = bnames,DATA_TYPE = dt,$
ns = ns, nl = nl
startTime = systime(1)
for curBand =0,nb-1 do begin
out_name = outfiledir+PATH_SEP()+fileName+'_band'+StrTrim(curBand+1,2)+'.img'
envi_doit, 'cf_doit', $
fid=fid, pos=curBand, dims=dims, $
remove=0, out_name=out_name
endfor
;
print,'cf_doit time',systime(1)-startTime
startTime = systime(1)
for curBand =0,nb-1 do begin
out_name = outfiledir+PATH_SEP()+fileName+'_band_resize'+StrTrim(curBand+1,2)+'.img'
envi_doit, 'resize_doit', $
fid=fid, pos=curBand, dims=dims, $
interp=1, rfact=[1,1], $
out_name=out_name
endfor
print,'resize_doit time',systime(1)-startTime
startTime = systime(1)
for curBand =0,nb-1 do begin
out_name = outfiledir+PATH_SEP()+fileName+'_band_bandmath'+StrTrim(curBand+1,2)+'.img'
pos = curBand
exp = 'b1'
envi_doit, 'math_doit', $
fid=fid, pos=pos, dims=dims, $
exp=exp, out_name=out_name
endfor
print,'math_doit time',systime(1)-startTime
startTime = systime(1)
for curBand =0,nb-1 do begin
pos = curBand
out_proj = envi_get_projection(fid=fid, $
pixel_size=out_ps)
out_name = outfiledir+PATH_SEP()+fileName+'_layer_stacking'+StrTrim(curBand+1,2)+'.img'
envi_doit, 'envi_layer_stacking_doit', $
fid=fid, pos=pos, dims=dims, $
out_dt=dt, out_name=out_name, $
interp=2, out_ps=out_ps, $
out_proj=out_proj
endfor
print,'layer_stacking_doit time',systime(1)-startTime
;依次读写文件
startTime = systime(1)
for curBand =0,nb-1 do begin
pos = curBand
map_info = envi_get_map_info(fid=fid)
out_name = outfiledir+PATH_SEP()+fileName+'_writeu'+StrTrim(curBand+1,2)+'.img'
openw,lun,out_name,/get
writeu,lun,envi_get_data(fid=fid, dims=dims, pos=pos)
free_lun,lun
ENVI_SETUP_HEAD, fname=out_name, $
ns=ns, nl=nl, nb=1, $
interleave=0, data_type=dt, $
offset=0, /write,$
MAP_INFO = MAP_INFO
endfor
print,'writeU time',systime(1)-startTime
;输出完成
ENVI_FILE_MNG, id=fid, /remove
;设置进度条
IDLITWDPROGRESSBAR_SETVALUE,(*pState).PRSBAR,(i+1)*per
ENDFOR
|