# Non-Local Means Hole Repair Algorithm Based on Adaptive Block
## 3 Experimental Results and Analysis
### Quantitative Evaluation  
In this section, we evaluate the efficacy of the aforementioned methods in the Middlebury dataset using five metrics: Root Mean Square Error (RMSE), Peak Signal-to-Noise Ratio (PSNR), Structural Similarity Index (SSIM), Depth Error (DE), and Average Local Mean Error (ALME). These metrics serve to measure the quality of the restoration outcomes. Figure 5: Presents a comparison of hole inpainting results between the NLM and AB-NLM algorithms utilizing a self-constructed dataset from the Orbbec camera. In the restoration of in-depth images, RMSE is employed to quantify the disparity between the repaired image and the original image. A lower RMSE value indicates that the restored image closely approximates the original image. The RMSE is defined as follows:  
\[RMSE=\sqrt{\frac{1}{n}\sum_{(x,y)\in D}\left(d_{g}(x,y)-d_{i}(x,y)\right)^{2}} \tag{6}\]  
where \(n\) represents the number of pixels contained in \(D\) and \((x,y)\) denotes the pixel coordinates. \(d_{g}(x,y)\) and \(d_{i}(x,y)\) refer to the depth values of the original image and the restored image at point \((x,y)\), respectively. PSNR is commonly utilized to assess the quality of repaired images. A higher PSNR value signifies a reduced disparity between the repaired image and the original image, highlighting the commendable performance of the algorithm. The PSNR is defined as follows:  
\[PSNR=10\log_{10}\left(\frac{\max(d_{i})^{2}}{MSE}\right) \tag{7}\]  
where \(\max(d_{i})\) represents the maximum depth value of the restored depth image, and MSE represents the mean square error between the original and restored images. SSIM measures the structural similarity of image quality between two images. We strive for an SSIM value close to one to ensure a high degree of consistency between the repaired image and the original image in terms of structural features. The SSIM is defined as follows:  
\[SSIM=\frac{\left(2\mu_{xy}+C_{1}\right)\left(2\sigma_{xy}+C_{2}\right)}{\left( \mu_{x}^{2}+\mu_{y}^{2}+C_{1}\right)\left(\sigma_{x}^{2}+\sigma_{y}^{2}+C_{2 }\right)} \tag{8}\]  
where \(\mu_{x}\) and \(\mu_{y}\) represent the mean values of depth values \(d_{g}(x,y)\) and \(d_{i}(x,y)\), respectively. \(\sigma_{x}^{2}\) and \(\sigma_{y}^{2}\) represent the variances of \(d_{g}(x,y)\) and \(d_{i}(x,y)\), respectively. \(\mu_{xy}\) and \(\sigma_{xy}\) represent the covariances of \(d_{g}(x,y)\) and \(d_{i}(x,y)\), respectively. Additionally, \(C_{1}\) and \(C_{2}\) are chosen as 0.0001 and 0.0009, respectively, to prevent division by zero and avoid potential system errors. DE conducts a holistic error measurement on the repaired depth images, utilizing absolute depth error to quantify the disparities between them. A smaller absolute depth error indicates a more favorable restoration outcome. The definition of DE is as follows:  
\[DE=\frac{1}{N}\sum_{(x,y)}\left|d_{g}(x,y)-d_{i}(x,y)\right| \tag{9}\]  
where \(N\) represents the total number of pixels in the image. ALME involves a comparison of the local means between the repaired and original depth images, with a smaller value indicating greater consistency of the repaired depth image with the original one in terms of local means. The definition of the local mean error for the kth local region is as follows:  
\[LME_{k}=\frac{1}{m}\sum_{(x,y)\in R}\left|d_{g}(x,y)-d_{i}(x,y)\right| \tag{10}\]  
where \(R\) denotes a fixed-size local region (a 10 \(\times\) 10 window) that sequentially slides 10 steps from left to right and top to bottom across the image. \(m\) represents the pixels within \(R\), resulting in a value of 100. The definition of ALME is expressed as follows:  
\[ALME=\frac{1}{M}\sum_{k=1}^{M}LME_{k} \tag{11}\]  
where \(M\) represents the total number of local regions in the image. To assess the robustness of this research findings, Monte Carlo simulation was employed to estimate the 95% confidence intervals for various evaluation metrics. For RMSE, experimental results based on the dataset yielded a 95% confidence interval of [0, 10].