IDL遥感可视化开发

简要描述

云和沙尘遥感检测在地球科学和气象学领域具有重要的意义和目的。云和沙尘遥感检测可以提供大规模天气系统和气候变化的关键信息。通过监测云的类型、高度、厚度等参数,可以帮助预测天气状况、降水概率、风速和风向等气象要素。而对于沙尘暴的遥感检测,可以提供沙尘暴的强度、范围和路径等信息,有助于及时发布警报并采取相应的防护措施。

通常情况下,不同类型的云具有不同的反照率特征。云顶通常具有较高的反照率,而云底部则较低。沙尘颗粒对太阳辐射的反照率较高,这使得沙尘区域在遥感图像中呈现明亮的特征,而且沙尘遥感图像中的沙尘区域大都呈现为棕色或灰色,与其他地物有着较为明显的光谱差异。因此本程序基于MODIS数据具有多光谱波段、高时间分辨率和大范围覆盖的优势,采用多阈值法实现云(1、3、26通道)、沙尘(3、17或20、31通道)的检测。

设计思路

1fde8965b838491688a41617526c215b.png

 e0e2d27ea19d40bcb6473f12ebee53cf.png

pro envi_total_event,event
;一级主页面搭建
  common imagedata,data,ns,nl,openfile,$
    draw,index,aaa,poss,dustsize,dataout
  common dataimage,jcsdata,dustxy,$
    cloudxy,hcloudxy,lcloudxy,menun,bnames
  common dataimage1,endlcloud,endhcloud,$
    enddust,endcloud,endhccloud,pos
  common otherdata,wm,bppp,resultdust,$
    bpppp,menu4,menu5,cloudsize,menu8,savefile
  common anotherdata,dustimage,cloudimage,$
    menu6,menu7,menu0,endimage,menu1
  common enddata,menu9,menu10,outputlcloud
  Compile_opt idl2
  ENVI,/restore_base_save_files
  ENVI_BATCH_INIT
  index=0
  base=widget_base(/row, /fram)
  menu1 = WIDGET_BUTTON(base, VALUE='    File   ', /MENU)
  openfile = WIDGET_BUTTON(menu1, VALUE='OpenFile')
  savefile = WIDGET_BUTTON(menu1, VALUE='SaveFile')
  menu2 = WIDGET_BUTTON(base, VALUE='Calculate', /MENU)
  dustsize=WIDGET_BUTTON(menu2, VALUE='Dustsize')
  cloudsize=WIDGET_BUTTON(menu2, VALUE='Cloudsize')
  menu3 = WIDGET_BUTTON(base, VALUE='   Image   ', /MENU)
  dustimage=WIDGET_BUTTON(menu3, VALUE='DustImage')
  cloudimage=WIDGET_BUTTON(menu3, VALUE='CloudImage')
  endimage=WIDGET_BUTTON(menu3, VALUE='EndImage')
  WIDGET_CONTROL, base, /REALIZE
  xmanager,'abc',base,/no_block
end

;二级主页面搭建以及部分一级页面控件功能实现
pro abc_event,ev
  common imagedata,data,ns,nl,openfile,$
    draw,index,aaa,poss,dustsize,dataout
  common dataimage,jcsdata,dustxy,$
    cloudxy,hcloudxy,lcloudxy,menun,bnames
  common dataimage1,endlcloud,endhcloud,$
    enddust,endcloud,endhccloud,pos
  common otherdata,wm,bppp,resultdust,$
    bpppp,menu4,menu5,cloudsize,menu8,savefile
  common anotherdata,dustimage,cloudimage,$
    menu6,menu7,menu0,endimage,menu1
  common enddata,menu9,menu10,outputlcloud
  help,ev
  index=0
  index_1=0
  if ev.id eq openfile then begin
    ENVI_SELECT,title='difen', fid=fid, dims=dims,pos=pos, ROI=ROI
    envi_file_query,fid,dims=dims,ns=ns,nl=nl,bnames=bnames,nb=nb
    if(fid eq -1) then return
    data=fltarr(ns,nl,n_elements(pos))
    dataout=fltarr(ns,nl,n_elements(pos))
    for k=0,n_elements(pos)-1 do begin
      data[*,*,k]=envi_get_data(fid=fid,dims=dims,pos=pos[k])
      dataout[*,*,k]=envi_get_data(fid=fid,dims=dims,pos=pos[k])
    endfor
    base=widget_base(/row, /fram)
    baa=widget_base(base,row=10, /fram)
    menu0=WIDGET_BUTTON(baa, VALUE='    Caledata   ')
    menu1 = WIDGET_BUTTON(baa, VALUE='    SaveImage   ')
    menun = WIDGET_BUTTON(baa, VALUE='    ShowImage   ')
    menu4 = WIDGET_BUTTON(baa, VALUE='    DustSize    ')
    menu5 = WIDGET_BUTTON(baa, VALUE='    CloudSize   ')
    menu6=WIDGET_BUTTON(baa, VALUE='    DustImage   ')
    menu9=WIDGET_BUTTON(baa, VALUE='  HighCloudImage ')
    menu10=WIDGET_BUTTON(baa, VALUE='   LowCloudImage ')
    menu7=WIDGET_BUTTON(baa, VALUE='    CloudImage   ')
    menu8=WIDGET_BUTTON(baa, VALUE='    EndImage   ')
    draw = WIDGET_DRAW(base,XSIZE=ns/4, YSIZE=nl/4,/BUTTON,/MOTION)
    WIDGET_CONTROL, draw, /REALIZE
    WIDGET_CONTROL, base, /REALIZE
    xmanager,'file',base,/no_block
  endif
  if ev.id eq dustsize then begin
    print,'okok'
    sbbb=widget_base(row=2, /fram)
    list=['sea','land']
    wm = widget_menu(sbbb, list=list, uvalue='menu_1',/excl, /auto)
    bppp = WIDGET_button(sbbb,VALUE='dust')
    bpppp=WIDGET_button(sbbb,VALUE='dustsize')
    WIDGET_CONTROL, sbbb, /REALIZE
    xmanager,'lst',sbbb,/no_block
  endif
  if ev.id eq cloudsize then begin
    if total(cloudxy) ne 0 then begin
      print,'cloudsize'
      base=widget_base(row=3, /fram)
      hlcloud=hcloudxy+lcloudxy
      b=where(hlcloud eq 2,count)
      resultcloud=total(cloudxy)
      resulthcloud=total(hcloudxy)
      str=['The size of Cloud is ',string(resultcloud)]
      str1=['The size of high Cloud is ',string(resulthcloud)]
      str2=['The size of low Cloud is ',string(count)]
      str=strjoin(str)
      str1=strjoin(str1)
      str2=strjoin(str2)
      wss = widget_slabel(base, prompt=str)
      wss1 = widget_slabel(base, prompt=str1)
      wss2 = widget_slabel(base, prompt=str2)
      WIDGET_CONTROL, base, /REALIZE
    endif
  endif
  if ev.id eq dustimage then begin
    if total(cloudxy) ne 0 then begin
      aaa=congrid(enddust,ns/4,nl/4,3)
      tvscl,aaa,true=3,/order
    endif
  endif
  if ev.id eq cloudimage then begin
    if total(cloudxy) ne 0 then begin
      aaa=congrid(endhccloud,ns/4,nl/4,3)
      tvscl,aaa,true=3,/order
    endif
  endif
  if ev.id eq endimage then begin
    if total(cloudxy) ne 0 then begin
      for row=0,nl-1 do begin
        for cols=0,ns-1 do begin
          if total(enddust[cols,row,*]) ne 0 then begin
            dataout[cols,row,0:2]=enddust[cols,row,*]
          endif
          if total(endhccloud[cols,row,*]) ne 0 then begin
            dataout[cols,row,0:2]=endhccloud[cols,row,*]
          endif
        endfor
      endfor
      aaa=congrid(dataout[*,*,0:2],ns/4,nl/4,3)
      tvscl,aaa,true=3,/order
    endif
  endif
  if ev.id eq savefile then begin
    if total(cloudxy) ne 0 then begin
      value=['DustImage','CloudImage','EndImage']
      base=widget_auto_base(title='saveimage')
      sb= widget_base(base, /row, /fram)
      we = WIDGET_SLIST(base, list=value, uvalue='menu', /auto)
      sb= widget_base(base, /row, /frame)
      wf= widget_outfm(sb, uvalue='outf', /auto)
      result = auto_wid_mng(base)
      if (result.accept eq 0) then return
      if(result.outf.in_memory eq 0) then outname=result.outf.name
      method=result.menu
      if method eq 0 then begin
        Envi_enter_data, enddust, r_fid=out_fid
        ENVI_FILE_QUERY, out_fid, dims=dimso
        if(result.outf.in_memory eq 0) then Envi_output_to_external_format,$
           fid=out_fid, out_name= outname, $
          out_bname=bnames[0:2], $
          dims=dimso, pos=[0:2], /envi
      endif
      if method eq 1 then begin
        Envi_enter_data, endhccloud, r_fid=out_fid
        ENVI_FILE_QUERY, out_fid, dims=dimso
        if(result.outf.in_memory eq 0) then Envi_output_to_external_format,$
           fid=out_fid, out_name= outname, $
          out_bname=bnames[0:2], $
          dims=dimso, pos=[0:2], /envi
      endif
      if method eq 2 then begin
        Envi_enter_data, dataout, r_fid=out_fid
        ENVI_FILE_QUERY, out_fid, dims=dimso
        if(result.outf.in_memory eq 0) then Envi_output_to_external_format,$
           fid=out_fid, out_name= outname, $
          out_bname=bnames[0:2], $
          dims=dimso, pos=[0:2], /envi
      endif
    endif
  endif
end

;二级主页面控件功能实现
pro file_event,fl
  common imagedata,data,ns,nl,openfile,$
    draw,index,aaa,poss,dustsize,dataout
  common dataimage,jcsdata,dustxy,$
    cloudxy,hcloudxy,lcloudxy,menun,bnames
  common dataimage1,endlcloud,endhcloud,$
    enddust,endcloud,endhccloud,pos
  common otherdata,wm,bppp,resultdust,$
    bpppp,menu4,menu5,cloudsize,menu8,savefile
  common anotherdata,dustimage,cloudimage,$
    menu6,menu7,menu0,endimage,menu1
  common enddata,menu9,menu10,outputlcloud
  help,fl
  if fl.id eq draw then begin
    if fl.clicks eq 2 then begin
      index=1
    endif
    if index eq 1 then begin
      base=widget_base(row=2, /fram)
      arr=['X:'+string(fl.x)+'_'+'Y:'+string(fl.Y)]
      str=strjoin(arr)
      str=strcompress(str, /remove_all)
      arrgb=['R:'+string(aaa[fl.y,fl.x,0])+'_'+'G:'+$
        string(aaa[fl.y,fl.x,1])+'_'+'B:'+string(aaa[fl.y,fl.x,2])]
      strgb=strjoin(arrgb)
      strgb=strcompress(strgb, /remove_all)
      wss = widget_slabel(base, prompt=str)
      wsss = widget_slabel(base, prompt=strgb)
      WIDGET_CONTROL, base, /REALIZE
    endif
  endif
  if fl.id eq menun then begin
    list = [bnames]
    ba = widget_auto_base(title='RSvisualization')
    bae=widget_base(ba,/row, /fram)
    we=WIDGET_SLIST(bae,list=list,uvalue='menu', /auto,PROMPT='R')
    wm1=WIDGET_SLIST(bae,list=list,uvalue='list', /auto,PROMPT='G')
    wc=WIDGET_SLIST(bae,list=list,uvalue='list1', /auto,PROMPT='B')
    result1 = auto_wid_mng(ba)
    if (result1.accept eq 0) then return
    index_1=1
    b=intarr(3,1)
    b[0]=result1.menu
    b[1]=result1.list
    b[2]=result1.list1
    poss=pos[b]
    aaa=congrid(data[*,*,poss],ns/4,nl/4,3)
    tvscl,aaa,true=3,/order
  endif
  if fl.id eq menu4 then begin
    print,'okok'
    sbbb=widget_base(row=2, /fram)
    list=['sea','land']
    wm = widget_menu(sbbb,list=list, uvalue='menu_1',/excl, /auto)
    bppp = WIDGET_button(sbbb,VALUE='dust')
    bpppp=WIDGET_button(sbbb,VALUE='dustsize')
    WIDGET_CONTROL, sbbb, /REALIZE
    xmanager,'lst',sbbb,/no_block
  endif
  if fl.id eq menu5 then begin
    print,'cloudsize'
    base=widget_base(row=3, /fram)
    hlcloud=hcloudxy+lcloudxy
    b=where(hlcloud eq 2,count)
    resultcloud=total(cloudxy)
    resulthcloud=total(hcloudxy)
    str=['The size of Cloud is ',string(resultcloud)]
    str1=['The size of high Cloud is ',string(resulthcloud)]
    str2=['The size of low Cloud is ',string(count)]
    str=strjoin(str)
    str1=strjoin(str1)
    str2=strjoin(str2)
    wss = widget_slabel(base, prompt=str)
    wss1 = widget_slabel(base, prompt=str1)
    wss2 = widget_slabel(base, prompt=str2)
    WIDGET_CONTROL, base, /REALIZE
  endif
  if fl.id eq menu0 then begin
    sbbb=widget_base(row=2, /fram)
    list=['sea','land']
    wm = widget_menu(sbbb, list=list, uvalue='menu_1', /excl, /auto)
    bppp = WIDGET_button(sbbb,VALUE='jisuan')
    bpppp=WIDGET_button(sbbb,VALUE='end')
    WIDGET_CONTROL, sbbb, /REALIZE
    xmanager,'lst',sbbb,/no_block
  endif
  if fl.id eq menu6 then begin
    if total(cloudxy) ne 0 then begin
      aaa=congrid(enddust,ns/4,nl/4,3)
      tvscl,aaa,true=3,/order
    endif
  endif
  if fl.id eq menu7 then begin
    if total(cloudxy) ne 0 then begin
      aaa=congrid(endhccloud,ns/4,nl/4,3)
      tvscl,aaa,true=3,/order
    endif
  endif
  if fl.id eq menu8 then begin
    if total(cloudxy) ne 0 then begin
      for row=0,nl-1 do begin
        for cols=0,ns-1 do begin
          if total(enddust[cols,row,*]) ne 0 then begin
            dataout[cols,row,0:2]=enddust[cols,row,*]
          endif
          if total(endhccloud[cols,row,*]) ne 0 then begin
            dataout[cols,row,0:2]=endhccloud[cols,row,*]
          endif
        endfor
      endfor
      aaa=congrid(dataout[*,*,0:2],ns/4,nl/4,3)
      tvscl,aaa,true=3,/order
    endif
  endif
  if fl.id eq menu1 then begin
    if total(cloudxy) ne 0 then begin
      value=['DustImage','CloudImage','EndImage','HighCloud','LowCloud']
      base=widget_auto_base(title='saveimage')
      sb= widget_base(base, /row, /fram)
      we = WIDGET_SLIST(base, list=value, uvalue='menu', /auto)
      sb= widget_base(base, /row, /frame)
      wf= widget_outfm(sb, uvalue='outf', /auto)
      result = auto_wid_mng(base)
      if (result.accept eq 0) then return
      if(result.outf.in_memory eq 0) then outname=result.outf.name
      method=result.menu
      if method eq 0 then begin
        Envi_enter_data, enddust, r_fid=out_fid
        ENVI_FILE_QUERY, out_fid, dims=dimso
        if(result.outf.in_memory eq 0) then Envi_output_to_external_format,$
           fid=out_fid, out_name= outname, $
          out_bname=bnames[0:2], $
          dims=dimso, pos=[0:2], /envi
      endif
      if method eq 1 then begin
        Envi_enter_data, endhccloud, r_fid=out_fid
        ENVI_FILE_QUERY, out_fid, dims=dimso
        if(result.outf.in_memory eq 0) then Envi_output_to_external_format,$
          fid=out_fid, out_name= outname, $
          out_bname=bnames[0:2], $
          dims=dimso, pos=[0:2], /envi
      endif
      if method eq 2 then begin
        Envi_enter_data, dataout, r_fid=out_fid
        ENVI_FILE_QUERY, out_fid, dims=dimso
        if(result.outf.in_memory eq 0) then Envi_output_to_external_format,$
           fid=out_fid, out_name= outname, $
          out_bname=bnames[0:2], $
          dims=dimso, pos=[0:2], /envi
      endif
      if method eq 3 then begin
        Envi_enter_data, endhcloud, r_fid=out_fid
        ENVI_FILE_QUERY, out_fid, dims=dimso
        if(result.outf.in_memory eq 0) then Envi_output_to_external_format,$
           fid=out_fid, out_name= outname, $
          out_bname=bnames[0:2], $
          dims=dimso, pos=[0:2], /envi
      endif
      if method eq 4 then begin
        Envi_enter_data, outputlcloud, r_fid=out_fid
        ENVI_FILE_QUERY, out_fid, dims=dimso
        if(result.outf.in_memory eq 0) then Envi_output_to_external_format,$
           fid=out_fid, out_name= outname, $
          out_bname=bnames[0:2], $
          dims=dimso, pos=[0:2], /envi
      endif
    endif
  endif
  if fl.id eq menu9 then begin
    if total(cloudxy) ne 0 then begin
      aaa=congrid(endhcloud,ns/4,nl/4,3)
      tvscl,aaa,true=3,/order
    endif
  endif
  if fl.id eq menu9 then begin
    if total(cloudxy) ne 0 then begin
      redacloud=lcloudxy-hcloudxy
      outputlcloud=fltarr(ns,nl,3)
      for row=0,nl-1 do begin
        for cols=0,ns-1 do begin
          if redacloud[cols,row] eq 1 then begin
            outputlcloud[cols,row,*]=endlcloud[cols,row,*]
          endif
        endfor
      endfor
      aaa=congrid(outputlcloud,ns/4,nl/4,3)
      tvscl,aaa,true=3,/order
    endif
  endif
end

;算法调用
pro lst_event,ls
  common imagedata,data,ns,nl,openfile,$
    draw,index,aaa,poss,dustsize,dataout
  common dataimage,jcsdata,dustxy,$
    cloudxy,hcloudxy,lcloudxy,menun,bnames
  common dataimage1,endlcloud,endhcloud,$
    enddust,endcloud,endhccloud,pos
  common otherdata,wm,bppp,resultdust,$
    bpppp,menu4,menu5,cloudsize,menu8,savefile
  common anotherdata,dustimage,cloudimage,$
    menu6,menu7,menu0,endimage,menu1
  common enddata,menu9,menu10,outputlcloud
  min0=min(data[*,*,0])
  min1=min(data[*,*,1])
  min2=min(data[*,*,2])
  max0=max(data[*,*,0])
  max1=max(data[*,*,1])
  max2=max(data[*,*,2])
  help,ls
  c=20
  b=31
  if ls.id eq wm then begin
    if ls.result eq 0 then begin
      c=17
      b=3
    endif
  endif
  if ls.id eq bppp then begin
    re=cale(c,b)
  endif
  if ls.id eq bpppp then begin
    base=widget_base(row=1, /fram)
    sizeofdust=total(resultdust)
    str=['The size of Dust is ',string(sizeofdust)]
    str=strjoin(str)
    wss = widget_slabel(base, prompt=str)
    WIDGET_CONTROL, base, /REALIZE
  endif
end

;功能算法实现
Function cale, c,b
  common imagedata,data,ns,nl,openfile,$
    draw,index,aaa,poss,dustsize,dataout
  common dataimage,jcsdata,dustxy,$
    cloudxy,hcloudxy,lcloudxy,menun,bnames
  common dataimage1,endlcloud,endhcloud,$
    enddust,endcloud,endhccloud,pos
  common otherdata,wm,bppp,resultdust,$
    bpppp,menu4,menu5,cloudsize,menu8,savefile
  common anotherdata,dustimage,cloudimage,$
    menu6,menu7,menu0,endimage,menu1
  common enddata,menu9,menu10,outputlcloud
  band=intarr(n_elements(pos))
  for i=0,n_elements(pos)-1  do begin
    b=strsplit(bnames[i],' ',/extract)
    band[i]=fix(b[2])
  endfor

  min0=min(data[*,*,0])
  min1=min(data[*,*,1])
  min2=min(data[*,*,2])
  max0=max(data[*,*,0])
  max1=max(data[*,*,1])
  max2=max(data[*,*,2])

  jcsdata=fltarr(ns,nl,3);存放假彩色影像,不需要额外操作
  r=where(band eq 1)
  g=where(band eq 20)
  b=where(band eq 30)
  jcsdata[*,*,0]=data[*,*,r]
  jcsdata[*,*,1]=data[*,*,g]
  jcsdata[*,*,2]=data[*,*,b]
;  outimage=image(jcsdata,xrange=[0,ns-1],yrange=[nl-1,0])

  dustxy=fltarr(ns,nl)  ;存放沙尘坐标
  cloudxy=fltarr(ns,nl)  ;存放云层坐标
  hcloudxy=fltarr(ns,nl) ;存放高云层坐标
  lcloudxy=fltarr(ns,nl) ;存放低云层坐标

  linshidata=data[*,*,b]-data[*,*,c]
  minlin=min(linshidata)
  for row=0,nl-1 do begin
    for cols=0,ns-1 do begin
      minn=data[cols,row,b]-data[cols,row,c]
      if minn le 0 then begin
        dustxy[cols,row]=1
      endif
    endfor
  endfor

  o=where(band eq 26)
  i=where(band eq 3)
  maxb=max(data[*,*,o])
  maxc=max(data[*,*,i])
  for row=0,nl-1 do begin
    for cols=0,ns-1 do begin
      if data[cols,row,i] ge 1500 then begin
        cloudxy[cols,row]=1
        lcloudxy[cols,row]=1
      endif
      if data[cols,row,o] ge 3000 then begin
        cloudxy[cols,row]=1
        hcloudxy[cols,row]=1
      endif
      if data[cols,row,0] ge 2900 then begin
        lcloudxy[cols,row]=1
      endif
    endfor
  endfor

  resultdust=dustxy-cloudxy
  for row=0,nl-1 do begin
    for cols=0,ns-1 do begin
      if resultdust[cols,row] eq -1 then begin
        resultdust[cols,row]=0
      endif
    endfor
  endfor

  endlcloud=fltarr(ns,nl,3)
  endhcloud=fltarr(ns,nl,3)
  enddust=fltarr(ns,nl,3)
  endcloud=fltarr(ns,nl,3)
  endhccloud=fltarr(ns,nl,3)
  for row=0,nl-1 do begin
    for cols=0,ns-1 do begin
      if resultdust[cols,row] eq 1 then begin
        enddust[cols,row,0]=data[cols,row,0]
        enddust[cols,row,1]=0
        enddust[cols,row,2]=data[cols,row,2]
      endif
      if cloudxy[cols,row] eq 1 then begin
        endcloud[cols,row,0]=max0*data[cols,row,0]/max0
        endcloud[cols,row,1]=max1*data[cols,row,0]/max1
        endcloud[cols,row,2]=max2*data[cols,row,0]/max2
      endif
      if lcloudxy[cols,row] eq 1 then begin
        endlcloud[cols,row,0]=0
        endlcloud[cols,row,1]=0
        endlcloud[cols,row,2]=max2*data[cols,row,0]/max2
        endhccloud[cols,row,*]=endlcloud[cols,row,*]
      endif
      if hcloudxy[cols,row] eq 1 then begin
        endhcloud[cols,row,0]=max0*data[cols,row,0]/max0
        endhcloud[cols,row,1]=0
        endhcloud[cols,row,2]=0
        endhccloud[cols,row,*]=endhcloud[cols,row,*]
      endif
    endfor
  endfor
  return,1
end

找不到原始的图,不想保存再发,截图凑合一下 

52aa9715db68452893dd6a3ad534061d.png

5fc4d9d1cbbd43f4838778106af2d209.png

  • 12
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值