IDL实现TM遥感影像直方图统计(中值、均值、方差、众数及峰度系
2020-05-31 本文已影响0人
遇见飖雪
1 实验代码
近红外波段:
Pro statistic_tm
fn=dialog_pickfile(title='Plesse choose image:')
tm_img=read_image(fn)
sz=size(tm_img)
n_columns=sz[2] & n_raws=sz[3]
;window,0,xsize=n_columns,ysize=n_raws
;tvscl,tm_img,/true
;tm_ref=reform(tm_img,)
tm_rgb=tm_img[0:2,*,*]
tm_nir=tm_img[3,*,*]
tm_r=tm_img[2,*,*]
tm_g=tm_img[1,*,*]
tm_b=tm_img[0,*,*]
tm_sf=[tm_nir,tm_r,tm_g]
;szr=size(tm_r)
;n_c=szr[2] & n_r=szr[3]
;statastic
MED=median(tm_nir)
MEA=mean(tm_nir)
VAR=variance(tm_nir)
KUR=kurtosis(tm_nir)
His=histogram(tm_nir,nbins=100,locations=locations,omin=omim,omax=omax)
Sel=where(His EQ max(His))
MODE=tm_nir[Sel[0]]
MED_label='Median='+string(MED,format='(f5.2)')
MEA_label='Mean='+string(MEA,format='(f5.2)')
VAR_label='Variance='+string(VAR,format='(f7.2)')
KUR_label='Kurtosis='+string(KUR,format='(f5.2)')
MOD_label='Mode='+string(MODE,format='(f5.2)')
p1=plot(locations,His,linestyle=0,color='red',thick=2,dimensions=[600,400],$
title='Histogram Of NIR Band',window_title='Histogram',xrange=[0,200],yrange=[0,10000])
t1=text(0.20,0.80,MED_label,target=p1,font_size=12)
t2=text(0.20,0.75,MEA_label,target=p1,font_size=12)
t3=text(0.20,0.70,VAR_label,target=p1,font_size=12)
t4=text(0.20,0.65,KUR_label,target=p1,font_size=12)
t5=text(0.20,0.60,MOD_label,target=p1,font_size=12)
;window,0,xsize=n_columns,ysize=n_raws
;tvscl,tm_img,/true
;imgshow_r=image(tm_r,dimension=[n_c,n_r],margin=0,title='TM Image of R',window_title='True R')
;imgshow_false=image(tm_sf,dimension=[n_columns,n_raws],margin=0,title='TM Image of Standared False',window_title='False Image')
;imgshow_true.save,'true.jpeg',resolution=600
;imgshow_false.save,'false.jpeg',resolution=600
End
注:以上代码是TM近红外波段统计与直方图显示,其他波段类似只需换一下如下代码,如统计红波段改为:
;statastic
MED=median(tm_r)
MEA=mean(tm_r)
VAR=variance(tm_r)
KUR=kurtosis(tm_r)
His=histogram(tm_r,nbins=100,locations=locations,omin=omim,omax=omax)
Sel=where(His EQ max(His))
MODE=tm_r[Sel[0]]
p1=plot(locations,His,linestyle=0,color='red',thick=2,dimensions=[600,400],$
title='Histogram Of R Band',window_title='Histogram',xrange=[0,200],yrange=[0,12000])
2 结果显示:
近红外波段直方图统计:
简单书写,
希望你十分美好!