Image splicing method and device, computer equipment, readable storage medium and program product

By preprocessing the images and mask data to be spliced ​​and constructing a contour directed graph, the problem of high device performance and connection traces caused by fixed shape templates in the existing technology is solved, and natural splicing and resource optimization of images of arbitrary shapes are realized.

CN118628347APending Publication Date: 2024-09-10XIAMEN MEITUZHIJIA TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410810598.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Existing image splicing technology usually uses fixed-shape templates, which results in high equipment performance requirements and easy connection traces during the processing process, making it difficult to adapt to image splicing of arbitrary shapes.

Method used

By preprocessing the images to be spliced ​​and mask data, construct a contour directed graph, divide node subsets, and perform image merging and mask fusion based on these subsets to generate target fusion images that can adapt to templates of different shapes.

Benefits of technology

The device performance requirements are reduced, the image fusion steps are optimized, the waste of computer resources is reduced, and the natural splicing of images of arbitrary shapes is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628347A
    Figure CN118628347A
Patent Text Reader

Abstract

The invention relates to an image splicing method and device, computer equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: respectively preprocessing a to-be-spliced image and mask data of the to-be-spliced image to obtain preprocessed mask data; performing contour expansion on a fusion mask image set in the preprocessed mask data to obtain an expanded contour line set; performing directed graph construction according to the fusion mask image set and the extended contour line set to obtain a contour directed graph; performing node division on nodes of the contour directed graph to obtain a contour node subset; according to the contour node subset, merging the to-be-spliced images and the preprocessed mask data to obtain a merged data set; and performing mask fusion splicing according to the merged data set to obtain a target fusion image. By adopting the method, the requirement on equipment performance can be reduced, and templates in any shape can be supported.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image stitching method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] With the popularity of smart phones, the number of photos taken by users continues to increase. In order to make the content of the photos richer, multiple images need to be stitched into one. However, most of the stitching technologies currently available stitch multiple pictures together according to a predetermined template, and there will still be obvious connection marks in most scenarios.

[0003] The image stitching technology in the existing technology usually uses a template of a fixed shape to stitch images, and the image stitching technology has high requirements on the performance of the equipment due to the repetitiveness of the processing and the complexity of image fusion. Summary of the invention

[0004] Based on this, it is necessary to provide an image stitching method, device, computer equipment, computer-readable storage medium and computer program product that can reduce the requirements on equipment performance while supporting templates of arbitrary shapes in order to address the above technical problems.

[0005] In a first aspect, the present application provides an image stitching method, comprising:

[0006] Preprocessing the image to be stitched and the mask data of the image to be stitched respectively to obtain preprocessed mask data;

[0007] Performing contour extension on the fused mask image set in the preprocessed mask data to obtain an extended contour line set;

[0008] Constructing a directed graph according to the fused mask image set and the extended contour line set to obtain a contour directed graph;

[0009] Performing node partitioning on the nodes of the contour directed graph to obtain contour node subsets;

[0010] According to the outline node subset, the images to be spliced ​​are merged and the pre-processed mask data are merged to obtain a merged data set;

[0011] Mask fusion and splicing are performed according to the merged data set to obtain a target fused image.

[0012] In one embodiment, the step of constructing a directed graph based on the fused mask image set and the extended contour line set to obtain a contour directed graph includes:

[0013] constructing an original directed graph according to the fused mask image set;

[0014] Performing a pairwise intersection judgment on each contour line in the extended contour line set to obtain an intersection judgment result;

[0015] The original directed graph is adjusted according to the intersection judgment result to obtain the contour directed graph.

[0016] In one embodiment, the step of performing directed graph adjustment on the original directed graph according to the intersection judgment result to obtain the contour directed graph includes:

[0017] If the intersection judgment result is that there are intersecting contours, then constructing intersection edges according to the contour lines that have intersections in each of the contour lines to obtain an edge set to be added;

[0018] The edge set to be added is added to the edge set of the original directed graph to obtain the contour directed graph.

[0019] In one embodiment, merging the images to be stitched and merging the preprocessed mask data according to the contour node subset to obtain a merged data set includes:

[0020] Merging the images to be spliced ​​corresponding to each of the outline node subsets to obtain a merged image set;

[0021] Merging the pre-processed mask data corresponding to each of the contour node subsets to obtain a merged mask data set;

[0022] The merged dataset is constructed according to the merged image set and the merged mask dataset.

[0023] In one embodiment, the step of performing contour extension on the fused mask image set in the preprocessed mask data to obtain an extended contour line set includes:

[0024] Performing contour extraction on the fused mask image set according to the contour extraction model to obtain the contour line set that meets the preset first condition;

[0025] The contours in the contour line set are extended according to the curve offset model to obtain the extended contour line set.

[0026] In one embodiment, the merged data set includes a target fusion mask data set and a merged image set; performing mask fusion and splicing according to the merged data set to obtain a target fused image includes:

[0027] Constructing a target fusion mask according to the target fusion mask data set;

[0028] The merged image set is spliced ​​according to the target fusion mask to generate the target fusion image.

[0029] In one embodiment, the mask data includes: importance mask data and template data; the preprocessed mask data includes: a preprocessed image, a mask image and a fused mask image set; the mask data of the image to be spliced ​​and the image to be spliced ​​are preprocessed respectively to obtain the preprocessed mask data, including:

[0030] Preprocessing the image to be stitched to obtain the preprocessed image;

[0031] Preprocessing the importance mask data to obtain the mask image;

[0032] The template data is preprocessed to obtain the fused mask image set.

[0033] In a second aspect, the present application also provides an image stitching device, comprising:

[0034] A preprocessing module, used for preprocessing the image to be stitched and the mask data of the image to be stitched respectively to obtain preprocessed mask data;

[0035] A contour extension module, used for performing contour extension on the fused mask image set in the preprocessed mask data to obtain an extended contour line set;

[0036] A directed graph construction module, used for constructing a directed graph according to the fused mask image set and the extended contour line set to obtain a contour directed graph;

[0037] A node partitioning module, used for partitioning the nodes of the contour directed graph to obtain a contour node subset;

[0038] A merging module, used for merging the images to be spliced ​​and the pre-processed mask data according to the contour node subset to obtain a merged data set;

[0039] The fusion and stitching module is used to perform mask fusion and stitching according to the merged data set to obtain a target fused image.

[0040] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0041] Preprocessing the image to be stitched and the mask data of the image to be stitched respectively to obtain preprocessed mask data;

[0042] Performing contour extension on the fused mask image set in the preprocessed mask data to obtain an extended contour line set;

[0043] Constructing a directed graph according to the fused mask image set and the extended contour line set to obtain a contour directed graph;

[0044] Performing node partitioning on the nodes of the contour directed graph to obtain contour node subsets;

[0045] According to the outline node subset, the images to be spliced ​​are merged and the pre-processed mask data are merged to obtain a merged data set;

[0046] Mask fusion and splicing are performed according to the merged data set to obtain a target fused image.

[0047] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0048] Preprocessing the image to be stitched and the mask data of the image to be stitched respectively to obtain preprocessed mask data;

[0049] Performing contour extension on the fused mask image set in the preprocessed mask data to obtain an extended contour line set;

[0050] Constructing a directed graph according to the fused mask image set and the extended contour line set to obtain a contour directed graph;

[0051] Performing node partitioning on the nodes of the contour directed graph to obtain contour node subsets;

[0052] According to the outline node subset, the images to be spliced ​​are merged and the pre-processed mask data are merged to obtain a merged data set;

[0053] Mask fusion and splicing are performed according to the merged data set to obtain a target fused image.

[0054] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0055] Preprocessing the image to be stitched and the mask data of the image to be stitched respectively to obtain preprocessed mask data;

[0056] Performing contour extension on the fused mask image set in the preprocessed mask data to obtain an extended contour line set;

[0057] Constructing a directed graph according to the fused mask image set and the extended contour line set to obtain a contour directed graph;

[0058] Performing node partitioning on the nodes of the contour directed graph to obtain contour node subsets;

[0059] According to the outline node subset, the images to be spliced ​​are merged and the pre-processed mask data are merged to obtain a merged data set;

[0060] Mask fusion and splicing are performed according to the merged data set to obtain a target fused image.

[0061] The image stitching method, device, computer equipment, computer-readable storage medium and computer program product are characterized in that the mask data of the image to be stitched and the image to be stitched are pre-processed respectively to obtain pre-processed mask data; then the fused mask image set in the pre-processed mask data is contour expanded to obtain an extended contour line set; a directed graph is constructed based on the fused mask image set and the extended contour line set to obtain a contour directed graph; nodes of the contour directed graph are divided to obtain a contour node subset; based on the contour node subset, the image to be stitched is merged and the pre-processed mask data is merged to obtain a merged data set; mask fusion and stitching are performed based on the merged data set to obtain a target fused image. Therefore, by extending the contours of the fused mask image set to adapt to templates of different shapes, and then constructing a directed graph based on the fused mask image set and the extended contour line set, a contour directed graph is obtained, and the images to be spliced ​​are merged according to the divided contour node subsets and the preprocessed mask data is merged, thereby converting the fusion problem of any number of images into the fusion problem of a very small number of images, that is, optimizing the image fusion steps, reducing the memory peak in the image processing process, and reducing the waste of computer resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0063] Figure 1 A diagram showing an application environment of an image stitching method in an embodiment;

[0064] Figure 2 is a schematic diagram of a flow chart of an image stitching method in one embodiment;

[0065] Figure 3 A schematic diagram of a process of constructing a contour directed graph in one embodiment;

[0066] Figure 4 is a structural block diagram of an image stitching device in one embodiment;

[0067] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0068] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0069] The image stitching method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers.

[0070] Both the terminal 102 and the server 104 can be used alone to execute the image stitching method provided in the embodiment of the present application. For example, taking the terminal 102 as an example, the terminal 102 can pre-process the mask data of the image to be stitched and the image to be stitched respectively to obtain the pre-processed mask data; perform contour expansion on the fused mask image set in the pre-processed mask data to obtain the extended contour line set; perform directed graph construction based on the fused mask image set and the extended contour line set to obtain the contour directed graph; perform node division on the nodes of the contour directed graph to obtain the contour node subset; merge the image to be stitched and merge the pre-processed mask data according to the contour node subset to obtain the merged data set; perform mask fusion stitching based on the merged data set to obtain the target fused image, and display the target fused image.

[0071] For another example, the server 104 obtains the mask data of the image to be stitched and the image to be stitched uploaded by the terminal 102, and then preprocesses the mask data of the image to be stitched and the image to be stitched respectively to obtain the preprocessed mask data; performs contour expansion on the fused mask image set in the preprocessed mask data to obtain the extended contour line set; constructs a directed graph based on the fused mask image set and the extended contour line set to obtain a contour directed graph; performs node division on the nodes of the contour directed graph to obtain a contour node subset; merges the image to be stitched and the preprocessed mask data according to the contour node subset to obtain a merged data set; performs mask fusion and stitching based on the merged data set to obtain a target fused image; and then sends the target fused image back to the terminal 102 for display.

[0072] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 may be an independent physical server, or a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.

[0073] In an exemplary embodiment, Figure 2 As shown, an image stitching method is provided, which can be executed by a terminal or a server alone, or can be implemented through interaction between a terminal and a server. Figure 1 The terminal 102 in the example is used as an example to illustrate, including the following steps 202 to 212. Among them:

[0074] Step 202 , preprocessing the image to be stitched and the mask data of the image to be stitched respectively to obtain preprocessed mask data.

[0075] In some embodiments, the mask data includes: importance mask data and template data; the preprocessed mask data includes: a preprocessed image, a mask image and a template image; the mask data of the image to be spliced ​​and the image to be spliced ​​are preprocessed respectively to obtain preprocessed mask data, including: preprocessing the image to be spliced ​​to obtain a preprocessed image; preprocessing the importance mask data to obtain a mask image; preprocessing the template data to obtain a template image.

[0076] The images to be stitched may be multiple images selected by a user, or may be random images obtained according to a preset rule, but are not limited thereto.

[0077] In some embodiments, the image to be stitched may be a set of input images Each image to be stitched When preprocessing the images to be stitched, the user can Perform deformation processing according to the image Deformation processing operation, treat the stitching image Perform preprocessing to obtain a preprocessed image. For example, create an image of the same size as the output image. , for the image The coordinates of each pixel use the corresponding affine transformation matrix Transform it to get its image The corresponding coordinates on the image are then used to calculate the pixel values ​​after interpolation transformation, thereby obtaining the preprocessed image. , the formula is:

[0078]

[0079] Among them, the pre-calculated affine transformation matrix For each input image to be stitched, it is assumed that it has properties such as horizontal flip, vertical flip, scaling, rotation, and translation, and the corresponding affine transformation matrix is ​​calculated based on these properties. . The function is used to transform the coordinates of the image to be stitched. Perform pixel interpolation to obtain the preprocessed image The target pixel value on The function may be bilinear interpolation, nearest neighbor interpolation or other interpolation methods, which are not limited in this embodiment.

[0080] In some embodiments, the importance mask data of the image to be stitched may be an importance mask set Each importance mask image of , preprocess the importance mask data and create an importance mask image of the same size as the output image , for the image The affine transformation matrix corresponding to the coordinates of each pixel Transform it to get its image The corresponding coordinates are then used to calculate the pixel value after interpolation transformation, and finally multiplied by the protection ratio. , thus obtaining the image The protection ratio at this coordinate position is:

[0081]

[0082] in, To protect the ratio, used for masking images Set the transition weight to make the image stitching process have a transition effect. If the protection ratio is 1, there is no transition effect. Mask Image It consists of a framed area and a non-framed area of ​​a preset target size.

[0083] In some embodiments, preprocessing the importance mask data of the images to be stitched to obtain a mask image of a preset target size may include: converting the importance mask of each image to be stitched into a mask image of a corresponding preset target size according to the affine transformation matrix of each image to be stitched. Perform a box selection operation and use the area outside the box selection as the image to be stitched Corresponding importance mask , according to the image to be stitched The deformation processing operation on the image Corresponding importance mask Perform the same preprocessing to obtain a mask image of the preset target size , mask image It consists of a framed area and a non-framed area of ​​a preset target size.

[0084] In some embodiments, the importance mask It may be other areas other than the portrait area determined by performing portrait area detection on the image to be stitched, or may be obtained by using other image segmentation methods, or may be determined by interactive drawing performed by the user on the image to be stitched, which is not limited in this embodiment.

[0085] In some embodiments, for the template data corresponding to the image to be stitched, the template set Each template in , create a template with the same size as the output , assuming that each template All have translation properties, where the horizontal translation is , the vertical translation is , apply its translation properties and transform to the template For mapping to template The pixels outside the image are assigned a value of 0, thereby obtaining a fused mask image set. , the process can be expressed by the following formula:

[0086] .

[0087] The image stitching method provided in the above embodiment preprocesses the mask data of the image to be stitched and the image to be stitched respectively to obtain the preprocessed mask data, which may specifically include calculating an affine transformation matrix according to the operation attributes of the image to be stitched, converting the image to be stitched into the preprocessed image according to the affine transformation matrix, and converting the importance mask data corresponding to the image to be stitched into the mask image. By calculating the affine transformation matrix based on the operation attributes of the image to be stitched, various rotations, translations, scaling, flipping and other transformations can be performed on the image to be stitched, thereby realizing diversified image stitching.

[0088] Step 204 , performing contour extension on the fused mask image set in the pre-processed mask data to obtain an extended contour line set.

[0089] In some embodiments, contour extension is performed on a fused mask image set in preprocessed mask data to obtain an extended contour line set, including: performing contour extraction on the fused mask image set according to a contour extraction model to obtain a contour line set that satisfies a preset first condition; and extending the contours in the contour line set according to a curve offset model to obtain an extended contour line set.

[0090] In some embodiments, for each image in the fused mask image set, a contour extraction algorithm model can be used to perform contour extraction on the fused mask image set, and the contour line corresponding to each mask in the fused image mask set is extracted to obtain a contour line set that meets the preset first condition.

[0091] Among them, the fusion mask image set can be The contour extraction algorithm model may be the Suzuki 85 contour extraction algorithm, the preset first condition may be contour closure, and the contour set may be , but not limited to this.

[0092] In some embodiments, all contours in the contour line set are expanded outward by a preset expansion size according to the curve offset model to obtain an expanded contour line set.

[0093] The curve offset model can use the polygon curve offset algorithm, and the preset expansion size can be size, the extended contour set can be .

[0094] Step 206, constructing a directed graph based on the fused mask image set and the extended contour line set to obtain a contour directed graph.

[0095] In some embodiments, each image in the fused mask image set is taken as a node in a directed graph, and the node corresponding to each image in the fused mask image set is added to the node set of the directed graph. Since the extended contour line set is extracted from the fused mask image set, that is, the relationship between each contour line in the extended contour line set corresponds one-to-one to the relationship between the images in the fused mask image set, therefore, the edge set in the directed graph can be constructed and added according to the intersection between the contour lines of the extended contour line set. Therefore, the contour directed graph constructed in this way can reflect the dependency relationship between each fused mask image in the fused mask image set.

[0096] Step 208: partition the nodes of the contour directed graph to obtain contour node subsets.

[0097] In some embodiments, a four-color labeling model may be used to divide the nodes of the contour directed graph to obtain a subset of contour nodes that meets a preset second condition.

[0098] Among them, the outline node subset includes: The four-color marking model can be a four-color marking model using a four-color marking algorithm according to the four-color theorem. The preset second condition includes a quantity condition and a set condition. The quantity condition is no more than 4 node subsets, and the set condition is (meaning that the intersection of any two sets is an empty set), and (expressed as the union of all sets being the labels of all input images).

[0099] In the above embodiment, by dividing the nodes of the contour directed graph to obtain contour node subsets, the fusion problem of any number of images can be converted into the fusion problem of a very small number of images.

[0100] Step 210 : merging the images to be spliced ​​and the pre-processed mask data according to the contour node subset to obtain a merged data set.

[0101] In some embodiments, the images to be stitched are merged and the preprocessed mask data are merged according to the contour node subsets to obtain a merged data set, including: merging the images to be stitched corresponding to each contour node subset to obtain a merged image set; merging the preprocessed mask data corresponding to each contour node subset to obtain a merged mask data set; and constructing a merged data set based on the merged image set and the merged mask data set.

[0102] In some embodiments, the contour node subset All the images to be stitched corresponding to each subset in Merge to get the merged image set For example, in the merging method, a standard 3x3 nine-square grid layout can be used, and the images to be stitched from top to bottom and from left to right can be marked as , a combination method can be derived through the node division method in step 208: , , , ,image Will be Combining them, we can get Similarly, the pre-processed mask data corresponding to each contour node subset is merged to obtain a merged mask data set. Since the pre-processed mask data includes an importance mask set and a template set, and the merged mask data set includes a merged template set and a merged importance mask set, the above merging method is used to merge the importance mask set. Merge to get the merged importance mask set , using the above merging method, the template set Merge to get the merged template set ,A merged mask dataset can be constructed according to the merged image set, the merged template set and the merged importance mask set.

[0103] In the above embodiment, by merging the image to be stitched, the importance mask set and the template set according to each contour node subset, and then constructing a merged data set based on the merged data, the subsequent use of the merged data set for image stitching and fusion can effectively reduce the repeated steps in the fusion, thereby optimizing the image fusion steps, reducing the memory peak in the image processing process, and reducing the waste of computer resources.

[0104] Step 212, performing mask fusion and splicing according to the merged data set to obtain a target fused image.

[0105] In some embodiments, the merged data set includes a target fusion mask data set and a merged image set; mask fusion and splicing are performed according to the merged data set to obtain a target fusion image, including: constructing a target fusion mask according to the target fusion mask data set; and splicing the merged image set according to the target fusion mask to generate a target fusion image.

[0106] In some embodiments, constructing a target fusion mask according to a target fusion mask dataset includes: generating a transition region mask based on a merged dataset, generating a target fusion mask according to the target fusion mask dataset and the transition region mask, respectively, and according to the target fusion mask.

[0107] In some embodiments, the merged image set is spliced ​​according to the target fusion mask to generate multiple target fusion images. By splicing the merged image set using the target fusion mask, the splicing area of ​​the target fusion image has a natural transition and strong continuity.

[0108] In the above-mentioned image stitching method, the mask data of the image to be stitched and the image to be stitched are pre-processed respectively to obtain the pre-processed mask data; then the fused mask image set in the pre-processed mask data is contour extended to obtain the extended contour line set; a directed graph is constructed according to the fused mask image set and the extended contour line set to obtain the contour directed graph; the nodes of the contour directed graph are node-divided to obtain the contour node subset; according to the contour node subset, the image to be stitched and the pre-processed mask data are merged to obtain the merged data set; mask fusion and stitching are performed according to the merged data set to obtain the target fused image. Therefore, by contour extension of the fused mask image set to adapt to templates of different shapes, a directed graph is constructed according to the fused mask image set and the extended contour line set to obtain the contour directed graph, and according to the divided contour node subset, the image to be stitched and the pre-processed mask data are merged, thereby realizing the conversion of the fusion problem of any number of images into the fusion problem of a very small number of images, that is, the image fusion steps are optimized, the memory peak value in the image processing process is reduced, and the waste of computer resources is reduced.

[0109] In an exemplary embodiment, Figure 3 As shown, a directed graph is constructed based on the fused mask image set and the extended contour line set to obtain a contour directed graph, including:

[0110] Step 302, constructing an original directed graph according to the fused mask image set;

[0111] In some embodiments, each image in the fused mask image set is used as a node in the original directed graph, and the node corresponding to each image in the fused mask image set is added to the node set of the original directed graph, thereby creating the original directed graph.

[0112] The original directed graph can be G = (V, E), where V is the node set of the original directed graph, E is the edge set of the original directed graph, and the node .

[0113] Step 304, performing a pairwise intersection determination on each contour line in the extended contour line set to obtain an intersection determination result;

[0114] In some embodiments, an intersection judgment is performed on each contour line in the extended contour line set, and each contour line is grouped with other contour lines in the extended contour line set except itself for intersection judgment to obtain an intersection judgment result, and the original directed graph is adjusted according to the intersection judgment result, so that the obtained contour directed graph can reflect the dependency relationship between the images to be spliced.

[0115] Step 306, adjusting the original directed graph according to the intersection judgment result to obtain a contour directed graph.

[0116] In some embodiments, the original directed graph is adjusted according to the intersection judgment result to obtain a contour directed graph, including: if the intersection judgment result is that there are intersecting contours, then intersecting edges are constructed according to the intersecting contour lines in each contour line to obtain a set of edges to be added; the set of edges to be added is added to the edge set of the original directed graph to obtain a contour directed graph.

[0117] It should be further explained that if the intersection judgment result is that there are intersecting contours, that is, there are two contours that intersect in the node set, that is, there is a relationship to be spliced, also known as a dependency relationship. If the two contours intersect, it is necessary to construct two intersecting edges corresponding to the intersecting contours, and add the two intersecting edges to the edge set to be added. Finally, the edge set to be added is added to the edge set of the original directed graph to obtain a contour directed graph that can reflect the dependency relationship between the images to be spliced. For example, if the two contours intersect, then in the edge set Connect the corresponding edges; for example, the contour and contour Intersect, and because It is a directed graph, so we need to Add the edge set to be added The two sides of are:

[0118] .

[0119] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0120] Based on the same inventive concept, the embodiment of the present application also provides an image stitching device for implementing the above-mentioned image stitching method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more image stitching device embodiments provided below can refer to the limitations on the image stitching method above, and will not be repeated here.

[0121] In an exemplary embodiment, Figure 4As shown, an image stitching device is provided, including: a pre-processing module 402, a contour expansion module 404, a directed graph construction module 406, a node division module 408, a merging module 410 and a fusion stitching module 412, wherein:

[0122] A preprocessing module 402 is used to preprocess the image to be stitched and the mask data of the image to be stitched respectively to obtain preprocessed mask data;

[0123] The contour extension module 404 is used to perform contour extension on the fused mask image set in the pre-processed mask data to obtain an extended contour line set;

[0124] A directed graph construction module 406 is used to construct a directed graph according to the fused mask image set and the extended contour line set to obtain a contour directed graph;

[0125] A node partitioning module 408 is used to partition the nodes of the contour directed graph to obtain a contour node subset;

[0126] A merging module 410 is used to merge the images to be spliced ​​and the pre-processed mask data according to the contour node subset to obtain a merged data set;

[0127] The fusion and stitching module 412 is used to perform mask fusion and stitching according to the merged data set to obtain a target fused image.

[0128] In some embodiments, the directed graph construction module 406 is also used to construct an original directed graph based on the fused mask image set; perform pairwise intersection judgment on each contour line in the extended contour line set to obtain an intersection judgment result; and perform directed graph adjustment on the original directed graph based on the intersection judgment result to obtain a contour directed graph.

[0129] In some embodiments, the directed graph construction module 406 is also used to construct intersection edges according to the existence of intersecting contours in each contour line if the intersection judgment result is that there are intersecting contours, to obtain a set of edges to be added; and add the set of edges to be added to the edge set of the original directed graph to obtain a contour directed graph.

[0130] In some embodiments, the merging module 410 is further used to merge the images to be spliced ​​corresponding to each contour node subset to obtain a merged image set; merge the preprocessed mask data corresponding to each contour node subset to obtain a merged mask data set; and construct a merged data set based on the merged image set and the merged mask data set.

[0131] In some embodiments, the contour extension module 404 is further used to perform contour extraction on the fused mask image set according to the contour extraction model to obtain a contour line set that meets a preset first condition; and to perform contour extension processing on the contour line set according to the curve offset model to obtain an extended contour line set.

[0132] In some embodiments, the mask data includes: importance mask data and template data; the preprocessed mask data includes: preprocessed image, mask image and fused mask image set; the preprocessing module 402 is also used to preprocess the mask data of the image to be spliced ​​and the image to be spliced ​​respectively to obtain the preprocessed mask data, including: preprocessing the image to be spliced ​​to obtain the preprocessed image; preprocessing the importance mask data to obtain the mask image; preprocessing the template data to obtain the fused mask image set.

[0133] In some embodiments, the merged data set includes a target fusion mask data set and a merged image set; there is a fusion stitching module 412, which is also used to construct a target fusion mask based on the target fusion mask data set; according to the target fusion mask, the merged image set is stitched to generate a target fusion image.

[0134] In the above-mentioned image stitching device, the mask data of the image to be stitched and the image to be stitched are pre-processed respectively to obtain the pre-processed mask data; then the fused mask image set in the pre-processed mask data is contour extended to obtain the extended contour line set; a directed graph is constructed according to the fused mask image set and the extended contour line set to obtain the contour directed graph; the nodes of the contour directed graph are node-divided to obtain the contour node subset; according to the contour node subset, the image to be stitched and the pre-processed mask data are merged to obtain the merged data set; mask fusion and stitching are performed according to the merged data set to obtain the target fused image. Therefore, by contour extension of the fused mask image set to adapt to templates of different shapes, a directed graph is constructed according to the fused mask image set and the extended contour line set to obtain the contour directed graph, and according to the divided contour node subset, the image to be stitched and the pre-processed mask data are merged, thereby realizing the conversion of the fusion problem of any number of images into the fusion problem of a very small number of images, that is, the image fusion step is optimized, the memory peak value in the image processing process is reduced, and the waste of computer resources is reduced.

[0135] Each module in the above-mentioned image stitching device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.

[0136] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store image data to be spliced. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an image splicing method is implemented.

[0137] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0138] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0139] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0140] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0141] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0142] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0143] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0144] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. An image stitching method, characterized in that: The method comprises: Preprocessing the image to be stitched and the mask data of the image to be stitched respectively to obtain preprocessed mask data; Performing contour extension on the fused mask image set in the preprocessed mask data to obtain an extended contour line set; Constructing a directed graph according to the fused mask image set and the extended contour line set to obtain a contour directed graph; Performing node partitioning on the nodes of the contour directed graph to obtain contour node subsets; According to the outline node subset, the images to be spliced ​​are merged and the pre-processed mask data are merged to obtain a merged data set; Mask fusion and splicing are performed according to the merged data set to obtain a target fused image.

2. The method according to claim 1, characterized in that The step of constructing a directed graph according to the fused mask image set and the extended contour line set to obtain a contour directed graph includes: constructing an original directed graph according to the fused mask image set; Performing a pairwise intersection judgment on each contour line in the extended contour line set to obtain an intersection judgment result; The original directed graph is adjusted according to the intersection judgment result to obtain the contour directed graph.

3. The method according to claim 2, characterized in that The step of performing directed graph adjustment on the original directed graph according to the intersection judgment result to obtain the contour directed graph includes: If the intersection judgment result is that there are intersecting contours, then constructing intersection edges according to the contour lines that have intersections in each of the contour lines to obtain an edge set to be added; The edge set to be added is added to the edge set of the original directed graph to obtain the contour directed graph.

4. The method according to claim 1, characterized in that The step of merging the images to be spliced ​​and the pre-processed mask data according to the contour node subset to obtain a merged data set includes: Merging the images to be spliced ​​corresponding to each of the outline node subsets to obtain a merged image set; Merging the pre-processed mask data corresponding to each of the contour node subsets to obtain a merged mask data set; The merged dataset is constructed according to the merged image set and the merged mask dataset.

5. The method according to any one of claims 1 to 4, characterized in that: The step of performing contour extension on the fused mask image set in the preprocessed mask data to obtain an extended contour line set includes: Performing contour extraction on the fused mask image set according to the contour extraction model to obtain the contour line set that meets the preset first condition; The contours in the contour line set are extended according to the curve offset model to obtain the extended contour line set.

6. The method according to claim 1, characterized in that The merged data set includes a target fusion mask data set and a merged image set; Performing mask fusion and splicing according to the merged data set to obtain a target fused image includes: Constructing a target fusion mask according to the target fusion mask data set; The merged image set is spliced ​​according to the target fusion mask to generate the target fusion image.

7. The method according to claim 1, characterized in that The mask data includes: importance mask data and template data; the preprocessed mask data includes: a preprocessed image, a mask image and a fused mask image set; the mask data of the image to be spliced ​​and the image to be spliced ​​are preprocessed respectively to obtain the preprocessed mask data, including: Preprocessing the image to be stitched to obtain the preprocessed image; Preprocessing the importance mask data to obtain the mask image; The template data is preprocessed to obtain the fused mask image set.

8. An image stitching device, characterized in that: The device comprises: A preprocessing module, used for preprocessing the image to be stitched and the mask data of the image to be stitched respectively to obtain preprocessed mask data; A contour extension module, used for performing contour extension on the fused mask image set in the preprocessed mask data to obtain an extended contour line set; A directed graph construction module, used for constructing a directed graph according to the fused mask image set and the extended contour line set to obtain a contour directed graph; A node partitioning module, used for partitioning the nodes of the contour directed graph to obtain a contour node subset; A merging module, used for merging the images to be spliced ​​and the pre-processed mask data according to the contour node subset to obtain a merged data set; The fusion and stitching module is used to perform mask fusion and stitching according to the merged data set to obtain a target fused image.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.