*3.2. Pixel Compensation Module*

In this work, we compensate luminance according to the optimal backlight described as **BLop** and the luminance of the input image. Before the compensation, we use Improved Blur Mask Approach (IBMA) [10] to smooth optimal backlight to removes the block artifacts. Specifically, Zhang, T.; Wang, Y.F. [10] divided the points of **BLop** into three categories. The first category includes the corner points, the second category includes the peripheral points except for the cornet points, and the third category includes the internal points of **BLop**. Different Low Pass Filter (LPF) templates are used to smooth points of **BLop** in different categories. IBMA uses the smoothing process to simulate the light diffusion, and **BLop** is resized after each smoothing operation. By several smoothing operations, the smoothed backlight has the same size as the input image. The process is expressed in Equation (13).

$$\mathbf{BL\_{sm}} = IBMA\left(\mathbf{BL\_{op}}\right) \tag{13}$$

where **BLsm** represents the backlight after IBMA and **BLop** is the optimal backlight. The comparison results of using or not using IBMA are shown in Figure 6.

**Figure 6.** (**a**) Backlight without Improved Blur Mask Approach; and (**b**) backlight with Improved Blur Mask Approach.

Compared with Figure 6a, artifacts are removed obviously in Figure 6b by applying IBMA.

We use a compensation coefficient *k* to control the compensation degree, which is determined by the smoothed backlight and the luminance of the input image. The process is formulated as Equations (14) and (15).

$$\mathbf{k}\left(\mathbf{x},\mathbf{y}\right) = \left(\mathbf{BL\_{sm}}\left(\mathbf{x},\mathbf{y}\right) \div \mathbf{I}\left(\mathbf{x},\mathbf{y}\right)\right)^{\gamma} \tag{14}$$

$$\mathbf{I}\_{\mathbf{p}}\left(\mathbf{x},\boldsymbol{y}\right) = \mathbf{k}\left(\mathbf{x},\boldsymbol{y}\right) \times \mathbf{I}\left(\mathbf{x},\boldsymbol{y}\right) + \left(1 - \mathbf{k}\left(\mathbf{x},\boldsymbol{y}\right)\right) \times \mathbf{B}\mathbf{L}\_{\mathbf{sm}}\left(\mathbf{x},\boldsymbol{y}\right) \tag{15}$$

where *γ* = 0.125 is selected from multiple experimental results to prevent overcompensation problem and enhance the overall luminance of the image effectively. **IP** is the compensated luminance.

Next, IBHE is used to further enhance the compensated luminance. In BHE, an image is decomposed into two sub-images based on its mean, and then the sub-images are equalized independently to improve CR while maintaining the luminance of the image. Different from this, we rely on the Otsu method and the histogram of **r** in Equation (6) to obtain two sub-images. Algorithm 1 is devised to acquire the breakpoint for the image segmentation.

**Algorithm 1** Proposed algorithm for breakpoint acquisition.

```
Input: r, IP;
Output: the breakpoint T;
 1: [z1, z2] = size (r);
 2: num = 0;
 3: Im = IP;
 4: for i = 1 to z1 do
 5: for j = 1 to z2 do
 6: if r (i, j) == 0 then
 7: num+ = 1;
 8: else
 9: Im (i, j) = 0;
10: end if
11: end for
12: end for
13: T1 = (sum (sum (Im))) ÷ num;
14: T2 = Otsu ((Im)); the breakpoint obtained by Otsu method
15: T = floor ((T1 + T2) ÷ 2); the average value of T1 and T2
16: return T;
```
By the breakpoint *T*, the CDF curves of the two sub-images are obtained to perform BHE [17]. The process is expressed as Equation (16).

$$\mathbf{I\_{out}}(k) = \begin{cases} \left(T - I\_{p\text{min}}\right) \times \mathbb{C}DF\_1\left(k\right) + I\_{p\text{min}} & 0 < k < T\\ \left(I\_{p\text{max}} - T\right) \times \mathbb{C}DF\_2\left(k\right) + T & T + 1 < k < 255 \end{cases} \tag{16}$$

where *Ipmin* and *Ipmax* are the minimum and the maximum of compensated luminance **Ip**, respectively. *CDF*<sup>1</sup> and *CDF*<sup>2</sup> are respective CDF curves of the two sub-images.

Finally, **Iout** and **r** in Equation (6) are combined to reconstruct final luminance image by Equation (17), and color transformation from *YCbCr* to *RGB* [25] is employed to generate the final image.

$$\mathbf{Y\_{out}}\left(\mathbf{x},\boldsymbol{y}\right) = \mathbf{I\_{out}}\left(\mathbf{x},\boldsymbol{y}\right) \times \boldsymbol{e}^{\mathbf{r}\left(\mathbf{x},\boldsymbol{y}\right)}\tag{17}$$
