Hope this code helps.
Code structure:
1. define the data size and arrays used
2.read in the images here
3.devide each pixel by 10000
4.write data in output format
Pro reflectance
filepath ='D:\MODIS\'
fname_input=filepath+'TERRA_2003_06_13_03_35_BJ.MOD021KM_PRJ.img'
fname_output=filepath+'TERRA_2003_06_13_03_35_BJ.MOD021KM_PRJ_float.img'
Samples=337
Lines=415
data=uintarr(Samples,Lines,38); 38 is the band number in each image
data1=fltarr(Samples,Lines,38)
openR,lun,fname_input,/Get_lun
readU, lun,data
Free_Lun,lun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
for k=0,37 do begin
for i=0,336 do begin
for j=0,414 do begin
data1[i,j,k]=float(data[i,j,k])/10000.0000
endfor
endfor
endfor
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
openW,lun,fname_output,/Get_lun
writeU,lun, data1
Free_Lun,lun
End
|