### 1. Introduction

### 2. Related Works

### 2.1 Bilateral Filter

*p*can be obtained by Eq. (1):

**is the window space.**

*S**G*

_{σ}_{d}(·) and

*G*

_{σ}_{r}(·) are the closeness and the similarity functions that are the Gaussian functions with the standard deviations of

*σ*

*and*

_{d}*σ*

*, respectively. ||·||represents the Euclidean distance, and*

_{r}*ω*

*is used for normalization.*

_{p}*σ*

*and*

_{d}*σ*

*.*

_{r}*σ*

*is important in image spatial domain processing because it determines the level of low-pass filtering. A greater value of*

_{d}*σ*

*will combine and weigh more pixels in the neighborhood together, which leads to a greater blurring effect.*

_{d}*σ*

*determines the weights in an image intensity domain. According to the value of*

_{r}*σ*

*, pixel points in the window space*

_{r}**where their values are closer to each other are combined and weighted together. Examples of smoothing images by the bilateral filter with fixed parameters are shown in Fig. 1. The bilateral filter with fixed parameters cannot obtain good results in removing the blocking artifacts.**

*S*### 2.2 Local Entropy

*i*is grayscale and

*L*is the maximal grayscale.

*i*in the image,

*n*

*is the amount of pixel points whose grayscale is*

_{i}*i*, and the image size is

*M*×

*N*. Similar to the image entropy, the local entropy of small neighborhood Ω

*within image*

_{k}*E*(Ω

*) can be written as:*

_{k}*j*is the grayscale.

*j*in the small neighborhood Ω

*.*

_{k}*n*

*is the amount of pixel points whose grayscale is*

_{j}*j*in the small neighborhood Ω

*. The window size of Ω*

_{k}*is*

_{k}*M*

*×*

_{k}*N*

*.*

_{k}*, the local entropy*

_{k}*E*(Ω

*) is closely correlated with the variance of grayscales. From Eq. (3), the local entropy is smaller in homogeneous regions and larger in inhomogeneous regions. Hence, the pixel points in smooth regions will have smaller local entropy values than those in unsmooth (edge and texture) regions of the image. If we select an appropriate neighbor window Ω for the image, the local entropy of the image would be computed. When the neighbor window Ω is moved on a per-pixel basis within the image from top to bottom and from left to right, the local entropy value of each pixel point will be obtained, that is, we can obtain a local entropy image. Fig. 2 is the local entropy map of Lena. From Fig. 2, we can see that the edge and texture regions can be clearly distinguished from the smooth regions.*

_{k}### 3. The Proposed Scheme Using an Adaptive-Weighted Bilateral Filter

*σ*

*and*

_{r}*σ*

*must be larger to remove blocking artifacts in smooth regions. For regions with more significant details,*

_{d}*σ*

*and*

_{r}*σ*

*should be smaller to avoid blurring details. Although a bilateral filter can protect image edges while smoothing the image, the filter with fixed parameters cannot work well because it may lead to the loss of some texture information, as shown in Fig. 1. Local entropy can show the discrete degree of image grayscales. For smooth regions of the image, the local entropy is smaller. In texture and edge regions, the local entropy is larger. As such, this paper proposes a novel adaptive-weighted bilateral filter using the local entropy map*

_{d}*g*(

*x*) as the guidance image to obtain adaptive parameters.

*σ*

*is calculated for a pixel located at*

_{r}*x*:

*n*

*is a minimum level of filtering to avoid*

_{r}*σ*

*= 0.*

_{r}*g*

_{max}is the maximum value of

*g*(

*x*), and

*k*

*is a constant parameter that controls the mapping process of*

_{r}*g*(

*x*) to

*σ*

*.*

_{r}*σ*

*is calculated for a pixel located at*

_{d}*x*:

*n*

*is a minimum level of filtering to avoid*

_{d}*σ*

*= 0, and*

_{d}*k*

*is a constant parameter that controls the mapping process of*

_{d}*g*(

*x*) to

*σ*

*. The parameters*

_{d}*k*

*and*

_{r}*k*

*are similar to*

_{d}*σ*

*and*

_{r}*σ*

*, which determine the performance of the bilateral filter. The framework of our proposed adaptive-weighted filter is shown in Fig. 3.*

_{d}*k*

*and*

_{r}*k*

*) to smooth images as much as possible. For images with slight blocking artifacts, we should select smaller parameters (*

_{d}*k*

*and*

_{r}*k*

*) to avoid over-smoothing images. In this paper, we adopted three sets of data for*

_{d}*k*

*and*

_{r}*k*

*according to the severity of image blocking artifacts.*

_{d}*k*

*and*

_{r}*k*

*) for different decoded images. For the test image signal*

_{d}*x*(

*m*,

*n*) with

*m*∈ [1,

*M*] and

*n*∈ [1,

*N*], and a differencing signal on each horizontal line can be calculated as:

*f*

*(*

_{m}*n*) = |

*d*

*(*

_{h}*m*,

*n*)|, we first calculated its power spectrum for

*m*= 1,2, …,

*M*and then averaged them together. Finally, the power spectrum estimation

*P*

*(*

_{h}*l*), 0 ≤

*l*≤ 2/

*N*can be obtained, which is exemplified in Fig. 4. As shown in Fig. 4, the different original images have similar power spectrum. When we adopted different quantization factors (

*Q*= 1,

*Q*= 3, and

*Q*= 5), the image blocking artifacts can be easily picked out based on the peaks at the feature frequencies (1/8, 2/8, 3/8, and 4/8), as shown in Fig. 5. In addition, if the image is compressed more highly, the peaks will change more significantly. According to the characteristics of the image power spectrum, the criterion to select the parameters (

*k*

*and*

_{r}*k*

*) is to calculate*

_{d}*S*. This is defined as:

*S*of three images, which are calculated by Eqs. (7)–(10), are shown in Fig. 6. The three images are Lena, Barbara, and Peppers. All of them are compressed by JPEG where the quantization factor

*Q*varies from 1 to 10. From Fig. 6, we can see that if the quality of image is bad,

*S*is large. The flow diagram of our proposed image-deblocking scheme is shown in Fig. 7. If

*S*was smaller than

*α*, then we selected (

*k*

*,*

_{rs}*k*

*) for (*

_{ds}*k*

*,*

_{r}*k*

*); if*

_{d}*S*was larger than α and smaller than

*β*, then (

*k*

*,*

_{rm}*k*

*) was used; and if*

_{dm}*S*was larger than

*β*, (

*k*

*,*

_{rl}*k*

*) was used. The parameters (*

_{dl}*k*

*,*

_{rs}*k*

*), (*

_{ds}*k*

*,*

_{rm}*k*

*), and (*

_{dm}*k*

*,*

_{rl}*k*

*) were determined empirically and set as follows: (*

_{dl}*k*

*,*

_{rs}*k*

*) = (1,10), (*

_{ds}*k*

*,*

_{rm}*k*

*) = (3,20), and (*

_{dm}*k*

*,*

_{rl}*k*

*) = (5,30).*

_{dl}*α*and

*β*(

*α<β*), we selected three images: Lean, Barbara, and Peppers. They were compressed by JPEG where the quantization factor

*Q*varied from 1 to 10. All of them were carried out according to the steps shown below, which are also shown in Fig. 8:

The first decoded image of the Lena (Barbara or Peppers) image is processed by the proposed adaptive-weighted bilateral filter in which the parameters of (

*k*,_{r}*k*) are (_{d}*k*,_{rs}*k*) and (_{ds}*k*,_{rm}*k*), respectively. The obtained images are called output image1 and output image. Their scores are calculated using the proposed method, namely_{dm}*S*and_{s}*S*. If_{m}*S*<_{s}*S*, then_{m}*S*_{0}, which is the quality score of the compressed image, is the threshold value*α*. If*S*>_{s}*S*, continue to step (ii). This step is shown in the black box and solid line._{m}The decoded image is processed by the proposed adaptive-weighted bilateral filter in which the parameters of (

*k*,_{r}*k*) are (_{d}*k*,_{rl}*k*), and we calculated the scores of the obtained image called output image2, namely_{dl}*S*. If_{l}*S*<_{l}*S*,_{m}*S*_{0}is the threshold value*β*. If*S*>_{l}*S*,_{m}*S*_{0}is larger than*α*and smaller than*β*. This step is shown in the blue box and dotted line.The other images of Lena use the same steps to modify

*α*and*β*.

### 4. Experimental Results

*μ*

*and*

_{x}*μ*

*are the average of the deblocked image*

_{y}*x*and the uncompressed image

*y*, respectively, and

*x*and the uncompressed image

*y*, respectively.

*σ*

*is the covariance of the deblocked image*

_{xy}*x*and the uncompressed image

*y*.

*c*

_{1}= (

*k*

_{1}

*L*)

^{2}and

*c*

_{2}= (

*k*

_{2}

*L*)

^{2}are the two parameters to prevent the denominator from being 0.

*L*is the maximal grayscale. In general,

*k*

_{1}= 0.01 and

*k*

_{2}= 0.03 by default. If SSIM is equal to 0, it means that there is no correlation between the deblocked image

*x*and the uncompressed image

*y*, and 1 means that the uncompressed image

*y*is almost exactly the same as the deblocked image

*x*.

### 5. Conclusions

*σ*

*and*

_{r}*σ*

*) in a bilateral filter. In this process, we also proposed one criterion to determine*

_{d}*k*

*and*

_{r}*k*

*, because blocking artifacts of different images after compression are different. Through these two steps, we were able to obtain good results in terms of PSNR and SSIM.*

_{d}