Image splicing method and device based on homography estimation
Through the image splicing method based on homography estimation, a fast image registration and splicing repair network is constructed, which solves the problem of insufficient timeliness of image splicing in the existing technology, achieves efficient and accurate image splicing, and is suitable for real-time processing scenarios.
Patent Information
- Application Number
- CN202410756551.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-08-27
AI Technical Summary
It is difficult for the existing technology to meet the real-time processing requirements while ensuring accuracy and visual effects in image stitching. In particular, it is error-prone and consumes a lot of computing resources when processing image data in large-scale or complex environments.
An image splicing method based on homography estimation is adopted. By constructing a fast image registration network and a splicing repair network, the feature extraction module and the homography estimation module are used to calculate the homography matrix between images, and the splicing domain transformer is used for preprocessing. Align the deformation, and finally perform splicing and repair processing in the splicing repair network, optimizing the network structure and loss function to reduce computing resource requirements.
It significantly improves the speed and accuracy of image processing, reduces the demand for computing resources, enhances the system's robustness and ability to handle image distortion and noise, and is suitable for real-time splicing applications.
Smart Images

Figure CN118552402A
Abstract
Description
Technical Field
[0001] The present application relates to an image stitching method and device based on homography estimation, belonging to the technical field of computer vision. Background Art
[0002] Image stitching technology is an important computer vision application. It combines multiple local image fragments into a continuous and wide panoramic image through effective image registration and seamless fusion technology. This technology is widely used in many fields, including but not limited to virtual reality, monitoring, medical imaging, and map making. In traditional image stitching technology, it usually relies on feature matching and image transformation algorithms, such as SIFT and SURF, to identify corresponding points between multiple images and calculate the geometric transformation between them.
[0003] However, these methods are often computationally intensive and prone to errors when processing image data in large-scale or complex environments. With the development of deep learning, researchers have proposed many deep learning-based image stitching methods. These methods use the powerful learning ability of neural networks to effectively handle image feature extraction and alignment, significantly improving stitching accuracy. In particular, deep learning methods can learn more complex image content and structural changes through training, thereby providing a more seamless and natural stitching effect visually. Although deep learning-based methods have obvious advantages in accuracy and visual effects, these methods usually involve complex network structures and a large number of parameters, resulting in high consumption of computing resources and slow processing speed. These limitations make deep learning methods difficult to apply to application scenarios that require real-time processing, such as real-time video surveillance analysis and real-time virtual reality content generation.
[0004] Therefore, the main problem existing in the prior art is how to ensure the image stitching accuracy and visual effect while meeting the needs of real-time processing. Summary of the invention
[0005] Purpose: In view of at least one of the above technical problems, the present application provides an image stitching method and device based on homography estimation, which improves the speed and efficiency of image stitching while ensuring the accuracy and visual continuity of the stitching results, and is particularly suitable for application scenarios that require real-time processing.
[0006] The technical solution adopted in this application is:
[0007] In a first aspect, the present application provides an image stitching method, comprising:
[0008] Acquire a pair of images to be stitched, wherein the pair of images to be stitched includes a first image and a second image;
[0009] Inputting the image pair to be spliced into an image registration network, wherein the image registration network includes a feature extraction module and a homography estimation module, extracting a multi-scale feature map of the image pair from the image pair to be spliced by the feature extraction module; and analyzing the multi-scale feature map of the image pair by the homography estimation module to generate a homography matrix representing the mapping relationship between the image pairs;
[0010] Based on the homography matrix, using a stitching domain transformer to pre-align and deform the image pair to be stitched to obtain a deformed image pair;
[0011] The deformed image pair is input into the stitching and restoration network for stitching and restoration to obtain a stitched image.
[0012] In a second aspect, the present application provides an image stitching device, including a processor and a storage medium;
[0013] The storage medium is used to store instructions;
[0014] The processor is configured to operate according to the instructions to execute the method according to the first aspect.
[0015] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method described in the first aspect.
[0016] In a fourth aspect, the present application provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described in the first aspect when executing the computer program.
[0017] In a fifth aspect, the present application provides a computer program product, comprising a computer program, which implements the steps of the method described in the first aspect when executed by a processor.
[0018] Beneficial effects: The image stitching method and device based on homography estimation provided by the present application solve the timeliness shortcomings of the traditional image stitching method based on deep learning. The method constructs two core models, a fast image registration network and a fast stitching repair network, to ensure the speed, accuracy and robustness of the stitching process. The fast image registration network is responsible for calculating the transformation relationship between the input image pairs and deforming the input image pairs through the stitching domain transformer. In the feature extraction module, a feature fusion strategy is introduced to extract feature maps of different scales through the feature pyramid and estimate the homography matrix from high to low layers. In order to cope with the distortion problem of the input image, the module also integrates a deformable convolution module to expand the perception domain of the model and enhance its adaptability. In addition, the present application also designs a new loss function for the image registration process, optimizes the process of calculating the content difference between pixels using masks, and focuses on the edge content of the image, which significantly improves the efficiency and quality of image registration. The fast stitching repair network is used to stitch the pre-aligned image pairs together and repair problems such as seams and artifacts generated after stitching. By optimizing the network structure and reducing the model parameters, the network meets the needs of real-time stitching applications and provides an efficient and practical technical means for image synthesis, display and analysis of a wide field of view. Specifically, it has at least the following advantages: (1) The application significantly improves the speed of image processing by optimizing the image registration network and the stitching and repair network.
[0019] (2) By simplifying the network structure and optimizing the computing process, this application reduces the demand for computing resources.
[0020] (3) This application adopts an unsupervised learning method, which reduces the reliance on a large amount of labeled training data and reduces the cost of model training.
[0021] (4) Through the integrated deformable convolution module and the carefully designed loss function, this application significantly improves the accuracy of image registration and the visual continuity of stitching.
[0022] (5) The present application can effectively process image data from different sources and with complex changes, including images with different lighting conditions, different dynamic ranges, and different viewing angles.
[0023] (6) By utilizing a new loss function and an optimized network structure, this application improves the ability to handle image distortion, noise, and other common problems, and enhances the robustness of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 is a schematic diagram of an image stitching method based on homography estimation according to an embodiment of the present application;
[0025] Figure 2 A schematic diagram of the structure of an image registration network according to an embodiment of the present application;
[0026] Figure 3 is a structural diagram of a regression network in a homography estimation module according to an embodiment of the present application;
[0027] Figure 4 1 is an overall structural diagram of a splicing repair network according to an embodiment of the present application. DETAILED DESCRIPTION
[0028] The present application is further described below in conjunction with the accompanying drawings and embodiments. The following embodiments are only used to more clearly illustrate the technical solution of the present application, and cannot be used to limit the protection scope of the present application.
[0029] In the description of this application, "several" means more than one, "more" means more than two, "greater than", "less than", "exceed", etc. are understood to exclude the number itself, and "above", "below", "within", etc. are understood to include the number itself. If there is a description of "first" or "second", it is only used for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0030] In the description of the present application, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0031] This application proposes a fast unsupervised image stitching method based on homography estimation. This method pays special attention to improving the speed and efficiency of image stitching, while ensuring the accuracy and visual continuity of the stitching results, and is particularly suitable for application scenarios that require real-time processing. To this end, this application adopts a three-part network model, namely an image registration network, a stitching domain transformer, and a stitching repair network. Among them, the image registration network uses a feature extraction module and a homography estimation module, and at the same time combines the loss function of the edge content to focus on comparing the content differences in the overlapping areas, and calculates the homography matrix representing the positional relationship between the input image pairs. Then, the input image pairs are deformed based on the calculated homography matrix through the stitching domain transformer. Finally, the deformed image pairs are stitched together using the stitching repair network, while processing the seams and artifacts generated when the images are not fully aligned, to achieve seamless stitching.
[0032] Embodiment 1: This embodiment provides an image stitching method, such as Figure 1 As shown, including:
[0033] Step S1: Acquire a pair of images to be stitched, wherein the pair of images to be stitched includes a first image and a second image.
[0034] Step S2: input the image pair to be stitched into an image registration network, wherein the image registration network includes a feature extraction module and a homography estimation module, and extracts a multi-scale feature map of the image pair by using the feature extraction module; and analyzes the multi-scale feature map of the image pair by using the homography estimation module to generate a homography matrix representing the mapping relationship between the image pairs.
[0035] In this step, the two input images (the first image and the second image) are extracted using a feature extraction module with different scale feature maps (i.e. and ) to construct a feature pyramid. Then the homography matrix is estimated from high-level to low-level. This is because high-level features usually contain more abstract and global information, while low-level features focus more on local details. The estimation strategy from high-level to low-level can first use global information to make a rough estimate of the homography, and then use low-level features to make fine adjustments, thereby obtaining a more accurate homography matrix.
[0036] like Figure 2 As shown, it is the overall structure diagram of the image registration network in the embodiment of the present application.
[0037] Specifically, in the feature extraction module, the image pair to be spliced is processed by the Focus module to obtain a first scale feature map, then processed by the first deformable convolution module DCM and the C3 module to obtain a second scale feature map, and then processed by the second deformable convolution module DCM and the C3 module to obtain a third scale feature map.
[0038] Furthermore, the first deformable convolution module DCM and the second deformable convolution module DCM in the feature extraction module are used to expand the perception domain to improve the adaptability of the network to image deformation;
[0039]
[0040] Among them, x is the input feature map of the deformable convolution module, w is the convolution kernel, p is the output position of the convolution operation, and p n Then it represents the relative position in the convolution kernel w; for a deformable convolution operation with a resolution of k×k, the input feature map first passes through a convolution operation to generate a k×k×3 mask map, and this mask map is decomposed into an offset vector ΔP and a weight mask ΔM;
[0041] For each position in the input feature map, the offset vector ΔP is used to offset it to obtain a new position; at the same time, the weight mask ΔM is constrained between [0,1] by the Sigmoid function, providing a different weight value for the convolution point at each position, thereby providing greater freedom for sampling.
[0042] The first image and the second image are respectively processed by the feature extraction module to obtain a multi-scale feature map of the image pair, specifically including a first scale feature map of the first image Second scale feature map The third scale feature map and the first scale feature map of the second image Second scale feature map And the third scale feature map
[0043] After obtaining feature maps of different scales, the homography estimation module uses a Concat operation to merge the channel dimensions of the feature maps obtained from the feature extraction module. The specific description is as follows:
[0044]
[0045] Among them, F a ∈w×h×c and F b ∈w×h×c are two input feature maps, F c ∈w×h×2c is the Concat operation (i.e. ) and then output the connected feature map. Next, this application uses an improved regression network to calculate F c of relevance.
[0046] like Figure 3 As shown, the improved regression network includes three convolutional layers, one depth-separable convolutional layer and two fully connected layers. Among them, the depth-separable convolutional layer is used to replace the average pooling layer to downsample the feature map, so that more position information can be retained by moving the convolution kernel during downsampling, and the relationship between different feature map channels can be learned. In order to make the model have better gradient propagation characteristics, this application uses the SiLU activation function between the two fully connected layers, which is described as follows:
[0047]
[0048] Assume that the four corner coordinates of the image are (u1, v1), (u2, v2), (u3, v3) and (u4, v4), and the offsets of these four points are expressed as (Δu1, Δv1), (Δu2, Δv2), (Δu3, Δv3) and (Δu4, Δv4). Then, the coordinate offset Δ output by the regression network is nIt can be expressed as:
[0049]
[0050] Each of these offsets has its own uniquely determined homography matrix.
[0051] Coordinate offset Δ n After tensor direct linear transformation (Tensor DLT), the corresponding homography matrix H is obtained n .
[0052] After obtaining the feature map F b After the homography matrix generated by the upper layer, the homography estimation module uses the spatial transformation layer (STL) to distort the feature map. The spatial transformation layer (STL) first uses a grid generator to transform the input feature map F b Generate a uniform grid. Then, use the homography matrix H generated in the previous layer n Transform this grid. In this way, each original position will be mapped to a new position. Finally, bilinear interpolation is used to extract pixel values according to these new positions to produce the same feature map F as the input. b The transformed feature map F of the same size b ', and pass it to the next layer, and calculate from coarse to fine, gradually improving the accuracy of homography estimation. Finally, this application obtains a highly accurate homography matrix H3.
[0053] In summary, in some embodiments, the step of analyzing the multi-scale feature map of the image pair using the homography estimation module to generate a homography matrix representing the mapping relationship between the image pairs includes:
[0054] The third scale feature map of the first image and the third scale feature map of the second image Perform the Concat operation to obtain the first connection feature graph Compute the first connection feature map using the improved regression network The correlation of is used to obtain a first coordinate offset Δ1; a tensor direct linear transformation (Tensor DLT) is performed on the first coordinate offset Δ1 to obtain a first homography matrix H1;
[0055] Based on the first homography matrix H1, a second scale feature map of the second image is transformed using a spatial transformation layer (STL) Perform a distortion transformation and obtain The second scale feature map of the second image after transformation of the same size The second scale feature map of the first image and Perform the Concat operation to obtain the second connection feature map Compute the second connection feature map using the improved regression network The correlation of is used to obtain a second coordinate offset Δ2; a tensor direct linear transformation (Tensor DLT) is performed on the second coordinate offset Δ2 to obtain a second homography matrix H2;
[0056] Based on the second homography matrix H2, a first scale feature map of the second image is transformed using a spatial transformation layer (STL) Perform a distortion transformation and obtain The second scale feature map of the second image after transformation of the same size The first scale feature map of the first image and Perform the Concat operation to obtain the third connection feature map Computing the third connection feature map using the improved regression network The correlation is used to obtain the third coordinate offset Δ3; a tensor direct linear transformation (Tensor DLT) is performed on the third coordinate offset Δ3 to obtain the final homography matrix H3.
[0057] Step S3: Based on the homography matrix, use a stitching domain transformer to perform pre-alignment deformation on the image pair to be stitched to obtain a deformed image pair.
[0058] In this embodiment, the splicing domain transformer and the spatial transformer layer work in the same principle, the difference is that the splicing domain transformer acts on the picture, while the spatial transformer layer acts on the feature map.
[0059] Specifically, step S3 may include: using a grid generator to generate a uniform grid for the second image; using the homography matrix H3 to transform the grid, and each original position of the second image will be mapped to a new position; using bilinear interpolation to extract pixel values according to these new positions to generate a transformed second image of the same size as the second image, and the first image and the transformed second image constitute a deformed image pair.
[0060] Step S4: input the deformed image pair into a stitching and restoration network for stitching and restoration processing to obtain a stitched image.
[0061] In this embodiment, the overall structure of the fast splicing recovery network is as follows: Figure 4 As shown in FIG, it includes a backbone network, a head network and a reconstructor. The backbone network and the head network are mainly responsible for processing the images of the low-resolution branches, while the reconstructor is mainly used to combine the images of the low-resolution branches with the input image pairs to reconstruct high-resolution images.
[0062] Specifically, the backbone network includes an improved Focus module and a combination of three Conv modules and a C3 module in sequence; in the backbone network, the improved Focus module is used to process the deformed image pair, the dimension of the input image pair is (b, c, w, h), the improved Focus module separates the deformed image pair in the channel dimension, and then sends them to the conventional Focus module respectively, and then re-aggregates them into a whole, and outputs the first feature map The dimension is (b, 4c, w / 2, h / 2); the first feature map After the first Conv module and the first C3 module, the second feature map is obtained Second feature map After the second Conv module and the second C3 module, the third feature map is obtained The third characteristic diagram After the third Conv module and the third C3 module, the fourth feature map is obtained The number of channels is 64, 128, 256 and 512 respectively.
[0063] In some embodiments, the first, second, and third Conv modules in the backbone network are the same, and each includes a convolutional layer, a batch normalization layer, and a ReLU activation function layer.
[0064] The head network includes a combination of three Conv modules, an upsampling module and a C3 module; in the head network, the fourth feature map The fourth Conv module reduces the number of feature channels to half (256), and then the first upsampling module and the fourth C3 module perform upsampling operations through nearest neighbor interpolation and compare them with the third feature map. Stacking to get the fifth feature map Fifth characteristic diagram After the fifth Conv module, the second upsampling module and the fifth C3 module and the second feature map Stacking to get the sixth feature map Sixth characteristic diagram After the sixth Conv module, the third upsampling module and the sixth C3 module and the first feature map Stack to get the seventh feature map Seventh characteristic diagram After the convolution operation (Conv-op), a low-resolution image is obtained. LR .
[0065] In some embodiments, the fourth, fifth, and sixth Conv modules in the head network are the same, and are all Conv modules with a convolution kernel size of 1×1.
[0066] In the reconstructor, the low-resolution image 1 LR Upsampling is performed, and the deformed image pair is aggregated, and high-resolution image reconstruction is achieved through the seventh Conv module and the seventh C3 module and the convolution operation (Conv-op), so as to obtain a high-resolution stitched image. HR .
[0067] In some embodiments, the fast splicing recovery network uses a fusion-aware loss function
[0068]
[0069] in, is the low-resolution deformation loss; is the high-resolution deformation loss; is the consistency loss;
[0070] Low resolution deformation loss It is expressed as:
[0071]
[0072] in, and Respectively represent the image loss and seam loss generated by the low-resolution branch; λ i and λ s are the weights of image loss and seam loss respectively;
[0073] High-resolution deformation loss It is expressed as:
[0074]
[0075] in, and They represent the image loss and seam loss generated by the high-resolution branch respectively;
[0076] In this embodiment, in order to emphasize the elimination of visible seams in the merged part, during the training process of FSRNet, λ i and λ s Setting this to 1 and 10 respectively can help achieve a more natural, seamless image merge.
[0077] In addition, in order to better fuse the low-resolution and high-resolution reconstruction results, the consistency loss is used
[0078]
[0079] in, is the mean absolute error loss, σ=W / w, W and w are the high-resolution stitched images I HR and low resolution images LR Width.
[0080] In some embodiments, the image registration network and the stitching and restoration network are pre-trained respectively. The entire model training method may include:
[0081] Step (1): Obtain and prepare synthetic datasets for training to simulate various real-world stitching scenarios.
[0082] In some embodiments, the dataset first needs to select base images from the MS-COCO dataset, and then apply random homography transformations to these images, such as rotation, translation, scaling, and tilting, to simulate perspective changes. By applying the above homography transformations, a new deformed image is generated from each base image to obtain image pairs and form a synthetic dataset.
[0083] Step (2): The image pairs in the synthetic data set are used as the first image and the second image respectively, and the corresponding mask images are generated at the same time. All of them are stacked up as the input data of the entire network and input into the network in batches;
[0084] Step (3): Input the image pairs in the synthetic dataset into the image registration network. First, the feature extraction module is used to obtain the multi-scale feature map of the image pair to support accurate alignment from global to local. The extracted multi-scale feature map is analyzed by the homography estimation module to generate a homography matrix that represents the mapping relationship between images.
[0085] Step (4): Based on the homography matrix, use a stitching domain transformer to pre-align and deform the image pair to be stitched to obtain a deformed image pair.
[0086] Step (5): Input the deformed image pair into the stitching and inpainting network for stitching and inpainting to generate a high-resolution stitched image with a natural transition effect. In this embodiment, the training data set of the stitching and inpainting network is a deformed image pair generated by the image pairs in the synthetic data set through the image registration network and the stitching domain transformer.
[0087] In order to verify the superiority of the image stitching method proposed in this application in the image stitching task, its stitching results were compared with some classic and advanced methods. In the comparative experiment of this study, in order to evaluate the generalization performance of different stitching models, stitching image pairs with different degrees of overlap were generated as test sets, which were divided into three parts: 0%~30%, 30%~60% and 60%~100%, and marked as Part 1, Part 2 and Part 3 respectively. Among them, Part 1 has a large overlap rate, Part 2 has a moderate overlap rate, and Part 3 has a small overlap rate. This division method allows this application to analyze the performance of the model on different data subsets in more detail, so as to more comprehensively evaluate its generalization performance.
[0088] Table 1 Comparison of splicing results of PSNR, SSIM, Para and Time on synthetic datasets
[0089]
[0090] As shown in Table 1, the SR method is the most commonly used traditional image stitching method; APIS is an important improvement on the SR method and is used to stitch multiple panoramic images; APAP uses mobile DLT to maximize the accuracy and continuity of perspective projection, and is also a widely used traditional method; VFISNet and EPISNet are both arbitrary-view image stitching methods based on supervised learning methods, but VFISNet is only suitable for stitching low-resolution image pairs, so in the comparative experiment, the image pairs input to VFISNet are compressed to match the input scale of the model; UDISNet is currently the most widely used deep learning method in the field of arbitrary-view image stitching; and LUIS is a newly proposed image stitching method based on laryngeal superpixel features, which is mainly used in medical images.
[0091] From the comparison results in Table 1, it can be seen that the method of this application is significantly superior to other stitching methods in the image stitching task. In terms of the PSNR index, the method of this application is improved by 10.1% compared with SR, 6.1% compared with APIS, 6.3% compared with APAP, 2.1% compared with VFISNet, 1.6% compared with EPISNet, 0.4% compared with UDISNet, and 4.6% compared with LUIS. In terms of the SSIM index, the method of this application is improved by 2.1% compared with UDISNet (the second best model), and compared with the SR, APIS, APAP, VFISNet, EPISNet and LUIS models, the improvement of this application reached 182.4%, 128.6%, 65.5%, 9.1%, 6.7% and 33.3% respectively. This fully demonstrates the superiority of the network of this application in the stitching task.
[0092] Since SR, APIS, APAP and LUIS are not based on deep learning methods, their model parameters are not discussed here. As can be seen from Table 1, among the image stitching methods based on deep learning, the model of this application has the least number of parameters, which is approximately 62.4%, 87.3% and 87.6% less than VFISNet, EPISNet and UDISNet, respectively. Although the method of this application is not as good as the traditional methods SR, APIS and LUIS in reasoning time, the reasoning time of this application is the shortest among all the stitching methods based on deep learning, which is approximately 62.6%, 70.0% and 72.5% less than VFISNet, EPISNet and UDISNet, respectively. Even compared with the traditional method APAP, the model of this application has a decrease of about 20.8% in reasoning time. Although the improvement of the proposed model in PSNR and SSIM is not very significant, this is mainly because the image stitching task often involves complex alignment and fusion processes between multiple images, and PSNR and SSIM, as global evaluation indicators, may not reflect the subtle improvements of the model. However, considering comprehensively, the method of the present application still has significant advantages in terms of splicing effect and accuracy.
[0093] In addition, it is also obvious from the stitching result examples that the method of the present application (Ours) produces the results closest to the true value. In contrast, VFISNet produces a significant blurring effect when stitching. Although EPISNet and UDISNet are also high-quality stitching methods, their error probability in the registration process is higher than that of the method of the present application. It can also be seen that SR, APIS, and APAP perform very poorly in terms of pre-alignment accuracy. Since LUIS is pre-aligned based on the SIFT algorithm, it is only slightly better than the APAP method when processing data with random perspectives and diverse categories, and is far inferior to all deep learning-based methods. These visual results further verify that the method of the present application not only performs well in numerical indicators, but also produces stitching results that are visually closer to the true value.
[0094] Embodiment 2: Based on embodiment 1, this embodiment provides an image stitching device based on homography estimation, including a processor and a storage medium;
[0095] The storage medium is used to store instructions;
[0096] The processor is used to operate according to the instructions to execute the steps of the method according to embodiment 1.
[0097] Embodiment 3: Based on Embodiment 1, this embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in Embodiment 1 are implemented.
[0098] Embodiment 4: Based on Embodiment 1, this embodiment provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described in Embodiment 1 when executing the computer program.
[0099] Embodiment 5: Based on Embodiment 1, this embodiment provides a computer program product, including a computer program, which implements the steps of the method described in Embodiment 1 when executed by a processor.
[0100] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0101] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0102] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1The steps for the functions specified in one or more boxes.
[0104] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. An image stitching method, characterized in that: include: Acquire a pair of images to be stitched, wherein the pair of images to be stitched includes a first image and a second image; Inputting the image pair to be spliced into an image registration network, wherein the image registration network includes a feature extraction module and a homography estimation module, and using the feature extraction module to extract the image pair to be spliced to obtain a multi-scale feature map of the image pair; Analyzing the multi-scale feature map of the image pair using a homography estimation module to generate a homography matrix representing a mapping relationship between the image pairs; Based on the homography matrix, using a stitching domain transformer to pre-align and deform the image pair to be stitched to obtain a deformed image pair; The deformed image pair is input into the stitching and restoration network for stitching and restoration to obtain a stitched image.
2. The method according to claim 1, characterized in that The feature extraction module includes a deformable convolution module DCM, which is used to expand the perception domain to improve the network's adaptability to image deformation; , in, is the input feature map of the deformable convolution module, is the convolution kernel, is the output position of the convolution operation, It represents the convolution kernel The relative position in The deformable convolution operation of , the input feature map first passes through a convolution operation to generate a The mask map is decomposed into offset vectors and weight mask ; For each position in the input feature map, use the offset vector It is offset to obtain the new position; at the same time, the weight mask Through the Sigmoid function constraint Different weight values are provided for the convolution points at each position, thus providing greater freedom for sampling; In the feature extraction module, the image pair to be spliced is processed by Focus to obtain a first scale feature map, then processed by a first deformable convolution module DCM and a C3 module to obtain a second scale feature map, and then processed by a second deformable convolution module DCM and a C3 module to obtain a third scale feature map.
3. The method according to claim 1, characterized in that The multi-scale feature map of the image pair includes a first scale feature map of the first image , the second scale feature map , the third scale feature map and the first scale feature map of the second image , the second scale feature map And the third scale feature map ; but, The step of analyzing the multi-scale feature map of the image pair using the homography estimation module to generate a homography matrix representing the mapping relationship between the image pairs includes: The third scale feature map of the first image and the third scale feature map of the second image Perform Concat operation to obtain the first connection feature graph ; Compute the first connection feature map using the improved regression network The correlation of the first coordinate offset is obtained ; Offset the first coordinate Perform direct linear transformation of the tensor to obtain the first homography matrix ; Based on the first homography matrix , using the spatial transformation layer to transform the second scale feature map of the second image Perform a distortion transformation to obtain The second scale feature map of the second image after transformation of the same size ; The second scale feature map of the first image and Perform the Concat operation to obtain the second connection feature map ; Use the improved regression network to calculate the second connection feature map The correlation of the second coordinate offset is obtained ; Offset the second coordinate Perform direct linear transformation of the tensor to obtain the second homography matrix ; Based on the second homography matrix , using the spatial transformation layer to transform the first scale feature map of the second image Perform a distortion transformation to obtain The second scale feature map of the second image after transformation of the same size ; The first scale feature map of the first image and Perform the Concat operation to obtain the third connection feature map ; Use the improved regression network to calculate the third connection feature map The correlation of the third coordinate offset is obtained ; Offset the third coordinate Perform direct linear transformation of the tensor to obtain the final homography matrix .
4. The method according to claim 3, characterized in that The improved regression network includes three convolutional layers, one depthwise separable convolutional layer and two fully connected layers; wherein the depthwise separable convolutional layer is used to replace the average pooling layer to downsample the feature map, so as to retain more position information by moving the convolution kernel during downsampling and learn the relationship between different feature map channels; in order to have better gradient propagation characteristics, the SiLU activation function is used between the two fully connected layers.
5. The method according to claim 3, characterized in that: The processing process of the spatial transformation layer includes: The spatial transformation layer first uses a grid generator to transform the input feature map Generate a uniform grid; then, use the homography matrix generated by the previous layer Transform this grid; in this way, each original position will be mapped to a new position; finally, use bilinear interpolation to extract pixel values according to these new positions to produce the same feature map as the input Transformed feature maps of the same size .
6. The method according to claim 3, characterized in that The loss function of the image registration network is for: , is an improved overlapping area registration loss function, defined as follows: , in, Represents the multiplication operation between pixels; , and is the weight factor of the loss terms of different layers; represents the mean absolute error loss; represents the distortion operation corresponding to the homography matrix obtained from feature maps of different scales, where ; is the overlapping area calculated using the mask map: , in, Represents the "and" operation; and Respectively represent the first image and the second image All mask images have the same size; represents a twist operation; is the edge content loss function: , in, represents the Canny operator, and The first image and the second image and The result after the "AND" operation.
7. The method according to claim 1, characterized in that The processing of the splicing domain transformer includes: generating a uniform grid for the second image using a grid generator; Using the homography matrix By transforming this grid, each original position of the second image will be mapped to a new position; Bilinear interpolation is used to extract pixel values according to these new positions to generate a transformed second image with the same size as the second image, and the first image and the transformed second image constitute a deformed image pair.
8. The method according to claim 1, characterized in that The fast splicing and restoration network includes a backbone network, a head network and a reconstructor; The backbone network sequentially includes an improved Focus module and a combination of three Conv modules and a C3 module; In the backbone network, an improved Focus module is used to process the deformed image pair. The improved Focus module separates the deformed image pair in the channel dimension, and then sends them to the conventional Focus module respectively, and then reaggregates them into a whole to output the first feature map. ; The first feature map After the first Conv module and the first C3 module, the second feature map is obtained ; The second feature map After the second Conv module and the second C3 module, the third feature map is obtained ; The third characteristic map After the third Conv module and the third C3 module, the fourth feature map is obtained ; The head network includes a combination of three Conv modules, an upsampling module and a C3 module; in the head network, the fourth feature map The fourth Conv module reduces the number of feature channels to half, and then the first upsampling module and the fourth C3 module perform upsampling operations through nearest neighbor interpolation and compare them with the third feature map. Stacking to get the fifth feature map ; The fifth characteristic diagram After the fifth Conv module, the second upsampling module and the fifth C3 module and the second feature map Stacking to get the sixth feature map ; Sixth characteristic diagram After the sixth Conv module, the third upsampling module and the sixth C3 module and the first feature map Stack to get the seventh feature map ; Seventh characteristic diagram After the convolution operation, a low-resolution image is obtained ; In the reconstructor, the low-resolution image Up-sampling is performed, and the deformed image pair is aggregated, and a high-resolution stitched image is obtained after the seventh Conv module and the seventh C3 module and convolution operation. .
9. The method according to claim 8, characterized in that The fast splicing recovery network uses a fusion-aware loss function ; , in, is the low-resolution deformation loss; is the high-resolution deformation loss; is the consistency loss; Low resolution deformation loss It is expressed as: , in, and They represent the image loss and seam loss generated by the low-resolution branch respectively; and are the weights of image loss and seam loss respectively; High-resolution deformation loss It is expressed as: , in, and They represent the image loss and seam loss generated by the high-resolution branch respectively; Consistency loss It is expressed as: , in, is the mean absolute error loss, , and They are high-resolution stitched images. and low-resolution images Width.
10. An image stitching device, characterized in that: including processor and storage medium; The storage medium is used to store instructions; The processor is configured to operate according to the instructions to execute the steps of the method according to any one of claims 1 to 9.
Citation Information
Cited By
Image splicing method and device and storage medium
CN120725864A
Image registration method and device, electronic equipment and storage medium
CN121564055A
An image registration method, device, electronic equipment and storage medium
CN121564055B
