Opened 11 years ago

Closed 3 years ago

Last modified 7 months ago

#2213 closed defect (fixed)

GTiff : inconsistant [0-255] <--> [0-65535] colormap values translation

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone: 2.2.4
Component: default Version: unspecified
Severity: normal Keywords: gtiff colormap
Cc:

Description

The conversion between the GDAL 8 bit color map space, ranging from 0 to 255, to the TIFF 16 bit color map space, ranging from 0 to 65535, is not done currently in a very consistent way in the code. Most places multiply or divide by 256, and one place multiplies by 257 (GTiffCreateCopy for a GDT_Byte band).

I think that the right factor is 257, in order to use the full dynamics of the 0-65535 range. I would propose too to use the following formula, (tiff_color_value + 127) / 257, that rounds to the nearest value.

However, there's maybe a good reason to do as it's actually done ? I could imagine it's done because some other software use 256 as the multiplication/division factor and we want to be consistent with them ? But if it is the case, then we should replace the 257 factor by 256.

Attachments (1)

gdal_svn_trunk_gtiff_colormap_translation.patch (2.5 KB) - added by Even Rouault 11 years ago.

Download all attachments as: .zip

Change History (7)

Changed 11 years ago by Even Rouault

comment:1 Changed 4 years ago by Jukka Rahkonen

Any news about this one?

comment:2 Changed 3 years ago by Jukka Rahkonen

It may be that patch has been at least partly applied into https://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/gtiff/geotiff.cpp but geotiff.cpp has grown quite a lot since 2008. Patch is not usable as is any more but Even can probably tell if the idea is still alive.

comment:3 Changed 3 years ago by Even Rouault

Resolution: wontfix
Status: newclosed

Let's close that. This is probably more a theoretical concern that somethings that surfaces in real world cases...

comment:4 Changed 7 months ago by Even Rouault

Resolution: wontfixfixed

In 41665:

GTiff: use consistently multiplication/division by 257 when converting between GDAL [0,255] range to TIFF [0,65535] range for color map values (fixes #2213)

comment:5 Changed 7 months ago by Even Rouault

Milestone: 2.2.4

comment:6 Changed 7 months ago by Even Rouault

In 41666:

GTiff: use consistently multiplication/division by 257 when converting between GDAL [0,255] range to TIFF [0,65535] range for color map values (fixes #2213)

Note: See TracTickets for help on using tickets.