TIFF 画像を読み取って処理を実行しようとしています。理想は、このイメージを OpenCV 構造にインポートできることですが、別の方法でアクセスできるようにすることも素晴らしいことです。
取得した画像に対して tiffinfo を実行すると、
TIFF Directory at offset 0x2bb00 (178944)
Subfile Type: (0 = 0x0)
Image Width: 208 Image Length: 213
Resolution: 1, 1
Bits/Sample: 32
Sample Format: IEEE floating point
Compression Scheme: None
Photometric Interpretation: min-is-black
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 1
Rows/Strip: 1
Planar Configuration: single image plane
単一のピクセル値にアクセスしたい。画像はグレースケールで、そこに含まれるデータの範囲は 0.0 から 10372.471680 です。
私はLibTIFF、Magick ++でいくつかの試行を行いましたが、単一のピクセル値にアクセスできませんでした(ピクセルをループして、これらの値を画面に出力しようとしました)。
これが私が使用しようとしているコードの一部です。オンラインの例から取得しました。
#include "tiffio.h"
#include "stdio.h"
int main()
{
TIFF* tif = TIFFOpen("test.tif", "r");
if (tif) {
uint32 imagelength;
tsize_t scanline;
tdata_t buf;
uint32 row;
uint32 col;
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
scanline = TIFFScanlineSize(tif);
buf = _TIFFmalloc(scanline);
for (row = 0; row < imagelength; row++)
{
int n = TIFFReadScanline(tif, buf, row, 0);
if(n==-1){
printf("Error");
return 0;
}
for (col = 0; col < scanline; col++)
printf("%f\n", buf[col]);
printf("\n");
}
printf("ScanLineSize: %d\n",scanline);
_TIFFfree(buf);
TIFFClose(tif);
}
}
私はそれをコンパイルします
gcc test.c -ltiff -o テスト
私がそれを実行すると、私は得る
test.c: In function ‘main’:
test.c:24: warning: dereferencing ‘void *’ pointer
test.c:24: error: invalid use of void expression
ヒントはありますか?御時間ありがとうございます。