IDL 建立影像金字塔

形成按目录放好的,类似于Google Map Tile的金字塔瓦片Jpg。

   1:  ;
   2:  pro tsplit
   3:      ; 读入Jpeg格式文件
   4:      szFile = 'e:\test.jpg'; dialog_pickfile(title = 'input data')
   5:      read_jpeg,szFile,image,true = 3
   6:      ; 切割5级
   7:      nlevel = 5;
   8:      ;
   9:      for iLevel = 0,nLevel-1 do begin
  10:          split,image,ilevel,ib
  11:      endfor
  12:      return
  13:  end
  14:   
  15:  pro split,image,level,iband
  16:      src = 'e:\src'
  17:      ns0 = 512
  18:      nl0 = 512
  19:      n0 = 2^level
  20:      sz = size(image,/dimensions)
  21:      help,sz
  22:      print,sz
  23:      nx = sz[0]
  24:      ny = sz[1]
  25:      xspan = nx*1.0/n0;
  26:      yspan = ny*1.0/n0;
  27:      imglet = bytarr(ns0,nl0,3)
  28:   
  29:      fmt = '(%"%s\\%d\\img_%d_%d.jpg")';
  30:      for is = 0l,n0-1 do begin
  31:          for il = 0l,n0 -1 do begin
  32:              x = indgen(ns0)#replicate(1,nl0)*xspan/ns0 + is*xspan
  33:              y = replicate(1,ns0)#indgen(nl0)*yspan/nl0 + il*yspan
  34:              for ib = 0,2 do begin
  35:                  imglet[*,*,ib] = bilinear(image[*,*,ib],x,y)
  36:              endfor
  37:              fileout = string(src,level,n0-il-1,is,format =fmt)
  38:              dir = file_dirname(fileout)
  39:              if(file_test(dir,/directory) lt 1) then file_mkdir,dir
  40:              write_jpeg,fileout,imglet,true = 3
  41:          endfor
  42:      endfor
  43:  end
  44:   
  45:  ; 主程序
  46:  pro ttt
  47:   
  48:      tsplit
  49:      print,'Done
  50:  end

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

上一篇:wamp目录索引图片不显示


下一篇:Linux 中强大且常用命令:find、grep