A colorization method for infrared images based on convolution and Transformer

By combining the convolution and Transformer models, the generative adversarial network solves the problem of low texture details and color matching in infrared image colorization, achieves more natural and realistic color image generation, and improves the stability and training efficiency of the network.

CN116137043BActive Publication Date: 2024-09-27CHANGCHUN UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310145265.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-21
Publication Date
2024-09-27
Estimated Expiration
2043-02-21

AI Technical Summary

Technical Problem

Existing infrared image colorization methods have deficiencies in texture detail recovery and color matching, resulting in the generated colorized images not meeting the visual effects of the human eye.

Method used

A generative adversarial network based on convolution and Transformer is used, combined with a local feature extraction module and a global feature extraction module, to optimize the generator and discriminator through a composite loss function and a separate learning rate to achieve high-quality colorization of infrared images.

Benefits of technology

It improves the ability to restore image texture details and color matching, making the generated color images more natural and realistic, reducing training time and improving the stability of the network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116137043B
    Figure CN116137043B
Patent Text Reader

Abstract

The present invention belongs to the technical field of image colorization in computer vision, and is particularly a method for colorizing infrared images based on convolution and Transformer. The method comprises the following specific steps: Step 1, constructing a network model: the infrared image colorization model is a generative adversarial network including a generator and a discriminator; Step 2, preparing a data set: first training the entire generative adversarial network with an infrared image data set 1; Step 3, training the network model: preprocessing the infrared image data set 1, and inputting the processed data set into the constructed network model for training. The method of the present invention introduces a Transformer model, which can capture long-distance features, thereby being able to easily obtain the global information of an image, strengthen the extraction of deep information of an image, and enhance the naturalness and authenticity of a colored image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image colorization in computer vision, and in particular to an infrared image colorization method based on convolution and Transformer. Background Art

[0002] Image colorization is a process of converting a single-channel grayscale image into a three-channel color image, adding corresponding color information according to the semantic information in the image. With the rise of deep learning, image colorization technology has been widely used in military, film, medical, national defense, and monitoring fields. As a type of grayscale image, infrared images are less affected by light and have stronger anti-interference ability than ordinary grayscale images, and have a wider application value. The current colorization method mainly uses convolutional neural networks. Although it has achieved great success, the receptive field of the convolution operation is very limited, and only very local features can be calculated, not global features, resulting in a bottleneck in colorization. Transformer, as a codec architecture model based on the attention mechanism, can extract global features well, especially the introduction of the visual Transformer, which makes the Transformer architecture applicable to the field of computer vision. In terms of colorization effect, there are two key problems in the colorized images generated by the existing infrared image colorization algorithm, namely, poor texture detail restoration and low color matching.

[0003] The Chinese patent publication number is "CN112365559B", and its name is "A method for infrared image colorization based on a generative adversarial network based on structural similarity". This method first constructs a generative adversarial network based on structural similarity; secondly, a generative adversarial loss function is used for the discriminator, and a generative adversarial loss function, a cycle-consistent loss function, a reconstruction loss function, and a loss function based on structural similarity are used for the generator; finally, the network is trained to the convergence condition using pre-collected infrared images and color images, and the obtained generator can realize the colorization of infrared images; the colorization result obtained by this method does not meet the visual effect of the human eye, the texture detail restoration is poor, and the color matching is low. Summary of the invention

[0004] 1. Technical issues to be resolved

[0005] In view of the shortcomings of the prior art, the present invention provides an infrared image colorization method based on convolution and Transformer, which solves the problem that the images obtained by the existing infrared image colorization method lack texture details and have low color matching.

[0006] (II) Technical solution

[0007] In order to achieve the above-mentioned purpose, the present invention specifically adopts the following technical solutions:

[0008] A method for colorizing infrared images based on convolution and Transformer, the specific steps are:

[0009] Step 1, build a network model: the infrared image colorization model is a generative adversarial network including a generator and a discriminator;

[0010] Step 2, prepare the data set: first train the entire generative adversarial network with infrared image data set 1;

[0011] Step 3, training the network model: preprocess the infrared image data set 1, and input the processed data set into the constructed network model for training;

[0012] Step 4, select the minimized loss function and the optimal evaluation index: By minimizing the loss function of the network output image and the label, until the number of training times reaches the set threshold or the value of the loss function reaches the set range, the model parameters are considered to have been pre-trained and saved; at the same time, the optimal evaluation index is selected to measure the accuracy of the algorithm and evaluate the performance of the system;

[0013] Step 5, fine-tuning the model: Use infrared image dataset 2 to train and fine-tune the model to obtain stable and usable model parameters;

[0014] Step 6, save the model: solidify the final model parameters, and when the infrared image colorization operation is needed, directly input the image into the network to obtain the final colored image.

[0015] Furthermore, the generator is composed of a local feature extraction module, a global feature extraction module, a feature fusion module 1, a feature fusion module 2, a feature fusion module 3, a feature reconstruction module 1, a feature reconstruction module 2, a feature reconstruction module 3 and an output block, and is used to realize the conversion from the infrared image to the infrared colorized image;

[0016] The local feature extraction module is composed of convolution block 1, convolution block 2 and convolution block 3, and performs shallow feature extraction on the image in a local feature extraction manner. Each convolution block is composed of convolution, instance normalization, activation function and pooling;

[0017] The global feature extraction module is composed of Transformer module 1, Transformer module 2, Transformer module 3, Transformer module 4, Transformer module 5 and Transformer module 6, and extracts the remote deep semantic information of the image in a global feature extraction manner. Each Transformer module is composed of block embedding, array flattening, position encoding and Transformer encoder, wherein the block embedding is composed of linear mapping and layer normalization, and the Transformer encoder is composed of layer normalization, space reduction, multi-head attention and feedforward network;

[0018] The feature fusion module 1, feature fusion module 2 and feature fusion module 3 respectively fuse the feature information of each scale obtained by the local feature extraction module and the global feature extraction module, so that the network can learn more comprehensive and detailed semantic information and color information. Each feature fusion module consists of convolution, upsampling and splicing operations;

[0019] The feature reconstruction module 1, the feature reconstruction module 2 and the feature reconstruction module 3 respectively receive the fused feature information from the feature fusion module 3, the feature fusion module 2 and the feature fusion module 1, decode the received feature information and reconstruct the output image, and each feature reconstruction module is composed of upsampling, convolution, instance normalization and activation function;

[0020] The output block consists of convolution, normalization and activation functions, and outputs a reconstructed color image.

[0021] Furthermore, the discriminator adopts a Markov discriminator, which is composed of convolution, normalization and activation functions. The infrared colorized image generated by the generator and the visible light color image in the dataset are input into the discriminator, and the discriminator outputs true or false probability information to determine whether the input image is real.

[0022] Furthermore, the infrared image dataset 1 is the KAIST dataset.

[0023] Furthermore, during the data preprocessing process, first, the size of each image in the dataset is adjusted and the size of the input image is fixed. Then, the cropped image is normalized to speed up the training of the model. Finally, a data enhancement operation is performed to change the brightness, contrast and saturation of the visible light image to provide high-quality data for model training. During the training process, separate learning rates are used for the generator and discriminator so that each generator update uses fewer discriminator updates.

[0024] Furthermore, during the training process, the loss function is selected to use a composite loss function. The generator uses adversarial loss, edge loss, and perceptual loss, and the discriminator uses adversarial loss.

[0025] Furthermore, the second infrared image dataset is an OTCBVS dataset.

[0026] (III) Beneficial effects

[0027] Compared with the prior art, the present invention provides an infrared image colorization method based on convolution and Transformer, which has the following beneficial effects:

[0028] The method of the present invention introduces the Transformer model, which can capture long-distance features, so that the global information of the image can be easily obtained, the deep information of the image can be extracted, and the naturalness and reality of the colored image can be enhanced.

[0029] The present invention combines the respective advantages of convolutional neural networks and Transformer models in the generator. The convolutional neural network only focuses on local features and is used for shallow feature information extraction. The Transformer model can capture long-distance features and is used for deep feature information extraction. The features obtained by the two are fused, which improves the network's feature extraction capability and enhances the ability to restore image texture details.

[0030] The present invention proposes a composite loss function composed of adversarial loss, edge loss and perceptual loss, which optimizes the quality of generated color images from two aspects: edge structure and visual perception, so that the content and color of the generated image are more matched and more in line with human visual observation.

[0031] The present invention uses spectral normalization in the discriminator and uses separate learning rates for the generator and the discriminator during training, making it possible to use fewer discriminator updates for each generator update, thereby accelerating the convergence speed, reducing the training time, and improving the stability of network training. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 This is a flow chart of an infrared image colorization method based on convolution and Transformer;

[0033] Figure 2 The generator structure diagram of a convolution and Transformer-based infrared image colorization method that generates an adversarial network;

[0034] Figure 3 A diagram of the discriminator architecture of a generative adversarial network for infrared image colorization based on convolution and Transformer.

[0035] Figure 4A specific composition structure diagram of each Transformer module in Transformer module 1, Transformer module 2, Transformer module 3, Transformer module 4, Transformer module 5 and Transformer module 6 described in the present invention;

[0036] Figure 5 This is a specific structural diagram of each module in the convolution block 1, convolution block 2 and convolution block 3 of the present invention;

[0037] Figure 6 It is a specific composition structure diagram of each module in the feature fusion module 1, feature fusion module 2 and feature fusion module 3 of the present invention;

[0038] Figure 7 It is a specific composition structure diagram of each module in the feature reconstruction module 1, feature reconstruction module 2 and feature reconstruction module 3 of the present invention;

[0039] Figure 8 This is a comparison chart of related indicators between the prior art and the method proposed in the present invention. DETAILED DESCRIPTION

[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0041] Example 1

[0042] The embodiment of the invention provides a method for colorizing infrared images based on convolution and Transformer, and the method specifically comprises the following steps:

[0043] Step 1, build a network model: the entire generative adversarial network includes a generator and a discriminator; the generator consists of a local feature extraction module, a global feature extraction module, a feature fusion module 1, a feature fusion module 2, a feature fusion module 3, a feature reconstruction module 1, a feature reconstruction module 2, a feature reconstruction module 3 and an output block to realize the conversion of infrared images to infrared colorized images; the discriminator uses a Markov discriminator, and the infrared colorized image generated by the generator and the visible light color image in the data set are input into the discriminator, and the discriminator outputs true and false probability information to determine whether the input image is real; the local feature extraction module consists of convolution block 1, convolution block 2 and convolution block 3, and performs shallow feature extraction on the image in the form of local feature extraction. A convolution block consists of convolution, instance normalization, activation function and pooling, and the size of the convolution kernel is n×n; the global feature extraction module consists of Transformer module 1, Transformer module 2, Transformer module 3, Transformer module 4, Transformer module 5 and Transformer module 6, which extracts the remote deep semantic information of the image in a global feature extraction manner. Each Transformer module consists of block embedding, array flattening, position encoding and Transformer encoder, where block embedding consists of linear mapping and layer normalization, and Transformer encoder The self-attention network consists of layer normalization, space reduction, multi-head attention and feedforward network. Multi-head attention is a mechanism that can be used to improve the performance of ordinary self-attention layers. Different attention heads use different Q, K, and V matrices (Q can be understood as the information to be queried, K can be understood as the queried vector, and V can be understood as the query value). Due to random initialization, these matrices can project the trained input vector into different representation subspaces and are processed in parallel by multiple independent attention heads. The result vectors are aggregated and mapped to the final output. Feature fusion module 1, feature fusion module 2 and feature fusion module 3 respectively fuse the feature information of each scale obtained by the local feature extraction module and the global feature extraction module to make the network It can learn more comprehensive and detailed semantic information and color information. Each feature fusion module consists of convolution, upsampling and splicing operations, and the convolution kernel size is n×n; feature reconstruction module 1, feature reconstruction module 2 and feature reconstruction module 3 receive the fused feature information from feature fusion module 3, feature fusion module 2 and feature fusion module 1 respectively, decode the received feature information and reconstruct the output image. Each feature reconstruction module consists of upsampling, convolution, instance normalization and activation function, and the convolution kernel size is n×n; the output block consists of convolution, normalization and activation function, and the convolution kernel size is n×n, and the reconstructed color image is output; finally, the size of the feature map is consistent with the input image size;The discriminator consists of convolution, normalization and activation functions. The convolution kernel size is n×n, and the output is true or false probability information to determine whether the input image is real. ;

[0044] Step 2, prepare the data set: first train the entire generative adversarial network with the infrared image data set 1; the network is trained using the KAIST data set during the pre-training process described in step 2.

[0045] Step 3, training the network model: preprocess the data set prepared in step 2, and input the processed data set into the network model built in step 1 for training; in the data preprocessing process, first, adjust the size of each image in the data set, fix the size of the input image, and then normalize the cropped image to speed up the training of the model, and finally perform a data enhancement operation to change the brightness, contrast and saturation of the visible light image to provide high-quality data for model training.

[0046] Step 4, select the minimized loss function and the optimal evaluation index: by minimizing the loss function of the network output image and the label, until the number of training times reaches the set threshold or the value of the loss function reaches the set range, the model parameters can be considered to have been pre-trained and the model parameters can be saved; at the same time, the optimal evaluation index is selected to measure the accuracy of the algorithm and evaluate the performance of the system; during the training process, the loss function uses a composite loss function, the generator uses adversarial loss, edge loss and perceptual loss, and the discriminator uses adversarial loss; the choice of loss function affects the quality of the model, can truly reflect the difference between the predicted value and the true value, and can correctly feedback the quality of the model; suitable evaluation indicators include peak signal-to-noise ratio (PSNR), structural similarity (SSIM) and natural image quality evaluator (NIQE), which can effectively evaluate the quality of the algorithm colorization results and the degree of image distortion, and measure the role of the colorization network.

[0047] Step 5, fine-tuning the model: Use infrared image dataset 2 to train and fine-tune the model to obtain stable and usable model parameters, further improve the model's infrared image colorization capability, and ultimately make the model's image colorization effect better; use the OTCBVS dataset in the process of fine-tuning the model parameters.

[0048] Step 6, save the model: solidify the final model parameters, and when the infrared image colorization operation is needed, directly input the image into the network to obtain the final colored image.

[0049] Embodiment 2:

[0050] The generator and discriminator network model structures in step 1 are as follows Figure 2 and 3 As shown;

[0051] The generator consists of a local feature extraction module, a global feature extraction module, a feature fusion module, a feature reconstruction module and an output block; the local feature extraction module consists of convolutional blocks 1, 2 and 3. The convolutional blocks focus on local features and are used to extract shallow feature information. The convolutional block network structure is shown in the figure. Figure 5 As shown in FIG, it includes convolution, instance normalization, activation function and pooling. The convolution kernel size is 3×3, the step size is 1, and the activation function selects the ReLU function. The ReLU function can converge quickly in the stochastic gradient descent algorithm and can effectively alleviate the problem of gradient disappearance. The pooling selects the maximum pooling, the window size is 2×2, and the step size is 2. The maximum pooling returns the maximum grayscale value in the sliding frame, which can well extract the image structure and retain more texture information. The global feature extraction module consists of Transformer module one, Transformer module two, Transformer module three, Transformer module four, Transformer module five, and Transformer module six. The Transformer module can capture long-distance features and strengthen the extraction of deep information of the image, thereby enhancing the naturalness and authenticity of the colored image. The network structure diagram of the Transformer module is shown in FIG. Figure 4 As shown in the figure, it includes block embedding, array flattening, position encoding, concatenation operation, layer normalization, space reduction, multi-head attention and feedforward network. The purpose of block embedding is to extract multi-scale feature maps of image blocks. The purpose of array flattening is to convert feature maps into vectors. The purpose of adding position encoding is to make up for the position information missing in matrix operations in the attention mechanism. Normalization overcomes the disadvantage that batch normalization is difficult to handle sequence tasks with variable-length inputs, and transfers the scope of normalization from across samples to the hidden layer of the same sample, so that it does not depend on the input size and is suitable for Transformer encoders. Space reduction reduces the spatial scale of K and V before the attention operation, thereby greatly reducing memory overhead. Multi-head attention calculates Q, K, and V in parallel and then concatenates them in the channel dimension. The feedforward network consists of two linear layers plus a ReLU activation function; the feature fusion module consists of feature fusion module one, feature fusion module two, and feature fusion module three. The feature fusion module fuses local features and global features, improves the feature extraction capability of the network, and enhances the ability to restore image texture details. The network structure diagram of the feature fusion module is shown in Figure 6 As shown in , it includes convolution, upsampling and splicing operations. The convolution kernel size of convolution one is 1×1, the convolution kernel size of convolution two is 3×3, and the step size is 1. Upsampling is used to adjust the size of the input feature map, and the splicing operation uses concat; feature reconstruction module one, feature reconstruction module two and feature reconstruction module three are composed of upsampling, convolution, instance normalization and activation function, as shown in Figure 7As shown in the figure, the convolution kernel size is 3×3, the step size is 1, and the activation function selects the ReLU function; the output block consists of convolution, instance normalization and activation function, the convolution kernel size is 3×3, the step size is 1, and the activation function uses the Tanh function.

[0052] The discriminator consists of convolution, spectral normalization and activation function. The convolution kernel size is 4×4 and the step size is 1. Spectral normalization can improve the stability of network training. Activation function one, activation function two, activation function three and activation function four all use LeakyReLU function. The use of spectral normalization and LeakyReLU function makes the model more stable and effectively realizes the back propagation of gradient. Activation function five uses Sigmoid function. The essence of the discriminator is a binary classification task, and Sigmoid function is suitable for binary classification tasks.

[0053] In general, the colorization process is to input an infrared image, extract the local feature information of the image through the local feature extraction module, and then extract the long-range global feature information of the image through the global feature extraction module. The local information and the global information are then fused, and the fused feature information is input into the feature reconstruction module for image reconstruction. The generated infrared colorized image is then output through the output block, and finally the generated image and the visible light image are input into the discriminator.

[0054] The definitions of ReLU function, Tanh function, LeakyReLU function and Sigmoid function are as follows:

[0055]

[0056]

[0057]

[0058]

[0059] The sin-cos position encoding formula used in the present invention is defined as follows:

[0060] PE (pos,2i) =sin(pos / 10000 2i / d )

[0061] PE (pos,2i+1) =cos(pos / 10000 2i / d )

[0062] Where pos represents the position of each element in the sequence, and 2i and 2i+1 represent the dimensions of the position encoding.

[0063] The formula definition of multi-head attention with space reduction adopted by the present invention is as follows:

[0064]

[0065]

[0066] In the formula, Concat represents the concatenation operation. and represents the linear projection parameter, N i represents the number of heads in the attention layer, SR(·) represents the space reduction operation, and the formula is defined as follows:

[0067] SR(x)=Norm(Reshape(x,R i )W S )

[0068] In the formula, represents the input sequence, R i represents the reduction rate of the attention layer, represents linear projection, and Norm(·) represents layer normalization.

[0069] The feedforward network formula is defined as follows:

[0070] FFN=max(0,XW1+b1)W2+b2

[0071] Where X is the input image matrix, W i is a matrix of the same size as X, b i is a one-dimensional vector with length equal to the number of channels in X.

[0072] In step 2, the infrared image dataset uses the KAIST dataset. The KAIST dataset contains 95,000 day and night color thermal image pairs. These thermal infrared images are taken using a FLIRA35 microbolometer long-wave infrared camera. The scene categories are: campus, streets, and various conventional traffic scenes in the countryside. 33,399 color thermal image pairs in its daytime training dataset are used for training, and 29,179 color thermal image pairs in its daytime test dataset are used for evaluation. The adversarial training of the KAIST dataset can determine a set of initialization parameters to speed up the subsequent network training process.

[0073] In the step 3, the images of the data set are preprocessed. First, the size of each image in the data set is adjusted to 256×256, the size of the input image is fixed, and then the cropped image is normalized to speed up the training of the model. Finally, a data enhancement operation is performed to change the brightness, contrast and saturation of the visible light image to provide high-quality data for model training. Among them, the resizing, normalization and data enhancement can be achieved through software algorithms. During the training process, separate learning rates are used for the generator and the discriminator, so that each generator update uses fewer discriminator updates, which speeds up the network convergence and reduces the training time.

[0074] The output of the network in step 4 and the label calculate the loss function, and a better fusion effect is achieved by minimizing the loss function. During the training process, the loss function chooses to use a composite loss function, so that the content and color of the generated image are more matched and more in line with human visual observation. The generator uses adversarial loss, edge loss and perceptual loss, and the discriminator uses adversarial loss.

[0075] In order to encourage the network to output color results with more realistic details, an adversarial loss is used to make the generated infrared color image indistinguishable from the real visible light color image, which is defined as follows:

[0076] L adv =E X [log(1-D(X,G(X)))]

[0077] In the formula, X is not only the input of the generator, but also the input of the discriminator as a conditional term.

[0078] Edge loss is used to encourage the generated image to have a clearer edge structure. The Laplace edge operator, which is easy to convolutionally calculate, is used. This second-order differential operator can retain most of the key edge information in the thermal infrared image while excluding non-critical and unexpected information, and optimize the quality of the generated color image from the edge structure. It is defined as follows:

[0079]

[0080] Where Δ is the edge operator, ∈ 2 is the regularization term.

[0081] Margin loss sometimes cannot ensure the consistency between perceptual quality and objective indicators. Therefore, perceptual loss is used to constrain the output infrared color image to be similar to the ground truth in high-dimensional space, and optimize the quality of the generated color image from the perspective of visual perception. Specifically, the VGG-19 network pre-trained on the ImageNet dataset is used as the feature extractor of perceptual loss, which is defined as follows:

[0082]

[0083] In the formula, C j , H j and W j is the number of channels, height and weight of a given feature map generated by the VGG-19 network, φ j (x) represents the j-th layer activation of the network φ when processing the input image.

[0084] Therefore, the total loss of the generator is defined as:

[0085] L G =λ adv L adv +λ edge L edge +λ perceptual L perceptual

[0086] In the formula, λ adv , edge and λ perceptual They respectively represent the weights that control different loss shares in the complete objective function, and the setting of the weights is based on preliminary experiments on the training dataset.

[0087] The loss function of the discriminator is defined as:

[0088] L D =E X [log(D(X,G(X)))]+E X,Y [log(1-D(X,Y))]

[0089] Where X is the input image, Y is the real image, and G(X) is the generated image.

[0090] By optimizing the generator and discriminator loss functions, it helps the network learn clearer edges and more detailed texture information, making the coloring image more natural, more realistic and with better visual effects.

[0091] In step 4, suitable evaluation indicators include peak signal-to-noise ratio (PSNR), structural similarity (SSIM) and natural image quality evaluator (NIQE).

[0092] Peak signal-to-noise ratio is a commonly used objective evaluation method for image quality. It is usually simply expressed by the mean square error. The larger the value, the better the image quality. It is defined as follows:

[0093]

[0094]

[0095] In the formula, I nrepresents the nth pixel value of the ground truth image, P n Represents the nth pixel value of the generated image.

[0096] Structural similarity is used to compare the similarity between two images. The value range is fixed in the interval [0,1]. The closer the value is to 0, the lower the similarity between the two images. Conversely, the higher the similarity between the two images, the definition is as follows:

[0097]

[0098] In the formula, μ x and μ y Represent the mean and variance of images x and y respectively, and Represents the standard deviation of images x and y, σ xy represents the covariance of images x and y, c1 and c2 are constants.

[0099] The natural image quality evaluator is a no-reference image quality evaluation method that measures image quality by calculating the distance between the distorted image and the natural image fitting parameters. The smaller the value, the better the image quality.

[0100] The number of training times is set to 300, the learning rate of the first 100 training processes is set to 0.0002, and the learning rate of the next 200 training processes gradually decreases from 0.0002 to 0; the number of images input to the network each time is about 8-16, and the upper limit of the number of images input to the network each time is mainly determined by the performance of the computer graphics processor. Generally, the number of images input to the network each time is in the range of 8-16, which can make the network training more stable and the training results better, and can ensure fast network fitting; the network parameter optimizer selects the Adam optimizer, which has the advantages of simple implementation, efficient calculation, low memory requirement, and parameter update is not affected by the scaling transformation of the gradient, making the parameters relatively stable; when the ability of the discriminator to judge fake images is balanced with the ability of the generator to generate images that deceive the discriminator, the network is considered to have been basically trained.

[0101] In the step 5, the model is trained and fine-tuned using the second infrared image dataset. The OTCBVS dataset is used in the process of fine-tuning the model parameters. Specifically, a subset of the dataset, OSU Color-Thermal Database, is used. The subset provides 17,089 images of busy road intersection scenes on a university campus. We use 1,000 images for training and 200 images for testing.

[0102] After the network training is completed in step 6, all parameters in the network need to be saved. When the infrared image colorization operation is required, the image can be directly input into the network to obtain the final colored image.

[0103] Among them, the implementation of convolution, activation function, splicing operation, normalization and Transformer, etc. are algorithms well known to those skilled in the art, and the specific processes and methods can be found in corresponding textbooks or technical literature.

[0104] The present invention constructs an infrared image colorization method based on convolution and Transformer, which can directly generate a colorized image from an infrared image without going through other intermediate steps, avoiding the manual design of relevant colorization rules. Under the same conditions, the relevant indicators of the image obtained by calculating the existing method are further verified, and the relevant indicators of the existing technology and the method proposed by the present invention are compared. Figure 8 shown.

[0105] from Figure 8 It can be seen that the method proposed in the present invention has higher peak signal-to-noise ratio, structural similarity, lower natural image quality evaluator index and fewer generator parameters than the existing methods. These indicators also further illustrate that the method proposed in the present invention has better colorization quality and lower computational complexity.

[0106] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for colorizing infrared images based on convolution and Transformer, characterized in that: The specific steps are: Step 1, build a network model: the infrared image colorization model is a generative adversarial network including a generator and a discriminator; The generator consists of a local feature extraction module, a global feature extraction module, a feature fusion module 1, a feature fusion module 2, a feature fusion module 3, a feature reconstruction module 1, a feature reconstruction module 2, a feature reconstruction module 3 and an output block, and is used to realize the conversion from infrared image to infrared colorized image; The local feature extraction module is composed of convolution block 1, convolution block 2 and convolution block 3, and performs shallow feature extraction on the image in a local feature extraction manner. Each convolution block is composed of convolution, instance normalization, activation function and pooling; The global feature extraction module is composed of Transformer module 1, Transformer module 2, Transformer module 3, Transformer module 4, Transformer module 5 and Transformer module 6, and extracts the remote deep semantic information of the image in a global feature extraction manner. Each Transformer module is composed of block embedding, array flattening, position encoding and Transformer encoder, wherein the block embedding is composed of linear mapping and layer normalization, and the Transformer encoder is composed of layer normalization, space reduction, multi-head attention and feedforward network; The feature fusion module 1, feature fusion module 2 and feature fusion module 3 respectively fuse the feature information of each scale obtained by the local feature extraction module and the global feature extraction module, so that the network can learn more comprehensive and detailed semantic information and color information. Each feature fusion module consists of convolution, upsampling and splicing operations; The feature reconstruction module 1, the feature reconstruction module 2 and the feature reconstruction module 3 respectively receive the fused feature information from the feature fusion module 3, the feature fusion module 2 and the feature fusion module 1, decode the received feature information and reconstruct the output image, and each feature reconstruction module is composed of upsampling, convolution, instance normalization and activation function; The output block consists of convolution, normalization and activation functions, and outputs a reconstructed color image; The discriminator uses a Markov discriminator, which is composed of convolution, normalization and activation functions. The infrared colorized image generated by the generator and the visible light color image in the data set are input into the discriminator. The discriminator outputs true or false probability information to determine whether the input image is real; Step 2, prepare the data set: first train the entire generative adversarial network with infrared image data set 1; Step 3, training the network model: preprocess the infrared image data set 1, and input the processed data set into the constructed network model for training; Step 4, select the minimized loss function and the optimal evaluation index: By minimizing the loss function of the network output image and the label, until the number of training times reaches the set threshold or the value of the loss function reaches the set range, the model parameters are considered to have been pre-trained and saved; at the same time, the optimal evaluation index is selected to measure the accuracy of the algorithm and evaluate the performance of the system; Step 5, fine-tuning the model: Use infrared image dataset 2 to train and fine-tune the model to obtain stable and usable model parameters; Step 6, save the model: solidify the final model parameters, and when the infrared image colorization operation is needed, directly input the image into the network to obtain the final colored image.

2. The infrared image colorization method based on convolution and Transformer according to claim 1, characterized in that: The first infrared image dataset is the KAIST dataset.

3. The infrared image colorization method based on convolution and Transformer according to claim 1, characterized in that: In the data preprocessing process, first, adjust the size of each image in the data set and fix the size of the input image. Then, normalize the cropped image to speed up the model training. Finally, perform a data enhancement operation to change the brightness, contrast, and saturation of the visible light image to provide high-quality data for model training. Using separate learning rates for the generator and discriminator during training allows each generator update to use fewer discriminator updates.

4. The infrared image colorization method based on convolution and Transformer according to claim 1, characterized in that: During the training process, the loss function uses a composite loss function. The generator uses adversarial loss, edge loss, and perceptual loss, and the discriminator uses adversarial loss.

5. The infrared image colorization method based on convolution and Transformer according to claim 1, characterized in that: The second infrared image dataset is the OTCBVS dataset.