PIXELBANKv9.1.0
Menu

Camera Response Linearization

Apply inverse camera response curve to convert pixel values to linear radiance.

Digital cameras apply a non-linear response curve (typically gamma correction) to the captured light intensity. To recover the original scene radiance for HDR processing, we must invert this transformation.

Assuming a simple gamma response model:

L=(Z/255)γtL = \frac{(Z/255)^\gamma}{t}

where:

  • ZZ is the observed pixel value [0, 255]
  • γ\gamma is the camera gamma (typically 2.2 for sRGB)
  • tt is the exposure/shutter time in seconds
  • LL is the recovered linear radiance

The division by exposure time normalizes for how long light was collected, giving us a value proportional to the actual scene radiance.

Example:

Input:
linearize(128, 0.01, 2.2)
Output:
21.7741
Reasoning:

For pixel value 128 with 0.01s exposure:

  1. Normalize pixel: 128 / 255 = 0.502
  2. Apply gamma: 0.502^2.2 = 0.2177
  3. Divide by exposure time: 0.2177 / 0.01 = 21.77
  4. Round to 4 decimals: 21.7741

Constraints:

  • pixel_value: integer in range [0, 255]
  • exposure_time: positive float representing shutter time in seconds
  • gamma: camera gamma value (default 2.2)
  • Return linear radiance rounded to 4 decimal places
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.