Converting Images Between 12i or 16i and 16f Encodings

It is often useful or necessary to convert 12-bit integer (12i) or 16-bit integer (16i) to 16-bit floating-point (16f) encoding or vice-versa. When round-tripping between encodings like this, it's important that the transforms are as lossless as possible to avoid image degradation.

In Flame Premium and Smoke, it is typically desirable to promote 16i media to 16f as part of the import process in order to maximize the precision available for compositing and other operations. If you need to convert back to 16i for your output, you should do so only when exporting to preserve the maximal precision throughout the processing.

Similarly, when using 12i media in Flame Reactor, it will get promoted to 16f.

Converting from 16i Log Encoding

There are many varieties of 16-bit integer log encodings, but few standards. As such it is difficult to make general purpose recommendations on how to convert these images.

To convert 16i images from log space to scene-linear, there are several options:

  • If you know the images are in ADX16 color space, you can use the ADX16_to_ACES transform from the film/ADX/ directory, which will take into account film channel crosstalk and provide more accurate colors. Alternatively, you can use the Log_to_Lin--adx16 transform from the film/LogLin/ directory, which is a simple 1D-LUT-style transform that is slightly more invertible for round-tripping back to 16i.
  • Alternatively, try one of the other Log_to_Lin transforms in the film/LogLin directory. However, be aware that these operate on each channel independently. This means that they are less accurate in terms of color reproduction, but are more invertible and give smaller errors than the ADX transforms when roundtripping.

Converting from 12i and 16i Video Encodings

To convert 12i or 16i images from a video-like space to scene-linear 16f and then back to 16i while preserving the original values as much as possible, there are some special transforms in the bitdepth/ directory.
  • The 12i_to_16f and 16f_to_12i transforms are designed to provide a lossless round-trip.
  • The 16i_to_16f and 16f_to_16i transforms are designed to minimize quantization loss — the maximum error when round-tripping is 2 code values in 65535.

However, because 12i_to_16f and 16i_to_16f are very different from typical inverse tone maps, you should use 16f_to_12i or 16f_to_16i respectively as your display transform as well as your output transform (when round-tripping back to 12i or 16i).

In addition, note that these transforms are not appropriate for use with all operations. For example, resizing and other operations that involve spatial filtering give very different results in scene-linear space than in video space. In particular, the Lanczos filter has large negative coefficients that can cause artifacts like rings or haloes around high-contrast edges. In these situations, you should consider alternative transforms to perform the conversions:
  • Use a log-to-linear transform such as Log_to_Lin--jzp in the film/LogLin/ directory for import, and its inverse such as Lin_to_Log--jzp for viewing and export.
  • Use a transform such as remove_2.40_gamma in the gamma/ directory for import, and its inverse such as apply_2.40_gamma for viewing and export. This minimizes the haloes, but results in more loss of precision when round-tripping.