Fragment Restoration Method and Storage Medium Based on Large-Scale Cooperative Genetic Algorithm
By using a large-scale collaborative genetic algorithm to identify and group edge point sets of fragmented images, a global tree is generated, which solves the problems of low fragment restoration efficiency and poor splicing effect in existing technologies, and achieves efficient splicing of the global optimal solution.
Patent Information
- Application Number
- CN202310965421.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-02
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2043-08-02
AI Technical Summary
In existing technologies, fragment restoration methods cannot perform depth search and solve for the global optimal solution, resulting in low restoration efficiency and poor splicing effect.
A method based on large-scale cooperative genetic algorithm is adopted. By identifying the edge point set of fragmented images, determining the edge similarity, grouping them and performing Prufer encoding, and using genetic evolution and large-scale cooperative algorithm to generate a global tree, the efficient stitching of fragmented images is achieved.
It achieves a deep search of the solution space, quickly obtains the global optimal solution, and improves the efficiency and splicing effect of fragment restoration.
Smart Images

Figure CN116934628B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a fragment restoration method and storage medium based on a large-scale cooperative genetic algorithm. Background Technology
[0002] Computer-aided splicing is an emerging technology that integrates the restoration of cultural relics with computational intelligence. It involves using a computer to scan and input fragment information (corresponding fragments of cultural relics) to form fragment modeling data. Then, a certain measurement method is used to exhaustively search and splice the corresponding fragments, thereby accelerating the work of fragment restoration.
[0003] In related technologies, fragment restoration using computers is divided into two parts: matching and solving. Matching often uses distance, content, and feature-based splicing. As for solving, since large-scale restoration problems are NP-hard, related technologies often use genetic algorithms, ant colony algorithms, and tabu search algorithms to solve combinatorial optimization problems. However, when solving more complex combinatorial optimization problems, existing conventional optimization algorithms can only satisfy local solutions, have poor robustness, and cannot perform depth search or achieve global optimal solutions. As a result, fragment restoration is inefficient and the splicing effect is poor.
[0004] There is no effective solution to the problem that fragment restoration schemes in related technologies cannot perform depth search and solve for the global optimal solution, resulting in low fragment restoration efficiency and poor splicing effect. Summary of the Invention
[0005] This application provides a fragment restoration method and storage medium based on a large-scale cooperative genetic algorithm, which at least solves the problem that fragment restoration schemes in related technologies cannot perform deep search and solve for the global optimal solution, resulting in low fragment restoration efficiency and poor splicing effect.
[0006] In a first aspect, embodiments of this application provide a fragment restoration method based on a large-scale collaborative genetic algorithm, comprising: identifying an edge point set corresponding to each of a plurality of fragment images to be restored, and determining an edge similarity corresponding to the fragment images based on the edge point set corresponding to the plurality of fragment images; grouping the plurality of fragment images according to the edge similarity to obtain a plurality of first fragment image groups, and performing Prufer encoding based on target information of the first fragment image groups to generate a plurality of gene coding sequences, wherein the target information is used to characterize the fragment images possessed by the first fragment image groups; and performing genetic evolution processing on the plurality of gene coding sequences based on a preset genetic algorithm to obtain each of the first fragment image groups. The fragmented image groupings are grouped into a first spanning tree, and multiple first spanning trees are merged using a preset large-scale collaborative algorithm to obtain a first global tree. The first global tree includes multiple second spanning trees used to characterize the splicing relationship information within the second fragmented image group. The genetic evolution operation includes at least one of the following: random tournament selection, genetic crossover, and genetic mutation. The first fitness corresponding to each second spanning tree is determined. Based on the first fitness, multiple second spanning trees are updated by genetic evolution operation to generate a target global tree. Based on the target splicing tree obtained by decoding the target global tree, multiple fragmented images are spliced together. The first fitness is used to characterize the splicing accuracy within the corresponding fragmented image group.
[0007] Secondly, embodiments of this application provide a storage medium storing a computer program that, when executed by a processor, implements the steps of the fragment restoration method based on a large-scale cooperative genetic algorithm as described in the first aspect above.
[0008] Compared to related technologies, the fragment restoration method and storage medium based on a large-scale cooperative genetic algorithm provided in this application involve identifying the edge point set corresponding to each fragment image in multiple fragment images to be restored, and determining the edge similarity of the fragment images based on the edge point set corresponding to the multiple fragment images; grouping the multiple fragment images according to the edge similarity to obtain multiple first fragment image groups, and performing Prufer encoding based on the target information of the first fragment image groups to generate multiple gene coding sequences; performing genetic evolution processing on the multiple gene coding sequences based on a preset genetic algorithm to obtain a first spanning tree corresponding to each first fragment image group, and merging the multiple first spanning trees using a preset large-scale cooperative algorithm to obtain a first global tree. The first global tree includes multiple second spanning trees used to characterize the splicing relationship information within the second fragment image group. A first fitness is determined for each second spanning tree. Based on the first fitness, the multiple second spanning trees are updated by genetic evolution to generate a target global tree. Based on the target splicing tree obtained by decoding the target global tree, the multiple fragment images are spliced. By using fragment edge information for splicing and fragment restoration based on a large-scale cooperative genetic algorithm, grouped cooperative evolution is used to solve large-scale problems, enabling a deep search of the solution space to quickly obtain the global optimal solution. This allows for efficient fragment restoration and splicing, solving the problem that fragment restoration schemes in related technologies cannot perform deep search and solve for the global optimal solution, resulting in low fragment restoration efficiency and poor splicing effect.
[0009] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description
[0010] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0011] Figure 1 This is a hardware structure block diagram of the terminal of the fragment restoration method based on large-scale cooperative genetic algorithm according to an embodiment of this application;
[0012] Figure 2 This is a flowchart of a fragment restoration method based on a large-scale cooperative genetic algorithm according to an embodiment of this application;
[0013] Figure 3 This is a flowchart illustrating a process optimization method according to a preferred embodiment of this application;
[0014] Figure 4This is a structural block diagram of a fragment restoration device based on a large-scale cooperative genetic algorithm according to an embodiment of this application. Detailed Implementation
[0015] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the application. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application. Furthermore, it is understood that although the efforts made in such a development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, modifications to design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as insufficient disclosure of the content of this application.
[0016] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0017] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms "a," "an," "a kind," "the," and similar words used in this application do not indicate quantity limitation and may indicate singular or plural. The terms "comprising," "including," "having," and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units not listed, or may include other steps or units inherent to these processes, methods, products, or devices. "Multiple stages" used in this application refers to two or more stages. "And / or" describes the relationship between related objects, indicating that three relationships may exist; for example, "A and / or B" can represent: A alone, A and B simultaneously, and B alone. The terms "first," "second," "third," etc., used in this application are merely to distinguish similar objects and do not represent a specific ordering of objects.
[0018] Before describing the embodiments of this application, the relevant technologies involved in the embodiments of this application are explained as follows:
[0019] In computer-aided stitching matching, the main aspects involved are distance-based, content-based, and feature-based matching and stitching.
[0020] Distance-based matching employs dimensionality reduction based on fragment edge vectors and proposes various matching metrics. If the distance between two edge vectors is small, it indicates a high degree of integration.
[0021] Content-based methods use fragmented texture descriptors or neural networks for recognition and stitching, which require high-quality fragmented textures.
[0022] Feature-based methods integrate local features such as color, grayscale, and gradient to form a feature descriptor, which is then used to traverse and match two fragments.
[0023] The least squares method is a mathematical tool widely used in many disciplines of data processing, such as error estimation, uncertainty, system identification and prediction, and forecasting. It finds the best function match for data by minimizing the sum of squares of errors. The least squares method can be used to easily obtain unknown data and minimize the sum of squares of errors between the obtained data and the actual data.
[0024] Genetic Algorithm (GA) is a computational model that simulates the biological evolution process based on natural selection and genetic mechanisms in Darwin's theory of evolution. Through mathematical methods, the problem-solving process is transformed into processes similar to the crossover and mutation of chromosomes and genes in biological evolution.
[0025] Prufer encoding is a method for converting an unrooted tree into a sequence. A tree with n nodes (nodes numbered 1 to n) can uniquely correspond to an n-2 bit Prufer sequence, and an n-2 bit Prufer sequence can also uniquely correspond to a tree with n nodes (nodes numbered 1 to n).
[0026] The Douglas-Peucker algorithm (also known as the Lamer-Douglas-Peucker algorithm, iterative adaptive point algorithm, split and merge algorithm) is an algorithm that approximates a curve as a series of points and reduces the number of points.
[0027] Kruskal's algorithm is a method for finding the minimum / maximum spanning tree of a connected network. The basic idea of Kruskal's algorithm for finding the minimum spanning tree is as follows: Assume a connected network G = (V, E). Let the initial state of the minimum spanning tree be a disconnected graph T = (V, {}) with only n vertices and no edges. In this graph, each vertex forms a connected component. In E, select the edge with the minimum cost. If the vertices attached to this edge are in different connected components in T, then add this edge to T; otherwise, discard this edge and select the next edge with the minimum cost. Continue this process until all vertices in T form a connected component.
[0028] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. Taking running on a terminal as an example, Figure 1 This is a hardware structure block diagram of the terminal of the fragment restoration method based on a large-scale cooperative genetic algorithm according to an embodiment of this application. Figure 1 As shown, a terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. Optionally, the terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0029] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the fragment restoration method based on a large-scale cooperative genetic algorithm in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0030] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0031] This embodiment provides a fragment restoration method based on a large-scale cooperative genetic algorithm that runs on the aforementioned terminal. Figure 2 This is a flowchart of a fragment restoration method based on a large-scale cooperative genetic algorithm according to an embodiment of this application, as follows: Figure 2 As shown, the process includes the following steps:
[0032] Step S201: In the multiple fragment images to be restored, identify the edge point set corresponding to each fragment image, and determine the edge similarity corresponding to the fragment images based on the edge point sets corresponding to the multiple fragment images.
[0033] In this embodiment, the fragment image is a digital image obtained by scanning scattered fragments of cultural relics. After obtaining the fragment image, the edges of each fragment image are extracted. For example, after filtering, edge extraction, and binarization according to a set threshold, the edge point set of each fragment image is identified. The identified edge point set is then upsampled by cubic spline interpolation to expand its distribution density and form sub-pixel edges. In this embodiment, after obtaining the edge point set, the similarity of the fragment images is measured based on the edge point set. It should be understood that the edge similarity of the fragment images can be measured using existing image similarity detection algorithms, such as the least squares method.
[0034] Step S202: Based on edge similarity, multiple fragment images are grouped to obtain multiple first fragment image groups, and Prufer encoding is performed based on the target information of the first fragment image groups to generate multiple gene coding sequences, wherein the target information is used to characterize the fragment images of the first fragment image groups.
[0035] In this embodiment, after determining the edge similarity of the fragment images, multiple fragment images are grouped based on edge similarity. This initial grouping is used for initial stitching of the fragment images. The greater the edge similarity between two fragment images, the better the stitching and restoration effect. In this embodiment, the first group of fragment images has achieved initial stitching. To optimize the local stitching based on the fragment grouping, a genetic algorithm is used to solve the problem and optimize the local stitching. It is understood that in local stitching, one fragment image can only be stitched with another fragment image, but one fragment image can be stitched with multiple other fragment images. Therefore, in this embodiment, the Prufer sequence is used as the gene encoding to model the stitching problem as a maximum spanning tree problem, i.e., based on the target information of the first fragment image grouping. Prufer encoding is used to generate multiple gene coding sequences. In this embodiment, according to the rules of Prufer encoding, r-2 random numbers (which can be repeated) between 0 and r-1 are randomly generated as gene coding sequences for a species (corresponding to a first fragment image group), where r represents the number of fragments in the first fragment image group. It can be understood that a first fragment image group includes its fragment images and the edge similarity between the fragment images. When generating the first fragment image group, its corresponding target information is also generated. For example, the fragment codes of the fragment images in the first fragment image group and the number of fragment images are used as the target information of the first fragment image group. The target information of the first fragment image group can also include the edge similarity between the fragment images. When Prufer encoding is performed to generate gene coding sequences and generate the corresponding spanning tree, the corresponding edge similarity is used as the weight of the corresponding individual or branch.
[0036] Step S203: Based on a preset genetic algorithm, perform genetic evolution processing on multiple gene coding sequences to obtain a first spanning tree corresponding to each first fragment image group, and use a preset large-scale collaborative algorithm to merge multiple first spanning trees to obtain a first global tree. The first global tree includes multiple second spanning trees used to characterize the splicing relationship information within the second fragment image group. The genetic evolution operation includes at least one of the following: random tournament selection, genetic crossover, and genetic mutation.
[0037] In this embodiment, when performing genetic evolution processing, random tournament selection, single-point crossover, and single-point mutation operators are used. The genetic evolution operations involved in this application are existing technologies, clear, and feasible. In some optional implementations, a random tournament selection operator is used, for example: for a set K of species (for a gene coding sequence). tRandomly select k individuals, evaluate them, and choose the best one to enter the next generation K. t+1 Repeat the iterative process until the next generation of species reaches size K. t+1 The population size K0 is reached. Simultaneously, a single-point crossover algorithm is used for genetic crossover, for example: randomly selecting a locus loc in the genomes of two individuals i and j, and exchanging the common parts of their genes to complete the crossover. Furthermore, single-point mutation is used for genetic mutation, for example: for gene coding sequences... Select any position loc, and reset the value of G at loc to 0 to r-1, then re-evaluate the individuals to complete the mutation; in some optional implementations, set the population size K0 to 50 and the tournament selection rate P c The mutation rate is 5%, and the probability of mutation is P. m The values are 0.1 and the crossover probability P. ex It is 0.8.
[0038] In this embodiment, a large-scale cooperative algorithm is used for global optimization. That is, all the first spanning trees generated by decoding the genetic code sequences that have completed the genetic evolution operation are cooperatively optimized to convert the distributed solutions obtained based on the genetic algorithm into global optimal solutions. Therefore, all the generated first spanning trees need to be merged into a first global tree for global optimal solution optimization. In this embodiment, after merging the first global tree, the second spanning tree of the first global tree corresponds to the first spanning tree before merging. That is, the second spanning tree is the reference of the first spanning tree under the first global tree.
[0039] Step S204: Determine the first fitness corresponding to each second spanning tree, update the multiple second spanning trees by genetic evolution operation according to the first fitness to generate the target global tree, and stitch the multiple fragment images according to the target stitching tree obtained by decoding the target global tree. The first fitness is used to characterize the accuracy of fragment stitching within the corresponding fragment image group.
[0040] In this embodiment, after generating the current first global tree, the fitness of each second spanning tree is calculated, which is to detect the average fitness of the fragment image group corresponding to each second spanning tree. This determines whether the fragment image group corresponding to the second spanning tree needs correction. When correction is needed, that is, when the splicing relationship of the corresponding fragment images needs to be corrected, the fragment images in the fragment image group corresponding to the second spanning tree are updated. For example, some fragment images are moved out of the corresponding fragment image group, and fragment images from other fragment image groups are moved in. This corrects the splicing relationship of the fragment images in the corresponding fragment image group, and thus corrects the fragment image group's... The stitching relationship of fragment images in a group is achieved by performing a genetic evolution operation within the fragment image group, which is also a Kruskal maximum spanning tree calculation, until each fragment image group no longer needs correction, thereby transforming the distributed solution into a globally optimal solution. When the first global tree that is the globally optimal solution is determined, this first global tree is used as the target global tree. Then, the fragment images are stitched together using the fragment image stitching relationships corresponding to all the second spanning trees corresponding to the target global tree, so as to obtain the expected output image. In this embodiment, the fragment images are stitched together based on the stitching relationship represented by the target global tree, which can be achieved by using affine transformation to stitch the fragment images together.
[0041] Through steps S201 to S204, the process involves identifying the edge point set corresponding to each fragment image in the multiple fragment images to be restored, and determining the edge similarity of the fragment images based on the edge point sets. Based on the edge similarity, the multiple fragment images are grouped to obtain multiple first fragment image groups. Prufer encoding is then performed based on the target information of the first fragment image groups to generate multiple gene coding sequences. A preset genetic algorithm is used to perform genetic evolution processing on the multiple gene coding sequences to obtain a first spanning tree corresponding to each first fragment image group. Finally, a preset large-scale collaborative algorithm is used to merge the multiple first spanning trees to obtain a first global tree. The first global tree includes multiple methods for representing... The second spanning tree is generated by identifying the splicing relationship information within the second fragment image group. A first fitness is determined for each second spanning tree. Based on the first fitness, multiple second spanning trees are updated through genetic evolution to generate a target global tree. Based on the target splicing tree obtained by decoding the target global tree, multiple fragment images are spliced. By utilizing fragment edge information for splicing and a large-scale cooperative genetic algorithm for fragment restoration, grouped cooperative evolution is used to solve large-scale problems, enabling a deep search of the solution space to quickly obtain the global optimal solution. This efficiently restores and splices fragments, solving the problem that related fragment restoration schemes cannot perform deep search and solve for the global optimal solution, resulting in low efficiency and poor splicing effect.
[0042] In some embodiments, identifying the set of edge points corresponding to each fragment image among multiple fragment images to be restored includes the following steps:
[0043] Step 21: Preprocess the first digital image corresponding to each fragment image acquired by scanning, wherein the preprocessing includes median filtering noise reduction and binarization.
[0044] Step 22: Extract edges from the preprocessed digital image using edge detection operators to obtain the first point set, where the edge detection operators include the Canny operator.
[0045] Step 23: After processing the first point set with a piecewise expression based on cubic spline interpolation to generate a sub-pixel edge point set, the sub-pixel edge point set is downsampled based on local curvature entropy and the interpolation expression method to reconstruct and generate the edge point set.
[0046] In this embodiment, cubic spline interpolation is performed on the first point set to complete upsampling and amplify its distribution density to form sub-pixel edges; then, using the interpolation expression, a second downsampling is performed based on the information entropy H(P) derived from the local curvature to reconstruct and generate the edge point set.
[0047] The first digital image corresponding to each fragment image acquired by scanning is preprocessed through the above steps; the edge is extracted from the preprocessed digital image by the edge detection operator to obtain the first point set; after the first point set is processed by the piecewise expression based on cubic spline interpolation to generate the sub-pixel edge point set, the sub-pixel edge point set is downsampled based on the local curvature entropy and the interpolation expression method to reconstruct the edge point set, thereby realizing edge scanning and edge information amplification, and providing data for the calculation of edge similarity of fragment images.
[0048] In some embodiments, the edge similarity of fragment images is determined based on edge point sets corresponding to multiple fragment images, including the following steps:
[0049] Step 31: Using the Douglas Peucker segmentation method for trajectory compression, the edge point set corresponding to each fragment image is grouped to obtain contour segment groups, where each contour segment group corresponds to a coarse-grained level.
[0050] Step 32: Perform least-squares matching on the contour segment group corresponding to a target fragment image and the contour segment group corresponding to all matching fragment images to obtain the first pixel pair. The target fragment image includes one of multiple fragment images, and the matching fragment image includes one of all fragment images except the target fragment image. The first pixel pair is used to characterize the two contour segment groups with the smallest residual energy between the target fragment image and the matching fragment image.
[0051] Step 33: Obtain the left pixel pair set and the right pixel pair set composed of the second pixel pairs distributed on both sides of the first pixel pair. Starting from the first pixel pair, traverse the left pixel pair set and the right pixel pair set in sequence. When the distance between the first pixel pair and the second pixel pair is greater than a preset threshold, determine the first point set and the second point set from the edge points corresponding to the traversed second pixel pair. The second pixel pair includes two contour segment groups corresponding to the target fragment image and the matching fragment image. The first point set includes the edge points corresponding to the target fragment image and the second point set includes the edge points corresponding to the matching fragment image.
[0052] Step 34: Determine the first projection vector corresponding to the first point set and the second projection vector corresponding to the second point set, respectively, and determine the first metric coefficient based on the Euclidean distance between the first projection vector and the second projection vector. The first metric coefficient is used to characterize the degree of matching between the target fragment image and the matching fragment image on the contour segments corresponding to all the second pixel pairs traversed.
[0053] Step 35: Calculate the edge similarity between the target fragment image and the matching fragment image based on the residual energy corresponding to the first pixel pair, the first metric coefficient, and the number of pairs of the second pixel pairs traversed.
[0054] In this embodiment, the Douglas Peucker segmentation method is used to group the fragment edge point set, and then coarse-grained matching using least squares is performed according to the following logic:
[0055] Step 1: Select a fragment image as the target fragment image and another different fragment image as the matching fragment image. For a contour segment group i of the target fragment image, match the corresponding edge point set of the matching fragment image.
[0056] Step 2: Set the edge point set corresponding to the target fragment image as... Define the set of edge points {P} corresponding to the matching fragment image. j Let i walk along the edges of the matching fragment image. At each position, calculate the least squares matching according to the following formula:
[0057]
[0058] st
[0059] A∈R 2×2 , B∈R 2
[0060] s1≤L1s2≤L2l≤min{L1,L2}
[0061] Where A and B are affine transformation operators, A is the scaling factor, and B is the translation factor; R represents the real space, R 2 R represents a two-dimensional real number space. 2×2 L represents the real space of the second-order tensor k The residual energy is the optimization objective of the least squares method, which is to find the optimal A and B to minimize the residual energy. P and Q are points on the two curve segments, s is the starting point, and l is the matching length. Based on the above problem-solving, the equation T(a1,a2,b1,b2) is formed. T =H, the stationary point can be directly calculated:
[0062] (a1,a2,b1,b2)=T -1 H
[0063]
[0064]
[0065] Where T is a matrix representing the coefficients of the system of equations, and H is the constant of the system of equations; x p and y p The x and y coordinates of point P on the curve segment are represented by x. q and y q Similarly, by examining the x and y coordinates of point Q on the curve segment, we observe a convolution structure in the stationary point formula of H. Using a fast convolution algorithm to improve computational speed, we obtain the feature L value as follows:
[0066] The L value represents the minimum residual energy that the least squares method can achieve under optimal conditions.
[0067] Step 3: Calculate the minimum residual energy L at this location, and record all the minimum residual energies obtained during one round of walking. The smallest Record the affine operators A and B at this location, as well as the index of the contour segment group corresponding to this location in the two fragment images. The contour segments corresponding to the two serial numbers are grouped together to form the first pixel pair.
[0068] Step 4: The target fragment image and the matching fragment image are respectively from... The first pixel (forming the first pixel pair) begins to expand to both sides. During the expansion process, matching pixel pairs (that is, the corresponding distances are less than a preset threshold) are recorded:
[0069] Among them, G match For the set of matching pixel pairs, d t The threshold is 0.95-1.
[0070] Step 5: Separate the points belonging to the target fragment image and the points belonging to the matching fragment image; these are the sets respectively. exist Connect the first and last points to form a straight line. Project the two point sets onto the line respectively, using the projection length as an element to form two reduced-dimensional vectors. Calculate the cosine distance between the two vectors, using it as the correction coefficient β (corresponding to the first metric coefficient). Then, combine the minimum residual energy L, the correction coefficient β, and G... match The number of elements is calculated using the following formula to form a new metric function SE, which is the "similarity energy" corresponding to edge similarity pairs:
[0071]
[0072] In this embodiment, edge-based modeling is used, and only edge information of the fragment images is used for stitching. An information amplification algorithm is used, along with accelerated least squares method and fine-grained verification mechanism, to ensure efficient stitching.
[0073] It should be noted that in steps 31 to 35 above, after matching the minimum residual energy based on the least squares method, the system expands outwards from the minimum residual energy point to both sides to extend the features representing the similarity between the two fragment images. That is, the relevant data of the contour segments of the corresponding regions on both sides of the minimum residual energy point are used as data in one dimension to measure the relative degree. By performing linear projection mapping, cosine similarity calculation, and measuring the length of the corresponding contour segments, the parameters for measuring the similarity of the corresponding fragment images are obtained from the edge contour segments on both sides of the minimum residual energy point. Based on the measurement of edge similarity using the minimum residual energy, a new dimension of measurement data is introduced to make the measurement result more representative of the edge similarity between the two fragment images.
[0074] In some embodiments, multiple fragment images are grouped according to edge similarity to obtain multiple first fragment image groups, including the following steps: traversing the edge similarity corresponding to multiple fragment images, and grouping at least two fragment images whose edge similarity is within a preset similarity range to obtain multiple first fragment image groups, wherein a fragment image belongs to only one first fragment image group.
[0075] In some embodiments, Prufer encoding is performed based on the target information of the first fragment image grouping to generate multiple gene coding sequences, including the following steps:
[0076] Step 41: In the target information of each first fragment image group, obtain the fragment code and the number of fragment images corresponding to all fragment images.
[0077] In this embodiment, the target information of the first fragment group includes the fragment code of the fragment image, the number of fragment images, and the edge similarity between fragment images.
[0078] Step 42: Based on the fragment coding, generate the first gene code corresponding to the first fragment image group, and generate the group code corresponding to the first fragment image group according to the first gene code and the number of fragment images.
[0079] In this embodiment, when a first fragment image group has r fragment images, k is the fragment code of fragment image k in the first fragment image group, then the corresponding generated first gene code can be used This means, i.e., n k This represents the gene value of a first fragment image group; simultaneously, let N be the set of edge points corresponding to each fragment image in each first fragment image group. Based on the first gene encoding and the number of fragment images, the generated group encoding can be represented by a numbered list. This list of numbers is used to represent the set of all fragment images in the corresponding first fragment image group. The fragment images in the first fragment image group can be identified through this list of numbers.
[0080] Step 43: Map the grouped encoding to natural numbers, and generate random numbers for the array after natural number mapping according to the Prufer encoding rule to obtain the gene coding sequence corresponding to the corresponding first fragment image group, wherein the gene coding sequence includes a preset number of random numbers.
[0081] In this embodiment, the block code is mapped to natural numbers, which means mapping the label list to natural numbers. In this embodiment, according to the rules of Prufer encoding (refer to the above description of Prufer encoding), r-2 random numbers (corresponding to the number) between 0 and r-1 (corresponding to gene values) are randomly generated (which can be repeated) as the gene encoding of a species, that is, the gene encoding sequence.
[0082] In the above steps, the fragment codes and the number of fragment images corresponding to all fragment images are obtained from the target information of each first fragment image group. Based on the fragment codes, the first gene code corresponding to the first fragment image group is generated. According to the first gene code and the number of fragment images, the group code corresponding to the first fragment image group is generated. The group code is mapped to natural numbers, and random numbers are generated on the array after natural number mapping according to the Prufer coding rule to obtain the gene code sequence corresponding to the first fragment image group. This realizes the genetic algorithm gene encoding of the first fragment image group of the group, so as to model the fragment splicing problem as a maximum spanning tree problem, and solve it and obtain the distribution solution through the genetic algorithm.
[0083] It is understandable that by using the genetic evolution operation of a genetic algorithm to correct the initial stitching relationship of each initial first fragment image group obtained based on edge similarity, the stitching relationship of fragment images can be adjusted at least within that first fragment image group. For example, in the initial stitching relationship, fragment image 1 is stitched with fragment image 2, and after the genetic evolution operation, fragment image 1 is stitched with fragment image 8. At the same time, when optimizing all groups using a large-scale collaborative algorithm, the genetic evolution operation of the genetic algorithm can adjust the stitching relationship of fragment images between multiple first fragment image groups. It is also through the corresponding adjustment that the distributed solution is transformed into the global optimal solution. For example, after optimization, fragment image 1 in the first fragment group g is changed from being stitched with fragment image 2 to being stitched with fragment image 5 in the second fragment group v.
[0084] In some embodiments, a preset large-scale collaborative algorithm is used to merge multiple first spanning trees to obtain a first global tree, including the following steps:
[0085] Step 51: Obtain the first spanning tree corresponding to the target fragment image group in multiple first fragment image groups, and extract all branches from the obtained first spanning tree to obtain the first branch set. The first spanning tree is generated by gene decoding after the corresponding gene coding sequence has completed genetic evolution processing. The branches are used to represent the splicing of two fragment images, and the label value of the branches is used to represent the edge similarity of the corresponding two fragment images.
[0086] In this embodiment, for the gene coding sequence corresponding to a certain first fragment image group m (corresponding to the target fragment image group) to be optimized, for the random number corresponding to an individual corresponding to a fragment image, the Prufer gene is decoded, and after decoding all random numbers, a first spanning tree is generated. By extracting the branches contained in the first spanning tree, that is, the edges in the corresponding spanning tree, the first branch set G1 is obtained.
[0087] Step 52: Using a node randomly selected from the root nodes of the preset initial global tree as the root, search downwards for a preset number of root nodes, determine all branches connecting the searched root nodes, and obtain the second branch set. The initial global tree is randomly generated based on multiple first fragment images grouped together.
[0088] In this embodiment, before merging multiple first spanning trees using a large-scale cooperative algorithm to obtain the first global tree, a global tree S is randomly generated. g As the global initial solution; in S g Randomly select a node as the root of the tree and search downwards to the path (corresponding branches) of m sets of fragment nodes. The path traversed is denoted as set G2, which is the second branch set G2.
[0089] Step 53: Using Kruskal's maximum spanning tree algorithm, process the union of the first branch set and the second branch set to generate the maximum spanning tree subtree. After deleting all branches corresponding to the union from the preset global tree, add the maximum spanning tree subtree to the initial global tree after the branch deletion is completed to generate the current global tree. The current global tree includes at least one second spanning tree. The second fragment image group corresponding to the second spanning tree is generated by updating the target fragment image group.
[0090] In this embodiment, the set G3 = G1∪G2 is computed, and Kruskal's maximum spanning tree algorithm is executed on G3 to form the maximum spanning tree subtree T3. Then, the global solution S is... g Delete G3 and add T3 to form the current global tree.
[0091] Step 54: Repeat the preset iterative optimization steps to iteratively update the current global tree to generate the first global tree. The iterative optimization steps include obtaining the first branch set corresponding to the first fragment image group, searching for the corresponding second branch set in the current global tree, and deleting and updating branches in the current global tree based on the maximum spanning tree subtree generated by processing the union of the first branch set and the second branch set using the Kruskal maximum spanning tree algorithm. The preset number of times is determined based on the number of the first fragment image groups.
[0092] In this embodiment, the first spanning tree corresponding to the first fragment image group of m groups is iteratively optimized, that is, steps 51 to 53 are repeatedly executed to generate the first global tree in this cycle.
[0093] Through steps 51 to 53 above, a large-scale collaborative genetic algorithm is used to restore fragments. This algorithm performs a deep search on distributed solutions and quickly obtains the global optimal solution, forming a solution vector for fragment splicing, thereby improving the efficiency and accuracy of fragment restoration.
[0094] It should be noted that in this embodiment, after the generation of the first global tree is completed, that is, after the grouping correction is completed, if the number of fragments in the corresponding fragment image group is less than 3, an invalid gene length will be generated. This means that the current fragment image group cannot be optimized and frozen. It needs to wait for other fragment image groups to pass fragment images to it until it can be solved. During the freezing process, the splicing relationship represented by the fragment image group is fixed.
[0095] In some embodiments, a first fitness is determined for each second spanning tree, and genetic evolution operations are performed on multiple second spanning trees based on the first fitness to generate a target global tree, including the following steps:
[0096] Step 61: Obtain all branches and label values corresponding to all second spanning trees of the first global tree, and use the average of the label values corresponding to all branches as the first fitness of each second spanning tree.
[0097] Step 62: Calculate the mean of the first fitness of all second spanning trees of the first global tree, and use the calculated mean as the overall fitness of the first global tree.
[0098] Step 63: Determine whether the overall fitness has changed, and if the overall fitness has not changed, use the corresponding first global tree as the target global tree.
[0099] In this embodiment, it is determined whether the overall fitness of the first global tree generated in the current iteration has changed compared to the previous iteration. If the overall fitness does not change, it indicates that the first global tree in the current iteration has converged, which is the corresponding global tree S. g This is the globally optimal solution.
[0100] By obtaining all branches and label values corresponding to all second-spanning trees of the first global tree in the above steps, and taking the average of the label values corresponding to all branches as the first fitness of each second-spanning tree; calculating the average of the first fitness of all second-spanning trees of the first global tree, and taking the calculated average as the overall fitness of the first global tree, the target global tree is determined.
[0101] In some embodiments, the following steps are also performed:
[0102] Step 71: Obtain all branches and label values corresponding to all second spanning trees of the first global tree, and use the average of the label values corresponding to all branches as the first fitness of each second spanning tree.
[0103] Step 72: Calculate the mean of the first fitness of all second spanning trees of the first global tree, and use the calculated mean as the overall fitness of the first global tree.
[0104] Step 73: Determine whether the overall fitness has changed. If the overall fitness has changed, determine the gene coding sequence corresponding to the second spanning tree of the current first global tree to obtain the candidate gene coding sequence.
[0105] Step 74: Using a preset genetic algorithm, perform genetic evolution processing on the candidate gene coding sequences, and decode the candidate gene coding sequences that have completed genetic evolution processing to obtain the candidate spanning tree.
[0106] Step 75: Merge the candidate spanning trees using a preset large-scale collaborative algorithm to update the current first global tree, and determine the target global tree based on the overall fitness corresponding to the updated first global tree.
[0107] Through steps 71 to 75 above, all distributed solutions are iteratively optimized until global convergence is achieved, yielding the optimal solution S. g
[0108] In some embodiments, multiple fragment images are stitched together based on the target stitching tree obtained by decoding the target global tree, including the following steps:
[0109] Step 81: Decode the target global tree to obtain the target stitching tree, which includes the stitching relationship information of the fragment images.
[0110] Step 82: Based on the splicing relationship information, splice multiple fragment images using affine transformation to obtain the target output image.
[0111] Figure 3 This is a flowchart illustrating the fragment restoration process according to a preferred embodiment of this application. (Refer to...) Figure 3 The fragment restoration process according to the preferred embodiment of this application is described below, and the fragment restoration includes the following steps:
[0112] Step 1: Edge scanning.
[0113] In this embodiment, the fragmented images are first scanned into digital image signals. Assuming there are N such signals, after filtering and edge extraction, and binarization according to a set threshold, the edge point set of each fragmented image is identified and denoted as {P}. n}n∈0,1,2,...,N. Cubic spline interpolation is performed on the edge point set to perform upsampling, amplifying its distribution density to form sub-pixel edges.
[0114] Step 2: Measure the edge similarity of the fragmented images based on the least squares method.
[0115] In this embodiment, the original edge point set is grouped based on the Douglas-Peucker segmentation method to obtain multiple contour segment groups, each representing a target for coarse-grained matching. In this embodiment, least-squares matching modeling is performed on two fragmented images, and contour segment groups are defined. Grouping of contour segments Grouping of contour segments {P j A walking least-squares matching process is performed, traversing all fragment images i to find the part with the lowest residual energy, and then using a preset correction strategy to derive the similarity energy E. ij The expression is used to obtain edge similarity.
[0116] Step 3: Locally stitch together the fragmented images by grouping them using an improved genetic algorithm.
[0117] Step 4: Optimize the grouping of all fragmented images using an iterative large-scale collaborative algorithm.
[0118] In this embodiment, after obtaining the distributed solution based on the genetic algorithm, for each fragment image group and its corresponding fragment image, its average fitness is detected and it is determined whether correction is needed. The fragment images in the corrected fragment image group need to be removed from the corresponding fragment image group, and the optimization process of steps 1 to 3 is repeated. In this iterative process, the fitness continuously increases. In this embodiment, Kruskal maximum spanning tree calculation is performed within the fragment image group to transform the distributed solution into the global optimal solution.
[0119] Specifically, fragment reconstruction and splicing were performed using the K-CCGA large-scale collaborative genetic framework based on Kruskal merging.
[0120] First, configure a genetic algorithm module based on Prufer tree. For N fragment images (N is a very large number), divide them into M groups. Configure one module for each group. The gene length is r-2, where r represents the number of fragments assigned to the group. The genetic algorithm uses random tournament selection operator, single-point crossover operator, and single-point mutation operator.
[0121] Secondly, optimize a group of fragmented images by following these steps: 1. Before merging multiple first spanning trees using a large-scale collaborative algorithm to obtain the first global tree, randomly generate a global tree S. g1. As the global starting solution; 2. For the gene coding sequence corresponding to a certain first fragment image group m (corresponding to the target fragment image group) to be optimized, for the random number corresponding to an individual corresponding to a fragment image, decode its Prufer gene, and after decoding all random numbers, generate the first spanning tree. By extracting the branches contained in the first spanning tree, that is, the edges in the corresponding spanning tree, the first branch set G1 is obtained; 3. In S g 1. Randomly select a node as the root and search downwards to the m sets of fragment nodes (corresponding branches). Denote the path traversed as set G2, which is also the second branch set G2; 2. Calculate set G3 = G1∪G2, and execute Kruskal's maximum spanning tree algorithm on G3 to form the maximum spanning tree subtree T3; 3. In the global solution S... g Delete G3, add T3 to form the current global tree, and update S. g .
[0122] It should be further explained that the embodiments of this application are based on fragment edge modeling, using only fragment edge information for splicing. Through information amplification algorithms, accelerated least squares method and fine-grained verification mechanism are used to ensure efficient splicing. At the same time, based on the least squares residual energy, correction calculation is performed, and similarity energy SE is proposed as a matching degree metric function. Furthermore, a large-scale cooperative genetic algorithm is used for fragment restoration, which can search the solution space of combinatorial explosion more deeply and quickly obtain the global optimal solution, forming the solution vector for fragment splicing, which assists or fully automates fragment restoration, greatly improving the speed of cultural relic restoration work. Finally, this embodiment only uses fragment edge information for matching, which has high scalability, not only for 2D planar point clouds, but also for 3D stereo point clouds and even high-dimensional feature spaces containing other features.
[0123] This embodiment also provides a fragment restoration device based on a large-scale cooperative genetic algorithm. This device is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the terms "module," "unit," "subunit," etc., can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0124] Figure 4 This is a structural block diagram of fragment restoration based on a large-scale cooperative genetic algorithm according to an embodiment of this application, such as... Figure 4 As shown, the device includes an identification module 41, an encoding module 42, an optimization module 43, and a processing module 44, wherein...
[0125] The recognition module 41 is used to identify the edge point set corresponding to each fragment image in the multiple fragment images to be restored, and to determine the edge similarity corresponding to the fragment images based on the edge point sets corresponding to the multiple fragment images.
[0126] The encoding module 42, coupled to the recognition module 41, is used to group multiple fragment images according to edge similarity to obtain multiple first fragment image groups, and to perform Prufer encoding based on the target information of the first fragment image groups to generate multiple gene coding sequences, wherein the target information is used to characterize the fragment images of the first fragment image groups.
[0127] The optimization module 43, coupled to the encoding module 42, is used to perform genetic evolution processing on multiple gene coding sequences based on a preset genetic algorithm to obtain a first spanning tree corresponding to each first fragment image group, and to merge multiple first spanning trees using a preset large-scale collaborative algorithm to obtain a first global tree. The first global tree includes multiple second spanning trees used to characterize the splicing relationship information within the second fragment image group. The genetic evolution operation includes at least one of the following: random tournament selection, genetic crossover, and genetic mutation.
[0128] The processing module 44, coupled to the optimization module 43, is used to determine the first fitness corresponding to each second spanning tree, update the multiple second spanning trees by genetic evolution operation according to the first fitness to generate a target global tree, and stitch multiple fragment images together based on the target stitching tree obtained by decoding the target global tree. The first fitness is used to characterize the accuracy of fragment stitching within the corresponding fragment image group.
[0129] The fragment restoration device based on the large-scale cooperative genetic algorithm described above involves identifying the edge point set corresponding to each fragment image in the multiple fragment images to be restored, and determining the edge similarity of the fragment images based on the edge point sets corresponding to the multiple fragment images. According to the edge similarity, the multiple fragment images are grouped to obtain multiple first fragment image groups, and Prufer encoding is performed based on the target information of the first fragment image groups to generate multiple gene coding sequences. Based on a preset genetic algorithm, the multiple gene coding sequences undergo genetic evolution processing to obtain a first spanning tree corresponding to each first fragment image group. Finally, a preset large-scale cooperative algorithm is used to merge the multiple first spanning trees to obtain a first global tree, wherein the first global tree includes multiple... A second spanning tree is used to characterize the splicing relationship information within the second fragment image group; a first fitness is determined for each second spanning tree; based on the first fitness, multiple second spanning trees are updated through genetic evolution to generate a target global tree; and multiple fragment images are spliced based on the target splicing tree obtained by decoding the target global tree. By using fragment edge information for splicing and fragment restoration based on a large-scale cooperative genetic algorithm, grouped cooperative evolution is used to solve large-scale problems, enabling deep search of the solution space to quickly obtain the global optimal solution, thereby efficiently restoring and splicing fragments. This solves the problem that fragment restoration schemes in related technologies cannot perform deep search and solve for the global optimal solution, resulting in low efficiency and poor splicing effect in fragment restoration.
[0130] In some embodiments, the identification module 41 further includes:
[0131] The first preprocessing unit is used to preprocess the first digital image corresponding to each fragment image acquired by scanning, wherein the preprocessing includes median filtering noise reduction processing and binarization processing.
[0132] The first edge detection unit is coupled to the first preprocessing unit and is used to extract edges from the preprocessed digital image using an edge detection operator to obtain a first point set, wherein the edge detection operator includes the Canny operator.
[0133] The first reconstruction unit, coupled to the first edge detection unit, is used to reconstruct the edge point set after processing the first point set with a piecewise expression based on cubic spline interpolation to generate a sub-pixel edge point set, and then downsampling the sub-pixel edge point set based on local curvature entropy and using the interpolation expression method.
[0134] In some embodiments, the identification module 41 further includes:
[0135] The first grouping unit is used to group the edge point set corresponding to each fragment image using the trajectory compression Douglas Peucker segmentation method to obtain contour segment groups, wherein each contour segment group corresponds to a coarse-grained level.
[0136] The first matching unit, coupled to the first grouping unit, is used to perform least-squares matching between the contour segment group corresponding to a target fragment image and the contour segment group corresponding to all matching fragment images to obtain a first pixel pair. The target fragment image includes one of multiple fragment images, and the matching fragment image includes one of all fragment images except the target fragment image. The first pixel pair is used to characterize the two contour segment groups with the smallest residual energy between the target fragment image and the matching fragment image.
[0137] The first extension unit, coupled to the first matching unit, is used to obtain a left pixel pair set and a right pixel pair set composed of second pixel pairs distributed on both sides of the first pixel pair. Starting from the first pixel pair, the left pixel pair set and the right pixel pair set are traversed sequentially. When the distance between the first pixel pair and the second pixel pair is greater than a preset threshold, the first point set and the second point set are determined from the edge points corresponding to the traversed second pixel pair. The second pixel pair includes two contour segment groups corresponding to the target fragment image and the matching fragment image. The first point set includes the edge points corresponding to the target fragment image and the second point set includes the edge points corresponding to the matching fragment image.
[0138] The first determining unit, coupled to the first extending unit, is used to determine the first projection vector corresponding to the first point set and the second projection vector corresponding to the second point set, respectively, and to determine the first metric coefficient based on the Euclidean distance between the first projection vector and the second projection vector. The first metric coefficient is used to characterize the degree of matching between the target fragment image and the matching fragment image in the contour segments corresponding to all the second pixel pairs traversed.
[0139] The first calculation unit, coupled to the first determination unit, is used to calculate the edge similarity between the target fragment image and the matching fragment image based on the residual energy corresponding to the first pixel pair, the first metric coefficient, and the number of logarithms of the traversed second pixel pairs.
[0140] In some embodiments, the encoding module 42 is used to traverse the edge similarity corresponding to multiple fragment images and group at least two fragment images whose edge similarity is within a preset similarity range to obtain multiple first fragment image groups, wherein a fragment image belongs to only one first fragment image group.
[0141] In some embodiments, the encoding module 42 is used to obtain the fragment codes and the number of fragment images corresponding to all fragment images in the target information of each first fragment image group; generate a first gene code corresponding to the first fragment image group based on the fragment codes; generate a group code corresponding to the first fragment image group according to the first gene code and the number of fragment images; map the group code to natural numbers, and generate random numbers on the array after natural number mapping according to the Prufer encoding rule to obtain the gene code sequence corresponding to the corresponding first fragment image group, wherein the gene code sequence includes a preset number of random numbers.
[0142] In some embodiments, the optimization module 43 further includes:
[0143] The first extraction unit is used to obtain the first spanning tree corresponding to the target fragment image group in multiple first fragment image groups, and extract all branches from the obtained first spanning tree to obtain the first branch set. The first spanning tree is generated by gene decoding after the corresponding gene coding sequence has completed genetic evolution processing. The branches are used to represent the splicing of two fragment images, and the label value of the branches is used to represent the edge similarity of the corresponding two fragment images.
[0144] The first search unit, coupled to the first extraction unit, is used to search downwards for a preset number of root nodes, using a node randomly selected from the root nodes of the preset initial global tree as the root, to determine all branches connecting the searched root nodes and obtain a second branch set. The initial global tree is randomly generated based on multiple first fragment images grouped together.
[0145] The first generation unit, coupled to the first search unit, is used to process the union of the first branch set and the second branch set using the Kruskal maximum spanning tree algorithm to generate the maximum spanning tree subtree. After deleting all branches corresponding to the union from the preset global tree, the maximum spanning tree subtree is added to the initial global tree after the branch deletion is completed to generate the current global tree. The current global tree includes at least one second spanning tree, and the second fragment image group corresponding to the second spanning tree is generated by updating the target fragment image group.
[0146] The first processing unit is used to repeatedly execute preset iterative optimization steps to iteratively update the current global tree to generate a first global tree. The iterative optimization steps include obtaining the first branch set corresponding to the first fragment image group, searching for the corresponding second branch set in the current global tree, and deleting and updating branches in the current global tree based on the maximum spanning tree subtree generated by processing the union of the first branch set and the second branch set using the Kruskal maximum spanning tree algorithm. The preset number of times is determined based on the number of first fragment image groups.
[0147] In some embodiments, the processing module 44 further includes:
[0148] The first acquisition unit is used to acquire all branches corresponding to all second spanning trees of the first global tree and the label value corresponding to each branch, and to use the average of the label values corresponding to all branches as the first fitness of each second spanning tree.
[0149] The first processing unit, coupled to the first acquisition unit, is used to calculate the average of the first fitness corresponding to all second spanning trees of the first global tree, and to use the calculated average as the overall fitness corresponding to the first global tree.
[0150] The first judgment unit, coupled to the first operation unit, is used to determine whether the overall fitness has changed, and if the overall fitness has not changed, the corresponding first global tree is used as the target global tree.
[0151] In some embodiments, the processing module 44 is further configured to, upon determining a change in the overall fitness, determine the gene coding sequence corresponding to the second spanning tree of the current first global tree to obtain a candidate gene coding sequence; perform genetic evolution processing on the candidate gene coding sequence using a preset genetic algorithm, and decode the candidate gene coding sequence after the genetic evolution processing to obtain a candidate spanning tree; merge the candidate spanning trees using a preset large-scale cooperative algorithm to update the current first global tree, and determine the target global tree based on the overall fitness corresponding to the updated first global tree.
[0152] In some embodiments, the processing module 44 is further configured to decode the target global tree to obtain the target stitching tree, wherein the target stitching tree includes stitching relationship information of the fragment images; based on the stitching relationship information, multiple fragment images are stitched together using affine transformation to obtain a target output image.
[0153] This embodiment also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0154] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0155] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0156] S1. In the multiple fragment images to be restored, identify the edge point set corresponding to each fragment image, and determine the edge similarity corresponding to the fragment images based on the edge point sets corresponding to multiple fragment images.
[0157] S2, based on edge similarity, group multiple fragment images to obtain multiple first fragment image groups, and perform Prufer encoding based on the target information of the first fragment image groups to generate multiple gene coding sequences.
[0158] S3, based on a preset genetic algorithm, performs genetic evolution processing on multiple gene coding sequences to obtain a first spanning tree corresponding to each first fragment image group, and uses a preset large-scale collaborative algorithm to merge multiple first spanning trees to obtain a first global tree, wherein the first global tree includes multiple second spanning trees used to characterize the splicing relationship information within the second fragment image group.
[0159] S4. Determine the first fitness corresponding to each second spanning tree. Based on the first fitness, perform genetic evolution operations to update multiple second spanning trees to generate a target global tree. Then, based on the target stitching tree obtained by decoding the target global tree, stitch together multiple fragment images.
[0160] Furthermore, in conjunction with the fragment restoration method based on a large-scale cooperative genetic algorithm in the above embodiments, this application embodiment can provide a storage medium for implementation. This storage medium stores a computer program; when executed by a processor, the computer program implements any of the fragment restoration methods based on a large-scale cooperative genetic algorithm in the above embodiments.
[0161] Those skilled in the art should understand that the technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been 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 specification.
[0162] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A fragment restoration method based on a large-scale cooperative genetic algorithm, characterized in that, include: In multiple fragmented images to be restored, the edge point set corresponding to each fragmented image is identified, and the edge similarity corresponding to the fragmented images is determined based on the edge point set corresponding to the multiple fragmented images. Based on the edge similarity, the multiple fragment images are grouped to obtain multiple first fragment image groups, and Prufer encoding is performed based on the target information of the first fragment image groups to generate multiple gene coding sequences, wherein the target information is used to characterize the fragment images possessed by the first fragment image groups; Based on a preset genetic algorithm, a genetic evolution operation is performed on multiple gene coding sequences to obtain a first spanning tree corresponding to each first fragment image group. A preset large-scale collaborative algorithm is then used to merge multiple first spanning trees to obtain a first global tree. The first global tree includes multiple second spanning trees used to characterize splicing relationship information within the second fragment image group. The genetic evolution operation includes at least one of the following: random tournament selection, genetic crossover, and genetic mutation. A first fitness is determined for each second spanning tree. Based on the first fitness, a genetic evolution operation is performed on multiple second spanning trees to update them, so as to generate a target global tree. Based on the target stitching tree obtained by decoding the target global tree, multiple fragment images are stitched together. The first fitness is used to characterize the accuracy of fragment stitching within the corresponding fragment image group. The first global tree is obtained by merging multiple first spanning trees using a pre-defined large-scale collaborative algorithm, including: Obtain the first spanning tree corresponding to the target fragment image group in multiple first fragment image groups, and extract all branches from the obtained first spanning tree to obtain a first branch set. The first spanning tree is generated by gene decoding after the corresponding gene coding sequence has completed genetic evolution processing. The branches are used to represent the splicing of two fragment images, and the label value of the branches is used to represent the edge similarity of the corresponding two fragment images. The target fragment image group includes a set of first fragment image groups that have been optimized. Using a node randomly selected from the root nodes of a preset initial global tree as the root, a preset number of the root nodes are searched downwards to determine all the branches connecting the searched root nodes, thus obtaining a second branch set. The initial global tree is randomly generated based on multiple groups of the first fragment images. Using Kruskal's maximum spanning tree algorithm, the union of the first branch set and the second branch set is processed to generate a maximum spanning tree subtree. After deleting all branches corresponding to the union from the initial global tree, the maximum spanning tree subtree is added to the initial global tree after the branch deletion is completed to generate the current global tree. The current global tree includes at least one second spanning tree, and the second fragment image group corresponding to the second spanning tree is generated by updating the target fragment image group. The iterative optimization steps are repeated a preset number of times to iteratively update the current global tree to generate the first global tree. The iterative optimization steps include obtaining the first branch set corresponding to the first fragment image group, searching for the corresponding second branch set in the current global tree, and deleting and updating branches in the current global tree based on the maximum spanning tree subtree generated by processing the union of the first branch set and the second branch set using the Kruskal maximum spanning tree algorithm. The preset number of times is determined based on the number of the first fragment image groups.
2. The method according to claim 1, characterized in that, In the multiple fragmented images to be restored, the set of edge points corresponding to each fragmented image is identified, including: The first digital image corresponding to each of the fragment images acquired by scanning is preprocessed, wherein the preprocessing includes median filtering noise reduction and binarization. Edges are extracted from the preprocessed digital image using an edge detection operator to obtain a first set of points, wherein the edge detection operator includes the Canny operator; After processing the first point set using a piecewise expression based on cubic spline interpolation to generate a sub-pixel edge point set, the sub-pixel edge point set is downsampled based on local curvature entropy and using the interpolation expression method to reconstruct the edge point set.
3. The method according to claim 1, characterized in that, Based on the edge point set corresponding to multiple fragment images, the edge similarity corresponding to the fragment images is determined, including: Using the Douglas Peucker segmentation method for trajectory compression, the edge point set corresponding to each fragment image is grouped to obtain contour segment groups, wherein each contour segment group corresponds to a coarse-grained level. For each contour segment group corresponding to a target fragment image, least squares matching is performed with the contour segment groups corresponding to all matching fragment images to obtain a first pixel pair. The target fragment image includes one of a plurality of fragment images, and the matching fragment image includes one of all fragment images other than the target fragment image. The first pixel pair is used to characterize the two contour segment groups with the smallest residual energy between the target fragment image and the matching fragment image. Obtain a left pixel pair set and a right pixel pair set composed of second pixel pairs distributed on both sides of the first pixel pair. Starting from the first pixel pair, sequentially traverse the left pixel pair set and the right pixel pair set. When the distance between the first pixel pair and the second pixel pair is greater than a preset threshold, determine a first point set and a second point set from the edge points corresponding to the traversed second pixel pair. The second pixel pair includes two contour segment groups corresponding to the target fragment image and the matching fragment image. The first point set includes the edge points corresponding to the target fragment image and the second point set includes the edge points corresponding to the matching fragment image. A first projection vector corresponding to the first point set and a second projection vector corresponding to the second point set are determined respectively. A first metric coefficient is determined based on the Euclidean distance between the first projection vector and the second projection vector. The first metric coefficient is used to characterize the degree of matching between the target fragment image and the matching fragment image in the contour segments corresponding to all the second pixel pairs traversed. The edge similarity between the target fragment image and the matching fragment image is calculated based on the residual energy corresponding to the first pixel pair, the first metric coefficient, and the number of pairs of the second pixel pair traversed.
4. The method according to claim 1, characterized in that, Based on the edge similarity, multiple fragment images are grouped to obtain multiple first fragment image groups, including: traversing the edge similarity corresponding to multiple fragment images, and grouping at least two fragment images whose edge similarity is within a preset similarity range to obtain multiple first fragment image groups, wherein each fragment image belongs to only one first fragment image group.
5. The method according to claim 1, characterized in that, Based on the target information of the first fragment image grouping, Prufer encoding is performed to generate multiple gene coding sequences, including: In the target information of each first fragment image group, obtain the fragment code and the number of fragment images corresponding to all fragment images; Based on the fragment encoding, a first gene encoding corresponding to the first fragment image group is generated, and a group encoding corresponding to the first fragment image group is generated according to the first gene encoding and the number of fragment images; The group encoding is mapped to natural numbers, and random numbers are generated from the natural number-mapped array according to the Prufer encoding rule to obtain the gene encoding sequence corresponding to the corresponding first fragment image group, wherein the gene encoding sequence includes a preset number of random numbers.
6. The method according to claim 1, characterized in that, Determine the first fitness corresponding to each second spanning tree, and update the multiple second spanning trees through genetic evolution operations based on the first fitness to generate the target global tree, including: Obtain all branches corresponding to all second spanning trees of the first global tree and the label value corresponding to each branch, and use the average of the label values corresponding to all branches as the first fitness corresponding to each second spanning tree; Calculate the mean of the first fitness corresponding to all the second spanning trees of the first global tree, and use the calculated mean as the overall fitness corresponding to the first global tree; Determine whether the overall fitness has changed, and if it is determined that the overall fitness has not changed, use the corresponding first global tree as the target global tree.
7. The method according to claim 6, characterized in that, If the change in overall fitness is detected, the method further includes: Determine the gene coding sequence corresponding to the second spanning tree of the current first global tree to obtain candidate gene coding sequences; Using a preset genetic algorithm, the candidate gene coding sequences are subjected to genetic evolution processing, and the candidate gene coding sequences that have undergone genetic evolution processing are decoded to obtain a candidate spanning tree; The candidate spanning trees are merged using a preset large-scale collaborative algorithm to update the current first global tree, and the target global tree is determined based on the overall fitness corresponding to the updated first global tree.
8. The method according to claim 1, characterized in that, Based on the target stitching tree obtained by decoding the target global tree, multiple fragment images are stitched together, including: The target global tree is decoded to obtain the target stitching tree, wherein the target stitching tree includes the stitching relationship information of the fragment images; Based on the splicing relationship information, multiple fragment images are spliced together using affine transformation to obtain the target output image.
9. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the fragment restoration method based on the large-scale cooperative genetic algorithm as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Three-dimensional fragment splicing reconstruction method, system and device and storage medium
CN112288856A
Image processor and image processing method
JP2004038537A