Discussion:
[gdal-dev] ALPHA and PHOTOMETRIC options in TIFF
Javier Jimenez Shaw
2021-06-05 08:24:19 UTC
Permalink
Hi

I am struggling to save my data in (Geo)TIFF files with the proper creation
options.
My data is not standard RGB(A), but a collection of bands like red, green,
(not necessarily blue), another type of red, near infrared, etc, and Alpha.
It can be uint8, uint16 or float.

I was using PHOTOMETRIC=MINISBLACK and ALPHA=YES, but now I am not sure if
this is the proper configuration. In addition to that, I am setting a
ColorInterpretation to the bands (many bands as GCI_Undefined, like for
Near Infrared. The alpha band is clear as GCI_AlphaBand).

The "extra samples" is obscure to me, I do not know how many bands expects,
and how many are "extra". (
https://www.awaresystems.be/imaging/tiff/tifftags/extrasamples.html)

TIFF says "There is no default for PhotometricInterpretation, and it is
required. Do not rely on applications defaulting to what you want." in
https://www.awaresystems.be/imaging/tiff/tifftags/photometricinterpretation.html

How should I create my TIFFs?

Thanks.
.___ ._ ..._ .. . ._. .___ .. __ . _. . __.. ... .... ._ .__
Entre dos pensamientos racionales
hay infinitos pensamientos irracionales.
Even Rouault
2021-06-05 08:30:06 UTC
Permalink
Javier,
Post by Javier Jimenez Shaw
Hi
I am struggling to save my data in (Geo)TIFF files with the proper
creation options.
My data is not standard RGB(A), but a collection of bands like red,
green, (not necessarily blue), another type of red, near infrared,
etc, and Alpha. It can be uint8, uint16 or float.
I was using PHOTOMETRIC=MINISBLACK and ALPHA=YES, but now I am not
sure if this is the proper configuration. In addition to that, I am
setting a ColorInterpretation to the bands (many bands as
GCI_Undefined, like for Near Infrared. The alpha band is clear as
GCI_AlphaBand).
This looks good. GDAL will potential write into its GDAL_METADATA XML
tag custom band color interpretation if the very basic ones implied by
only TIFF tags (Grey, Grey+Alpha, RGB, RGBA) don't fit your settings
Post by Javier Jimenez Shaw
The "extra samples" is obscure to me, I do not know how many bands
expects, and how many are "extra".
(https://www.awaresystems.be/imaging/tiff/tifftags/extrasamples.html
<https://www.awaresystems.be/imaging/tiff/tifftags/extrasamples.html>)
You shouldn't worry too much about that tag. The GeoTIFF driver will
take care of setting it. But basically if you use
Photometric=MinIsBlack, then count(extra_samples) = number_bands - 1, or
if you use Photometric=RGB, count(extra_samples) = number_bands - 3.
Post by Javier Jimenez Shaw
TIFF says "There is no default for PhotometricInterpretation, and it
is required. Do not rely on applications defaulting to what you want."
in
https://www.awaresystems.be/imaging/tiff/tifftags/photometricinterpretation.html
<https://www.awaresystems.be/imaging/tiff/tifftags/photometricinterpretation.html>
How should I create my TIFFs?
For what you describe, MinIsBlack is the appropriate Photometric value

Even
--
http://www.spatialys.com
My software is free, but my time generally not.
Loading...