Random access of TIFF/GeoTIFF an…

来源:互联网 发布:失落沙洲知乎 编辑:程序博客网 时间:2024/06/06 04:30
Random access of TIFF/GeoTIFF and pyramid based on it
   --拔剑

http://blog.sina.com.cn/s/blog_54b5ea250100raqp.html
鉴于ECW中存在一些未fix的bug, 最近指导学生做了点影像金字塔的工作,已实现了不错的性能。
顺便看了一下TIFF/GeoTIFF文件的格式。

1. TIFF支持多个图片存储,最多0xFFFF (255*256+255(TIFF文件中2个字节))约为60000个图片
2. TIFF文件中,存储顺序如下
    (1)Image File Header 
           ( byteorder(2b), version(2b), offset to thefirst IFD(4b)) ->8字节头
    (2)Image File Directory(IFD) - 表征子图的存储和位置
           Directory Entity Count(2B)   ->最多FFFF个图片
           Directory Entry    (12B)  ->表针第一个子图信息,包含如下信息
               (tag(2B),type(2B),length(4B), valueofOffset(4B)) ->offset指向图片属性存储的位置
           Directory Entry    (12B)
           Directory Entry    (12B)
           ....
    (3)实际数据区
           image 1
           image 2
           ...
           image N
3. 每个Image中又包括tag区以及图像区
4. 每个Image都可以用压缩或者非压缩格式存储(如原始数据,jpeg压缩方式。。。)
5.每个Image可以用strip方式存储,也可以TILE方式存储,也可以原始方式存储。因此大多数GeoTIFF
   文件实际上支持随机对文件的读取。
    (1)Scanline Read: 以行号读取图像,不适用于 TILE的TIFF文件,图像不能压缩
    (2)Strip read: 以带读取图像(高度较小,全宽),支持压缩和非压缩图像
    (3)TILE read:  以tile读取,必须为TILE类型的图象(瓦片图像)
6. 在cygwin中安转了libtiff/libgeotiff(也许缺省就有,没确认过),下述命令可以供参考:
   tiff2bw.exe    tiffcmp.exe     tiffdump.exe   tiffmedian.exe
   tiff2pdf.exe   tiffcp.exe     tiffgt.exe     tiffset.exe
   tiff2ps.exe    tiffdiff.exe    tifficc.exe    tiffsplit.exe
   tiff2rgba.exe   tiffdither.exe tiffinfo.exe   tifftopnm.exe
   geotiffcp.exe

结论:
   (1)理论上很多GeoTIFF图像支持随机读取,如果TILE型图像,可以实现大图像小内存的快速局部显示
     (2)利用TIFF支持多个图片以及每个图片支持TILE存放的特性,每个图放置不同比例图像,可以很容易
       扩充支持影像金字塔。用LibTIFF操作就行了。土是土了点,可是管用。呵呵~
 
一些有用的数据:
  (1)加入存储的是非压缩图像,即使1个tile为512*512, 每个图片最大tile数为0xFFFF
         512*512*3  * 255 * 255  ==750,000 * 62,500 = 45,000M
         ===> 45G
     which means even only with 1 picture in a tiff file, with 6000tile, you
      canhave a tiff file with 45G. Actually, maximum normal TIFF is 4G, ofcourse
     large TIFF could be more than 4G.
   (2) maximum pictures in aTIFF file is 6000, so it is enough for pyramid algorithm.
 

 
很有参考价值的文档:
  1. http://libtiff.maptools.org/libtiff.html#dirs  (libtiffAPI介绍)
  2. https://www.ibm.com/developerworks/linux/library/l-libtiff/  (关于行读、带读、和片读的形象说明和代码),并附加了源代码
  3. http://hi.baidu.com/fjr988/blog/item/972513f46c6c72e47709d730.html 一些TAG的说明
  4. TIFF specification6.0
  5. libtiff/libgeotiff(cygwin支持)
  
URL:TIFF/GeoTIFF的随机读取及影像金字塔
0 0
原创粉丝点击