-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcal_calibration.pro
69 lines (62 loc) · 1.85 KB
/
cal_calibration.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;定标
;+
;ENVI二次开发功能代码
;描述:
;定标
;调用方法:
; cal_Calibration, 'c:\temp\can_tmr.img','c:\temp\result.img',[[2,2,2,2,2,2],[1,1,1,1,1,1]]
;注意事项:
; gainoffset参数与波段个数一一对应
;-
Pro cal_calibration, infile, outFile, gainOffset,wl = wv;(可选关键字,wv是定标后单位)
COMPILE_OPT idl2
CATCH, Error_status
errorshow = 'Sorry to see the error,'+ $
' please send the error Information to "[email protected]"'
IF Error_status NE 0 THEN BEGIN
tmp = DIALOG_MESSAGE(errorshow+STRING(13b)+$
!ERROR_STATE.MSG,/error,title = '错误提示!')
return
ENDIF
;获取ENVI的配置参数
cfg = envi_get_configuration_values()
tmppath = cfg.DEFAULT_TMP_DIRECTORY
;是否设置了输出文件名
IF N_ELEMENTS(outFile) EQ 0 THEN out_name=tmppath+PATH_SEP()+'void.tmp'
ENVI_OPEN_FILE,infile,R_fid= fid
;获取信息
ENVI_FILE_QUERY, FID, $
dims = dims, $
BNAMES = BNAMEs, $
NB = NB
;定标功能
ENVI_DOIT,'gainoff_doit', fid=fid, pos=LINDGEN(nb), dims=dims, out_name=outFile, $
gain=1./gainOffset[*,0], offset=gainOffset[*,1], r_fid=r_fid, in_memory=0,$
OUT_DT = 4
ENVI_FILE_QUERY, r_fid, $
dims = dims, $
DATA_TYPE = 4, $
INTERLEAVE = INTERLEAVE, $
NB = NB, $
NL = NL, $
NS=NS ,$
OFFSET = OFFSET
map_info = ENVI_GET_MAP_INFO(fid=r_fid)
;先关掉文件
ENVI_FILE_MNG, id = fid,/Remove
ENVI_FILE_MNG, id = r_fid,/Remove
;再写入头文件
ENVI_SETUP_HEAD, $
DATA_TYPE = DATA_TYPE, $
BNAMES = '定标后:'+BNAMES, $
DESCRIP = '定标公式 y=x/gain+offset', $
FNAME=outFile,$
INTERLEAVE = INTERLEAVE, $
MAP_INFO = map_info, $
wl = wv, $
NB = NB, $
NL = NL, $
NS=NS ,$
OFFSET = OFFSET,$
/Write
END