Image Painting Based FMM Algorithm Using Gradient Matrix

In this paper, we propose an improved image inpainting method based on FMM algorithm. The traditional approach gives a fast processing speed but it cannot contribute an optimal edge result. Using gradient matrix to detect the texture direction, the significant pixels for the inpainting process are selected. Furthermore, this procedure also reduced the noise pixels’ influence. Therefore, it can yield a better edge effect for inpainting procedure than the traditional approach.

region . Compared with diffusion-based inpainting algorithms, the examplar-based inpainting algorithms are more suitable for inpainting the large missing region.
FMM algorithm focuses on the diffusion-based inpainting approach. This algorithm firstly proposed by Telea, it has a high speed in processing and has a similar result with other method [14].
Yang add the Anisotropic diffusion theory to it and have a good result in large region inpainting [15]. This paper is organized as follows In section 2, it tell the development of FMM algorithm in the recent years, In section 3, it tells the improvement of the new method. The experiment and result is shown in section 4 and finally we conclude this work in section 5 In the theory of the FMM algorithm, we regard the Ω as the region need to be in-painted, regard   as the edge of the in-paint region, divide the pixels into 3 sets: Band(the pixels on the edge of region), Known(the grey value we've already known), Inside( grey value unknown pixels). By using a time function

.The current development of the FMM algorithm
T(x,y) to determine the sequence of the in-paint, then in-paint the region from the edge to the inside.
In-paint process: the p is the pixel needed to be in-painted, we select a window , use all the known pixels(q) and equation to compute the grey value of p, ) (q I  means the gradient of q, for different q ,we use a weight function w(p, q)to weight the influence between p and q, and finally weighted average it, so the equation for the weight function w(p, q),it has three elements ) , In it, the three elements are These three elements represent the 3 points of the known pixels have influence to the inpainting. Dir element shows the direction influence for the in-paint, it means if the pixel q's direction is close to the pixel p's direction, the more influence it will have. Dst element shows the distance influence for the inpaint, it means if the pixel q is near the pixel p, the more influence it will have. Lev element shows the time influence for the inpaint, if the pixel q is close to the known information, the more influence it will have.
From the sets of equation, we can see that at last the three elements have the same importance in it, but actually in the inpainting, the pixels which have the same texture direction with the destroyed pixel will do more contribute to the inpainting. So, if we compute under this method, the pixels which are near the destroyed pixel but with different texture direction will regard have much useful information, in fact, this kind pixels always are noise pixels. So it will make the edge unclear.
The most important advantage is this method can spend very little time and give a good result. But when in-paint one pixel, this method use all the neighbor information, so it may add any noise into the in-paint pixel. And finally we can see that if the width of the in-paint area is larger than 20 pixels, the result will be unclear, especially in the isolux line and edge tangent place.

.Use gradient matrix to improve the FMM algorithm
Because of the disadvantage of the old FMM method, I consider a new method to remain the fast advantage and give a good edge remaining result at the same time. For the natural image, the pixels on the texture direction may make more influence to the in-paint pixel. So if we just select the pixels on the texture direction of the in-paint pixel, we can reduce the influence made by the noise pixels.

extract gradient matrix from the image
First we compute the gradient value and direction of the all the Known pixels, for Known pixels: For Band pixels, they are indispensable in the computing, but one hand of band pixels may be the inside pixels, so the grey value we don't know and we can not get the Band pixels' gradient, then we need to change the equation, use the band pixel itself replace the inside pixel.
Finally we get two matrix, one matrix gv(x, y) represent the gradient value of every pixel, and the other matrix g(x, y) represent the gradient direction of every pixel.

select the texture direction by the gradient matrix
Now we've get the two gradient matrix, the value are continuous, but we hope the gradient direction to be a discrete value to carry on the next work .So we should define several gradient direction to replace the gradient direction value .according to the number of the defined direction, it will influence the in-paint result, here we just for demonstrating the feasibility of our method ,so we use a easier condition to work, set the direction number to 4.so the gradient direction will be divided into 4 situations.
Then add another situation represent the situation that the gradient value of all the pixels in the window ) ( p B  are very small .we set a threshold, if the sum of the gradient value is less than the threshold, regard it gradient direction as this situation. Count the gradient value on every direction of all the known pixels in the window ,select the direction which has the biggest value as the in-paint pixel's gradient direction .then according to the gradient direction ,only select the pixels on its texture direction(from gradient direction we can get texture direction because they are vertical) to compute the grey value.

.Experiment result
In this section, we test the proposed improved FMM algorithm region the outside part just use the real information to in-paint, but the inside part is different, they use the in-painted pixel to in-paint, so the noise influence gained to make the inside part unclear. But the new method is different, it only select the same texture direction pixels, so the noise influence reduced.

5.Conclusion
In this work, the gradient matrix was adopted to the FMM inpainting algorithm, it overcame the disadvantage of traditional FMM inpainting method, which cannot contribute an optimal edge result. By using the gradient matrix to detect the texture direction, and selecting the significant pixels for the inpainting process, the resulting images seem more reasonable and more similar to the natural scenes. In fact, the proposed approach not only remains the advantage of fast processing speed, but also contributes a better estimation result of edges compared to the traditional method.