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=t(Z/255)γ​
where:
- Z is the observed pixel value [0, 255]
- γ is the camera gamma (typically 2.2 for sRGB)
- t is the exposure/shutter time in seconds
- L 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:
linearize(128, 0.01, 2.2)
21.7741
For pixel value 128 with 0.01s exposure:
- Normalize pixel: 128 / 255 = 0.502
- Apply gamma: 0.502^2.2 = 0.2177
- Divide by exposure time: 0.2177 / 0.01 = 21.77
- 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
More from CV: Computational Photography
You are modeling a very simple HDR pre-processing step: undo the camera’s gamma curve and exposure scaling to get linear scene radiance from pixel values.
1. Background Knowledge (Key Concepts)
-
Camera response & gamma Most cameras (and image formats like sRGB JPEG) do not store light intensities linearly. Instead, they apply a non-linear response curve, often approximated as a power law: Znorm​=Lsensor1/γ​ where Z_\text{norm}=Z/255 is the stored pixel (0–1), Lsensor​ is proportional to actual irradiance × exposure time, and γ≈2.2 for sRGB. This non-linearity saves bits (more detail in darks) and matches human vision, but it breaks the direct proportionality between pixel value and real-world radiance.
-
Linear domain & HDR imaging HDR algorithms need linear radiance values so they can correctly combine multiple exposures, perform averaging, and integrate physically-based operations. To get this, you invert the gamma curve and divide out the exposure time. That is exactly what your given formula does: $$L = \frac{(Z/255)^\gamma}{t}$$$ Here, (Z/255)γ approximates the linear sensor response, and 1/t removes the effect of different shutter speeds so the result is proportional to scene radiance.
2. Algorithm / Approach Pattern
For this type of problem, the general pattern is:
- Normalize discrete pixel values into [0, 1].
- Linearize them by applying the inverse camera response (here, a simple power law with known γ).
- Normalize for exposure using the known exposure time t.
- Return or store the resulting linear radiance values, often as floating-point numbers.
In code terms, for each pixel:
- Convert to float in [0, 1].
- Apply x↦xγ.
- Divide by exposure time.
3. Step-by-Step Strategy
Assume the function signature is something like:
def linearize_pixel(Z, gamma, t):
...
A clean step-by-step strategy:
- Cast to float and normalize
z_norm = Z / 255.0
Ensure Z is treated as float to avoid integer division.
Continue the full explanation
You're reading the free preview. Unlock the complete walkthrough, the code editor, test runner and reference solution with Premium.
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.