# Exposure Bracketing Techniques for Camera Document Image Enhancement
## 3 HDR Document Image Generation
### Tone Mapping Method  
The tone mapping method can generate an HDR image by capturing multiple images of the same scene at different exposure levels and merging them to reconstruct the original dynamic range of the captured scene. In order to understand why HDR is possible with multiple images of different exposure times, it is necessary to know the image acquisition pipeline, which is illustrated in Figure 8.  
Figure 8 shows how scene radiance becomes pixel values for both film and digital cameras, and we can use an unknown aggregate nonlinear mapping function to transform scene radiance L to digital pixel values Z. The unknown aggregate nonlinear mapping function is called the camera response function (CRF). It attempts to compress as much of the dynamic range of the real world as possible into the limited 8-bit storage. There are many methods that exist in the literature on how to estimate CRF and in this paper, we used the classical CRF estimation method that was proposed by [PERSON] and [PERSON] [10]. With this method, estimating CRF is equal to optimizing the following objective function:  
\[o=\sum_{i=1}^{N_{\text{e}}}\sum_{j=1}^{M}\left(\alpha\left(I_{i}\left(x_{j} \right)\right)\left[g\left(I_{i}\left(x_{j}\right)\right)-\log E\left(x_{j} \right)-\log\Delta t_{i}\right]\right)^{2}+\lambda\sum_{x=T_{\text{min}}+1}^{T_ {\text{max}}-1}\left(\omega\left(x\right)g^{\prime\prime}\left(x\right)\right)^ {2} \tag{2}\]  
where \(g=f^{-1}\) is the inverse of the CRF, \(M\) is the number of pixels used in the minimization, \(T_{\text{max}}\) and \(T_{\text{min}}\) are, respectively, the maximum and minimum integer values in all LDR images \(I_{i}\), \(N_{e}\) is the number of LDR images, and \(\omega\) is a weighting function defined as:  
\[\omega(x)=\left\{ \begin{array}{ll}x-T_{\text{min}}&if\ x\leq\frac{1}{2}(T_{ \text{max}}+T_{\text{min}})\\ T_{\text{max}}-x&if\ x>\frac{1}{2}(T_{\text{max}}+T_{\text{min}})\end{array} \right. \tag{3}\]  
Figure 8: Image acquisition pipeline. Figure 7: Pseudo color image composed of registered Figure 1a,c. The green and blue bands come from the green and blue bands of the registered well-exposed image while the red band is from the red band of the registered over-exposed image. (**a**) The small image patch from the left central part of the pseudo color image. (**b**) The small image patch from the right central part of the pseudo color image. The implementation of [PERSON]'s method relies on the HDR Matlab Toolbox [3] and with this method, the estimated reverse CRF functions for images captured in Figure 1 are shown in Figure 9.  
Once the reverse CRF is recovered, it can be used to quickly convert pixel values to relative radiance values based on the following formula:  
\[\ln E_{i}=\frac{\sum\limits_{i=1}^{P}\omega\Big{(}Z_{ij}\Big{)}\Big{(}g\Big{(}Z_ {ij}\Big{)}-\ln\Delta t_{j}\Big{)}}{\sum\limits_{j=1}^{P}\omega\Big{(}Z_{ij} \Big{)}} \tag{4}\]  
The unit of radiance is of double-float format in order to keep the high dynamic range of real-world radiance, while most monitors can only display 255 colors. Therefore, in the last two decades, researchers have spent a significant amount of time and effort on compressing the range of HDR images and videos so that data may be visualized more naturally on LDR display. Tone mapping is the operation that adapts the dynamic range of HDR content to suit the lower dynamic range that is available on a given display. Furthermore, only luminance is usually tone mapped by a tone mapping operator (TMO), while colors are unprocessed. The TMO processing chain is as follows [11]:  
Step 1: the luminance channel is first extracted from the radiance map and color information compression is avoided. Step 2: the luminance is mapped to (0, 255) with a TMO. Step 3: the following formula is used to obtain the mapping RGB channels:  
\[\left[ \begin{array}{c}R_{d}\\ G_{d}\\ B_{d}\end{array} \right]=L_{d}\Bigg{(}\frac{1}{L_{w}}\left[ \begin{array}{c}R_ {w}\\ G_{w}\\ B_{w}\end{array}