The segmentation of Thangka damaged regions based on the local distinction

Damaged regions must be segmented before digital repairing Thangka cultural relics. A new segmentation algorithm based on local distinction is proposed for segmenting damaged regions, taking into account some of the damaged area with a transition zone feature, as well as the difference between the damaged regions and their surrounding regions, combining local gray value, local complexity and local definition-complexity (LDC). Firstly, calculate the local complexity and normalized; secondly, calculate the local definition-complexity and normalized; thirdly, calculate the local distinction; finally, set the threshold to segment local distinction image, remove the over segmentation, and get the final segmentation result. The experimental results show that our algorithm is effective, and it can segment the damaged frescoes and natural image etc.


Introduction
In the process of preservation, Thangka which has rich cultural connotation and research values will be damaged differently because of natural and human factors, the positions and shape of damaged region are uncertain. Accurate segmentation of damaged regions is the premise of digital inpainting and the segmentation result will directly affect the quality of inpainting. At present, the proposed algorithms which aim directly at damaged regions are less, researchers usually use the manual annotation [1][2][3][4] and semi-automatic segmentation algorithms [5][6][7][8] to segment damaged regions when digital inpainting. Those method can segment the parts of damaged regions, they remain to be further improved.
Transition region is refers to the intermediary between target and background region. It's a special region, having the characteristic of the boundary which can separate different regions (foreground and background), and having the characteristic of region which has width and whose area is not zero [9]. Segmentation based on transition region is a new rise of algorithm in the recent years, which has certain advantage in the practical application [10][11][12]. Therefore, it is an effective way to solve damaged region segmentation from transition region and itself characteristics of damaged regions. In order to segment damaged region of Thangka effectively, a new segmentation algorithm based on local distinction is proposed considering the gray mean, local complexity and local difference of damaged region. Theoretical analysis and experimental results show that the proposed algorithm can obtain better segmentation effect.

Local complexity
The gray distribution of the Thangka damaged regions is fluctuation, its feature is similar with feature of transition region. It has better segmentation effect in practice when using the feature of transition region, the segmentation method based on transition region can make up the deficiency of the traditional algorithm. Among them, the segmentation algorithm [13] based on the local complexity is a typical transition region segmentation algorithm.
( , ) f i j denotes the distribution function of gray-scale images, ( , ) i j S ∈ , S denotes the pixel space coordinates set of integers. Image has 256 gray levels, the size is M N × , and the image histogram is shown in formula (2).
Defining a flag function as (3).
The definition of local complexity is shown in formula (4).
Within a local window, the local complexity is equal to the number of different gray levels in the window. If the colour is the same, the local complexity is 1, if all colors are not the same, then the local complexity is the number of pixels in the window.

Local difference
The damaged degree in the damage regions are difference, gray level of damaged regions is large, so the homogeneity in the damaged regions is poor, local complexity value is higher. But the complexity value reflects the difference of the gray level, and it has nothing to do with the gray value. In addition, although the isolated noise has little effect on the local complexity, it also weakens the difference between the pixels, so that the contrast of the transition region is reduced.
In order to better extract the image transition region and improve the difference between the pixels, Chen et al [14] proposed a segmentation algorithm based on the image transition region, which increases the gray level and detail information of the transition region.
The size of the local window k Ω is Where the definition of the function ( , ) f x y ′ is formula (6) ( , ) f x y ′ is the enhancement function in the local window, ( , ) f x y is the mean value of gray level distribution in the local window( k Ω ), C is the enhancement factor, and reflects the local gray level distribution, the value of C is the local complexity which is normalized. The range of k B can be The definition of the local difference is formula (7).
Here, the definition of ( ) k h B as shown in the formula (8).
Compared with the local complexity, LDC can reflect the characteristic of the transition region is more obvious.

The segmentation of transition based on local distinction
When missing colours, the damaged area in the Thangka has the following characteristics: (1) the local difference in the transition regions is larger; (2) There is a difference between the gray value and the local mean; (3) the area which miss colour was smaller; (4) the regions which missed colours, have the features of transition region. Based on the above 4 features, a segmentation algorithm based on local distinction is proposed.

Local distinction
The bottom of the Thangka is white colour, when the colour missing, the damaged regions have transition features, so the gray value is higher in the serious damaged regions. When original subtract the men filtering image, the result has the feature, the value in the damaged regions is relatively high, which can help us to find the position of the damaged regions, however, there are also some over segmented region, they can be filtered by feature of transition. Local difference can find transition regions, damaged region is in the transition regions, so the local difference value is higher in the damaged regions, we can further filter out some over segmentation regions by formula (9). The local distinction can be calculated by formula (9).
Among them, f and LDC can be calculated by formula (1) and (7). Because the damaged regions have transition features, the damaged regions colour is white when missing colours, so the term of ( , ) f x y f β − denotes getting the regions whose gray value are larger than f β in the image, β is the weight of f , (0,1) β ∈ , the value of β should be suitable, too smaller will lead to over segmentation, too larger will lead to inadequate segmentation. Experimental verification that segmentation can achieve a very good result when setting The value of the local distinction ( )  Step 1: calculate the local complexity by formula (4) and normalized, it will be as C in the formula (6).

The step of segmentation
Step 2: calculate the local difference by formula (7) and normalized, it will be as LDC in the formula (9).
Step 3: calculate the local distinction by formula (9), we will get local distinction image.
Step 4: obtain the segmentation result by setting threshold segTh in the local distinction image.
Step 5: remove the over segmentation in the last segmentation result, we will get final segmentation result.

The pseudocode of segmentation methodology
We give pseudocode of segmentation methodology to explain process of segmentation. MAX P l = (9) Set SegTh as threshold and get segmentation result (10) Remove over segmentation and get final segmentation result

Parameter setting
The parameters involved in this paper are verified by experiments. The size of the block is 7 7 × , and (0.1, 0.4) λ ∈ , they can be adjusted according to the experimental results. Segmentation algorithm was accomplished by Matlab. Figure 1a is a broken Thangka, the size of image is 197×238. Figure 1b shows the result of artificial segmentation, it can evaluate the accuracy of image segmentation and over segmentation rate. Figure  1c shows the segmentation result by Local complexity, it can be seen that there is a fracture in the damaged area, and over segmentation region is large. Figure 1d shows the segmentation result by Local difference, it can be seen that the damaged regions can be segmented, and there is no fracture phenomenon, but it leads to many over segmentation, it is difficult for us to segment by artificial operator. Figure 1e shows the segmentation result by our algorithm, it can be seen that the damaged area can be extracted completely. Compared with local complexity and local difference, our algorithm has less over segmentation, it is easy to separate the damaged region and the over segmentation region when we carry out artificial operator.

The experiment result
In order to verify the effectiveness of our algorithm, we select several traditional segmentation algorithms and compare the result with them. The results are shown in Figure 2. Figure 2a is damaged origin image, its size is 195×156, figure 2b is segmentation result by artificial operator, figure 2c is the segmentation result by our algorithm ( 0.25 λ = ), we can see that the damaged regions can be segmented well. Figure 2d is segmentation result by Otsu algorithm [15], and it produce much over segmentation region. Figure 2e is the segmentation result by k-mean clustering algorithm [16], the result is bad because of much over segmentation region. Figure 2f  coordinate maximum entropy segment method [17], there has been a shortage of the segmentation, some damaged regions failed to segment. Figure 2g is the segmentation result using local complexity algorithm [13], although the segmentation result has greatly improved than figure 2d, 2e, 2f, but there are still over segmentation. Figure 2h is the segmentation result using fuzzy entropy neighborhood [18], there has been a shortage of the segmentation. Figure 2i is the segmentation result using transition region algorithm based on digital morphology [19], although most of the damaged regions are segmented, but also there are over segmentation badly. Figure 2j is the segmentation result using local difference algorithm [14], but there are over segmentation badly. Through the comparison, we can know that the proposed segmentation algorithm can segment damaged regions which has the feature of the transition region, and create the over segmentation less. We also choose another broken type Thangka image which are color missing type and scratch type to validate our algorithm, they are shown in Figure 3a and 3d. Figure 3c and Figure 3f is the segmentation result using our algorithm. We can see that the damaged regions which missed color can be segmented from Figure 3c, and scratched region can be segmented from Figure 3f. The segmentation result are very well from the Figure 3c and Figure 3f.
Our algorithm can also applied to segment nature image, Figure 4a is a rice image, and gray distribution in the image is not uniform. Figure 4c and Figure 4d are the segmentation result by Otsu Algorithm and two-dimensional maximum entropy algorithm, segmentation results are not completely. Figure 4b is the segmentation result by our algorithm, we can see that the rice can be segmented very well, so our algorithm is optimal.

Algorithm performance evaluation
In order to quantitatively evaluate the algorithm, the segmentation accuracy and the over segmentation rate are used as evaluation criteria to measure the processing effect and performance of the algorithm. 1 P is the segmentation regions by algorithm, 2 P is the segmentation regions by artificial operator, ( ) count P is the total pixels number in the region, the segmentation accuracy is defined as    (( ( ( )) / ( ))% F count P P P count P = −  [20]. Table 1 shows the processing data for the segmentation of Figure 2a using different algorithms, the segmentation accuracy of our algorithm is higher than the other 6 algorithms, the over segmentation rate is significantly lower than the other 6 algorithms, the segmentation effect of our algorithm is better.

Conclusion
Some Thangka damaged regions have the features of transition region, we proposed an algorithm based on distinction after analysing local complexity and local difference. It can segment damaged regions in which colour missed and whose area is small, better than other algorithms. If the gray value of damaged regions is close to the surrounding regions, or the gray value of the damaged regions is lower than the local average, or the area of damaged regions is large, the segmentation result is not ideal. In view of the local distinction algorithm is a transition region segmentation algorithm, segmentation result will lead too much over segmentation for the rich texture image. When Thangka have seriously damaged regions, or have grease regions, or have severe fade regions, the segmentation result is not ideal, it will be the further study focus.