Forum

Author Topic: Appropriate format (TIFF/PNG/JP2/etc) for 12-bit images  (Read 2444 times)

marcel.d

  • Newbie
  • *
  • Posts: 15
    • View Profile
Appropriate format (TIFF/PNG/JP2/etc) for 12-bit images
« on: January 27, 2021, 11:45:12 PM »
Dear Agisoft Community!

I have images coming from a 12-bit camera. Reading through the many useful posts on the forum I came across this: https://www.agisoft.com/forum/index.php?topic=308.0 which made me curious to use the whole bit depth in Metashape.

The easy thing to do is to store the 12 significant bits as the most significant bits of an unsigned 16-bit integer and pad the least significant bits with zeroes. It is easy because I can see the colors well when I open these images in any viewer. The other option is to store the data in the least significant bits. But then the images initially look almost black in most image viewers. They do look just as good as the other ones with the correct settings.

Another argument for using the 12 top bits, in PNG I can set the sBIT (SignificantBits) tag to 12, so the original data can be retrieved with the precision/accuracy that it was captured with.

Unfortunately the sBIT tag is not available in the TIFF file specification, but the Metashape manual (beginning of chapter 2) specifically recommends using TIFF (https://www.agisoft.com/pdf/metashape_1_7_en.pdf#page=11).

I do pre-processing in OpenCV and can save the files in both formats. And with both "bit-positions".

With the exact same data (12MP, 12-bit significant, RGB), I get the following file sizes:

Option 1: PNG, data in MOST significant bits: 40.1 MB   (Deflate/Inflate lossless compression)
Option 2: TIFF, data in MOST significant bits: 43.1 MB        (LZW lossless compression)
---------------
Option 3: PNG, data in LEAST significant bits: 42.2 MB   (Deflate/Inflate lossless compression)
Option 4: TIFF, data in LEAST significant bits: 47.6 MB        (LZW lossless compression)

Option 1 wins by a small margin also regarding the file size.

Summarizing:
1. Is either "Data in MSB (Options 1&2)" or "Data in LSB (Options 3&4)" better / easier for Metashape / preferable?
2. Is either TIFF or PNG  (or JPEG2000/something else)  better / easier for Metashape / preferable?
Again: the underlying data is exactly the same!

@Alexey: I know the questions are rather loaded, but I would appreciate it if you found the time to go through them. Thank you in advance!

Thanks,
Marcel Dogotari