Re: Tiff with signed samples
Bob Friesenhahn <[email protected]> Tue, 18 Aug 2020 08:58:38 -0500 (CDT)
| Newsgroups | gmane.comp.video.graphicsmagick.help |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 17 Aug 2020, Tom Lechner wrote: > > I'm trying to process this image, a 2G tiff with apparently signed samples: > https://astrogeology.usgs.gov/search/map/Mars/GlobalSurveyor/MOLA/Mars_MGS_MOLA_DEM_mosaic_global_463m The 2GB download size seems somewhat prohibitive to easily test with. :-) > If I try to "gm convert" to a smaller size so I can actually edit on my > computer, it converts, but the samples seem to be read as unsigned, making > very light and very dark areas. > > I can mess with the pixel values to get something that seems right, but is > there some option I'm missing to convert properly with gm? It is indeed true that GM currently lacks direct support for signed TIFF since it only uses unsigned types for its pixel quantum storage. The signed values will be parsed as if they are unsigned. Values less than zero will become very large positive values since the top-bit is set in 2's-complement notation. As long as the Quantum size in the GM build is at least the size of the original samples, then no actual loss should have occured yet. A problem with signed values is that it is necessary to know the range of the values in order to make sense of the image. Often the range is suggested by tags in the TIFF file. If the range is all positive values, then the solution is relatively easy since the image will appear darker (by half) as normal. If the range includes negative values, then things are more tricky. GM's -operator command can be useful such as using the logical And operator, as well as the LShift, RShift, and Multiply operators to try to convert the data into useful unsigned values. Software such as GDAL may be better suited for dealing with these images. Bob -- Bob Friesenhahn [email protected], http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt