
Ich habe ein TIFF-Bild, von dem ich vermute, dass es einen linearen Farbraum haben sollte
exiftool alps.tif
ExifTool Version Number : 11.88
File Name : alps.tif
Directory : .
File Size : 2.1 GB
File Modification Date/Time : 2022:05:15 14:13:32+02:00
File Access Date/Time : 2022:06:09 18:42:11+02:00
File Inode Change Date/Time : 2022:06:08 17:03:37+02:00
File Permissions : rw-------
File Type : TIFF
File Type Extension : tif
MIME Type : image/tiff
Exif Byte Order : Little-endian (Intel, II)
Image Width : 38160
Image Height : 15930
Bits Per Sample : 32
Compression : LZW
Photometric Interpretation : BlackIsZero
Samples Per Pixel : 1
Planar Configuration : Chunky
Predictor : None
Tile Width : 256
Tile Length : 256
Tile Offsets : (Binary data 99752 bytes, use -b option to extract)
Tile Byte Counts : (Binary data 63037 bytes, use -b option to extract)
Sample Format : Float
Pixel Scale : 0.000277777777777778 0.000277777777777778 0
Model Tie Point : 0 0 0 5.79999999999998 48.1251388888889 0
Geo Tiff Version : 1.1.0
GT Model Type : Geographic
GT Raster Type : Pixel Is Area
Geographic Type : WGS 84
Geog Citation : WGS 84
Geog Angular Units : Angular Degree
Geog Semi Major Axis : 6378137
Geog Inv Flattening : 298.257223563
Image Size : 38160x15930
Megapixels : 607.9
Wenn ich dieses Bild in GIMP 2.10 öffne, wird angezeigt, dass es im sRGB-Format ist.
Folgendes führt Exiftool bei einem aus GIMP 2.10 exportierten Bild aus:
exiftool /dev/shm/slask.tiff
ExifTool Version Number : 11.88
File Name : slask.tiff
Directory : /dev/shm
File Size : 1217 kB
File Modification Date/Time : 2022:06:09 18:51:55+02:00
File Access Date/Time : 2022:06:09 18:52:07+02:00
File Inode Change Date/Time : 2022:06:09 18:51:55+02:00
File Permissions : rw-rw-r--
File Type : TIFF
File Type Extension : tif
MIME Type : image/tiff
Exif Byte Order : Little-endian (Intel, II)
Image Width : 512
Image Height : 512
Bits Per Sample : 32
Compression : Uncompressed
Photometric Interpretation : BlackIsZero
Document Name : /dev/shm/slask.tiff
Image Description : Created with GIMP
Orientation : Horizontal (normal)
Samples Per Pixel : 1
Rows Per Strip : 128
X Resolution : 300
Y Resolution : 300
Planar Configuration : Chunky
Page Name : Bakgrund
Resolution Unit : inches
Subfile Type : Reduced-resolution image
Strip Offsets : 1049421
Strip Byte Counts : 196608
Sample Format : Float
Profile CMM Type : Little CMS
Profile Version : 4.3.0
Profile Class : Display Device Profile
Color Space Data : GRAY
Profile Connection Space : XYZ
Profile Date Time : 2022:06:09 16:48:40
Profile File Signature : acsp
Primary Platform : Apple Computer Inc.
CMM Flags : Not Embedded, Independent
Device Manufacturer :
Device Model :
Device Attributes : Reflective, Glossy, Positive, Color
Rendering Intent : Perceptual
Connection Space Illuminant : 0.9642 1 0.82491
Profile Creator : Little CMS
Profile ID : 0
Profile Description : GIMP built-in D65 Linear Grayscale
Profile Copyright : Public Domain
Media White Point : 0.95045 1 1.08905
Gray Tone Reproduction Curve : (Binary data 16 bytes, use -b option to extract)
Device Mfg Desc : GIMP
Device Model Desc : D65 Linear Grayscale
Image Size : 512x512
Megapixels : 0.262
Thumbnail TIFF : (Binary data 196824 bytes, use -b option to extract)
Um meine Hypothese zu testen, möchte ich die Farbinterpretationsdaten von /dev/shm/slask.tiff
am bis zuweisen alps.tif
. Beachten Sie, dass ich keine Pixelwerte ändern möchte. Ich möchte nur die Metadaten aktualisieren, was mit GIMP anscheinend nicht möglich ist.
Anscheinend kann ich es verwenden, tificc
aber dadurch werden die GeoTIFF-Tags entfernt, und wenn ich versuche, sie mit geotifcp wieder hinzuzufügen, ist die Intensitätsinterpretation weg.
Antwort1
Obwohl ich mit dieser Lösung nicht wirklich zufrieden bin, kann ich natürlich auch selbst etwas unternehmen und die Pixelwerte in eine EXR-Datei übertragen:
//@ {"target":{"name":"geotiff2exr.o", "pkgconfig_libs":["OpenEXR"]}}
#include "./geotiff_loader.hpp"
#include "./file.hpp"
#include <OpenEXR/ImfIO.h>
#include <OpenEXR/ImfOutputFile.h>
#include <OpenEXR/ImfChannelList.h>
int main(int argc, char** argv)
{
if(argc != 3)
{
fprintf(stderr, "Usage: geotiff2exr input output\n");
return 1;
}
auto tiff = make_tiff(argv[1]);
auto const info = get_image_info(tiff.get());
auto pixels = load_floats(tiff.get(), info);
auto src_ptr = static_cast<float const*>(pixels.get());
auto const w = info.size.sizes[0];
auto const h = info.size.sizes[1];
Imf::Header header{static_cast<int>(w), static_cast<int>(h)};
header.channels().insert("Y", Imf::Channel{Imf::FLOAT});
Imf::FrameBuffer fb;
fb.insert("Y",
Imf::Slice{Imf::FLOAT,
(char*)(src_ptr),
sizeof(float),
sizeof(float) * w});
Imf::OutputFile dest{argv[2], header};
dest.setFrameBuffer(fb);
dest.writePixels(h);
return 0;
}