面朝大海,春暖华开

focus on scientific computue, 3dgis, spatial database
专注于科学计算、GIS空间分析

 

IDL实现TM遥感影像直方图统计(中值、均值、方差、众数及峰度系数计算)(转)

IDL实现TM遥感影像直方图统计(中值、均值、方差、众数及峰度系数计算)(转)

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 结果:

近红外波段直方图统计:

 

版权声明:本文为CSDN博主「遇见飖雪」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/qq_41799597/article/details/106452870

posted on 2022-09-02 10:28  风过 无痕  阅读(306)  评论(0编辑  收藏  举报

导航

向日葵支付宝收钱码