The real world is in high dynamic range.
A camera sensor is unable to capture in HDR; as bright spots may oversaturate a photosensor and force it to white – losing information in that area.
We can modify our exposure time to adjust the amount of light that enters the sensor – but there is no one exposure time that will give us a good picture, so we must take many.
Our goal is to go from Z to E, however, to fully go to E we must reverse the ADC – we have no interest or intention of doing so.
We can note that E is invariant to exposure time, so if we know Δt we can find E – typically Δt is given as metadata on an image.
We need multiple images to recover the Z vs H curve – typically with varying Δt.
where N is the number of pixels, P the number of images.
Number of Samples
For an 8-bit color depth image, Zi,j∈[0,255]→256 values, then there are 256 unknowns for the function g(Z), i.e. g(0),g(1),…,g(255).
We also have N unknowns for Ei.
There are N+256 unknowns
There are NP total equations
Then, NP>N+256⟹NP−N>256⟹N(P−1)>256⟹N>P−1256.
Usually N=5(P−1256) is sufficient, e.g. if P=11 then N=128 random pixel samples is sufficient to recover E.
This makes the assumption that the images are reliable – however, this is not the case, we modify our equation to
w(z) is a function that assigns a weight to a pixel value; we want large z values to map to smaller values, as these are generally unreliable.
One possible function is the triangle function given by
w(z)={z,2b−(z+1), if z≤2b−1otherwise
where b is the bit-depth of the image.
2. There is no reason for a manufacturer to use a noisy curve; therefore, by making the assumption that the camera's response curve is smooth,
dz2d2g(z)≊g(z−1)−2g(z)+g(z+1)=0.
λ is a factor used to balance the two terms – a larger λ gives a smoother response curve.
We only need to perform this optimization once per camera, then we can reuse it for other images; sometimes this method is called "irradiance calibration".
Previously we solved for g:Z→E,g(Zi,j)=logEi+logΔtj, or for every pixel we get P estimates for logEi, we cannot just use the arithmetic mean as the highly irradiant areas in longer exposures will bias the mean.
We can then reuse the weight function w(Z) to get a weighted mean,
Having recovered the irradiance of each pixel in an image, we can now use it in various applications such as reusing the irradiance in a computer rendering or in viewing an image – however, we must compress the high dynamic range into the range displayable by a device.
Clipping
I=min(E,I)
Causes the loss of detail in highly irradiant areas.
Scaling
I=maxEE
Causes the loss of detail in areas of low irradiance.
Reinhard Global Operator
I=1+EE
Better than scaling and clipping as it increasly sharply at small values (boosting), and compresses the high irradiance areas.
Gamma Compression
I′′=(I′)γ,I′=maxEE
We first perform scaling, then a gamma correction to boost the smaller values like Reinhard.
Colour gets washed out.
Gamma Compression on Intensity
Intensity is given by L=31(R+G+B)
Then, gamma compression on intensity L′′=(L′)γ,L′=maxLL
Colour is given by ParseError: KaTeX parse error: Got function '\\' with no arguments as argument to '\left' at position 21: …frac{1}{L}\left\̲\̲{R, G, B\right\…
Then, the final image is computed via I′′=L′′C
This preserves colour, but instead washes out intensity – or lowers the constrast of the image.
In Chiu[1], the authors propose the following method:
I′=I−(I⋆f(x))=I−J,
where f(x) is the Gaussian function,
f(x)=2πσ21e−2σ2x2.
Their process can be visualised by the following image,
Their motivation was to use a lowpass filter (here, we used the Gaussian as an illustration) to isolate ranges of radiance that are perceptually important.
Unfortunately, this approach leads to a "halo" effect around sharp irradiance transitions due to undesirable easing of a transition in a step-like function.
To understand why, we turn towards the definition of the convolution,
J(p)=q∑f(p−q)I(q).
We may notice that f(p−q) is a weighting on I(q) that is dependent on the spatial distance between the two pixels p and q.
Visually, we can see the effect that this spatial weighting has on the step-like result that we desire
In Tomasi[2], they explore a method called "bilateral filtering" to reduce the halo effect.
The method is given by the following adjustment the convolution calculation
J(p)=k(p)1q∑fs(p−q)fc(I(p)−I(q))I(q),(1a)
where
k(p)=q∑fs(p−q)fc(I(p)−I(q)).(1b)
The fs and fc functions represent the spatial and colour filters – now instead of weighting just the spatial distance of two pixels, we also use the "colour distance".
§ Durand and Dorsey (2002); Paris and Durand (2006)
In Durand[3], they explore a method of computing an approximation of the bilateral filter that is O(1) per pixel.
A further improvement upon Durand[3:1] was made in Paris[4].
The authors note that the product of the spatial and range Gaussian defines a higher dimensional Gaussian in the 3D product space between the domain and range of the image.
Visualization of the weights in the 3D product space in Durand[^3]
However, the definition of the bilateral filter in eq. 1 is not a convolution as it is a summation over the 2D spatial domain.
The authors introduce a new dimension ζ for the intensity for each point in the product space in order to define a summation of the 3D space.
We now define for each point (x,y,ζ) an intensity I, and we let R be the interval for which intensites are defined.
Also, we define the Kronecker symbol δ(ζ) by δ(0)=1,δ(ζ)=0.