IDL创建动态图
在做报告时,把我们处理的图像做成动态图总会得到意想不到的结果。在IDL中可以直接写入GIF图片,效果不错。
以本人在积雪遥感是的工作为例,动态显示积雪面积的时空变化。
1 pro out_gif 2 compile_opt IDL2 3 4 ;读取所有图像--SAD.GIF 5 Fir = 'F:\data\snow_albedo_assimilation\babaohe\SAD\nocloud\2008_JPG\' 6 gifarr = file_search(Fir,'*_snow_albedo_daily.jpg',count=num) 7 in_filenamelist = gifarr 8 dir = 'F:\data\snow_albedo_assimilation\babaohe\SAD\nocloud\' 9 outfname = dir+'2008_snow_albedo_daily.gif' 10 print,outfname 11 delay_time = 50 12 create_gif_animation,gifarr,outfname,delay_time 13 spawn,outfname 14 15 end
1 PRO create_gif_animation,in_filenamelist, outfname, delay_time 2 COMPILE_OPT IDL2 3 4 ;Get the number of input files. 5 file_nums = N_ELEMENTS(in_filenamelist) 6 7 IF (file_nums GT 0) AND ~STRCMP(in_filenamelist[0], '') THEN BEGIN 8 FOR i = 0, file_nums - 1 DO BEGIN 9 img = READ_IMAGE(in_filenamelist[i], red, green, blue) 10 11 ;Get the size information. 12 img_s = SIZE(img) 13 14 ;If the dimension of the img is 3-D, then convert it to a index image first. 15 IF (img_s[0] EQ 3) THEN BEGIN 16 img_idx = COLOR_QUAN(img[0, *, *], img[1, *, *], img[2, *, *], tbl_r, tbl_g, tbl_b) 17 18 ;Reverse array in the second dimension. 19 img_idx = REFORM(img_idx) 20 21 WRITE_GIF, outfname, img_idx, tbl_r, tbl_g, tbl_b, $ 22 DELAY_TIME = delay_time, /MULTIPLE, REPEAT_COUNT = 0 23 ENDIF 24 25 ;If the dimension of the img is 2-D, then write it to the gif file directly. 26 IF (img_s[0] EQ 2) THEN BEGIN 27 img =REFORM(img) 28 IF (N_ELEMENTS(red) GT 0) AND (N_ELEMENTS(green) GT 0) AND (N_ELEMENTS(blue) GT 0) THEN BEGIN 29 30 WRITE_GIF, outfname, img, red, green, blue, DELAY_TIME = delay_time, /MULTIPLE, REPEAT_COUNT = 0 31 ENDIF 32 ENDIF 33 print,i 34 ENDFOR 35 36 ;Close the file. 37 WRITE_GIF, outfname, /CLOSE 38 ENDIF 39 END
效果图: