Page 1 of 1

converting 16-bit grayscale to 8-bit

Posted: 2010-03-17T13:51:32-07:00
by taranaki
I'm trying to convert a 16-bit grayscale .tif image (intensity min, max: 0, 4095) down to an 8-bit grayscale .tif (or .png), but naively using -depth 8 isn't working and results in an image with too much missing information.

For example:

Orig.tif has up to 4095 unique color values.

Code: Select all

convert orig.tif -fx 'intensity/16' dithered.tif
--> creates a 16-bit version of orig.tif that looks very close to the original, but only has 256 unique color values. This is what I want, but with 8-bit quality.

Code: Select all

convert orig.tif -depth 8 new.tif
--> poorly dithered 8-bit version. :(

I've tried a lot of things with the same result. The part that gives me some concern that this may be a bug is that when I try to convert the dithered.tif using -depth 8 it is the same as out.tif.

Any assistance would be greatly appreciated!
~Cameron

The images:
http://dl.dropbox.com/u/222088/orig.tif
http://dl.dropbox.com/u/222088/dithered.tif
http://dl.dropbox.com/u/222088/out.tif

Version: ImageMagick 6.5.8-2 2010-02-22 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Features: HDRI OpenMP

Re: converting 16-bit grayscale to 8-bit

Posted: 2010-03-17T15:14:38-07:00
by magick
Try
  • convert orig.tif -evaluate multiply 16 -depth 8 orig-8.tif

Re: converting 16-bit grayscale to 8-bit

Posted: 2010-03-18T10:36:03-07:00
by taranaki
This works! Thank you.

Re: converting 16-bit grayscale to 8-bit

Posted: 2010-04-26T11:16:16-07:00
by andrew
What is the significance of

Code: Select all

-evaluate multiply 16
.. is 16 arbitrary?

Re: converting 16-bit grayscale to 8-bit

Posted: 2010-04-26T11:34:28-07:00
by snibgo
[quote]Orig.tif has up to 4095 unique color values.[quote]

Multiplying by 16 takes the maximum value (white) to 65520, which isn't far from the maximum 16-bit quantum 65525.

Re: converting 16-bit grayscale to 8-bit

Posted: 2010-04-26T12:20:23-07:00
by fmw42
you could use -auto-level -depth 8 which would stretch your original image to full dynamic range if that is what you want so that your 8-bit image ranged from 0 to 255.