4
$\begingroup$

I have a CMOS camera which records images at 12 bit resolution. The camera software allows to save them as 12-bit TIFs. However, Mathematica cannot import this:

Import["12_bit.tif", "BitDepth"] (* -> 12 *) img = Import["12_bit.tif"] (* -> $Failed *) 

Import::unsup: Unsupported type of TIFF file.

How can I read 12-bit TIF images?

Here is the original image: http://tinyurl.com/jyg6jwm

I also can save camera images as 16 Bit TIFs.

Comparison of image size on my computer (Win 10 Pro, NTFS):

12 Bit TIF:

Size: 6.299.794 Bytes

Size on SSD: 6.303.744 Bytes

16 Bit TIF:

Size: 8.396.946 Bytes

Size on SSD: 8.400.896 Bytes

$\endgroup$
7
  • $\begingroup$ You might have to convert it to a 16-bit pixel format in some other software before you can import it. Or, assuming that this is a scientific camera, you can save it in some other format (such as FITS). $\endgroup$ Commented Jan 13, 2016 at 14:53
  • $\begingroup$ I tried the same as you. Also Photoshop CC 2015 can read 12 Bit TIFs and can save them as 16 BIT TIFs ... but I think this is a task which should also be implemented in Mathematica (if not yet possible)! $\endgroup$ Commented Jan 13, 2016 at 15:06
  • 1
    $\begingroup$ Perhaps you might like to submit it as a feature request to WRI. I'm not sure how common are 12-bit TIFF files, because the TIFF 6.0 specification seems not to actually define how a 12-bit file should be produced--there are no 12-bit field types defined. Thus, implementations could vary. It seems that LibTIFF (and thus MATLAB) does not support it either. TIFF is not necessarily the best choice of format; I tend to avoid it unless others ask me to use it. $\endgroup$ Commented Jan 13, 2016 at 15:22
  • $\begingroup$ Our SEM kicks out 12bit TIFF by default. I changed the settings to 16bit to avoid this, but have posted a workaround below that may or may not be useful for you. $\endgroup$ Commented Jan 13, 2016 at 16:23
  • $\begingroup$ shot in the dark but see if Import[ .. "Data"] works $\endgroup$ Commented Jan 13, 2016 at 17:15

2 Answers 2

7
$\begingroup$

Here is the answer from Wolfram Technical Support

12-bit TIFF files are not currently supported by Mathematica. Our developers are interested in supporting this format, however, and I have filed a suggestion on your behalf. I have also included your contact information so that you can be notified if this gets implemented.

$\endgroup$
1
  • 3
    $\begingroup$ 12-bit TIFF files are supported in Mathematica 10.4. $\endgroup$ Commented Mar 16, 2016 at 8:05
5
$\begingroup$

If you're command line friendly, one possible workaround is to use imagemagick or one of the various libtiff command line tools to turn your image into 16-bit, viz.---

Import["12_bit.tif"] (* $Failed *) Run["/usr/local/bin/convert 12_bit.tif -depth 16 16_bit.tif"] (* 0 *) Import["16_bit.tif"] (* sweet sweet success *) 

On the Mac, I have imagemagick and friends installed via homebrew for these sorts of situations.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.