My final goal is to implement cloud detection algorithm with C++. However, I faced a problem.
I have an issue with extracting information from pixels. For data pre-processing, SNAP was used and I can see a lot of information there for a given pixel (longitude, latitude, band value, etc.).
The problem arises when I export the image as a TIFF file. To deal with it, I used LibTIFF library. However, I do not really know how to extract specific information about a given pixel. Currently, I have a standard code given in LibTIFF documentation to loop through all the pixels of an image and print out its value. Unfortunately, the values I get do not make sense.
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);
}
So, my question is is there an straightforward way to extract a particular info for a given pixel, ideally using LibTIFF? If not, what should be the best way to do it? Apologies if the question is very basic, I just could not find any information about it. Thanks in advance.
EDIT: Output of 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