Personal View site logo
Understanding linear to log RAW mappings
  • So, I have a 12-bit RAW file. We are looking at 12-stops, 2^1, 2^2....2^12

    Now, I want to map this to 10-bit, so I have 2^1,2^2...2^10 I can divide the shadows to keep details. 2^1, 2^2,...2^7,2^8 = 0-255

    Now I have 2^8 to 2^10 = 1024 - 256 = 768 mappings And I have to map 2^8 to 2^12 = 4096 - 256 = 3840

    768 mappings can be divided into 4 regions - of values 192 (896/4) each

    Now I can take 2^8 - 2^9 and map it to 256 to 256+192 = 448 2^9 - 2^10 goes to 448 to 640

    And so on... This is how a log mapping would work.

    A LUT tells the RAW processor how this was done. However, here I am stumped. Knowing this formula, how would I implement a LUT ?

  • 6 Replies sorted by
  • LUT is same formula, just faster.

    You can define translation as y = x*x

    or you can define it as lookup array [1,4,9, ... ] were x is index of array and array item defines y value.

  • So, for 10-bit log, do I need to define 1024 values to contain a LUT ?

  • If you translate 12 bit raw, your array size must be corresponding, and array elements value must be within 10 bit bounds.

  • So thats a one to one correspondance, 12-bit RAW to 10-bit log would be a 4096 array of 10-bit elements. I think Adobe DNG calls this a Linearization table.

    Does this make sense ?

  • Does this make sense ?

    Yes.

    All such array do is making y=a[x], hence the term "lookup". Lookup tables are used usually if some heavy calculations are used or translation is too complex, hence you can save time.

  • OK. To complete this thread, these are Linearization Tables within the DNG spec.

    >

    Description

    LinearizationTable describes a lookup table that maps stored values into linear values. This tag is typically used to increase compression ratios by storing the raw data in a non-linear, more visually uniform space with fewer total encoding levels.

    If SamplesPerPixel is not equal to one, this single table applies to all the samples for each pixel.

    See Chapter 5, "Mapping Raw Values to Linear Reference Values" on page 77 for details of the processing model.

     

    Linearization

    The first step is to process the raw values through the look-up table specified by the LinearizationTable tag, if any. If the raw value is greater than the size of the table, it is mapped to the last entry of the table.

     

    Black Subtraction

    The black level for each pixel is then computed and subtracted. The black level for each pixel is the sum of the black levels specified by the BlackLevel, BlackLevelDeltaH and BlackLevelDeltaV tags.

     

    Rescaling

    The black subtracted values are then rescaled to map them to a logical 0.0 to 1.0 range. The scale factor is the inverse of the difference between the value specified in the WhiteLevel tag and the maximum computed black level for the sample plane.

     

    Clipping

    The rescaled values are then clipped to a 0.0 to 1.0 logical range.

    >