The painted murals in Mogao Grottoes and Longmen Grottoes are symbols of China history and culture. However, most of the murals with complex texture and structure have suffered from different degrees of disease erosion after thousands of years. It is necessary to restore the damaged parts of the murals and to accurately restore their contents. In recent years, the use of new virtual technologies such as digital images to repair the damage can largely avoid secondary damage to the murals caused by manual restoration methods. Therefore, this paper takes the restoration of the most typical shedding diseases to the Mogao Caves murals in Dunhuang as an example. Furthermore, the research object of this paper is the shedding diseases including contour lines. For the traditional virtual methods of repairing shedding diseases, the structure and texture are usually restored at the same time, and these methods have little effect on the accurate removal of shedding disease through the contour line. It can be seen that shedding disease through the contour line is more difficult to repair, and more appropriate inpainting methods need to be explored. Considering the particularity of the shedding disease that passes through the contour line, this paper proposes a mural image inpainting algorithm based on structure priority to repair the shedding diseases. First, the structure repair problem is further converted into a optimization problem, and then the global optimization capability of the genetic algorithm is used to realize the connection of the structure information of the damaged area. Then, the texture is filled by subarea optimization to obtain an ideal repair effect, which can reasonably and effectively solve the problem of shedding disease repair through the contour line. Subjective and objective evaluation of experimental results is also better than other comparative methods.