A method and system for colorizing infrared images guided by feature information
By constructing a generative adversarial network, combining the self-attention mechanism and feature fusion module, and using the auxiliary information of the visible light reference image, the problem of serious color overflow and blurred semantic information in the colorization of infrared images is solved, and the realism of the colorized image is improved. and naturalness, achieving effective fusion of infrared image and visible light reference image features.
Patent Information
- Application Number
- CN202410891742.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-04
AI Technical Summary
In existing infrared image colorization methods, color overflow is serious, semantic information is blurred, gradients disappear due to the use of multiple residual blocks, it is difficult to learn implicit mapping, and there is a lack of auxiliary information to overcome these shortcomings.
Build a generative adversarial network, including a generator and a discriminator. Through the encoder, decoder, dense residual block, multi-scale attention block and feature fusion module, use the KAIST and FLIR data sets for training, introducing self-attention mechanism and features The transfer block combines the auxiliary information of the visible light reference image to colorize the infrared image.
It improves the realism and naturalness of colorized images, enhances the ability to extract deep information, reduces the loss of feature information, realizes the effective fusion of infrared image and visible light reference image features, and generates colorized output that takes into account both realism and naturalness.
Smart Images

Figure CN118429473B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of infrared image processing, and in particular to a feature information guided infrared image colorization method. Background Art
[0002] Color is an important auxiliary content for human cognition of the world. Although infrared imaging can capture information that is invisible to the human eye, its special imaging method leads to poor visual perception, so it is valuable to colorize it. The content in infrared images contains temperature information, while the content in color images contains brightness and chromaticity information, and the characteristics of the two are very different. The process of colorizing infrared images is to find the nonlinear mapping between the temperature information of infrared images and the brightness and chromaticity information of visible light reference images. It is necessary to ensure that the generated color image has both good visual effects and retains the information and characteristics of the original infrared image.
[0003] The Chinese patent publication number is "CN114067018A", and its name is "A method for colorizing infrared images based on dilated residual generative adversarial networks". This method first extracts shallow features from the input infrared image through two layers of convolution blocks; down-samples through three layers of convolution residual blocks, and then uses dilated convolution residual blocks to extract high-level features of the image while maintaining the receptive field unchanged; eliminates the grid effect through three layers of convolution; the upsampling process consists of adding two pixel reorganizations to three convolution blocks, and the last convolution block outputs the final chrominance image. The color overflow phenomenon of the infrared image colorized image obtained by this method is slightly serious, and the semantic information is relatively vague. The use of multiple residual blocks is prone to cause gradient disappearance, and it is difficult to learn the implicit mapping from infrared images to color images alone. Therefore, considering how to add auxiliary information to infrared image generation and overcome the above-mentioned defects is an urgent problem that technicians in this field need to solve. Summary of the invention
[0004] The technical solution of the present invention to solve the above technical problem is to provide a method for colorizing infrared images guided by feature information, comprising the following steps:
[0005] Build a network model: Build a generative adversarial network with a generator and a discriminator. The generator includes the feature extraction and feature fusion parts of the infrared image and the visible light reference image, and the color image generation part; the discriminator is used to identify whether the generated color image corresponds to the color output of the infrared image;
[0006] Prepare the data set: Use the KAIST data set as the first data set, divide it into a training set and a test set; and use a part of the visible light reference image as the reference image for colorization of the infrared image, wherein a part of the visible light reference image can select paired and unpaired visible light reference images for the infrared image; Use the FLIR data set as the second data set to fine-tune the model;
[0007] Training network model: input the prepared data set into the constructed network model for training;
[0008] Fine-tune the model: Use the second dataset to train and fine-tune the network model again to obtain the final model;
[0009] Save model: solidify the finalized model parameters and save the model.
[0010] Furthermore, the generator includes encoder one, encoder two, a decoder, a dense residual block, a multi-scale attention block, a feature encoding block and a feature fusion module.
[0011] Furthermore, the encoder 1 and encoder 2 adopt the same structure, including five convolution blocks, the encoder 1 is used to extract infrared image features, and the encoder 2 is used to extract visible light reference image features; convolution block 1, convolution block 2, convolution block 3, convolution block 4 and convolution block 5 have two convolution layers, perform downsampling operations, and use batch normalization and L-type activation functions; the decoder adopts the mirror operation of the encoder to perform upsampling operations to generate a color image of the same size as the original infrared image; the dense residual block is arranged after the convolution block 5 of the encoder 1 to enhance the network's ability to extract deep features.
[0012] Furthermore, the multi-scale attention block is in the connection between encoder 1 and decoder, including convolution block 1, convolution block 2, convolution block 3, perceptual attention module 1, perceptual attention module 2 and global average pooling block; convolution block 1 uses convolution, convolution block 2 uses convolution with a void rate of 2, and convolution block 3 uses convolution with a void rate of 4; convolution block 1 and global average pooling block are the minimum and maximum receptive fields, retaining the inherent properties of the features; the input of convolution block 2 is the output of convolution block 1, and the input of convolution block 3 is the output of convolution block 2; the structure of perceptual attention module 1 and perceptual attention module 2 is the same, and the input feature is multiplied by its own transposition after passing through the convolution layer and dimension adjustment, and then transposed and multiplied by the dimension-adjusted feature after softmax, and finally dimension adjustment is performed to generate the feature output of the original feature dimension.
[0013] Furthermore, the feature encoding block is used to adaptively average pool the features of each level of the image in encoder 1 and encoder 2, and adjust the size to , sent to the feature fusion module, Indicates the number of channels after pooling;
[0014] The feature fusion module includes two feature transfer blocks with the same structure. The input of feature transfer block 1 is the encoded infrared feature and the reference feature. The input of feature transfer block 2 is the concatenation of the input of feature transfer block 1 and the original infrared feature to obtain the self-attention feature. Batch normalization is used after the feature transfer block for faster convergence and more stable training process. Feature transfer block 1 and feature transfer block 2 have the same structure. Feature 1 is dimensionally adjusted after being input into the feature transfer block and is respectively input into the fully connected layer 1 and the fully connected layer 2 to generate a K feature matrix and a V feature matrix. Feature 2 is dimensionally adjusted after being input into the feature transfer block and is input into the fully connected layer 3 to generate a Q feature matrix. The Q feature matrix and the K feature matrix are inner-producted to form a new attention tensor matrix. After passing through the softmax layer, the result is multiplied with the V feature matrix and finally dimensionally adjusted to make it consistent with the input feature dimension to obtain the final attention feature result feature 3. The final fusion feature is formed after the obtained features are synthesized.
[0015] Furthermore, in the step of preparing the data set, the reference image is enhanced: the same image is subjected to a random diffraction transformation and cropped to the size of the input image as the network input.
[0016] Furthermore, in the step of training the network model, the loss function is a composite loss function, which is composed of adversarial loss, perceptual loss, total variation loss and contrast loss. When paired images are used as references for training, pixel loss and synthesis loss are introduced.
[0017] Furthermore, the step of training the network model also includes: evaluating the quality of the algorithm colorization result and the degree of image distortion through evaluation indicators.
[0018] In order to solve the above technical problems, the present invention also proposes a feature information guided infrared image colorization system, comprising:
[0019] Image loading module: used to load data sets, including infrared images to be colorized and visible light reference images as reference images;
[0020] Image processing module: used to process the data set into paired or unpaired form;
[0021] Feature extraction module: used to extract feature maps of different scales of infrared images and visible light reference images;
[0022] Feature fusion module: used to adaptively pool the feature maps of the infrared image and the visible light reference image, and fuse the features of the two through the self-attention mechanism;
[0023] Model training module: used to load the processed data set for training and obtain the final colorization model through iteration;
[0024] Image colorization module: used to input the infrared image and the visible light reference image into the model, and colorize the infrared image with the auxiliary information of the visible light reference image;
[0025] Storage medium: used to save the trained infrared image colorization system after the model training is completed.
[0026] Furthermore, the image processing module cuts the image into size, paired data sets were subjected to random diffraction transformation, and unpaired data sets were not subjected to subsequent processing;
[0027] The feature extraction module obtains a multi-scale feature map through five downsamplings, and each downsampling feature map size is reduced to 1 / 2 of the original size, and then an adaptive pooling operation is performed to input the feature fusion module;
[0028] The feature fusion module includes two feature transfer blocks, wherein the feature transfer block 1 forms a fusion feature by using a self-attention mechanism for the features of the infrared image and the visible light reference image, and the feature transfer block 2 is used for the self-attention mechanism for the fusion features;
[0029] The model training module is used to train the entire model. The number of training rounds for the generator and the discriminator is set to 200. The learning rate for the first 100 rounds is 0.0002, and gradually decreases to 0 for the next 100 rounds. The training is stopped when the model gradually learns to convergence.
[0030] After the image colorization module inputs the infrared image and the visible light reference image, it uses the visible light reference image as a reference image to generate a colorization result of the infrared image.
[0031] Compared with the prior art, the present invention has the following beneficial effects:
[0032] 1. The present invention utilizes the generative adversarial network structure and the game characteristics between the generator and the discriminator to improve the ability to extract deep information of the image, so as to enhance the realism and naturalness of the colorized image and dynamically improve the quality of the colorized image.
[0033] 2. The present invention designs a dual-channel convolutional network, the long-wave infrared branch extracts thermal features, and the visible light branch extracts color and texture features. Through cross-modal interactive connection, the attention mechanism is used to achieve the pairing of infrared image information and visible light reference image information, thereby achieving feature fusion.
[0034] 3. The present invention proposes a natural colorization scheme based on thermal features. In order to make the synthesized color image conform to the visual perception of the human eye, the features of the infrared image are reused, which not only participates in the feature fusion of the visible light reference image, but also participates in the color image generation of the encoder. This method achieves effective fusion while retaining the respective advantageous features of the infrared and visible light reference images, and generates a colorized infrared image output that takes into account both realism and naturalness.
[0035] 4. The present invention adds dense residual blocks and multi-scale attention blocks between encoder 1 and decoder to make the network more capable of extracting features from deep layers to shallow layers, reduce the feature information loss of feature maps, and enhance the network's detail recovery ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0037] Figure 1 It is a structural schematic diagram of the infrared image colorization method guided by feature information of the present invention;
[0038] Figure 2 A network structure diagram of the network model of the present invention;
[0039] Figure 3 Schematic diagram of the structure of the convolution block in the encoder 1 and the encoder 2 of the present invention;
[0040] Figure 4 Schematic diagram of the structure of the multi-scale attention block of the present invention;
[0041] Figure 5 It is a schematic diagram of the structure of the perception attention block in the multi-scale attention block of the present invention;
[0042] Figure 6 It is a structural schematic diagram of the feature fusion module of the present invention;
[0043] Figure 7 It is a structural schematic diagram of a feature transfer block in the feature fusion module of the present invention;
[0044] Figure 8 It is a structural schematic diagram of the network identifier of the present invention;
[0045] Fig. 9 A schematic diagram of the infrared image colorization system guided by feature information of the present invention;
[0046] Fig.10 This is a schematic diagram of the infrared image colorization device guided by the characteristic information described in the present invention. DETAILED DESCRIPTION
[0047] The present invention proposes a feature information-guided infrared image colorization method and system, aiming to design a feature information-guided infrared image colorization method.
[0048] The infrared image colorization method guided by feature information proposed by the present invention will be described in the following specific embodiments:
[0049] In the technical solution of this embodiment, Figure 1 As shown, a feature information-guided infrared image colorization method comprises the following steps:
[0050] Step 1: Build a network model: Build a generative adversarial network with a generator and a discriminator. The generator includes the feature extraction and feature fusion parts of the infrared image and the visible light reference image, and the color image generation part; the discriminator is used to identify whether the generated color image corresponds to the color output of the infrared image;
[0051] Step 2: Prepare the data set: Use the KAIST data set as the first data set, divide it into a training set and a test set; and use a part of the visible light reference image as the reference image for colorization of the infrared image, wherein a part of the visible light reference image can be selected as paired and unpaired visible light reference images for the infrared image; use the FLIR data set as the second data set to fine-tune the model;
[0052] Step 3: Train the network model: Input the prepared data set into the constructed network model for training;
[0053] Step 4: Fine-tune the model: Use the second dataset to retrain and fine-tune the network model to obtain the final model;
[0054] Step 5: Save the model: Solidify the finalized model parameters and save the model.
[0055] It can be understood that after the infrared image and the visible light reference image are input into the network model, a color image corresponding to the infrared image can be output.
[0056] Furthermore, the generator includes encoder one, encoder two, a decoder, a dense residual block, a multi-scale attention block, a feature encoding block and a feature fusion module.
[0057] Furthermore, the encoder 1 and encoder 2 adopt the same structure, including five convolution blocks, the encoder 1 is used to extract infrared image features, and the encoder 2 is used to extract visible light reference image features; convolution block 1, convolution block 2, convolution block 3, convolution block 4 and convolution block 5 have two convolution layers, perform downsampling operations, and use batch normalization and L-type activation functions; the decoder adopts the mirror operation of the encoder to perform upsampling operations to generate a color image of the same size as the original infrared image; the dense residual block is arranged after the convolution block 5 of the encoder 1 to enhance the network's ability to extract deep features.
[0058] Furthermore, the multi-scale attention block is in the connection between encoder 1 and decoder, including convolution block 1, convolution block 2, convolution block 3, perceptual attention module 1, perceptual attention module 2 and global average pooling block; convolution block 1 uses convolution, convolution block 2 uses convolution with a void rate of 2, and convolution block 3 uses convolution with a void rate of 4; convolution block 1 and global average pooling block are the minimum and maximum receptive fields, retaining the inherent properties of the features; the input of convolution block 2 is the output of convolution block 1, and the input of convolution block 3 is the output of convolution block 2; the structure of perceptual attention module 1 and perceptual attention module 2 is the same, and the input feature is multiplied by its own transposition after passing through the convolution layer and dimension adjustment, and then transposed and multiplied by the dimension-adjusted feature after softmax, and finally dimension adjustment is performed to generate the feature output of the original feature dimension.
[0059] Furthermore, the feature encoding block is used to adaptively average pool the features of each level of the image in encoder 1 and encoder 2, and adjust the size to , sent to the feature fusion module, Indicates the number of channels after pooling;
[0060] The feature fusion module includes two feature transfer blocks with the same structure. The input of feature transfer block 1 is the encoded infrared feature and the reference feature. The input of feature transfer block 2 is the concatenation of the input of feature transfer block 1 and the original infrared feature to obtain the self-attention feature. Batch normalization is used after the feature transfer block for faster convergence and more stable training process. Feature transfer block 1 and feature transfer block 2 have the same structure. Feature 1 is dimensionally adjusted after being input into the feature transfer block and is respectively input into the fully connected layer 1 and the fully connected layer 2 to generate a K feature matrix and a V feature matrix. Feature 2 is dimensionally adjusted after being input into the feature transfer block and is input into the fully connected layer 3 to generate a Q feature matrix. The Q feature matrix and the K feature matrix are inner-producted to form a new attention tensor matrix. After passing through the softmax layer, the result is multiplied with the V feature matrix and finally dimensionally adjusted to make it consistent with the input feature dimension to obtain the final attention feature result feature 3. The final fusion feature is formed after the obtained features are synthesized.
[0061] Furthermore, the paired reference image dataset requires image enhancement, random diffraction transformation of the same image, and cropping it to the size of the input image as network input.
[0062] It can be understood that random diffraction transformation is the process of paired images simulating unpaired images. Proper deformation of paired images can reduce the risk of network overfitting.
[0063] Furthermore, in the step of training the network model, the loss function is a composite loss function, which is composed of adversarial loss, perceptual loss, total variation loss and contrast loss. When paired images are used as references for training, pixel loss and synthesis loss are introduced.
[0064] Understandably, the design of the loss function affects the quality of the model and can correctly feedback the quality of the model.
[0065] Furthermore, the step of training the network model also includes: evaluating the quality of the algorithm colorization result and the degree of image distortion through evaluation indicators.
[0066] To solve the above technical problems, the present invention also proposes a feature information guided infrared image colorization system, such as Fig. 9 As shown, including:
[0067] Image loading module: used to load data sets, including infrared images to be colorized and visible light reference images as reference images;
[0068] Image processing module: used to process the data set into paired or unpaired form;
[0069] Feature extraction module: used to extract feature maps of different scales of infrared images and visible light reference images;
[0070] Feature fusion module: used to adaptively pool the feature maps of the infrared image and the visible light reference image, and fuse the features of the two through the self-attention mechanism;
[0071] Model training module: used to load the processed data set for training and obtain the final colorization model through iteration;
[0072] Image colorization module: used to input the infrared image and the visible light reference image into the model, and colorize the infrared image with the auxiliary information of the visible light reference image;
[0073] Storage medium: used to save the trained infrared image colorization system after the model training is completed.
[0074] Furthermore, the image processing module cuts the image into size, paired data sets were subjected to random diffraction transformation, and unpaired data sets were not subjected to subsequent processing;
[0075] The feature extraction module obtains a multi-scale feature map through five downsamplings, each time the size of the feature map is reduced to 1 / 2 of the original size, and then an adaptive pooling operation is performed to input the feature fusion module;
[0076] The feature fusion module includes two feature transfer blocks, wherein the feature transfer block 1 forms a fusion feature by using a self-attention mechanism for the features of the infrared image and the visible light reference image, and the feature transfer block 2 is used for the self-attention mechanism for the fusion features;
[0077] The model training module is used to train the entire model. The number of training rounds for the generator and the discriminator is set to 200. The learning rate for the first 100 rounds is 0.0002, and gradually decreases to 0 for the next 100 rounds. The training is stopped when the model gradually learns to convergence.
[0078] After the image colorization module inputs the infrared image and the visible light reference image, it uses the visible light reference image as a reference image to generate a colorization result of the infrared image.
[0079] Embodiment 1: A method for colorizing an infrared image guided by feature information of a paired image, such as Figure 1 As shown, the following steps are included:
[0080] Step 1: Build a network model: Generate an adversarial network. The adversarial network includes a generator and a discriminator.
[0081] Among them, Figure 2 As shown in the figure, the generator includes encoder 1, encoder 2, decoder, dense residual block, multi-scale attention block, feature encoding block and feature fusion module. Encoder 1 and encoder 2 have the same structure, and each encoder contains five convolution blocks. Encoder 1 is used to extract the features of infrared images, while encoder 2 is used to extract the features of visible light reference images. Each convolution block consists of two convolution layers and performs downsampling operations while applying batch normalization and L-type activation functions. The decoder performs upsampling operations in the opposite way to the encoder to generate a color image with the same size as the original infrared image. A dense residual block is set after the fifth convolution block of encoder 1 to enhance the network's ability to extract deep features.
[0082] In the connection between encoder 1 and decoder, a multi-scale attention block is used. The multi-scale attention block consists of convolution block 1, convolution block 2, convolution block 3, perceptual attention module 1, perceptual attention module 2, and global average pooling block. Convolution block 1 uses standard convolution operation, convolution block 2 uses convolution with a dilation rate of 2, and convolution block 3 uses convolution with a dilation rate of 4. Convolution block 1 and global average pooling block represent the minimum and maximum receptive fields, respectively, to preserve the inherent properties of the features. The input of convolution block 2 needs to integrate the output of convolution block 1, and the input of convolution block 3 needs to integrate the output of convolution block 2.
[0083] Perceptual attention module 1 and perceptual attention module 2 have the same structure. After the input feature passes through the convolution layer and dimension adjustment, it is multiplied by its own transpose, and then multiplied by the dimension-adjusted feature after the softmax operation. Finally, the dimension adjustment is performed to generate the feature output of the original feature dimension.
[0084] The feature encoding block is used for adaptive average pooling to resize the image features at all levels in encoder 1 and encoder 2 so as to facilitate feeding into the feature fusion module.
[0085] The feature fusion module consists of two feature transfer blocks with the same structure. The input of feature transfer block 1 includes the encoded infrared features and reference features. The input of feature transfer block 2 includes the concatenation of the input of feature transfer block 1 and the original infrared features to generate self-attention features. Batch normalization is applied after the feature transfer block to promote faster convergence and a more stable training process. Feature transfer block 1 and feature transfer block 2 have the same structure. Feature 1 is dimensionally adjusted after passing through the feature transfer block and input into fully connected layer 1 and fully connected layer 2 respectively to generate K feature matrix and V feature matrix. Feature 2 is dimensionally adjusted after passing through the feature transfer block and input into fully connected layer 3 to generate Q feature matrix. The Q feature matrix and the K feature matrix are inner-producted to form a new attention tensor matrix, which is processed by the softmax layer and multiplied with the V feature matrix. Finally, the dimension is adjusted to make it consistent with the dimension of the input feature to obtain the final attention feature (feature 3). The synthesized features form the final fusion feature.
[0086] Step 2, prepare the dataset: train the network with the first dataset. When using the KAIST dataset as the first dataset, the training set and the test set are divided. In addition, a part of the visible light reference images needs to be selected as reference images for colorization of infrared images. These reference images are visible light reference images that are not paired with infrared images; use the FLIR dataset to fine-tune the model for the second dataset.
[0087] Step 3, training the network model: train the infrared image colorization model, preprocess the data set prepared in step 2, adjust the size of each image in the data set, fix the size of the input image, and input the processed data set into the network model constructed in step 1 for training.
[0088] During the training process, the loss function value to be minimized and the optimal evaluation index are selected. Specifically, 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 the model parameters are 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 is selected to use a composite loss function, the generator uses adversarial loss, perceptual loss and contrast 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; the peak signal-to-noise ratio and structural similarity are selected as appropriate evaluation indicators, 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.
[0089] Step 4, fine-tuning the model: Use the second data set to train and fine-tune the model to obtain stable and usable model parameters, further improving the model's infrared image colorization capability. Ultimately, the model has a better effect on image colorization. The FLIR data set is used in the process of fine-tuning the model parameters.
[0090] Step 5, save the model: solidify the finalized model parameters and save the model. After the model inputs the infrared image and the visible light reference image, it can output a color image corresponding to the infrared image.
[0091] Embodiment 2: A method for colorizing an infrared image guided by feature information, such as Figure 1 As shown, the following steps are included:
[0092] Step 1: Build a network model: Generate an adversarial network. The adversarial network includes a generator and a discriminator.
[0093] like Figure 2 As shown in the figure, the generator includes encoder 1, encoder 2, decoder, dense residual block, multi-scale attention block, feature encoding block and feature fusion module. In the feature encoding process, encoder 1 and encoder 2 are first used to extract features of the input image. The two encoders have the same structure, and each encoder consists of five convolution blocks. Encoder 1 is responsible for extracting the features of the infrared image, while encoder 2 is responsible for extracting the features of the visible light reference image.
[0094] The structural diagram of the convolutional block in encoder 1 and encoder 2 is as follows Figure 3As shown in the figure; it contains two convolutional layers, and uses batch normalization and L-type activation function in the downsampling operation. These convolution blocks are able to capture different levels of features of the input image. Next, the decoder performs upsampling through the inverse operation to generate a color image with the same size as the original infrared image. After the fifth convolution block of encoder one, a dense residual block is introduced. The role of this residual block is to enhance the network's ability to extract deep features and further improve the feature representation and reconstruction quality of the image. Through such a feature encoding process, we can effectively extract and fuse the features of the infrared image and the visible light reference image, providing valuable information for the subsequent colorization process.
[0095] Multi-scale attention block structure, such as Figure 4 As shown in Figure 1, the multi-scale attention block connects the encoder 1 and the decoder, including convolution block 1, convolution block 2, convolution block 3, perceptual attention module 1, perceptual attention module 2, and global average pooling block. The convolution blocks use different convolution operations, and convolution block 1 and global average pooling block retain basic features. Convolution block 2 and convolution block 3 need to integrate the output of the previous block. The perceptual attention module has the same structure, as shown in Figure 1. Figure 5 It accepts input features, performs self-attention operations, and finally generates output features.
[0096] The feature encoding block adaptively averages the image features of encoder 1 and encoder 2 and sends them to the feature fusion module after resizing, including two feature transfer blocks with the same structure (feature transfer block 1 and feature transfer block 2).
[0097] The structures of the feature fusion module and feature transfer block are as follows: Figure 6 and Figure 7 As shown in the figure, feature transfer block 1 receives the encoded infrared and reference features, and feature transfer block 2 receives the connection between feature transfer block 1 and the original infrared features to generate self-attention features. Subsequent batch normalization helps convergence and stability. Feature 1 is dimensionally adjusted and operated in the fully connected layer to generate K and V feature matrices. Feature 2 is dimensionally adjusted and input to the fully connected layer 3 to generate the Q feature matrix. The inner product of the Q and K feature matrices generates the attention tensor matrix, which is multiplied with the V feature matrix after softmax processing. The final dimension is adjusted to obtain the attention feature, which is integrated to form the fusion feature.
[0098] The fused features are fed into the dense residual block of the encoder and then into the encoder to participate in the colorization process. The original features in the encoder are connected to each layer of the decoder through a multi-scale attention block, which preserves the infrared image features while taking into account the color and semantic details of the visible light reference image. The encoder is activated with a T-type function.
[0099] The structure of the discriminator is as follows Figure 8As shown in Figure 1, it consists of five convolutional layers, a normalization layer, an L-type function, and an S-type function. Convolutional layer 1, convolutional layer 2, convolutional layer 3, convolutional block 4, and convolutional layer 5 are standard convolutions, and the convolution kernel size is , the step size is 1; 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.
[0100] In general, the feature information-guided colorization process is to input the infrared image and the visible light reference image, perform feature extraction at each level of downsampling, and send it to the feature extraction module to obtain the fused feature. This fused feature is used to colorize the infrared image. In order to retain the features of the original infrared image, it is reused and a color image is generated after five layers of convolution blocks. The generated color image is then sent to the discriminator.
[0101] In order to ensure the robustness of the network, retain more structural information, and fully extract image features, this embodiment uses three activation functions, namely T-type function, L-type function and S-type function. The activation functions in the discriminator are L-type function and S-type function, the last layer of the generator is T-type function, and the others are L-type functions. The definitions of T-type function, L-type function and S-type function are as follows: ; ; ; 1 / a represents the slope, a is set to 100, that is, the slope is 0.01. Step 2, prepare the data set, train the network with the image data set, and the image data set uses the KAIST pedestrian road data set. Take the selected 2875 pictures, the scene entities of which include roads, buildings, traffic lights, pedestrians, trees, cars, sky, etc. Among the 2875 pictures in the data set, select 2500 for training, and pair the reference image with the infrared image. Resize these 2500 images to The paired reference image dataset requires image enhancement, random diffraction transformation of the same image, and cropping it to the size of the input image as the input of the network.
[0102] Step 3: Train the network model. Input the processed image dataset into the network model built in step 1 for training. The network output calculates the loss function, and achieves a better colorization effect by minimizing the loss function. During the training process, the loss function uses a composite loss function. The generator uses adversarial loss, pixel loss, perceptual loss, total variation loss, and synthetic loss, and the discriminator uses adversarial loss.
[0103] The adversarial loss is used to generate color images that are more similar to the real RGB images and is defined as: ; E represents the mathematical expectation, and the pixel loss is used to make the generated color image consistent with the corresponding real RGB image in global chromaticity and brightness, which is defined as: in and Represents the height and width of the image respectively, represents the L1 norm, represents the pixels of the image generated by the generator, represents the pixels of the real image, and Represents an index.
[0104] In order to avoid the loss of high-level semantic information of the image, a perceptual loss based on the pre-trained VGG-19 network is proposed, which is defined as: ; k represents the kth layer of the network, C represents the number of channels, H represents the height, and W represents the width. Represents the features of the real image y at the kth layer in the loss network; Represents the features of the generated image x at the kth layer in the loss network,
[0105] The total variation loss is used to enhance the spatial smoothness of the color image and is defined as: ; , Represents the horizontal gradient and vertical gradient operations respectively; the contrast loss makes the encoder focus on the common parts between the two domains, such as shape, and ignores the differences between the two domains, such as texture. The contrast loss design of this method selects the encoder downsampling part Layer feature map, pass it through a 2-layer MLP network A series of characteristics are generated ,in Indicates Layer output features. Sequence , ,in Indicates Layer The corresponding feature is recorded as , and other features are marked as ,in is the number of channels per layer. Similarly, the output image Also coded as The goal is to match the image blocks at the corresponding positions of the input and output, and the image blocks at other positions of the same image are used as negative samples, which are defined as: ; It represents the mathematical expectation when the sample comes from X. represents the calculation of cross entropy loss,
[0106] The synthesis loss calculates the L1 distance between the true value and the generated color image, which is defined as: ;in represents the true value, i.e., the visible light reference image, represents the image after the infrared image is colored. The total loss is defined as: ; , , and Respectively represent the weights of each loss, and the weight values are determined by preliminary experimental results.
[0107] The loss function of the discriminator is: ;in, represents the mathematical expectation when the sample belongs to the true value, Indicates that when the sample belongs to the mathematical expectation of the generated image, it means True value, Represents the color image generated by the generator. In step 3, the evaluation indicators are peak signal-to-noise ratio, structural similarity and FID (Fréchet Inception Distance). The peak signal-to-noise ratio (PSNR) is an image quality evaluation indicator based on pixel-level error. It is sensitive to errors and is used to measure the quality difference between images. The structural similarity (SSIM) is an indicator that comprehensively considers brightness, contrast and structure to measure the similarity between two digital images. FID is an indicator used to evaluate the quality of images generated by a generative model, combining image quality and diversity metrics. The FID indicator measures the similarity between generated data and real data by calculating the distribution distance between real data and generated data in the feature space of the intermediate layer of the pre-trained convolutional neural network. SSIM aims to evaluate the similarity of images, PSNR is mainly used to measure errors, and a smaller FID value indicates that the image generated by the generative model has higher quality and better diversity. The definitions of the three are as follows: ; ; ;in, Represents the square of the Fréchet distance between the true data distribution and the generative model. and Represents the mean vector of the true data distribution and the generative model. and Represents the covariance matrix of the real data distribution and the generated model. By calculating the mean covariance matrix of the two distributions and calculating the Fréchet distance between them, the FID value can be obtained. The smaller the FID value, the closer the generated image is to the real data distribution. represents the trace of the matrix, ||·|| represents the bi-norm of the matrix, , Represents images and The mean and variance of and Represent the standard deviations of images and respectively, Representing images and The covariance of and is a constant, and The true distribution and generate distribution The parameters of the multidimensional Gaussian distribution.
[0108] This embodiment sets 200 rounds of training, with a learning rate of 0.0002 for the first 100 rounds and gradually decreasing to 0 for the next 100 rounds. The number of images input to the network each time is affected by the performance of the computer's graphics processor, usually between 8 and 16, which helps stabilize the training and improve the quality of the results, ensuring that the network can quickly adapt to the data. We choose the Adam optimizer as the network parameter optimizer because it is simple to use, computationally efficient, has low memory requirements, and can stabilize parameter updates without being affected by gradient scaling. When the discriminator cannot easily judge the images generated by the generator, and the generator is not easily distinguished by the discriminator, we believe that the basic training of the network has been completed.
[0109] Step 4: Fine-tune the model. Use the FLIR dataset to train and fine-tune the model to further improve the model's infrared image colorization capabilities.
[0110] Step 5: After the network training is completed, save the model.
[0111] When the network is used again, there is no need to retrain it. The colorized image can be obtained by directly inputting the infrared image and the visible light reference image.
[0112] The present invention constructs a feature information guided infrared image colorization method, which can generate a colorized image with the participation of a reference image. By calculating the relevant indexes of the image obtained by the existing method, the feasibility and superiority of the method are further verified. The comparison of the relevant indexes of the prior art (patent number CN114067018A) and the method proposed by the present invention is shown in Table 1: Table 1
[0113] method Peak signal-to-noise ratio Structural similarity FID Existing methods 28.163 0.412 80.695 This method 28.593 0.473 50.245
[0114] As can be seen from the table, the method proposed in the present invention has a higher peak signal-to-noise ratio and structural similarity than the existing method, and the FID index also performs better. These indicators further illustrate that the method proposed in the present invention has better colorization quality.
[0115] Embodiment 3: A feature information guided infrared image colorization device, such as Fig.10 As shown. Includes:
[0116] Memory: used to store the engineering code of the proposed method, save the weight files of the generator and discriminator, and save the staged evaluation image effects during the training process;
[0117] Processor: The processor calls the engineering code of the present invention stored in the memory to execute the infrared image colorization method guided by the feature information of the present invention.
[0118] Furthermore, the memory is composed of a control unit and a storage unit, and its storage content will not be lost even if the power is cut off. When the program is running, it exchanges data with the processor through the memory;
[0119] Further, the memory is used to call out executable code and data sets, etc. from the storage, and store training files in the storage;
[0120] Furthermore, the processor is divided into a central processing unit (CPU) and a graphics processing unit (GPU), which establish communication with the storage through the memory. After the CPU loads the data set, it sends the model to the GPU through the bus for calculation;
[0121] Furthermore, the bus enables communication between system components.
[0122] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A feature information guided infrared image colorization method, characterized in that: The following steps are involved: Build a network model: Build a generative adversarial network with a generator and a discriminator. The generator includes the feature extraction and feature fusion parts of the infrared image and the visible light reference image, and the color image generation part; the discriminator is used to identify whether the generated color image corresponds to the color output of the infrared image; Prepare the data set: Use the KAIST data set as the first data set and divide it into a training set and a test set; and using a portion of the visible light reference image as a reference image for colorization of the infrared image, wherein the portion of the visible light reference image may be a paired or unpaired visible light reference image for the infrared image; Fine-tune the model for the second dataset using the FLIR dataset; Training network model: input the prepared data set into the constructed network model for training; Fine-tune the model: Use the second dataset to retrain and fine-tune the network model to obtain the final model; Save model: solidify the finalized model parameters and save the model; The generator includes encoder 1, encoder 2, decoder, dense residual block, multi-scale attention block, feature encoding block and feature fusion module; In the step of constructing the network model, the encoder 1 and the encoder 2 adopt the same structure and include five convolution blocks. The encoder 1 is used to extract infrared image features, and the encoder 2 is used to extract visible light reference image features. Convolution block 1, convolution block 2, convolution block 3, convolution block 4 and convolution block 5 have two convolution layers, perform downsampling operations, and use batch normalization and L-type activation functions. The decoder uses the mirror operation of the encoder to perform upsampling operations to generate a color image of the same size as the original infrared image. The dense residual block is arranged after the convolution block 5 of the encoder 1 to enhance the network's ability to extract deep features.
2. The feature information guided infrared image colorization method according to claim 1, characterized in that: The multi-scale attention block is in the connection between encoder 1 and decoder, including convolution block 1, convolution block 2, convolution block 3, perceptual attention module 1, perceptual attention module 2 and global average pooling block; convolution block 1 uses convolution, convolution block 2 uses convolution with a void rate of 2, and convolution block 3 uses convolution with a void rate of 4; convolution block 1 and global average pooling block are the minimum and maximum receptive fields, retaining the inherent properties of the features; the input of convolution block 2 is the output of convolution block 1, and the input of convolution block 3 is the output of convolution block 2; the structure of perceptual attention module 1 and perceptual attention module 2 is the same, and the input feature is multiplied by its own transposition after passing through the convolution layer and dimension adjustment, and then transposed and multiplied by the dimension-adjusted feature after softmax, and finally dimension adjustment is performed to generate feature output of the original feature dimension.
3. The feature information guided infrared image colorization method according to claim 1, characterized in that: The feature encoding block is used to perform adaptive average pooling on the features of each level of the image in encoder 1 and encoder 2, and the size is adjusted to , sent to the feature fusion module, Indicates the number of channels after pooling; The feature fusion module includes two feature transfer blocks with the same structure, and the input of the feature transfer block 1 is the encoded infrared feature and the reference feature; The input of feature transfer block 2 is the concatenation of the input of feature transfer block 1 and the original infrared feature to obtain the self-attention feature; Batch normalization is used after the feature transfer block for faster convergence and a more stable training process; Feature transfer block 1 and feature transfer block 2 have the same structure. Feature 1 is input into the feature transfer block and then dimensionally adjusted, and then input into fully connected layer 1 and fully connected layer 2, respectively, to generate K feature matrix and V feature matrix; Feature 2 is input into the feature transfer block and then dimensionally adjusted, and then input into fully connected layer 3, to generate Q feature matrix; The Q feature matrix and the K feature matrix perform inner product operations to form a new attention tensor matrix. After passing through the softmax layer, the result is multiplied with the V feature matrix, and finally the dimension is adjusted to be consistent with the input feature dimension to obtain the final attention feature result feature three; the obtained features are combined to form the final fusion feature.
4. The feature information guided infrared image colorization method according to claim 1, characterized in that: In the step of preparing the data set, the reference image is enhanced: the same image is subjected to a random diffraction transformation and cropped to the size of the input image as the network input.
5. The feature information guided infrared image colorization method according to claim 1, characterized in that: In the step of training the network model, the loss function is a composite loss function, which is composed of adversarial loss, perceptual loss, total variation loss and contrast loss; when paired images are used as references for training, pixel loss and synthesis loss are introduced.
6. The method for colorizing infrared images guided by feature information according to claim 1, characterized in that: The step of training the network model also includes: evaluating the quality of the algorithm colorization result and the degree of image distortion through evaluation indicators.
7. A feature information guided infrared image colorization system, used to implement the feature information guided infrared image colorization method according to any one of claims 1 to 6, characterized in that: include: Image loading module: used to load data sets, including infrared images to be colorized and visible light reference images as reference images; Image processing module: used to process the data set into paired or unpaired form; Feature extraction module: used to extract feature maps of different scales of infrared images and visible light reference images; Feature fusion module: used to adaptively pool the feature maps of the infrared image and the visible light reference image, and fuse the features of the two through the self-attention mechanism; Model training module: used to load the processed data set for training and obtain the final colorization model through iteration; Image colorization module: used to input the infrared image and the visible light reference image into the model, and colorize the infrared image with the auxiliary information of the visible light reference image; Storage medium: used to save the trained infrared image colorization system after the model training is completed.
8. The feature information guided infrared image colorization system according to claim 7, characterized in that: The image processing module cuts the image into size, paired data sets were subjected to random diffraction transformation, and unpaired data sets were not subjected to subsequent processing; The feature extraction module obtains a multi-scale feature map through five downsamplings, and each downsampling feature map size is reduced to 1 / 2 of the original size, and then an adaptive pooling operation is performed to input the feature fusion module; The feature fusion module includes two feature transfer blocks, wherein the feature transfer block 1 forms a fusion feature by using a self-attention mechanism for the features of the infrared image and the visible light reference image, and the feature transfer block 2 is used for the self-attention mechanism for the fusion features; The model training module is used to train the entire model, and the number of training rounds for the generator and the discriminator is set to 200; After the image colorization module inputs the infrared image and the visible light reference image, it uses the visible light reference image as a reference image to generate a colorization result of the infrared image.
