A fresco image inpainting method and system based on multi-stage zero-increment connection
By employing a multi-stage, zero-incremental connection method for mural image restoration, combined with edge structure guidance and texture structure enhancement, the problem of insufficient global perception in mural image restoration is solved, resulting in more realistic and clearer restoration results.
Patent Information
- Application Number
- CN202411137274.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-08-19
AI Technical Summary
Existing technologies lack global perception capabilities in mural image restoration, making it difficult to effectively learn the global semantic consistency of images. This results in unrealistic restoration results, and in cases where the structure is weak, the restoration results are highly dependent on the consistency of the structure.
A mural image restoration method based on multi-stage zero-incremental connectivity is adopted. It utilizes a two-stage network combined with edge structure guidance and texture structure enhancement. Through the edge prior guidance module and the multi-stage incremental connectivity feature module, the global and local receptive fields are fused. The global edge structure is obtained and restored using Transformer, and multi-scale perceptual spatial denoising is performed in the texture restoration stage.
It has achieved effective restoration of murals with complex textures, generating clearer and more realistic images of cultural relics, and improving restoration performance.
Smart Images

Figure CN119090779B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image restoration technology, and in particular to a method and system for restoring mural images based on multi-stage zero-incremental connections. Background Technology
[0002] Cultural relics represent invaluable remnants of human societal development and evolution, containing immense historical value. However, due to improper preservation throughout history, many relics, including murals and calligraphy, have suffered varying degrees of damage such as mold, cracking, and fading. Unlike typical natural landscapes or urban street scenes, these relics possess complex textures and structures, often rendering traditional manual restoration methods inadequate. Therefore, it is necessary to develop effective mural restoration methods specifically addressing the complex textures of mural images, thereby strengthening the protection of traditional cultural relics.
[0003] Several deep learning algorithms have effectively addressed the problem of image inpainting. For example, existing techniques, considering the specific characteristics of image inpainting masks where missing pixels should not participate in mask update calculations, have proposed partial convolutions, effectively solving the problem of invalid pixels participating in the calculation. Another existing technique introduces a learnable version of gated convolutions (GC) based on partial convolutions. This network uses a soft gating mechanism to control mask updates, effectively solving the artifact problem that may occur after inpainting. Still other existing techniques propose a two-stage edge prior network structure. The first stage is used to inpaint edges, and the second stage performs image inpainting based on edge guidance, thereby effectively improving the structural integrity of the overall result.
[0004] These innovative methods have brought significant progress to the field of image inpainting. However, these methods still have some problems. Convolutional neural network-based methods lack effective global perception capabilities, and these networks have difficulty learning the global semantic consistency of images, which may lead to unrealistic-looking restoration results. Furthermore, when the image structure is weak, the restoration result is highly dependent on the consistency of the structure. Therefore, it is necessary to maintain effective restoration results in the first-stage structural prior process and to use effective methods to provide prior guidance for the second-stage restoration. Summary of the Invention
[0005] To address the above problems, this invention proposes a method and system for mural image restoration based on multi-stage zero-incremental connections. Addressing the lack of structural guidance and large receptive field in cultural relic image restoration, a two-stage network is used with edge structure guidance and texture structure enhancement. This restoration network, providing global and local receptive fields, integrates the complex texture information of the mural into the restoration model. It is suitable for mural image restoration in cases of complex textures and significant damage, while also exhibiting superior restoration performance.
[0006] To achieve the above objectives, the present invention provides the following solution:
[0007] This invention provides a method for restoring mural images based on multi-stage zero-incremental connectivity, comprising the following steps:
[0008] S1: Obtain the mural dataset and preprocess the images of the murals to be restored;
[0009] S2: Construct a mural image restoration model; the mural image restoration model includes: an edge prior guidance module for processing mural damage edge information and a multi-stage incremental connection feature module, and a module for focusing on global context information of the mural image; the first stage is the edge restoration stage, and the features generated in the first stage are used in the second stage, the texture restoration stage, to restore the mural image with complex textures using the texture module to be restored.
[0010] S3: Train a mural image restoration model using preprocessed mural images;
[0011] S4: Use a trained mural image restoration model to restore mural images with complex textures.
[0012] Furthermore, the images of the murals to be restored undergo preprocessing, including:
[0013] The mural image dataset was preprocessed by cropping, rotating, and sorting to crop the mural images into rectangles of 256x256.
[0014] The mural image dataset was divided into training and testing sets, with the mural images divided into an 8:1:1 ratio for the training, validation, and testing sets; this yielded data samples for image restoration.
[0015] Furthermore, the multi-stage incremental connection feature module for processing mural damage edge information includes:
[0016] Encoder, feature diffusion section, and decoder:
[0017] The encoder includes multiple convolutional blocks of different scales that gradually decrease in size, used to extract depth features and reduce the size of the mural image feature map to obtain intermediate features;
[0018] The feature diffusion part includes at least one self-attention encoder for diffusing the intermediate features to obtain the encoded features of the global context.
[0019] The decoder includes multiple convolutional blocks of different scales that are expressed progressively, used to perform deep extraction of the encoded features of the global context and restore the feature scale to the encoder stage size.
[0020] Furthermore, the feature diffusion portion includes layer normalization, an axial attention layer, a forward layer, and a self-attention layer:
[0021] The layer normalization addresses the internal covariate shift problem, ensuring that the distribution of inputs to each neural layer remains consistent during training; it also makes the distribution of input data in each layer of the network relatively stable, accelerating the model's learning speed; the intermediate features are input into the layer normalization process to obtain feature vectors of the same size.
[0022] The axial attention layer decomposes the normalized output feature vector of the layer into its axial components, and then applies attention independently to each axis; the receptive field is the pixels in the same row of the target pixel, and then the row and column attention are added together to obtain the global attention;
[0023] The feedforward network layer is used to transform the global attention into new feature representations; these features are generally more beneficial for subsequent layers to learn and process than the original input.
[0024] The self-attention layer is used to find relevant information throughout the input sequence of the new feature representation, enhancing the understanding of the context of the mural image features and capturing long-range dependencies.
[0025] Furthermore, the module for focusing on the global context information of the mural image includes:
[0026] The edge feature information output by the decoder is input into a downsampling encoder with three gated convolutional blocks to obtain concentrated feature information.
[0027] The concentrated feature information is input into the squeeze attention to enhance the obtained edge information features; through the global and local feature structure encoder, edge features of different scales are extracted and added to the texture restoration features in the next step in an incremental manner to obtain multi-level structure encoding features.
[0028] Furthermore, the downsampling encoder extracts effective features from the edge structure image through three gated convolutions, including effective feature gating and improved convolution to obtain the convolution result:
[0029] Y = σ(X*V+c)⊙(X*Y+b);
[0030] Where * represents the convolution operation, σ is an activation function used to calculate the gating value, ⊙ represents element-wise multiplication, X*V+c generates the gating matrix, the value of which is between 0 and 1 and is used to control the information flow, and X*W+b is the result of the standard convolution operation.
[0031] Furthermore, the global and local feature structure encoder models the dependencies between channels through two operations: compression and activation, thereby improving the quality of feature representation. The convolution result of the feature-gated convolution structure is input, and global average pooling is used to compress the input feature map into a vector.
[0032]
[0033] Where X represents the input feature map, H represents the height of the feature map, W represents the width of the feature map, and Z represents the height of the feature map. c Let z represent the global average pooling result of the C-th channel; z is transformed through two fully connected layers and a non-linear activation function to generate the weight vector s:
[0034] s=σ(W2δ(W1z));
[0035] Where W1 and W2 are the weight matrices of the fully connected layer, δ represents the ReLU activation function, and σ represents the sigmoid activation function; the weight vector s is reweighted onto the input feature map X. i,j,c On each channel:
[0036] Y i,j,c =s c ·X i,j,c ;
[0037] Where Y i,j,c For feature map X i,j,c The reweighted output feature map;
[0038] Through multi-level and multi-scale deep fusion, low-frequency features of generated textures are increased, resulting in a global texture perception domain. After obtaining spatial and frequency domain fusion features, spatial denoising is used to enhance the frequency domain features. The denoising module extracts spatial noise values from the image, and the original frequency domain feature map is used to eliminate spatial noise values to obtain purer frequency domain features. The final feature map has dual-domain enhanced structure and texture feature maps.
[0039] Furthermore, a mural image restoration model is trained using the preprocessed mural images, including:
[0040] The joint loss function is used to calculate the joint loss between the restored mural image and the original mural image in the training set, and the network parameters are optimized through backpropagation.
[0041] Furthermore, the joint loss function is trained using multiple loss functions, and its expression is:
[0042] L final =λ L1 L1+λ adv L adv +λ fm Lfm +λ hrf L hrf ;
[0043] Where L1 is the reconstruction loss, L... adv To combat losses, L fm For feature matching loss and L hrf For, high receptive field loss; λ L1 For L1, λ adv , λ fm and λ hrf These represent the weight values of each loss function.
[0044] This invention also discloses a mural image restoration system based on multi-stage zero-incremental connectivity, comprising:
[0045] The data preprocessing module is used to acquire the mural dataset and preprocess the images of the murals to be restored.
[0046] The model building module constructs a mural image restoration model. The mural image restoration model includes: an edge prior guidance module for processing the edge information of mural damage, a multi-stage incremental connection feature module, and a module that focuses on the global context information of the mural image. The first stage is the edge restoration stage, in which the features generated in the first stage are used in the second stage, the texture restoration stage, to restore the mural image with complex textures using the texture module to be restored.
[0047] The training module uses preprocessed mural images to train a mural image restoration model;
[0048] The restoration module utilizes a trained mural image restoration model to restore mural images with complex textures.
[0049] The beneficial effects of this invention are as follows:
[0050] To address the lack of structural guidance and large receptive field in cultural relic image restoration, this paper utilizes a restoration network that leverages edge structure guidance and provides global and local receptive fields. This network is applied in three directions: structural guidance, global and local feature fusion, and multi-scale spatial perception. In the edge structure restoration stage, a Transformer is used to acquire and restore the global edge structure. In the global and local structural feature fusion stage, structural features from different parts are extracted and incrementally added to a texture restoration network to adaptively generate textures. In the texture restoration stage, a multi-scale perceptual spatial denoising method is used to restore a clearer and more realistic cultural relic image. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0052] Figure 1 This is a flowchart of a mural image restoration method based on multi-stage zero-incremental connections in an embodiment of the present invention;
[0053] Figure 2 This is an overall framework structure diagram in an embodiment of the present invention;
[0054] Figure 3 This is a structural diagram of the edge prior guidance module in an embodiment of the present invention;
[0055] Figure 4 This is a diagram of the multi-level coding structure of edge prior features in an embodiment of the present invention;
[0056] Figure 5 This is a structural diagram of the multi-stage feature fusion module in an embodiment of the present invention. Detailed Implementation
[0057] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0058] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0059] like Figure 1 As shown, a method for mural image restoration based on multi-stage zero-incremental connectivity is described, with the following specific steps:
[0060] S1: Obtain the mural dataset and preprocess the images of the murals to be restored;
[0061] Data preprocessing of the mural image dataset includes:
[0062] Step S11: Perform cropping, rotation and sorting preprocessing on the mural image dataset to crop the mural images into rectangles of 256x256.
[0063] Step S12: Divide the mural image dataset into training and testing sets, dividing the mural images into an 8:1:1 ratio for the training, validation, and testing sets; thus obtaining data samples for image restoration.
[0064] S2: Construct a model for mural image restoration;
[0065] Among them, the mural image restoration model is a network structure that integrates multi-level attention fusion and global and local contexts, focusing on global contextual information to build an effective and reliable mural image restoration model.
[0066] Specifically, the mural image restoration model mainly includes: an edge prior guidance module, a multi-stage incremental connection feature module for processing mural damage edge information, and a module that focuses on global contextual information of the mural image.
[0067] The edge prior guidance module includes a lightweight self-attention encoder and a U-net feature extraction module. The lightweight self-attention encoder includes row and column attention for multi-scale feature aggregation to obtain global edge context information. Row and column attention mechanisms include self-attention and local complementarity mechanisms for complementary weighting of row and column self-attention. The U-net feature extraction module includes downsampling convolution, layer normalization, a self-attention encoder, a feedforward network layer, and upsampling convolution. Downsampling convolution reduces the spatial dimension of the feature map, thereby reducing the computational cost and number of parameters in subsequent layers, accelerating model training and inference, and obtaining intermediate layer features. Layer normalization normalizes the input features in each training sample to a distribution with a mean of 0 and a variance of 1, helping to reduce internal covariate shifts, making the network more stable and converging faster, and obtaining normalized intermediate layer features. The self-attention encoder captures global semantic information. Through self-alignment and weighted combination at different positions in the input sequence, the self-attention encoder can generate richer and more accurate semantic representations, obtaining global context intermediate features. The feedforward network layer is used to transform global attention into new feature representations, which are often more beneficial to subsequent layers for learning and processing than the original input. Upsampling convolutions are used to restore the size of the original input or add spatial details by expanding the low-resolution feature map, thereby improving the model's performance and effectiveness in various vision and image processing tasks, and obtaining feature vectors.
[0068] The multi-stage incremental connection feature module includes an encoder, a feature diffusion part, and a decoder. The encoder comprises multiple convolutional blocks of varying scales that gradually decrease in size, used to extract depth features and reduce the size of the mural image feature map to obtain intermediate features. The feature diffusion part includes at least one self-attention encoder used to diffuse the intermediate features, obtaining the encoded features of the global context. The feature diffusion part includes layer normalization, an axial attention layer, a feedforward layer, and a self-attention layer. Layer normalization addresses the internal covariate shift problem, ensuring that the distribution of inputs to each neural layer remains consistent during training and that the distribution of input data to each layer in the network is relatively stable. To accelerate model learning, intermediate features are input into layers and normalized to obtain feature vectors of the same size. An axial attention layer decomposes the normalized output feature vector into its axial components and then applies attention independently to each axis. The receptive field is the pixels in the same row as the target pixel; row and column attention are then summed to obtain global attention. A feedforward network layer transforms the global attention into new feature representations; these features are typically more beneficial for subsequent layers' learning and processing than the original input. A self-attention layer finds relevant information throughout the input sequence of new feature representations, enhancing the understanding of the context of mural image features and capturing long-range dependencies. The decoder, consisting of multiple progressively larger convolutional blocks of different scales, performs deep extraction of the encoded features of the global context and restores the feature scale to the encoder stage size.
[0069] The multi-stage incremental connection feature module inputs the feature vector into the multi-level feature guidance module, fusing edge and texture features; it then inputs the edge and texture features into a multi-level gated convolution to obtain a hierarchical guided feature vector; finally, it inputs the hierarchical guided feature vector into a module that focuses on the global context information of the mural image, fusing global context edge and texture information. The multi-level feature guidance module includes a linear projection module and a squeezed attention module. The linear projection module uses linear transformations to change the feature representation space, used for dimensionality reduction or feature dimension increases, helping the model learn more efficient and effective feature representations, improving the model's expressive power and performance, and obtaining a linear projection vector. The squeezed attention module extracts global information from each channel, dynamically learns the weights of each channel through the activation phase, and reweights the feature maps of each channel through a scale reweighting phase, enhancing the network's ability to focus on different feature channels, and improving the model's expressive power and performance through a self-attention model. The multi-level gated convolution uses a gating mechanism to dynamically adjust features, improving the model's adaptability and expressive power to input data, capturing long-term dependencies and important features in sequences, and obtaining a hierarchical guided feature vector.
[0070] The module focusing on global contextual information of mural images includes an incremental coding downsampling structure, segmented squeeze attention, a multi-level feature cross-multiplication module, a fast Fourier convolution module, and a feature aggregation module. The incremental coding downsampling structure utilizes multi-level guided feature vectors, introducing edge structure information through feature addition with a zero bias. It progressively builds and updates the internal state during input processing, helping the model better capture long-term dependencies and contextual information in the sequence, resulting in incrementally fused features. The segmented squeeze attention module re-establishes long-distance dependencies in the global context using incrementally fused features, obtaining long-distance structural feature dependencies. The multi-level feature cross-multiplication module captures rich and complex feature interaction information by crossing features at different levels and scales. Crossing features at different levels introduces more non-linear relationships, improving the model's performance in complex tasks and enhancing its ability to richly express input data features and model non-linearities, resulting in hierarchical features. The Fast Fourier Transform (FFT) convolution module utilizes the properties of the Fourier transform to perform convolution operations in the frequency domain, and then uses the inverse Fourier transform to return the result to the time domain. The FFT algorithm significantly accelerates convolution computation, especially for long sequences or large convolution kernels. The feature aggregation module effectively integrates and summarizes feature information from different levels or sources to enhance the model's representational and generalization capabilities.
[0071] The module focusing on global contextual information of mural images inputs the edge feature information output by the decoder into a downsampling encoder with three gated convolutional blocks to obtain concentrated feature information. The concentrated feature information is then input into a squeeze attention module to enhance the obtained edge information features. Through a global and local feature structure encoder, edge features at different scales are extracted and added incrementally to the texture restoration features in the next step to obtain multi-level structured coding features.
[0072] The downsampling encoder extracts effective features from the edge structure image through three gated convolutions, including effective feature gating and improved convolution to obtain the convolution result:
[0073] Y = σ(X*V+c)⊙(X*Y+b);
[0074] Where * represents the convolution operation, σ is an activation function, such as the sigmoid function, used to calculate the gate value, ⊙ represents element-wise multiplication, X*V+c generates the gate matrix, the value of which is between 0 and 1 and is used to control the information flow, and X*W+b is the result of the standard convolution operation.
[0075] The global and local feature structure encoder models inter-channel dependencies through two operations: "squeezing" and "activation," improving the quality of feature representation. The convolution result of the feature-gated convolution structure is input, and global average pooling is used to compress the input feature map into a vector.
[0076]
[0077] Where X represents the input feature map, H represents the height of the feature map, W represents the width of the feature map, and Zc represents the global average pooling result of the C-th channel; z is transformed through two fully connected layers and a non-linear activation function to generate the weight vector s:
[0078] s=σ(W2δ(W1z));
[0079] Where W1 and W2 are the weight matrices of the fully connected layer, δ represents the ReLU activation function, and σ represents the sigmoid activation function. This is achieved by reweighting the weight vector s onto each channel of the input feature map X:
[0080] Y i,j,c =s c ·X i,j,c ;
[0081] Where Y is the reweighted output feature map.
[0082] Through multi-level, multi-scale deep fusion, low-frequency features of the generated texture are increased, resulting in a global texture perception domain. After obtaining spatial and frequency domain fused features, spatial denoising is used to enhance the frequency domain features. A denoising module extracts spatial noise values from the image, and the original frequency domain feature map is used to eliminate spatial noise values, resulting in cleaner frequency domain features. The final feature map has dual-domain enhanced structural and texture feature maps. A joint loss function is used to calculate the joint loss between the restored mural image and the original mural image in the training set, and the network parameters are optimized through backpropagation.
[0083] like Figure 2 As shown, TSR is an edge prior guidance module, including: a CNN downsampling network, a lightweight Transformer structure repair block, and a CNN upsampling network; the input of TSR is a binary mask M (replacing the damaged areas in the image, where all pixel values corresponding to the damaged areas in M are 1, and all pixel values of the undamaged areas are 0), containing the damaged image I. m And the edge map of the damaged image (referred to as the damaged edge image) I e The image obtained after channel stitching; the output of TSR is the repaired edge structure map I. pe .
[0084] GLSFE is a multi-stage incremental connectivity feature module, including gated convolution downsampling, squeezed attention incremental module, CNN incremental module, and gated convolution structure encoding upsampling; the input of GLSFE is the output of TSR after CNN upsampling; the output is the structure encoding result.
[0085] MSDFTR is a module that focuses on the global contextual information of mural images, including a CNN incremental structure coding downsampling network, a TDFF block, and a CNN upsampling network; the input of MSDFTR is a binarized mask M and an image containing damage I. m The image after channel stitching also includes the output of GLSFE; the output of MSDFTR is the repaired image I. output .
[0086] The input image is fed into the Transformer structure recovery network of TSR, and then input into the axial attention and self-attention structures to extract structural features for edge recovery. The specific formula is expressed as follows:
[0087] I pe =TSR(I m I e M) (1)
[0088] During the structural reconstruction inference stage, after upsampling via a fast CNN, the feature map is fed into the Global and Local Structural Feature Encoding Block (GLSFE) for structural encoding. This encoder extracts effective local structural features around the damaged area of the image through gated convolution and extracts fixed-size effective global structural features through a lightweight compression attention mechanism, performing incremental encoding to generate a feature encoding map with a multi-scale fusion receptive field. The specific formula is expressed as follows:
[0089] [F LK F G32 ] = GLSFE(I pe (2)
[0090] Where L k G32 represents different local downsampling scales k∈{32, 64, 128, 256}, and G32 represents the global feature scale.
[0091] Incremental encoded features are introduced into the texture restoration stage for structure guidance. The texture restoration stage uses the MSDFTR module, which combines multi-scale spatial denoising and fast Fourier convolution, to output the final restored image. The specific formula is as follows:
[0092] I output =MSDFTR(I m F LK F G32 M) (3)
[0093] The overall structure, by combining edge restoration, structural encoding, and texture restoration modules, effectively repairs missing regions and ultimately generates a complete restored image I. output .
[0094] like Figure 3 As shown, TSR is based on the U-Net model. It uses a masked, damaged image as input to a downsampling convolutional module. The input 256×256 stacked image undergoes three convolutional downsampling operations to reduce its dimensionality to 32×32 image features. These features are then encoded into tokens and fed into a lightweight self-attention module. To reduce the quadratic complexity of the standard self-attention mechanism, an axial attention module is used. Features are divided into row and column features for self-attention calculation. After processing by the convolutional upsampling network, the image features are upsampled to a 256×256 edge feature map.
[0095] like Figure 4 As shown, the TSR feeds the obtained edge map into the downsampled autoencoder in GLSFE. Specifically, all encoding layers use gated convolution to downsample the feature map to a size of 32×32. This downsampled feature is then input into the squeezed attention increment module, and after linear projection, vectors q, k, and v are obtained. These three vectors are then input into the detail enhancement branch and the squeezed axis attention branch, respectively, to obtain the global squeezed feature FG32. The specific formula is as follows:
[0096]
[0097] Where F detail F enhances the characteristics of branches through details. attn This is an attention feature obtained by compressing axial attention. `row` represents the row vector of the feature matrix, and `column` represents the column vector of the feature matrix.
[0098] Small-scale local edge features were extracted using residual-gated convolutions at the smallest scale. Finally, a three-layer gated convolutional decoder was used to decode local features at different scales, which were then added to the incremental structural feature set. Ultimately, this module generated multi-scale structural features.
[0099] like Figure 5 As shown, the multi-stage feature fusion module uses an improved Fast Fourier Frequency Domain Convolution to remove spatial noise and a squeezed attention module to enhance global spatial features. The image with missing holes and its mask are concatenated and input into the multi-stage feature fusion network, as shown in the following expression:
[0100] I input =Cat[Im ,M] (5)
[0101] In the encoder stage, the multi-scale edge structure encoding features output by GLSFE are added to the encoder stage with zero increment to effectively guide texture generation. After three layers of downsampling, the feature map becomes 1 / 8 of its original size, while the number of channels remains unchanged. The specific formulas for the residual local features FL256, FL128, FL64, and FResL32 encoded by the edge prior structure features are as follows:
[0102]
[0103] After extracting and fusing local and global spatial features using a squeeze-type attention module, and adding global guiding structural features FG32, the contextual fusion features of structure and texture are obtained. The formula expression is as follows:
[0104] F st =SEA(F down32_2 )+FG 32 (7)
[0105] Global edge structure features encoded with GLSFE are incorporated, and the 32×32 Fst feature map is fed into the multi-level frequency domain adaptive fusion MFDAF module for multi-level frequency domain texture feature adjustment. In MFDAF, residual fast Fourier convolutions with frequency domain kernel sizes of 3, 5, 7, and 9 are used for feature learning. Feature maps are grouped into C / Head groups with a Head value of 4, and deep feature fusion convolutions with 1×1 kernels are used to obtain the feature map F. fusion The specific formula expression is as follows:
[0106]
[0107] Where j (3, 5, 7, 9) represents the size of the FFC convolution kernel; different sizes of Fast Fourier Convolution kernels can capture frequency domain features at different scales. K (1, 2, 3, 4) indicates which group of feature maps.
[0108] Through multi-level, multi-scale deep fusion, the low-frequency features of the generated texture are effectively increased, resulting in a global texture perception domain. After obtaining the fused spatial and frequency domain features, spatial denoising is used to enhance the frequency domain features. This denoising module extracts the spatial noise values of the image, and then uses the original frequency domain feature map to eliminate the spatial noise values, resulting in cleaner frequency domain features. The final feature map has dual-domain enhanced structural and texture feature maps. After three layers of upsampling, the restored mural image is obtained.
[0109] The restored mural image is processed to obtain the damaged restoration result, which is compared with the original image to calculate the reconstruction loss. This result is also used as the input to the comprehensive loss unit, and the output of the overall restoration loss guides the discriminator to correct the training direction of the next step of the network. The discriminator unit can further distinguish between the generated restored image and the original image.
[0110] S3: Train a mural image restoration model using preprocessed mural images;
[0111] In practice, training the mural image restoration model includes:
[0112] The model is trained by combining the loss function with the edge prior guidance module, the multi-stage incremental connection feature module, and the module that focuses on the global context information of the mural image, and the optimal model parameters are obtained and saved.
[0113] The overall loss includes the fusion loss of four loss functions: L1 reconstruction loss, adversarial loss, and so on. adv Feature matching loss LFM and high receptive field loss L hrf Optimize the repair network.
[0114] L1 reconstruction loss is used to measure the pixel difference between the original and restored images of the cultural relic. The formula is expressed as follows:
[0115]
[0116] Where M is a mask containing 0 or 1 pixel values, where 1 represents the masked part and 0 represents the valid pixel part; I is an image of the real cultural relic, while I is an image of the cultural relic reconstructed from the network in this article;
[0117] Combat loss L adv This is a constrained loss used in GAN training to improve the realism of restored artifact images and generate more natural local details. PatchGAN is used as the discriminator, treating masked regions as fake samples. The adversarial loss consists of the generator loss LG and the discriminator loss LD. The formulas are expressed as follows:
[0118]
[0119] in I is an image of the original cultural relic, and I is an image of the restored cultural relic. It is a gradient penalty; λG p= 1e-3;
[0120] Feature matching loss (LFM), used as the loss function in GAN network training, can effectively improve the realism of artifact image restoration results. The formula is expressed as follows:
[0121]
[0122] High receptive field loss L hrf This increases the size of the holes in the artifact repair model. The formula is expressed as follows:
[0123]
[0124] Where, φ hrf It is the process of extracting features using a preprocessed ResNet50 with dilated convolutions.
[0125] The overall loss, combining the four loss functions, is expressed by the following formula:
[0126] L final =λ L1 L1+λ adv L adv +λ FM L FM +λ HRF L hrf (13)
[0127] Where, λ L1 , λ adv , λ FM and λ HRF These represent the weight values of each loss function.
[0128] During the training of the discriminator and the overall model, the loss continuously decreases, the images restored by the restoration model become more realistic and effective, and the discriminator unit becomes more able to distinguish between generated images and real images. When the training model and the discriminator model approach Nash equilibrium, it means the training is over, and the final restoration result of the damaged mural image is obtained.
[0129] S4: Use a trained mural image restoration model to restore mural images with complex textures.
[0130] In the above embodiments, to address the problems of lack of structural guidance and large receptive field in cultural relic image restoration, a restoration network that utilizes edge structure guidance and provides global and local receptive fields is employed. This network is applied in three directions: structural guidance, global and local feature fusion, and multi-scale spatial perception. In the edge structure restoration stage, a Transformer is used to obtain and restore the global edge structure. In the global and local structural feature fusion stage, structural features of different parts are extracted and incrementally added to the texture restoration network to adaptively generate textures. In the texture restoration stage, a multi-scale perceptual spatial denoising method is used to restore a clearer and more realistic cultural relic image.
[0131] Corresponding to the above-mentioned mural image restoration method, the present invention also provides a mural image restoration system based on multi-stage zero-incremental connections, the system comprising:
[0132] The data preprocessing module is used to acquire the mural dataset and preprocess the images of the murals to be restored.
[0133] The model building module constructs a mural image restoration model. The mural image restoration model includes: an edge prior guidance module for processing the edge information of mural damage, a multi-stage incremental connection feature module, and a module that focuses on the global context information of the mural image. The first stage is the edge restoration stage, in which the features generated in the first stage are used in the second stage, the texture restoration stage, to restore the mural image with complex textures using the texture module to be restored.
[0134] The training module uses preprocessed mural images to train a mural image restoration model;
[0135] The restoration module utilizes a trained mural image restoration model to restore mural images with complex textures.
[0136] The repair method of this invention is relatively simple to describe because it corresponds to the repair system in the above embodiments. For related similarities, please refer to the description of the repair method section in the above embodiments, which will not be described in detail here.
[0137] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for restoring mural images based on multi-stage zero-incremental connections, characterized in that, Includes the following steps: S1: Obtain the mural dataset and preprocess the images of the murals to be restored; S2: Construct a mural image restoration model; the mural image restoration model includes: an edge prior guidance module for processing mural damage edge information and a multi-stage incremental connection feature module, and a module for focusing on global context information of the mural image; the first stage is the edge restoration stage, and the features generated in the first stage are used in the second stage, the texture restoration stage, to restore the mural image with complex textures using the texture module to be restored. The multi-stage incremental connection feature module for processing mural damage edge information includes: Encoder, feature diffusion section, and decoder: The encoder includes multiple convolutional blocks of different scales that gradually decrease in size, used to extract depth features and reduce the size of the mural image feature map to obtain intermediate features; The feature diffusion section includes at least one self-attention encoder for diffusing the intermediate features to obtain encoded features of the global context. The feature diffusion section includes layer normalization, an axial attention layer, a feedforward network layer, and a self-attention layer. Layer normalization addresses the internal covariate shift problem, ensuring a consistent distribution of inputs to each neural layer during training and stabilizing the distribution of input data in each layer, thus accelerating model learning. The intermediate features are input to the layer normalization layer for processing, resulting in feature vectors of the same size. The axial attention layer decomposes the output feature vector of the layer normalization layer into its axial components and then independently applies attention to each axis. The receptive field is the pixels in the same row of the target pixel, and the row and column attention are summed to obtain global attention. The feedforward network layer converts the global attention into new feature representations. These features are more beneficial for subsequent layer learning and processing than the original input. The self-attention layer finds relevant information throughout the input sequence of the new feature representations, enhancing the understanding of the context of the mural image features and capturing long-range dependencies. The decoder includes multiple convolutional blocks of different scales that are expressed progressively, used to perform depth extraction of the encoded features of the global context and restore the feature scale to the encoder stage size; The module for focusing on the global context information of the mural image includes: The edge feature information output by the decoder is input into a downsampling encoder with three gated convolutional blocks to obtain concentrated feature information. The concentrated feature information is input into the squeeze attention to enhance the obtained edge information features; through the global and local feature structure encoder, edge features of different scales are extracted and added to the texture restoration features in the next step in an incremental manner to obtain multi-level structure encoding features; S3: Train a mural image restoration model using preprocessed mural images; S4: Use a trained mural image restoration model to restore mural images with complex textures.
2. The method for mural image restoration based on multi-stage zero-incremental connectivity according to claim 1, characterized in that, Preprocessing of the mural images to be restored includes: The mural image dataset was preprocessed by cropping, rotating, and sorting to crop the mural images into rectangles of 256x256. The mural image dataset was divided into training and testing sets, with the mural images divided into an 8:1:1 ratio for the training, validation, and testing sets; this yielded data samples for image restoration.
3. The method for mural image restoration based on multi-stage zero-incremental connectivity according to claim 1, characterized in that, The downsampling encoder extracts effective features from the edge structure image through three gated convolutions, including effective feature gating and improved convolution to obtain the convolution result: ; in, This represents a convolution operation, where σ is an activation function used to calculate the gate value, ⊙ represents element-wise multiplication, and X... V+c generates a gating matrix, whose values are between 0 and 1, used to control the information flow. X W+b is the result of a standard convolution operation.
4. The method for mural image restoration based on multi-stage zero-incremental connectivity according to claim 1, characterized in that, The global and local feature structure encoder models inter-channel dependencies through two operations: compression and activation, thereby improving the quality of feature representation. The convolution result of the feature-gated convolution structure is input, and global average pooling is used to compress the input feature map into a vector. ; in X Represents the input feature map, H Indicates the height of the feature map. W Indicates the width of the feature map. Z c Let z represent the global average pooling result of the C-th channel; z is transformed through two fully connected layers and a non-linear activation function to generate the weight vector s: ; in, W 1 and W 2 is the weight matrix of the fully connected layer, where δ represents the ReLU activation function and σ represents the sigmoid activation function; by using the weight vector... s Reweighting to the input feature map On each channel: ; in For feature map The reweighted output feature map; Through multi-level and multi-scale deep fusion, low-frequency features of generated textures are increased, resulting in a global texture perception domain. After obtaining spatial and frequency domain fusion features, spatial denoising is used to enhance the frequency domain features. The denoising module extracts spatial noise values from the image, and the original frequency domain feature map is used to eliminate spatial noise values to obtain purer frequency domain features. The final feature map has dual-domain enhanced structure and texture feature maps.
5. The method for mural image restoration based on multi-stage zero-incremental connectivity according to claim 1, characterized in that, The mural image restoration model was trained using the preprocessed mural images, including: The joint loss function is used to calculate the joint loss between the restored mural image and the original mural image in the training set, and the network parameters are optimized through backpropagation.
6. The method for mural image restoration based on multi-stage zero-incremental connectivity according to claim 5, characterized in that, The joint loss function is trained by calculating multiple loss functions, and its expression is: ; in To reconstruct losses, To combat losses, For feature matching loss and For, high receptive field loss; for L 1. , and These represent the weight values of each loss function.
7. A mural image restoration system based on multi-stage zero-incremental connectivity, characterized in that, include: The data preprocessing module is used to acquire the mural dataset and preprocess the images of the murals to be restored. The model building module constructs a model for mural image restoration. The mural image restoration model includes: an edge prior guidance module and a multi-stage incremental connection feature module for processing mural damage edge information, and a module focusing on global context information of the mural image; the first stage, i.e., the edge restoration stage, uses the features generated in the first stage for the second stage, i.e., the texture restoration stage, to restore the mural image with complex textures using the texture module to be restored; wherein, the multi-stage incremental connection feature module for processing mural damage edge information includes: Encoder, feature diffusion section, and decoder: The encoder includes multiple convolutional blocks of different scales that gradually decrease in size, used to extract depth features and reduce the size of the mural image feature map to obtain intermediate features; The feature diffusion section includes at least one self-attention encoder for diffusing the intermediate features to obtain encoded features of the global context. The feature diffusion section includes layer normalization, an axial attention layer, a feedforward network layer, and a self-attention layer. Layer normalization addresses the internal covariate shift problem, ensuring a consistent distribution of inputs to each neural layer during training and stabilizing the distribution of input data in each layer, thus accelerating model learning. The intermediate features are input to the layer normalization layer for processing, resulting in feature vectors of the same size. The axial attention layer decomposes the output feature vector of the layer normalization layer into its axial components and then independently applies attention to each axis. The receptive field is the pixels in the same row of the target pixel, and the row and column attention are summed to obtain global attention. The feedforward network layer converts the global attention into new feature representations. These features are more beneficial for subsequent layer learning and processing than the original input. The self-attention layer finds relevant information throughout the input sequence of the new feature representations, enhancing the understanding of the context of the mural image features and capturing long-range dependencies. The decoder includes multiple convolutional blocks of different scales that are expressed progressively, used to perform depth extraction of the encoded features of the global context and restore the feature scale to the encoder stage size; The module for focusing on the global context information of the mural image includes: The edge feature information output by the decoder is input into a downsampling encoder with three gated convolutional blocks to obtain concentrated feature information. The concentrated feature information is input into the squeeze attention to enhance the obtained edge information features; through the global and local feature structure encoder, edge features of different scales are extracted and added to the texture restoration features in the next step in an incremental manner to obtain multi-level structure encoding features; The training module uses preprocessed mural images to train a mural image restoration model; The restoration module utilizes a trained mural image restoration model to restore mural images with complex textures.
