An Automatic Image Inpainting Algorithm Based on FCM

There are many existing image inpainting algorithms in which the repaired area should be manually determined by users. Aiming at this drawback of the traditional image inpainting algorithms, this paper proposes an automatic image inpainting algorithm which automatically identifies the repaired area by fuzzy C-mean (FCM) algorithm. FCM algorithm classifies the image pixels into a number of categories according to the similarity principle, making the similar pixels clustering into the same category as possible. According to the provided gray value of the pixels to be inpainted, we calculate the category whose distance is the nearest to the inpainting area and this category is to be inpainting area, and then the inpainting area is restored by the TV model to realize image automatic inpainting.


Introduction
Inpainting is a trimming process for the defects and cracks of the art, originated from the art field which was originally the heritage restoration of experts on the basis of being faithful to the original. Image inpainting is a technology for restoring the damaged parts of an image by referring to the information from the undamaged parts to make the restored image look "complete", "continuous" and "natural".
The terminology "digital image inpainting" was firstly put forward on the international conference in Singapore in 2000. There are many typical image inpainting algorithms proposed by researchers during the past decade. The BSCB [1] model was presented by Bertalmio, Sapiro, Caselles, and Ballester. The TV (total variation) model [2,3] was proposed by Chan and his team. The CDD (curvature driven diffusions) model [4,5] was introduced by Chan T. and Shen J. An isotropic diffusion of fast image inpainting was proposed by Oliverira. A model based on RBF was proposed by Zhou et al. [6]. The p-Laplace inpainting model was calculated from p-Laplace operator by Zhang et al. [7][8][9]. Wang et al. proposed a new spread function to improve the TV model [10], algorithm based on wavelet decomposition was proposed by Zhang and Dai [11] and so forth. However, these models belong to semi-automatic image restoration algorithms that need to manually determine the repaired area. It is a difficult problem for automatically identifying the repaired area of the image and achieving automatically image inpainting function in the field of image inpainting.
This paper attempts to overcome this drawback of the traditional image inpainting techniques to a certain degree. The proposed algorithm utilizes the fuzzy C-means (FCM) clustering algorithm to automatically identify the damaged area and also combines the TV model to realize image automatic inpainting.

Theoretical Basis of FCM Identify
Damaged Areas 2.1. Basic Knowledge of the Fuzzy Sets. Fuzzy set theory and fuzzy logic [12] are presented by Zadeh, that is, to use precise methods, formulas, and models to measure and handle phenomena and rules which are vague, incomplete, or incorrect. Membership function is defined as the degree to which an object belongs to a fuzzy set , usually recorded as ( ); the scopes of its argument are the all possible objects which belongs to the set (that all the points of the space 2 The Scientific World Journal where the set in) in the range of [0, 1]; namely, 0 ≤ ( ) ≤ 1. ( ) = 1 means that completely belongs to set , which is equivalent to the traditional set concept ∈ . A membership function defined in the space of = { } is defined as a fuzzy set , or defined as fuzzy subset in the domain of = { }. For the fuzzy set̃which has finite objects 1 , 2 , . . . , can be expressed as Fuzzy set theory has played an important role in many applications, such as fuzzy clustering analysis, fuzzy pattern recognition [13], fuzzy synthetic judgments [14], fuzzy decision and forecast [15,16], fuzzy programming, fuzzy probability [17], and fuzzy statistics [18]. In the problem of clustering, the clusters generated by clustering can be regarded as fuzzy sets; therefore, the value of membership of each sample point belongs to a cluster that is in the interval [0, 1].

Theory of FCM
Algorithm. Fuzzy C-mean clustering (FCM) [19,20] is a clustering algorithm that uses membership to determine the degree of each data point which belongs to a cluster. In 1973, Bezdek proposed the algorithm that is an improved algorithm of the early hard C-means clustering (HCM). The fuzzy clustering algorithm uses the initialization method to determine several initial clustering centers and then performs a repeated iteration which continuously adjusts and optimizes the clustering centers to achieve the minimal variance within clusters. It is a method based on the principle of least squares using iterative methods to optimize objective function to get the fuzzy partition of the data sets. Its objective function is defined as where = { 1 , 2 , . . . , } ∈ × is a data set that composed of samples of dimension , which is divided it into C classes. is a -dimensional vector; ∈ [1, ∞) is the weighted index; when = 1, the fuzzy C-means clustering is degraded as the classical C-means clustering. Nikhil et al. studies show that the best choice for is in range of [1.5, 2.5] and its ideal value is usually set to = 2; is generally defined as the Euclidean distance, it means the distance between sample and center V , that is, = ‖ − V ‖ , ‖ ⋅ ‖ defines as norm of , usually = 2; that is, is 2-norm; = {V 1 , V 2 , . . . , V } ∈ × is the set of cluster centers. V isdimensional vector and denotes the th cluster center; is the membership of the th pixel that belongs to th class. Therefore, the classification results can be expressed as a ×order fuzzy classification matrix : where need to satisfy the following constraints: (1) ∈ [0, 1] , ∀ , ; (2) ∑ =1 = 1, ∀ ; ( FCM is to search the optimum number of ( , ) for minimizing the FCM ( , ). Due to the constraint ∑ =1 = 1, it introduces a Lagrange multiplier to solve the minimum of the following formula: So the implementation of FCM algorithm is as follows: Step 1. Select > 0, set the initial clustering centers (0) = {V 1 , V 2 , . . . , V }, and set the number of iteration = 1.
Step 2. The elements of membership matrix ( ) are calculated as Step 3. Calculate the new cluster center set ( +1) , whose elements are Step

Model Establishment. To establish a normal formula of variation image inpainting model
( , ) is the image gray function, shorthand for , 0 is the defect image grayscale function, is the repaired area, Ω is the entire image area, Ω \ is the known image field, and is the Lagrange operator, the equation = is a double integral.
In (9), we have set the energy functional of TV model [|∇ |] = |∇ |; that is, After calculating out the extreme value of formula (11), we can obtain Euler-Lagrange equation of TV model as follows:
Use Gauss-Jacobi iteration method to search the optimum: where is the number of iterations. According to the discretization process of TV model, the process of TV inpainting model mainly is shown in Algorithm 1.

FCM Experimental Analysis.
In the FCM experiment in this paper given gray values of the pixel which in the repaired areas, we can calculate the Euclidean distance of it with each clustering center concluded by formula (8), the cluster which has the minimum distance is the repaired area . In this experiment, it is crucial to select the appropriate values of these parameters, namely, the number of image clustering (C value), the initial value of the clustering center (V), C, and the clustering center initial value selected which directly influence whether the defect area can be accurately identified. Generally apply the gray value distribution of the gray histogram of the image to be repaired to determine the value of C and V.
We discussed the experimental results of FCM to identify scratches, text, and big block inpainting areas 4.1.1. Scratch Inpainting. In Figure 2(a) there is identification effect of areas to be repaired; Figure 2(b) is gray histogram of Figure 2(a).
As Table 1 has shown in the experiment, we set C = 6; to initialize clustering centers = [0, 50, 100, 125, 175, 255] and update the clustering centers, obtained clustering center 1 is 21.6442, and the clustering center 2 is 69.3399, the clustering center 3 is 108.8676, the clustering center 4 is 154.7014, the clustering center 5 is 192.2138, and the clustering center 6 is 217.2253. Apparently the area to be repaired in cluster 1 identifying the scratches of the repaired area was shown in Figure 2(a), the pixel in the image to be repaired where it close to black gray value will impact identification of the repaired areas from the figure.
When set C = 8, identification effect of areas to be repaired was shown in Figure 2(c).
Apparently, the effect of Figure 2(c) is better than that of Figure 2(a); at this time, we initialize the clustering center = [0, 20, 50, 75, 100, 125, 175, 255] and the clustering center 1 is 9.6953, the clustering center 2 is 45.918, the clustering center 3 is 78.5321, the clustering center 4 is 107.6517, the clustering center 5 is 139.0719, the clustering center 6 is 169.5539, the clustering center 7 is 196.3286, the clustering center 8 is 218.8029. Area to be repaired which has been in Cluster 1, as shown in Tables 1 and 2, the cluster center value of 1 is closer to the color of the area to be repaired (gray value is 0) than the cluster center value of 1 when C = 6. Therefore, for the greater value of C, the identification is more accurate. Figure 3(a), there is the identification result of the areas to be repaired; Figure 3(b) is gray histogram of Figure 3(a).

Text Inpainting. In
As Table 3 shows, in the experiment, we set C = 5 initialize clustering center = [0, 75, 150, 200, 255], obtained the clustering center 1 is 52.0827, the clustering center 2 is 85.3504, the clustering center 3 is 119.696, the clustering center 4 is 171.9693, and the clustering center 5 is 254.6589. Apparently, the area to be repaired in cluster 5 identifying the scratches of the repaired area was shown in Figure 3

The Big Block Area
Inpainting. In Figure 4(a), there is the identification result of areas to be repaired; Figure 4(b) presents gray histogram of Figure 4(a).
As Table 4 has shown, in the experiment, we set C = 7, to initialize clustering center = [10,20,50,100,125,175,255], update the clustering center, finally obtained the clustering center 1 is 22.732, the clustering center 2 is 60.23, the clustering center 3 is 93.2463, the clustering center 4 is 124.5873, the clustering center 5 is 162.8123, the clustering center 6 is 194.4558, and the clustering center 7 is 217.9387.
Apparently, area to be repaired in cluster 1 identifying the scratches of the repaired area was shown in Figure 4(a); the pixels in the image to be repaired nearly black will be misclassified as noise, so if the grayscale values of the area to be repaired are similar to the gray values of the known area, they will be misclassified.
When we set C = 10, the extracted area to be repaired was shown in Figure 4(c).
Apparently, the result of Figure 4(c) is better than Figure 4 10,20,30,40,50,100,125,175,255], update the clustering center, finally obtained the clustering center 1 is 12.2282, the clustering center 2 is 39.6536, the clustering center 3 is 63.6337, the clustering center 4 is 85.1273, the clustering center 5 is 106.6592, the clustering center 6 is 129.8529, the clustering center 7 is 156.3771, the clustering center 8 is 179.4131, the clustering center 9 is 198.9847, and  Tables 4 and  5, the cluster center value of 1 is closer to the color of the area to be repaired (gray value is 0) than the cluster center value of 1 when C = 7. Therefore, the greater value of C and the initial value of clustering center are more appropriate, and the more accurate identification results can be obtained. the objective metric standard of the quantity of the inpainting image, the definition of ISNR as

Realization of the
wherê( , ) is the original gray image, 0 ( , ) is the damaged image, and ( , ) is the recovered image.
Combining TV model inpainting algorithm with FCM identifying the damaged areas, we have discussed the automatic inpainting effect of scratches and big block damaged areas as follows.

Scratch Inpainting.
In the following experiments, is the number of iteration, is the inpainting time, and ISNR is improved signal-to-noise.    Figures 5  and 6, it shows that the automatic image inpainting model may generate blurred edges for big block damaged area, not as good as small inpainting areas.

Conclusions
FCM clustering is an unsupervised clustering technique applied to classify images into clusters with similar properties. It utilizes the distance between pixels and cluster centers in the repaired area to compute the membership function. Experiments showed that the inpainting effect of automatic image inpainting model was decided by the inpainting model, identifying the repaired area that depends on FCM algorithm.
The Scientific World Journal 9 Original image Autorepaired image with TV model When the selected clustering number C and the selected clustering center initial value are appropriate, FCM can accurately identify the repaired area. As combined with the inpainting model, we can realize automatic digital image inpainting function.