Page 1 of 1
Bits lost along the way with convert -combine
Posted: 2016-06-29T15:39:17-07:00
by Ocirne94
Hi all,
I'm trying to use convert to combine the three r, g and b bands of a landsat scene into an rgb image.
The bands are 16-bits grayscale, the command I use is
Code: Select all
convert -combine {4,3,2}.tif -depth 16 rgb.tif
The result is indeed 16-bits-per-channel, but apparently during the process there is some 8-bits bottleneck: what I get is the 16-bits representation of 8-bit data, the histogram shows only 256 equally-spaced values, and the file size corresponds to 8 bits per channel.
I'm using ImageMagick 6.9.2-10 Q16 x86_64 20151218 on ubuntu 16.04, and the problem images are here (200 Mb):
https://mega.nz/#!ChNCSBBb!hU1_Oen9l0gN ... auwyr-yC_M
What am I missing here?
Thank you very much,
Enrico
Re: Bits lost along the way with convert -combine
Posted: 2016-06-29T16:25:21-07:00
by fmw42
Read your input images before combining them. That is proper IM 6 syntax.
OK, so you have 3 separate grayscale images. Have you tried
Code: Select all
convert -quiet 4.tif 3.tif 2.tif -set colorspace sRGB -combine -depth 16 result.tif
However, using identify -verbose 4.tif, I see that your input data is 16/8-bits. That means that you extracted the data as 8-bits, but are storing it as 16 bits. So there are really only 8bits worth of grayscale information, which should be scaled to span the 16-bit range. So the software that you used to extract the channels and store in tif format converted the data to 8bits.
So there is really no point in saving as 16 bits. You might as well just use
Code: Select all
convert -quiet 4.tif 3.tif 2.tif -set colorspace sRGB -combine -depth 8 result.tif
This works for me, but your 4,3,2 channels are practically identical and so the result looks grayscale.
Re: Bits lost along the way with convert -combine
Posted: 2016-06-30T05:39:58-07:00
by Ocirne94
Now this is weird: opening the image (2.tif) with gimp I get the full 16-bits (there are more than 256 values and the histogram has a beautifully continuous and solid shape). So it really looks like IM is missing something...
P.S.: the channels are not identical, landsat images need a strong contrast curve if you want them to look natural. That's why they use 16-bits
Re: Bits lost along the way with convert -combine
Posted: 2016-06-30T05:42:48-07:00
by snibgo
Ocirne94 wrote:... opening the image (2.tif) with gimp I get the full 16-bits (there are more than 256 values and the histogram has a beautifully continuous and solid shape).
What version of Gimp is that? I thought Gimp only had 8 bits per channel?
Re: Bits lost along the way with convert -combine
Posted: 2016-06-30T05:56:16-07:00
by Ocirne94
Gimp 2.9.3, which supports up to 32-bits per channel and floating point.
Re: Bits lost along the way with convert -combine
Posted: 2017-03-14T09:46:16-07:00
by fmw42
To get 32-bit (floats) per channel for tiff, you will need at least Q16 HDRI compiled Imagemagick. Also see
http://www.imagemagick.org/script/formats.php -defines for tiff.
"To specify a single-precision floating-point format, use -define quantum:format=floating-point"