(接上一个程序)统计云层检测的二值化结果

pro Part_4

  compile_opt idl2

  e=envi(/headless)

  for k=1, 91, 1 DO BEGIN

    kk=strtrim(string(k),1)

    file_mkdir,"D:\Lansat_Data_Cloud_Result\"+kk+"\"

  endfor

  for i=1,91,1 do begin

    ;if (i lt 46) then continue

    if (i ne 86) then continue

    ii=strtrim(string(i),1)

    folder="D:\Lansat_Data_Cloud\"+ii+"\"

    filearr = file_search(folder,'*.dat',count=num)

    cloud_sum = long(0)

    pixel_sum = long(0)

    for j=0,num-1,1 do begin

      arr = strarr(1,8)

      cloud_sum = long(0)

      pixel_sum = long(0)

      file = filearr[j]

      raster = e.OpenRaster(file)

      fid = ENVIRasterToFID(raster)

      MAP_INFO = ENVI_GET_MAP_INFO(fid=fid)

      ENVI_FILE_QUERY, fid, ns=ns, nl=nl, nb=nb, dims=dim, data_type=data_type 

      data = raster.getdata()

      for l=0,ns-1,1 do begin

        for m=0,nl-1,1 do begin

          a=data[l,m]

          if (a eq 1) then begin

            pixel_sum = pixel_sum + 1

          endif else if (a eq 5) then begin

            cloud_sum = cloud_sum + 1

            pixel_sum = pixel_sum + 1

          endif

        endfor

      endfor

      print,cloud_sum,pixel_sum

      all_place = nl*ns

      if (pixel_sum ne 0) then begin

        percentage = (float(cloud_sum)/pixel_sum)*100

      endif else if (pixel_sum eq 0) then begin

        percentage = 0

      endif

      contain = (float(pixel_sum)/all_place)*100

      if (contain gt 95) then begin

        evaluation_1 = "1"

      endif else if (contain gt 80) then begin

        evaluation_1 = "2"

      endif else if (contain gt 50) then begin

        evaluation_1 = "3"

      endif else if (contain gt 25) then begin

        evaluation_1 = "4"

      endif else if (contain le 25) then begin

        evaluation_1 = "5"

      endif

      if (percentage gt 30) then begin

        evaluation_2 = "5"

      endif else if (percentage gt 20) then begin

        evaluation_2 = "4"

      endif else if (percentage gt 10) then begin

        evaluation_2 = "3"

      endif else if (percentage gt 5) then begin

        evaluation_2 = "2"

      endif else if (percentage le 5) then begin

        evaluation_2 = "1"

      endif

      arr[0,0] = strtrim(file,1);文件位置

      arr[0,1] = strtrim(string(i),1);ROI编号

      arr[0,2] = strtrim(string(pixel_sum),1);总像素量

      arr[0,3] = strtrim(string(cloud_sum),1);云像素量

      arr[0,4] = strtrim(string(percentage),1);含云百分比

      arr[0,5] = strtrim(string(contain),1);完整度百分比

      arr[0,6] = strtrim(evaluation_1,1);完整度评价

      arr[0,7] = strtrim(evaluation_2,1);含云量评价

      if (ii lt 10) then begin

        name_start=strmid(file,23,49)

      endif else if (i ge 10) then begin

        name_start=strmid(file,24,49)

      endif

      txt_file = "D:\Lansat_Data_Cloud_Result\"+ii+"\"+name_start+".txt"

      openw,lun,txt_file,/get_lun

      printf,lun,arr

      free_lun,lun

    endfor

    print,"-------------------------------------",i

  endfor

end

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值