一: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 }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)