【发布时间】:2017-12-28 20:34:17
【问题描述】:
我的最终目标是用 C++ 实现云检测算法。但是,我遇到了一个问题。
我在从像素中提取信息时遇到问题。对于数据预处理,使用了 SNAP,我可以在那里看到给定像素的大量信息(经度、纬度、波段值等)。
当我将图像导出为 TIFF 文件时出现问题。为了处理它,我使用了 LibTIFF 库。但是,我真的不知道如何提取有关给定像素的特定信息。目前,我在 LibTIFF 文档中给出了一个标准代码,用于遍历图像的所有像素并打印出它的值。不幸的是,我得到的值没有意义。
TIFF* tif = TIFFOpen(filename, "r");
if (tif) {
uint32 imagelength;
double * buf;
tsize_t scanline;
uint32 row;
uint32 i;
tsize_t y;
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
scanline = TIFFScanlineSize(tif);
buf = (double *) _TIFFmalloc(scanline);
for (row = 0; row < imagelength; row++) {
int n = TIFFReadScanline(tif, buf, row);
for (y = 0; y < scanline; y++) {
cout << "Row: " << row << " y: " << y << " " << (double) buf[y]
<< endl;
}
}
_TIFFfree(buf);
TIFFClose(tif);
}
那么,我的问题是,有没有一种直接的方法来提取给定像素的特定信息,最好是使用 LibTIFF?如果没有,最好的方法应该是什么?抱歉,如果问题非常基本,我只是找不到任何有关它的信息。提前致谢。
编辑:identify -verbose file.tif 的输出
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 1830x1830+0+0
Resolution: 1x1
Print size: 1830x1830
Units: Undefined
Colorspace: Gray
Type: Grayscale
Endianess: MSB
Depth: 16/8-bit
Channel depth:
Gray: 8-bit
Channel statistics:
Pixels: 3348900
Gray:
min: 0 (0)
max: 13107 (0.2)
mean: 1582.66 (0.0241498)
standard deviation: 1200.55 (0.0183193)
kurtosis: 2.79689
skewness: 1.81966
entropy: 0.63063
Colors: 34
Rendering intent: Undefined
Gamma: 0.454545
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 1830x1830+0+0
Dispose: Undefined
Iterations: 0
Compression: None
Orientation: TopLeft
Properties:
comment: band2
date:create: 2018-01-09T21:48:10+00:00
date:modify: 2018-01-09T21:48:14+00:00
signature: b3783beb7f7d2bdb32c3c64f8878a02c238a10f221f6a05f93991b26a58a4c78
tiff:alpha: unspecified
tiff:endian: msb
tiff:photometric: min-is-black
tiff:rows-per-strip: 1830
Artifacts:
verbose: true
Tainted: False
Filesize: 49.3701MiB
Number pixels: 3348900
Pixels per second: 3.88504MB
User time: 0.484u
Elapsed time: 0:01.861
【问题讨论】:
-
为什么你认为你的 TIFF 包含双打?你试过
tiffdump yourFile.tif,或者ImageMagick的identify -verbose yourFile.tif吗? -
我假设 TIFF 包含双精度值只是因为像素的某些值(例如波段值)是双精度值。我很确定我错了。不,我没有使用过 tiffdump 或 ImageMagick。如果我理解正确,他们会帮助我找出像素的内容吗?然后提取需要的东西?
-
你只需要运行一个或两个,看看你在处理什么。请点击帖子下方的
edit并粘贴到输出中。 -
有进展的消息吗?
-
很抱歉@MarkSetchell 回复晚了,但没有取得任何进展。我确实运行了
identify -verbose yourFile.tif,但我不知道如何分析它。输出文件很大,所以我不认为将它粘贴在这里是一个好主意。如果你能告诉我哪些信息是相关的,那就太好了。谢谢。