# A Deconvolutional Deblurring Algorithm Based on Dual-Channel Images
## 4 Blocked Image Restoration Based on Clustering Algorithm
\begin{table}
\begin{tabular}{l} \hline \hline
**Mean-Shift Cluster Method in Kernel Categorization** \\ \hline Step 1: \\ \multicolumn{2}{c}{Calculate the pixel sum of squares for each kernel as its weight:} \\ \(Weight_{i}=\sum\limits_{k,m}\left\|Kernel_{grid}^{i}\right\|^{2}\) \\ Step 2: \\ \multicolumn{2}{c}{Taking the \(Weight_{S}\) as the center value of the cluster\(C_{s}\)} \\ \(C_{s}=\{Weight_{S-C}\};Weight_{S-C}\in Kernel(Weight<Band)\) \\ Step 3: \\ \multicolumn{2}{c}{Taking the \(Weight_{S}\) as the center value of \(C_{s}\)} \\ \multicolumn{2}{c}{Calculate the sum of all the vectors:} \\ \(\overrightarrow{D}_{sum}=\sum\limits_{j\in S-C}\overrightarrow{D}_{j} \overrightarrow{D}_{j}=Weight_{j}-Weight_{S}\) \\ Step 4: \\ \multicolumn{2}{c}{Calculate the new center \(Weight_{new}\) with the \(\overrightarrow{D}_{sum}\):} \\ \(Weight_{new}=Weight_{S}+\overrightarrow{D}_{sum}\) \\ Add all the kernels which weigh less than \(\overrightarrow{D}_{sum}\)in the cluster \(C_{s}\) \\ Step 5: \\ \multicolumn{2}{c}{If} \\ \(Weight_{new}-Weight_{s}<\overrightarrow{D}_{sum}\) \\ \multicolumn{2}{c}{do:} \\ two clusters can be merged \\ else \\ \multicolumn{2}{c}{A new cluster should be obtained} \\ Step 6: \\ \multicolumn{2}{c}{Run step 3} \\ \multicolumn{2}{c}{Until \(\overrightarrow{D}_{sum}<t\) (\(t\) as selected by the experiment)} \\ Step 7: \\ \multicolumn{2}{c}{Run step 2} \\ Until all the kernels are visited \\ \hline \hline \end{tabular}
\end{table} 
Table 3: The flow of the mean-shift cluster method in kernel categorization. \(Weight_{i}\) denotes the weight of the \(i\)-th kernel, \(i\in N\times M\) is the order number of the kernel, \(n,m\) are the length and width of the kernel (unit: pixel), and \(\left\|Kernel_{pixel}^{i}\right\|^{2}\) means the sum of squares for all pixel values in the kernel, \(C_{s}\) is the cluster of all the kernels (representative weight value as \(Weight_{S-C}\) for all of them) whose absolute values of the difference between their weight values are less than a threshold (names _Band_ in follow, which was determined by experience), \(\overrightarrow{D_{j}}\) is the weight vector for the difference of the \(j\)-th kernel's weight in the cluster \(C_{s}\), the pool of \(j\) is the element's order number in \(C_{s}\), and \(Weight_{new}\) is the new center. 3. Each pixel's value from the sum of the normalized weights  
For computational convenience, all image blocks should be complemented first. For example, if the original image size was 800 \(\times\) 800 and the image block size was 200 \(\times\) 200, fill in zeros around the image block according to its position on the original image, until it is the same size as the original image; 800 \(\times\) 800 as layer-recovered images. Then, the value of the pixels in the final restoration image was determined by all values from the same location pixels in all layer-recovered images. The weight of layer-recovered images was calculated using the ratio of the total element number of the corresponding kernel's class to the total number of kernels. For example, if there are two kernels that have similar forms in one cluster and the total number of kernels is 8, then the weight of the pixels in the blocks recovered by the two kernels is 0.25. The calculation of the pixels' value of the final restoration image was performed as follows:  
\[X_{pixel}=\sum_{k\in\Omega_{c}}\lambda_{k}(X_{layer}^{k-pixel}) \tag{17}\]  
\(X_{pixel}\) denotes the selected pixel's value for the final restoration image \(X\). \(\lambda_{k}\) means the weights of the \(k\)-th kernel, \(X_{layer}^{k-pixel}\) signifies the same selected location pixel value as the \(k\)-th layer-recovered image, and \(\Omega_{c}\) means all of the layers recovered images.