3

I am working on a biomedical imaging application. I having some trouble finding a good container format for my 12 bit grayscale images.

Does anybody know of a 12 bit image format with a C++ or C api similiar to LibTIFF?

ulidtko
  • 14,740
  • 10
  • 56
  • 88
Mikhail
  • 7,749
  • 11
  • 62
  • 136
  • 1
    LibTIFF is a C API which is extremely similar to libTIFF. Use TIFF and save the images as 16bpp, using only the lower 12 bits. This is what I have done on two previous projects and it works just fine. – Ed S. Mar 20 '13 at 19:27
  • @EdS., certainly not a bad idea and what I am currently doing. But explaining to somebody that the dynamic range has half the bits chopped off is cumbersome. – Mikhail Mar 20 '13 at 19:40
  • @Mikhail: Why do you need to explain it? Does that annoyance justify finding a new library? LibTIFF is a battle-hardened, mature library with a huge existing toolset and a ton of support. Just embed the bit depth in the image. Anyone reading the image should know how to interpret the data. – Ed S. Mar 20 '13 at 19:59
  • @EdS. Maybe I'm doing it wrong, but when I open the image in the commercial editors it scales it from 0-2**16. Oh well. – Mikhail Mar 20 '13 at 21:59
  • @Mikhail: Yeah, that's a good point. I didn't even think of that because we had written our own reader. – Ed S. Mar 20 '13 at 22:05
  • 1
    Are these medical images that require the viewer to adjust the brightness/contrast (level/width)? If so, DICOM is the most logical format to store them. – BitBank Mar 22 '13 at 23:48

2 Answers2

4

I suggest using DICOM for medical imaging instead of some other image format. GDCM and DCMTK are both good opensource toolkits that allow reading and writing of dicom files (+ lots more).

A good free windows DICOM viewer is MicroDicom.

drescherjm
  • 10,365
  • 5
  • 44
  • 64
2

I'd consider researching existing HDR image formats and libraries, like OpenEXR, HDRi, Radiance, etc.

Also, as far as I know, TIFF is actually a very flexible format and you could use that.

ulidtko
  • 14,740
  • 10
  • 56
  • 88
  • Tiff is a wonderful format, but looking at this http://stackoverflow.com/questions/7068183/writing-10-12-bit-tiff-files-with-libtiff-c I would need to find a different API for using it. – Mikhail Mar 20 '13 at 19:17