Broken coin splicing and repairing method, device and equipment, medium and product
By acquiring and preprocessing the broken coin image, determining the outline coordinates and using the point merging algorithm to generate approximate polygons, the problem of traditional manual stitching is solved and efficient and accurate broken coin repair is achieved.
Patent Information
- Application Number
- CN202411852187.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-03-25
AI Technical Summary
The traditional method of shredding coins relies on manual splicing and repair, which is inefficient and accurate depending on the experience of the operator, and is prone to splicing errors or incomplete splicing.
By obtaining the broken coin image to be stitched, pre-processing to generate the stitched image to be stitched, determining the outline boundaries and contour coordinates of pixel points, and generating approximate polygons based on the point merging algorithm, thereby realizing the repair of broken coin.
Improves the efficiency and accuracy of broken coins repair, reduces manual workload, ensures that the restored broken coins are closer to the original complete form, and maintains integrity and consistency.
Smart Images

Figure CN119693227A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of financial technology, and in particular to a method, device, equipment, medium and product for splicing and repairing broken coins. Background Art
[0002] During the circulation process, currency may be damaged due to various reasons, such as tearing, wear, corrosion, etc., resulting in broken coins. If the broken coins are not properly handled, it will not only cause a waste of monetary resources, but may also affect the normal circulation of currency and economic order.
[0003] In the traditional way of dealing with broken coins, manual splicing and repair are mainly done. However, manual splicing and repair have many limitations. First, manual operation is inefficient and requires a lot of time and labor costs. Second, the accuracy of manual splicing depends largely on the experience and skills of the operator, and splicing errors or incompleteness are prone to occur. Summary of the invention
[0004] The present invention provides a method, device, equipment, medium and product for splicing and repairing broken coins. Approximate polygons are generated according to contour coordinates using a point merging algorithm, thereby realizing broken coin repair, helping to restore the integrity of broken coins and improving the efficiency of broken coin repair.
[0005] According to one aspect of the present invention, a method for splicing and repairing broken coins is provided, the method comprising:
[0006] Acquire the broken coin images to be stitched, and pre-process the broken coin images to generate the images to be stitched;
[0007] Determine the contour boundary of the pixel points in the image to be stitched, and determine the contour coordinates corresponding to the contour boundary;
[0008] Based on the point merging algorithm, an approximate polygon is generated according to the contour coordinates, and the broken coins are repaired according to the approximate polygon.
[0009] Optionally, the broken coin images are preprocessed to generate the image to be spliced, including: converting the broken coin images into a specified format to generate a converted image, and grayscale processing the converted image to generate a grayscale image; translating the grayscale image to a specified position to generate the image to be spliced.
[0010] Optionally, an approximate polygon is generated according to the contour coordinates based on a point merging algorithm, including: selecting two adjacent pixel point coordinates from the contour coordinates as target pixel point pairs; generating a target straight line according to the target pixel point pair, and determining an error value from the target pixel point pair to the target straight line; judging whether the error value is less than a preset threshold, and if so, reselecting the target pixel point pair from the contour coordinates; otherwise, generating an approximate polygon according to the target straight line.
[0011] Optionally, an approximate polygon is generated based on the target straight line, including: storing the target straight line as a candidate straight line; generating a target pixel point pair based on the end point of the target straight line and the next adjacent pixel point; when all contour coordinates are traversed, constructing an approximate polygon based on the stored candidate straight lines.
[0012] Optionally, repairing the broken coins based on the approximate polygons includes: using a translation algorithm to translate and align the approximate polygons to determine the degree of stitching of the broken coin images; and stitching the broken coin images based on the degree of stitching to generate a stitched image.
[0013] Optionally, after repairing the broken coins according to the approximate polygons, the method further includes: calculating a continuity index of the spliced image; judging whether the continuity index reaches a preset standard, and if so, determining that the broken coins are repaired successfully; otherwise, determining that the broken coins are repaired unsuccessfully.
[0014] According to another aspect of the present invention, a broken coin splicing and repairing device is provided, the device comprising:
[0015] The module for generating images to be spliced is used to obtain images of broken coins to be spliced, and pre-process the images of broken coins to generate images to be spliced;
[0016] The contour coordinate determination module is used to determine the contour boundary of the pixel points in the image to be spliced, and determine the contour coordinates corresponding to the contour boundary;
[0017] The broken coin repair module is used to generate an approximate polygon according to the contour coordinates based on the point merging algorithm, and repair the broken coins based on the approximate polygon.
[0018] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0019] at least one processor;
[0020] and a memory communicatively coupled to the at least one processor;
[0021] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute a method for splicing and repairing broken coins as described in any embodiment of the present invention.
[0022] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement a method for splicing and repairing broken coins as described in any embodiment of the present invention when executed.
[0023] According to another aspect of the present invention, a computer program product is provided, the computer program product comprising a computer program, and the computer program, when executed by a processor, implements a method for splicing and repairing broken coins according to any embodiment of the present invention.
[0024] The technical solution of the embodiment of the present invention helps to more accurately analyze the shape and characteristics of the broken coins and improve the accuracy of splicing by clarifying the contour coordinates. The point merging algorithm can reduce the amount of data and improve processing efficiency. At the same time, the generated approximate polygons can simplify the shape description of the broken coins and can more quickly and accurately splice the broken coins, reducing the manual workload while also improving the efficiency and quality of repair, helping to maintain the integrity and consistency of the broken coins after repair, and making the repaired broken coins closer to the original complete form.
[0025] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1 This is a flow chart of a method for splicing and repairing broken coins provided according to the first embodiment of the present invention;
[0028] Figure 2 is a flow chart of another method for splicing and repairing broken coins provided according to the second embodiment of the present invention;
[0029] Figure 3 This is a schematic diagram of the structure of a broken coin splicing and repairing device provided according to Embodiment 3 of the present invention;
[0030] Figure 4 The present invention is a schematic diagram of the structure of an electronic device for implementing a method for splicing and repairing broken coins according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] Embodiment 1
[0034] Figure 1 A flowchart of a broken coin splicing and repairing method is provided for the first embodiment of the present invention. This embodiment is applicable to the damaged coin repairing scene. The method can be performed by a broken coin splicing and repairing device. The broken coin splicing and repairing device can be implemented in the form of hardware and / or software. The broken coin splicing and repairing device can be configured in a computer controller. Figure 1 As shown, the method includes:
[0035] S110, obtaining images of broken coins to be spliced, and preprocessing the images of broken coins to generate images to be spliced.
[0036] Among them, the broken coin image refers to an image containing the appearance of broken and fragmented currency. Preprocessing refers to the operation performed on the acquired broken coin image before formal restoration, the purpose of which is to improve the image quality, simplify the data, etc., so that the broken coin image is more conducive to the subsequent contour boundary determination operation.
[0037] Specifically, the image data of the broken coins can be obtained from actual broken coins or an existing broken coin image repository by using an image acquisition device, such as a scanner or a high-resolution camera, etc. The image preprocessing can be grayscale processing.
[0038] Optionally, the broken coin images are preprocessed to generate the image to be spliced, including: converting the broken coin images into a specified format to generate a converted image, and grayscale processing the converted image to generate a grayscale image; translating the grayscale image to a specified position to generate the image to be spliced.
[0039] In actual applications, the obtained broken coin images may come from different devices or storage formats, and their original formats may not meet the requirements of subsequent processing, so the controller needs to convert the broken coin images to a specified format. Format conversion can ensure that all subsequent broken coin images are in a unified and adaptive format, which is convenient for unified management and various algorithm operations.
[0040] Specifically, the controller will also convert the broken coin image into a grayscale image. This is because color information is not necessary for subsequent key operations such as determining the outline of the broken coins, and grayscale can simplify the amount of data and reduce the complexity of calculations. Specifically, the color information of the three RGB channels can be converted into a single grayscale value through the weighted average method, and each pixel only retains the brightness information.
[0041] It can be known that the grayscale image is translated to a specified position in order to make the subsequent broken coin splicing operation more convenient and accurate. For example, a unified splicing area may be set in advance, and all broken coin images can be in a suitable position within this area after translation, which is convenient for subsequent comparison and splicing of broken coins according to features such as contours and shapes, so that the broken coin images can generate the final image to be spliced according to the expected layout, laying a good foundation for further operations such as broken coin repair. Exemplarily, when the grayscale image needs to be translated a units along the positive direction of the x-axis and b units along the positive direction of the y-axis, the new coordinates of any pixel point (x, y) in the grayscale image after translation become (x+a, y+b). By transforming the coordinates of all pixels in the grayscale image, the translation of the entire image can be achieved.
[0042] S120 , determining contour boundaries of pixel points in the images to be stitched, and determining contour coordinates corresponding to the contour boundaries.
[0043] Among them, the contour boundary refers to the edge line in the broken coin image that can distinguish the main body of the broken coin from the background or different parts of the broken coin, that is, the line composed of those pixel points with obvious changes in pixel value, which can be determined by the edge detection algorithm. The contour boundary clearly defines the shape range of the broken coin in the image, which is the basis for subsequent determination of the shape characteristics of the broken coin and restoration. The contour coordinates refer to the coordinate position of each pixel point on the contour boundary recorded by the coordinate system of the image as a reference after the contour boundary of the broken coin image is determined, and the contour coordinates can be generated.
[0044] Specifically, the image edge detection algorithm can be used to find the contour boundary of the pixel points in the broken coin image. For example, the Canny edge detection algorithm is used to calculate the gradient amplitude and direction of the broken coin image, and the broken coin image is first smoothed by Gaussian filtering to reduce the influence of noise, and then the gradient is calculated based on the Sobel operator, and then non-maximum suppression is performed, and the points with the largest local gradient are retained as edge candidate points. Finally, through double threshold detection and edge connection, the edge position where the pixel value changes dramatically in the broken coin image is determined as the contour boundary.
[0045] Furthermore, after determining the contour boundary, the controller will also establish a coordinate system for the broken coin image, for example, with the upper left corner of the broken coin image as the origin, the right as the positive direction of the x-axis, and the downward as the positive direction of the y-axis. And with the established coordinate system as a reference, the coordinate values of each key pixel point on the contour boundary are recorded, and the collection of each coordinate value constitutes the contour coordinates.
[0046] S130. Generate an approximate polygon according to the outline coordinates based on a point merging algorithm, and repair the broken coins based on the approximate polygon.
[0047] Among them, the point merging algorithm refers to an algorithm used to process a large number of contour coordinate points. The point merging algorithm can merge the adjacent coordinate points that meet the conditions according to the geometric relationship between the contour coordinate points, according to the set distance threshold, angle threshold and other conditions, so as to fit a polygon that can roughly represent the shape of the broken coins with relatively fewer key coordinate points, which simplifies the data while retaining the shape characteristics of the broken coins. Approximate polygons refer to polygons generated by processing the contour coordinates of the broken coin image through the point merging algorithm. Approximate polygons use fewer key coordinate points than all the coordinate points on the original contour boundary to simulate the shape of the broken coins, that is, the approximate polygon is similar in shape to the original contour of the broken coins, which can be used as an important basis for subsequent operations such as fragment splicing and shape matching during the repair of broken coins, which helps to complete the repair of broken coins more efficiently.
[0048] Specifically, when repairing broken coins, the generated approximate polygons can be used as a basis. For example, when there are multiple broken coin images, the shapes, side lengths, angles and other geometric features of the approximate polygons corresponding to the broken coins can be compared to find the matching sides or corners, just like piecing together the broken coins. Figure 1 In this way, the approximate polygons of the broken coins are reasonably spliced together, and then the images of the broken coins are accurately spliced and combined in space to fill the gaps between the broken coins, thereby repairing the broken coins and restoring them to a relatively complete shape.
[0049] Optionally, an approximate polygon is generated according to the contour coordinates based on a point merging algorithm, including: selecting two adjacent pixel point coordinates from the contour coordinates as target pixel point pairs; generating a target straight line according to the target pixel point pair, and determining an error value from the target pixel point pair to the target straight line; judging whether the error value is less than a preset threshold, and if so, reselecting the target pixel point pair from the contour coordinates; otherwise, generating an approximate polygon according to the target straight line.
[0050] It should be noted that the reason why two adjacent pixel coordinates are selected as the target pixel pair is that there is a direct spatial correlation between adjacent points, which can reflect the local direction and shape characteristics of the contour. For example, if there is a series of coordinate points on the contour, A(x1,y1), B(x2,y2), C(x3,y3)..., then first select the two adjacent points A and B as the target pixel pair, and then analyze the linear characteristics of this small section of the contour based on this pair of points to prepare for the construction of an approximate polygon. Moreover, by selecting adjacent point pairs in order, the entire contour can be systematically traversed without missing any shape information, ensuring that the approximate polygon generated subsequently can fully reflect the original contour of the broken coins.
[0051] Specifically, according to the two-point equation principle of a straight line, the equation of a straight line passing through two points in the target pixel pair can be determined. Then, the controller can measure the degree of fit between the target pixel pair and the generated target straight line by calculating the error value. For example, the minimum sum of squares between the target pixel pair and the straight line can be calculated as the error value. If the calculated error values are all less than the preset threshold, it means that the contour where the target pixel pair is located cannot be simply fitted with the currently generated target straight line, and its shape has obvious curvature and other features, and cannot be accurately represented by a straight line. At this time, the controller will continue to look for the next set of adjacent pixel coordinates as the new target pixel pair, repeat the above process of generating a straight line, calculating the error value, and judging the threshold, traverse along the contour coordinates in turn, and continuously analyze whether each small segment of the contour can be fitted with a straight line.
[0052] On the contrary, if the error value is not less than the preset threshold, it means that the two adjacent pixel points currently selected fit well with the target straight line generated by them, indicating that the contour between the target pixel point pairs can be approximately represented by the target straight line. At this time, the controller can use the target straight line as an edge of the approximate polygon, record the coordinate points corresponding to the two ends of the straight line, and then continue to select new target pixel point pairs from the subsequent unprocessed contour coordinates, repeat the entire process, continuously generate new target straight lines and judge errors, and gradually construct an approximate polygon composed of multiple edges.
[0053] Optionally, an approximate polygon is generated based on the target straight line, including: storing the target straight line as a candidate straight line; generating a target pixel point pair based on the end point of the target straight line and the next adjacent pixel point; when all contour coordinates are traversed, constructing an approximate polygon based on the stored candidate straight lines.
[0054] Among them, the target straight line that meets the requirements can be used as the basis for constructing an approximate polygon. The controller will save the target straight line as an alternative straight line, and then combine and connect it according to the stored straight line information to construct a polygonal shape that can roughly reflect the outline of the broken coins.
[0055] Specifically, the target straight line is generated by the coordinates of two adjacent pixel points, including a starting point and an end point. At this time, the controller can select the end point of the target straight line, and then combine it with the next pixel point adjacent to the end point in the contour coordinates to form a new target pixel point pair. Then, the operation is performed in the order of the broken coin contour coordinates. The entire contour can be processed section by section. Each newly generated target pixel point pair represents the next small segment on the contour, so as to determine whether the subsequent small segment of the contour can be approximated by a new straight line, thereby continuously enriching the alternative straight lines used to construct approximate polygons.
[0056] Finally, since each candidate straight line corresponds to a small segment of the shape approximation on the outline of the broken coin, and adjacent candidate straight lines are connected by common endpoints, these candidate straight lines can be connected end to end in the order of their sequence on the outline. For example, the end point of the first candidate straight line is the starting point of the second candidate straight line, and the end point of the second candidate straight line is the starting point of the third candidate straight line... By connecting all the candidate straight lines in sequence, a closed approximate polygon is finally formed. Compared with the method of describing it with all the contour coordinate points, the approximate polygon can, to a certain extent, approximate the original contour shape of the broken coin image in a relatively concise form, providing a suitable shape basis for subsequent operations such as broken coin repair.
[0057] The technical solution of the embodiment of the present invention helps to more accurately analyze the shape and characteristics of the broken coins and improve the accuracy of splicing by clarifying the contour coordinates. The point merging algorithm can reduce the amount of data and improve processing efficiency. At the same time, the generated approximate polygons can simplify the shape description of the broken coins and can more quickly and accurately splice the broken coins, reducing the manual workload while also improving the efficiency and quality of repair, helping to maintain the integrity and consistency of the broken coins after repair, and making the repaired broken coins closer to the original complete form.
[0058] Embodiment 2
[0059] Figure 2This is a flow chart of a method for repairing broken coins provided in the second embodiment of the present invention. This embodiment adds a specific process of repairing broken coins based on approximate polygons on the basis of the first embodiment. The specific contents of steps S210-S220 are roughly the same as those of steps S110-S120 in the first embodiment, so they will not be described in detail in this embodiment. Figure 2 As shown, the method includes:
[0060] S210, obtaining images of broken coins to be spliced, and preprocessing the images of broken coins to generate images to be spliced.
[0061] Optionally, the broken coin images are preprocessed to generate the image to be spliced, including: converting the broken coin images into a specified format to generate a converted image, and grayscale processing the converted image to generate a grayscale image; translating the grayscale image to a specified position to generate the image to be spliced.
[0062] S220 , determining contour boundaries of pixel points in the images to be stitched, and determining contour coordinates corresponding to the contour boundaries.
[0063] S230 , generating an approximate polygon according to the contour coordinates based on a point merging algorithm.
[0064] Optionally, an approximate polygon is generated according to the contour coordinates based on a point merging algorithm, including: selecting two adjacent pixel point coordinates from the contour coordinates as target pixel point pairs; generating a target straight line according to the target pixel point pair, and determining an error value from the target pixel point pair to the target straight line; judging whether the error value is less than a preset threshold, and if so, reselecting the target pixel point pair from the contour coordinates; otherwise, generating an approximate polygon according to the target straight line.
[0065] Optionally, an approximate polygon is generated based on the target straight line, including: storing the target straight line as a candidate straight line; generating a target pixel point pair based on the end point of the target straight line and the next adjacent pixel point; when all contour coordinates are traversed, constructing an approximate polygon based on the stored candidate straight lines.
[0066] S240: Use a translation algorithm to perform translation alignment on each approximate polygon to determine the degree of stitching of each broken coin image.
[0067] It should be noted that since the broken coins were originally complete currency, there is a matching relationship between the shapes of the fragments after they are damaged. In theory, the approximate polygons corresponding to the images of the broken coins can be aligned after appropriate translation operations, just like puzzle pieces can find suitable splicing positions by moving.
[0068] Specifically, the controller can select one of the approximate polygons as a reference, such as selecting a polygon with a more complete shape and more obvious features as a target polygon, and then try different translation amounts to translate the other approximate polygons one by one. In the translation process, the degree of overlap between them is determined by comparing the vertex coordinates, edge lengths, angles between edges and other geometric features of the polygons. For example, the distance difference and angle difference between the corresponding edges of different approximate polygons can be calculated. The smaller the difference, the more they match in the current translation state, and the higher the degree of splicing. At the same time, some mathematical metrics can also be used, such as the Hausdorff distance, to measure the overall similarity or proximity between two approximate polygons. The Hausdorff distance can comprehensively reflect the farthest distance between the vertex sets of the approximate polygons. If the Hausdorff distance is small, it means that the two approximate polygons are closer and more matched in spatial position, and the degree of set splicing is better. By continuously adjusting the translation amount, the translation position that makes the splicing degree between each approximate polygon reach the optimal level is found, and then the relatively reasonable splicing relationship of each broken coin image in space is determined.
[0069] S250, stitching the broken coin images together according to the stitching degree to generate a stitched image.
[0070] Specifically, the optimal stitching position of each approximate polygon can be determined through the above translation and alignment operation, that is, the relative position relationship of each broken coin image is determined, and then the broken coin images can be actually stitched according to the position relationship. The controller can combine each broken coin image at the pixel level according to the stitching of its approximate polygon, and merge the pixel matrices of the broken coin images in adjacent positions according to the stitching requirements, so that the originally scattered broken coin images are spatially connected into a whole, and finally a stitched image is generated.
[0071] Optionally, after repairing the broken coins according to the approximate polygons, the method further includes: calculating a continuity index of the spliced image; judging whether the continuity index reaches a preset standard, and if so, determining that the broken coins are repaired successfully; otherwise, determining that the broken coins are repaired unsuccessfully.
[0072] Among them, the continuity index is used to measure whether the spliced image generated after the restoration of the broken coins presents a continuous and natural state at the visual and geometric feature levels. It is based on a comprehensive consideration of multiple features such as pixels, edges, and shapes in the spliced image. At the pixel level, in a continuous currency image, when the pattern on the ticket transitions from one area to an adjacent area, the color change should be gradual, and there will be no sudden jump from one color to another completely unrelated color. At the geometric level, the outline and shape of the internal pattern of the spliced image after the broken coins are restored should be complete and naturally connected. For example, the originally continuous lines, patterns, and patterns on the broken coins should be able to be connected after the repair and splicing, without any illogical situations such as breaks or dislocations.
[0073] Specifically, continuity can be measured by calculating the gradient information of image pixels. The gradient values of each pixel in the image in the horizontal and vertical directions are first obtained through edge detection algorithms such as the Sobel operator and the Prewitt operator. If the continuity of the stitched image is good, the gradient change between adjacent pixels should be relatively stable, and there will be no drastic jumps in the gradient value. For example, the sum of the absolute values of the gradient differences of adjacent pixels in a certain area of the stitched image can be calculated, and the sum value can be used as a sub-indicator to measure local continuity. The same calculation is performed on each area of the entire stitched image, and then the average value is taken to obtain a continuity index that reflects the change of pixel gradients for the entire image.
[0074] It can be known that when the calculated continuity index of the stitched image reaches the preset threshold, it indicates that the stitched image already has the continuity characteristics of the complete currency image, and the various fragments of the broken coins have achieved good fusion after stitching. At this time, it can be determined that the broken coins have been repaired successfully. If the continuity index does not reach the preset standard, it means that there are still some discontinuities in the stitched image, such as obvious color differences at the splicing point, and the lines of the pattern cannot be connected. This shows that the broken coin repair has not achieved the expected effect, and the various fragments have not been well spliced and fused to form a complete and natural image. At this time, it can be determined that the broken coin repair has failed. The controller needs to re-examine the previous broken coin image preprocessing, approximate polygon construction or stitching, find problems and make improvements, and try to repair the broken coins again.
[0075] The technical solution of the embodiment of the present invention can accurately adjust the position of the broken coins by aligning them through a translation algorithm, thereby achieving a tighter and more natural splicing effect. By calculating the continuity index, a quantitative standard is provided for evaluating the quality of the repair of broken coins, avoiding the uncertainty of subjective judgment. By comparing with the preset standard, it is possible to accurately judge whether the repair is successful, thereby improving the reliability of the repair result and helping to timely discover the failure of the repair so as to take further improvement measures or re-repair, thereby increasing the probability of successful final repair.
[0076] Embodiment 3
[0077] Figure 3 This is a schematic diagram of the structure of a broken coin splicing and repairing device provided in the third embodiment of the present invention. Figure 3 As shown, the device includes: a to-be-joined image generation module 310, which is used to obtain the to-be-joined broken coin image and pre-process the broken coin image to generate the to-be-joined image;
[0078] The contour coordinate determination module 320 is used to determine the contour boundary of the pixel points in the image to be spliced, and determine the contour coordinates corresponding to the contour boundary;
[0079] The broken coin repair module 330 is used to generate an approximate polygon according to the outline coordinates based on a point merging algorithm, and repair the broken coins based on the approximate polygon.
[0080] Optionally, the image to be spliced generation module 310 is specifically used to: convert the broken coin image into a specified format to generate a converted image, and perform grayscale processing on the converted image to generate a grayscale image; translate the grayscale image to a specified position to generate the image to be spliced.
[0081] Optionally, the broken coin repair module 330 specifically includes: an approximate polygon generation unit, which is used to: select two adjacent pixel point coordinates from the contour coordinates as target pixel point pairs; generate a target straight line based on the target pixel point pair, and determine the error value from the target pixel point pair to the target straight line; determine whether the error value is less than a preset threshold, and if so, re-select the target pixel point pair from the contour coordinates; otherwise, generate an approximate polygon based on the target straight line.
[0082] Optionally, the approximate polygon generation unit specifically includes: an approximate polygon generation sub-unit, used to: store the target straight line as an alternative straight line; generate a target pixel point pair according to the end point of the target straight line and the next adjacent pixel point; when all contour coordinates are traversed, construct an approximate polygon according to the stored alternative straight lines.
[0083] Optionally, the broken coin repair module 330 specifically includes: a broken coin repair unit, which is used to: use a translation algorithm to translate and align each approximate polygon to determine the degree of splicing of each broken coin image; and splice each broken coin image according to the degree of splicing to generate a spliced image.
[0084] Optionally, the device also includes: a module for determining the result of repairing broken coins, which is used to calculate the continuity index of the spliced image after repairing the broken coins according to the approximate polygon; determine whether the continuity index reaches a preset standard, and if so, determine that the broken coins repair is successful; otherwise, determine that the broken coins repair has failed.
[0085] The technical solution of the embodiment of the present invention helps to more accurately analyze the shape and characteristics of the broken coins and improve the accuracy of splicing by clarifying the contour coordinates. The point merging algorithm can reduce the amount of data and improve processing efficiency. At the same time, the generated approximate polygons can simplify the shape description of the broken coins and can more quickly and accurately splice the broken coins, reducing the manual workload while also improving the efficiency and quality of repair, helping to maintain the integrity and consistency of the broken coins after repair, and making the repaired broken coins closer to the original complete form.
[0086] A broken coin splicing and repairing device provided in an embodiment of the present invention can execute a broken coin splicing and repairing method provided in any embodiment of the present invention, and has corresponding functional modules and beneficial effects of the execution method.
[0087] Embodiment 4
[0088] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0089] like Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0090] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0091] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a broken coin splicing and repair method.
[0092] In some embodiments, a method for splicing and repairing broken coins can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for splicing and repairing broken coins described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform a method for splicing and repairing broken coins in any other appropriate manner (for example, by means of firmware).
[0093] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0094] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0095] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0096] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0097] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0098] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0099] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0100] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for splicing and repairing broken coins, characterized in that: include: Acquire the broken coin images to be spliced, and pre-process the broken coin images to generate the images to be spliced; Determine the contour boundary of the pixel points in the image to be stitched, and determine the contour coordinates corresponding to the contour boundary; An approximate polygon is generated according to the outline coordinates based on a point merging algorithm, and the broken coins are repaired according to the approximate polygon.
2. The method according to claim 1, characterized in that The preprocessing of the broken coin images to generate the image to be spliced includes: Performing a specified format conversion on the broken coin image to generate a converted image, and performing grayscale processing on the converted image to generate a grayscale image; The grayscale image is translated to a specified position to generate an image to be stitched.
3. The method according to claim 1, characterized in that The step of generating an approximate polygon according to the contour coordinates based on a point merging algorithm includes: Selecting two adjacent pixel coordinates from the contour coordinates as a target pixel pair; Generate a target straight line according to the target pixel pair, and determine an error value from the target pixel pair to the target straight line; Determine whether the error value is less than a preset threshold, and if so, reselect the target pixel point pair from the contour coordinates; Otherwise, an approximate polygon is generated according to the target straight line.
4. The method according to claim 3, characterized in that: The step of generating an approximate polygon according to the target straight line comprises: storing the target straight line as a candidate straight line; Generate a target pixel point pair according to the end point of the target straight line and the next adjacent pixel point; When all contour coordinates are traversed, the approximate polygon is constructed according to the stored candidate straight lines.
5. The method according to claim 1, characterized in that The repairing of broken coins according to the approximate polygon comprises: Using a translation algorithm to perform translation alignment on each of the approximate polygons to determine the degree of splicing of each of the broken coin images; The broken coin images are spliced together according to the splicing degree to generate a spliced image.
6. The method according to claim 5, characterized in that After repairing the broken coins according to the approximate polygon, the method further includes: Calculating a continuity index of the stitched image; Determine whether the continuity index reaches a preset standard, and if so, determine that the broken coin is successfully repaired; Otherwise, it is determined that the broken coin repair has failed.
7. A broken coin splicing and repairing device, characterized in that: include: The module for generating images to be spliced is used to obtain images of broken coins to be spliced, and pre-process the images of broken coins to generate images to be spliced; A contour coordinate determination module, used to determine the contour boundary of the pixel points in the image to be stitched, and determine the contour coordinates corresponding to the contour boundary; The broken coin repair module is used to generate an approximate polygon according to the outline coordinates based on a point merging algorithm, and repair the broken coin according to the approximate polygon.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1 to 6.
9. A computer storage medium, characterized in that The computer storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method according to any one of claims 1 to 6 when executed.
10. A computer program product, characterized in that The computer program product comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 6.