zoukankan      html  css  js  c++  java
  • 几点TIFF的说明

    一:TIFF读图工具

    1.QuaPath:https://github.com/qupath

    2.ASAP:https://github.com/computationalpathologygroup/ASAP

     

    二: TIFF 格式限制

    TIFF格式限制了其文件只能存储最大4G,超出4个G无法存储,打破该限制的方法为使用本系列所推荐的方法编译最新的4.1版本,然后将文件存储为bigtiff

    如何存储为bigTIFF?

    只需要在TIFFOpen函数的参数里面增加一个选项即可

    1 //w 代表写文件,8 代表bigtiff ,4 代表标准tiff,默认为4
    2 TIFFOpen(pcPath, "w8");

    三:存储tile 图像

     1 bool SaveTile(const uchar *pucTile, uchar *pucJpeg, const int nL, const int nT,
     2     const int nR, const int nB, const int nLayer, const int nFocus)
     3 {
     4  
     5     LOG_E("left = %d,top = %d,bottom = %d,right = %d, nLayer=%d,nFocus=%d", nL, nT, nB, nR,nLayer,nFocus);
     6  
     7     LAYER_S &stLayer = m_pD->stTmap.stLayers[nLayer];
     8  
     9     
    10     const int nWidth = nR - nL;
    11     const int nHeight = nB - nT;
    12     int nLength = 0;
    13  
    14  
    15     try
    16     {
    17         TIFFSetDirectory(m_pD->pfFile, nLayer);
    18         TIFFSetField(m_pD->pfFile, TIFFTAG_IMAGEWIDTH, stLayer.nWidth);
    19         TIFFSetField(m_pD->pfFile, TIFFTAG_IMAGELENGTH, stLayer.nHeight);
    20         TIFFSetField(m_pD->pfFile, TIFFTAG_ROWSPERSTRIP, stLayer.nHeight);
    21  
    22         TIFFSetField(m_pD->pfFile, TIFFTAG_TILEWIDTH, m_pD->nTileW);
    23         TIFFSetField(m_pD->pfFile, TIFFTAG_TILELENGTH, m_pD->nTileH);
    24         TIFFSetField(m_pD->pfFile, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE);
    25         TIFFSetField(m_pD->pfFile, TIFFTAG_BITSPERSAMPLE, 8);
    26         TIFFSetField(m_pD->pfFile, TIFFTAG_SAMPLESPERPIXEL, 3);
    27         TIFFSetField(m_pD->pfFile, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
    28  
    29         TIFFSetField(m_pD->pfFile, TIFFTAG_COMPRESSION, COMPRESSION_JPEG);
    30         TIFFSetField(m_pD->pfFile, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
    31  
    32         /*int nJpegQuality = 60;
    33         TIFFSetField(m_pD->pfFile, TIFFTAG_JPEGQUALITY, nJpegQuality);*/
    34         if (nLayer == 0)
    35         {
    36             float fPixelSize = 0.0f;
    37             int nScale = 0;
    38             GetScanScale(nScale);
    39             GetPixelSize(fPixelSize);
    40             fPixelSize = fPixelSize * 100 / max(1, nScale);
    41             TIFFSetField(m_pD->pfFile, TIFFTAG_XRESOLUTION, 1.0 / (fPixelSize / 10));
    42             TIFFSetField(m_pD->pfFile, TIFFTAG_YRESOLUTION, 1.0 / (fPixelSize / 10));
    43             TIFFSetField(m_pD->pfFile, TIFFTAG_RESOLUTIONUNIT, 3);
    44         }
    45  
    46 
    47         
    48         // save tile information
    49         const int nTileRow = nT / m_pD->nTileH;
    50         const int nTileCol = nL / m_pD->nTileW;
    51         int tiffIndex = nTileRow * (stLayer.nWidth / m_pD->nTileW) + nTileCol;
    52  
    53  
    54         TIFFWriteEncodedTile(m_pD->pfFile, tiffIndex, (void *)pucTile, m_pD->nTileW * m_pD->nTileH * 3);
    55  
    56         TIFFWriteDirectory(m_pD->pfFile);
    57 }
  • 相关阅读:
    算法分类整理+模板②:字符串处理
    【HDU 1687】Lucky Light(思维+计算几何)
    省选总结
    算法分类整理+模板①:矩阵快速幂
    【FZU 1911】Construct a Matrix(矩阵快速幂+找规律)
    【ZOJ 2974】Just Pour the Water(矩阵快速幂)
    博客搬家 from csdn to cnblog
    【FZU 2215】Simple Polynomial Problem(后缀表达式+栈的应用)
    【POJ 1276】Cash Machine(多重背包)
    前端监听图片加载异常-自动替换默认图片
  • 原文地址:https://www.cnblogs.com/ybqjymy/p/13704472.html
Copyright © 2011-2022 走看看