Method and device for determining shape similarity of closed figures, storage medium, and computer device
By selecting the farthest point and the largest triangle point on the graphic outline as key points, the robustness and efficiency problems of graphic similarity calculation in the prior art are solved, and more efficient and accurate graphic similarity judgment is achieved.
Patent Information
- Application Number
- CN202410791139.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2044-06-19
AI Technical Summary
Existing methods for calculating image similarity suffer from insufficient robustness, high computational resource consumption, and poor model interpretability, especially in cases of local image changes and complex scenes where accuracy is low.
By selecting the farthest point on the outline of a graphic and the point that forms the largest triangle as key points, the similarity of the graphics is compared, which reduces the amount of calculation and improves accuracy. It is applicable to the comparison of graphics of different sizes, proportions and rotation angles.
It improves the accuracy and efficiency of graphic similarity judgment, enhances the robustness of the method, is applicable to the comparison of graphics of different sizes and rotation angles, and reduces the amount of computation.
Smart Images

Figure CN118674949B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method and apparatus for determining the shape similarity of closed graphics, a storage medium, and a computer device. Background Technology
[0002] Existing technologies for calculating image similarity mainly include feature matching and deep learning methods. Feature matching extracts key feature points from an image (such as SIFT, SURF, etc.) and compares the degree of matching between these feature points. This method is robust to local changes in the image, but its accuracy may be affected by insufficient feature extraction or excessive noise. Deep learning methods utilize neural networks to learn high-level feature representations of images, making them suitable for image similarity calculation in complex scenes. However, they require a large amount of labeled data for training, consuming significant computational resources, and have poor model interpretability.
[0003] Therefore, developing more efficient, robust, and easy-to-understand methods for calculating graph similarity remains a key research focus. Summary of the Invention
[0004] In view of this, embodiments of this application provide a method, apparatus, storage medium, and computer device for determining the shape similarity of closed graphics. By selecting specific key points on the graphic contour (the farthest points and the points forming the largest triangle) for comparison, this method can more accurately capture the main morphological features of the graphic, improving the accuracy of shape similarity judgment. Furthermore, it is applicable to the comparison of graphics of different sizes, proportions, and rotation angles, because methods based on contours and geometric features are relatively insensitive to these changes. Compared to directly comparing the entire graphic contour or pixel-level information, focusing on only a few key feature points can significantly reduce computational load and improve efficiency.
[0005] According to one aspect of this application, a method for determining the shape similarity of a closed figure is provided, the method comprising:
[0006] Obtain the image to be compared, wherein the image to be compared is a closed graphic image;
[0007] Identify the graphic contour corresponding to the image to be compared, and determine the two contour points that are farthest apart on the graphic contour, and construct a first line segment based on the two contour points;
[0008] Based on the first line segment, the graphic outline is divided into a first graphic sub-outline and a second graphic sub-outline. On the first graphic sub-outline, a first sub-outline point that forms the largest triangle with the first line segment is determined, and on the second graphic sub-outline, a second sub-outline point that forms the largest triangle with the first line segment is determined.
[0009] Obtain target comparison information corresponding to the target image, wherein the target comparison information includes a first target line segment, a first target sub-contour point, and a second target sub-contour point corresponding to the target image. The first target line segment is the line segment formed by the two farthest contour points on the target graphic contour of the target image. The first target sub-contour point is the point on the first target graphic sub-contour that forms the largest triangle with the first target line segment. The second target sub-contour point is the point on the second target graphic sub-contour that forms the largest triangle with the first target line segment. The first target graphic sub-contour and the second target graphic sub-contour are obtained by dividing the target graphic contour based on the first target line segment.
[0010] Based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information, the shape similarity between the image to be compared and the target image is determined.
[0011] Optionally, the target comparison information also includes the target included angle between the first target line segment and the second target line segment, and the target first length ratio between the first target line segment and the second target line segment, wherein the second target line segment is a line segment formed by the first target sub-contour point and the second target sub-contour point;
[0012] The step of determining the shape similarity between the image to be compared and the target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information includes:
[0013] The second line segment is determined based on the first sub-contour point and the second sub-contour point. The angle between the first line segment and the second line segment is measured. The lengths of the first line segment and the second line segment are measured respectively. The first length ratio between the first line segment and the second line segment is calculated.
[0014] Calculate the angle deviation between the included angle and the target included angle, and the first length ratio deviation between the first length ratio and the target first length ratio. Based on the angle deviation and the first length ratio deviation, determine the shape similarity between the image to be compared and the target image.
[0015] Optionally, after determining the shape similarity between the image to be compared and the target image based on the angle deviation and the first length ratio deviation, the method further includes:
[0016] If the shape similarity is greater than a preset threshold, the image to be compared is determined to be a similar closed graphic image of the target image, and the photographed object corresponding to the image to be compared is determined to be a qualified object, wherein the photographed object corresponding to the target image is a standard object;
[0017] If the shape similarity is less than or equal to the preset threshold, then the image to be compared is determined not to be a similar closed image of the target image, and the photographed object corresponding to the image to be compared is determined to be an unqualified object.
[0018] Optionally, the step of determining that the image to be compared belongs to a similar closed graphic image of the target image if the shape similarity is greater than a preset threshold includes:
[0019] If the shape similarity is greater than the preset threshold, then the four endpoints of the first line segment and the second line segment are connected sequentially to form four line segments, and the second length ratio between the four line segments is calculated. Based on the second length ratio and the target second length ratio in the target comparison information, it is determined whether the image to be compared belongs to a similar closed graphic image of the target image.
[0020] Optionally, the shooting distance and camera parameters corresponding to the image to be compared and the target image are the same; determining that the photographed object corresponding to the image to be compared is a qualified object includes:
[0021] Based on the length of the first line segment and the length of the target first line segment, the scaling ratio of the photographed object corresponding to the image to be compared relative to the standard object is determined;
[0022] If the scaling ratio is within the preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be a qualified object;
[0023] If the scaling ratio is outside the preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be an unqualified object.
[0024] Optionally, identifying the graphic contour corresponding to the image to be compared includes:
[0025] The image to be compared is binarized, and the binarized image to be compared is then subjected to contour recognition to obtain the graphic contour.
[0026] Optionally, the target image includes multiple images; determining the shape similarity between the image to be compared and the target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information includes:
[0027] Based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information corresponding to each target image, the shape similarity between the image to be compared and each target image is determined respectively.
[0028] Based on the shape similarity between the image to be compared and each of the target images, the image to be compared is divided into an image group with the highest shape similarity to the target image, so as to complete the classification of the image to be compared.
[0029] According to another aspect of this application, a shape similarity determination apparatus for a closed shape is provided, the apparatus comprising:
[0030] An acquisition module is used to acquire an image to be compared, wherein the image to be compared is a closed graphic image;
[0031] The calculation module is used to identify the graphic contour corresponding to the image to be compared, and determine the two contour points that are farthest apart on the graphic contour, and form a first line segment based on the two contour points; divide the graphic contour into a first graphic sub-contour and a second graphic sub-contour based on the first line segment, and determine a first sub-contour point on the first graphic sub-contour that forms a triangle with the first line segment with the largest area, and determine a second sub-contour point on the second graphic sub-contour that forms a triangle with the first line segment with the largest area.
[0032] The acquisition module is further configured to acquire target comparison information corresponding to the target image, wherein the target comparison information includes a first target line segment, a first target sub-contour point, and a second target sub-contour point corresponding to the target image. The first target line segment is the line segment formed by the two farthest contour points on the target graphic contour of the target image. The first target sub-contour point is the point on the first target graphic sub-contour that forms the largest triangle with the first target line segment. The second target sub-contour point is the point on the second target image sub-contour that forms the largest triangle with the first target line segment. The first target graphic sub-contour and the second target graphic sub-contour are obtained by dividing the target graphic contour based on the first target line segment.
[0033] The calculation module is further configured to determine the shape similarity between the image to be compared and the target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information.
[0034] Optionally, the target comparison information also includes the target included angle between the first target line segment and the second target line segment, and the target first length ratio between the first target line segment and the second target line segment, wherein the second target line segment is a line segment formed by the first target sub-contour point and the second target sub-contour point;
[0035] The computing module is also used for:
[0036] The second line segment is determined based on the first sub-contour point and the second sub-contour point. The angle between the first line segment and the second line segment is measured. The lengths of the first line segment and the second line segment are measured respectively. The first length ratio between the first line segment and the second line segment is calculated.
[0037] Calculate the angle deviation between the included angle and the target included angle, and the first length ratio deviation between the first length ratio and the target first length ratio. Based on the angle deviation and the first length ratio deviation, determine the shape similarity between the image to be compared and the target image.
[0038] Optionally, the computing module is further configured to:
[0039] If the shape similarity is greater than a preset threshold, the image to be compared is determined to be a similar closed graphic image of the target image, and the photographed object corresponding to the image to be compared is determined to be a qualified object, wherein the photographed object corresponding to the target image is a standard object;
[0040] If the shape similarity is less than or equal to the preset threshold, then the image to be compared is determined not to be a similar closed image of the target image, and the photographed object corresponding to the image to be compared is determined to be an unqualified object.
[0041] Optionally, the computing module is further configured to:
[0042] If the shape similarity is greater than the preset threshold, then the four endpoints of the first line segment and the second line segment are connected sequentially to form four line segments, and the second length ratio between the four line segments is calculated. Based on the second length ratio and the target second length ratio in the target comparison information, it is determined whether the image to be compared belongs to a similar closed graphic image of the target image.
[0043] Optionally, the image to be compared and the target image have the same shooting distance and camera parameters; the calculation module is further configured to:
[0044] Based on the length of the first line segment and the length of the target first line segment, the scaling ratio of the photographed object corresponding to the image to be compared relative to the standard object is determined;
[0045] If the scaling ratio is within the preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be a qualified object;
[0046] If the scaling ratio is outside the preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be an unqualified object.
[0047] Optionally, the computing module is further configured to:
[0048] The image to be compared is binarized, and the binarized image to be compared is then subjected to contour recognition to obtain the graphic contour.
[0049] Optionally, the computing module is further configured to:
[0050] Based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information corresponding to each target image, the shape similarity between the image to be compared and each target image is determined respectively.
[0051] Based on the shape similarity between the image to be compared and each of the target images, the image to be compared is divided into an image group with the highest shape similarity to the target image, so as to complete the classification of the image to be compared.
[0052] According to another aspect of this application, a storage medium is provided that stores a computer program thereon, which, when executed by a processor, implements the above-described method for determining the shape similarity of closed graphics.
[0053] According to another aspect of this application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the program to implement the above-described method for determining the shape similarity of a closed graphic.
[0054] Using the above technical solution, the embodiments of this application provide a method and apparatus for determining the shape similarity of closed figures, a storage medium, and a computer device. The method involves acquiring images of closed figures to be compared and identifying the figure contours in the images. On the identified figure contours, the two furthest points are found, and these two points form a first line segment that divides the figure contour into two sub-contours. In each of the two sub-contours, a point is determined such that these two points, together with the first line segment obtained in the first step, form the largest possible triangle, and these points are marked as the first sub-contour point and the second sub-contour point, respectively. Relevant information from the target image is acquired, including the target first line segment formed by the two furthest points on the target figure contour, and the target first sub-contour point and target second sub-contour point found on the two sub-contours of the target figure based on the same rules. Finally, using the first line segment, sub-contour points, and other information extracted from the images to be compared and the target image, the shape similarity of the closed figures in the two images is determined through a certain algorithm or formula. This application compares shapes by selecting specific key points on the outline of the graphic (the farthest point and the points forming the largest triangle). This method can more accurately capture the main morphological features of the graphic, improving the accuracy of shape similarity judgment. Furthermore, it is applicable to the comparison of graphics of different sizes, proportions, and rotation angles because methods based on outlines and geometric features are relatively insensitive to these changes. Compared to directly comparing the entire graphic outline or pixel-level information, focusing on only a few key feature points can significantly reduce computational load and improve efficiency.
[0055] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0056] 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:
[0057] Figure 1 A flowchart illustrating a method for determining the shape similarity of a closed graphic according to an embodiment of this application is shown.
[0058] Figure 2 A flowchart illustrating another method for determining the shape similarity of a closed graphic provided in an embodiment of this application is shown.
[0059] Figure 3 A schematic diagram of the structure of a shape similarity determination device for a closed graphic provided in an embodiment of this application is shown. Detailed Implementation
[0060] The present application will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the embodiments of the present application can be combined with each other.
[0061] This embodiment provides a method for determining the shape similarity of closed figures, such as... Figure 1 As shown, the method includes:
[0062] Step 101: Obtain the image to be compared, wherein the image to be compared is a closed graphic image.
[0063] Step 102: Identify the graphic contour corresponding to the image to be compared, and determine the two contour points that are farthest apart on the graphic contour, and form a first line segment based on the two contour points.
[0064] Step 103: Based on the first line segment, divide the graphic contour into a first graphic sub-contour and a second graphic sub-contour, and determine a first sub-contour point on the first graphic sub-contour that forms the largest triangle with the first line segment, and determine a second sub-contour point on the second graphic sub-contour that forms the largest triangle with the first line segment.
[0065] Step 104: Obtain target comparison information corresponding to the target image. The target comparison information includes a first target line segment, a first target sub-contour point, and a second target sub-contour point corresponding to the target image. The first target line segment is the line segment formed by the two farthest contour points on the target graphic contour of the target image. The first target sub-contour point is the point on the first target graphic sub-contour that forms the largest triangle with the first target line segment. The second target sub-contour point is the point on the second target image sub-contour that forms the largest triangle with the first target line segment. The first target graphic sub-contour and the second target graphic sub-contour are obtained by dividing the target graphic contour based on the first target line segment.
[0066] Step 105: Determine the shape similarity between the image to be compared and the target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information.
[0067] This application provides a method for evaluating the shape similarity between two closed graphic images. First, a closed graphic image to be compared is acquired as the analysis object. Then, edge detection is performed on this graphic to identify its contour line. Next, the two furthest points on this contour line are found; this step provides a stable baseline, i.e., a first line segment, for subsequent graphic segmentation and calculation. Then, using the first line segment, the entire graphic contour is divided into two parts, each forming a sub-contour: the first graphic sub-contour and the second graphic sub-contour. Points on these two sub-contours that can form the largest triangle with the first line segment (first sub-contour point and second sub-contour point) are found. This step ensures that the selected points are representative of their respective sub-contours. For the target image, the same process of contour recognition, furthest point determination, sub-contour segmentation, and key point selection is performed to obtain the target first line segment, the target first sub-contour point, and the target second sub-contour point. Finally, based on these key information from the image to be compared and the target image, the shape similarity between the two graphics is determined.
[0068] By applying the technical solution of this embodiment, and through refined processing of the graphic contour, especially the selection of the largest area triangle, the key features of the graphic can be captured more accurately, thereby improving the accuracy of shape similarity judgment. Because it uses contour-based global features (farthest point, largest area triangle) rather than relying solely on local pixels or simple geometric parameters, this method has better robustness to changes in graphic size, rotation, and slight deformation. This method can be effectively applied to both regular and irregular graphics because it focuses on the overall structure and proportional relationships of the contour, and is not limited by specific graphic types. Through a series of ordered operations, the complex shape similarity problem is simplified to the comparison of a few key points, facilitating automated processing and rapid comparison of large amounts of graphic data. The shape similarity determination method provided in this application, through precise contour analysis and key feature point extraction, not only improves the accuracy and robustness of similarity assessment but also broadens its application potential in multiple fields such as graphic recognition, pattern matching, and computer vision.
[0069] In this embodiment of the application, optionally, the target image includes multiple images; determining the shape similarity between the image to be compared and the target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information includes: determining the shape similarity between the image to be compared and each target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information corresponding to each target image; classifying the image to be compared into an image group with the highest shape similarity to the target image based on the shape similarity between the image to be compared and each target image, thereby completing the classification of the image to be compared.
[0070] In this embodiment, the image to be compared can also be compared with multiple target images in terms of graphic similarity. The target image most similar to the image to be compared is identified, and the image to be compared is assigned to the corresponding image group of the target image. Specifically, for each target image, the shape similarity between the image to be compared and the target image is calculated individually using the previously described method, based on the first line segment, the first sub-contour point, the second sub-contour point, and the corresponding information of the target image. This yields a set of similarity values, each representing the degree of graphic similarity between the image to be compared and a specific target image. Based on all calculated shape similarities, the image to be compared is assigned to the category or image group of the target image with the highest shape similarity. This enables the correct classification of images of unknown categories into the category of the most similar known image. Through this embodiment, by using refined shape feature analysis, even when faced with complex and varied images, more accurate identification and classification can be achieved, improving the accuracy of the classification system.
[0071] Furthermore, as a refinement and extension of the specific implementation of the above embodiments, and to fully illustrate the specific implementation process of this embodiment, another method for determining the shape similarity of closed graphics is provided, such as... Figure 2 As shown, the method includes:
[0072] Step 201: Obtain the image to be compared, wherein the image to be compared is a closed graphic image.
[0073] Step 202: Binarize the image to be compared, perform contour recognition on the binarized image to be compared to obtain the graphic contour, and determine the two contour points that are farthest apart on the graphic contour, and form a first line segment based on the two contour points.
[0074] Step 203: Based on the first line segment, divide the graphic contour into a first graphic sub-contour and a second graphic sub-contour, and determine a first sub-contour point on the first graphic sub-contour that forms the largest triangle with the first line segment, and determine a second sub-contour point on the second graphic sub-contour that forms the largest triangle with the first line segment.
[0075] Step 204: Obtain target comparison information corresponding to the target image. The target comparison information includes a first target line segment, a first target sub-contour point, and a second target sub-contour point corresponding to the target image. The first target line segment is the line segment formed by the two farthest contour points on the target graphic contour of the target image. The first target sub-contour point is the point on the first target graphic sub-contour that forms the largest triangle with the first target line segment. The second target sub-contour point is the point on the second target graphic sub-contour that forms the largest triangle with the first target line segment. The first target graphic sub-contour and the second target graphic sub-contour are obtained by dividing the target graphic contour based on the first target line segment. The target comparison information also includes the target included angle between the first target line segment and the second target line segment, and the target first length ratio between the first target line segment and the second target line segment. The second target line segment is the line segment formed by the first target sub-contour point and the second target sub-contour point.
[0076] Step 205: Determine the second line segment based on the first sub-contour point and the second sub-contour point, measure the angle between the first line segment and the second line segment, measure the lengths of the first line segment and the second line segment respectively, and calculate the first length ratio between the first line segment and the second line segment.
[0077] Step 206: Calculate the angle deviation between the included angle and the target included angle, and the first length ratio deviation between the first length ratio and the target first length ratio. Based on the angle deviation and the first length ratio deviation, determine the shape similarity between the image to be compared and the target image.
[0078] In the above embodiments, a closed graphic image to be compared is acquired, and the image is converted to black and white through binarization to highlight the image's contour. A contour recognition image processing algorithm is used to identify the closed graphic contour in the image, and the two points furthest apart on the contour are determined to form a first line segment. The graphic contour is divided into two sub-contours using the first line segment. Then, points forming the largest triangle with the first line segment on each of these two sub-contours are found, namely the first sub-contour point and the second sub-contour point. On the image to be compared, a second line segment is determined based on the determined first and second sub-contour points, and the angle between the first and second line segments, the line segment length, and the length ratio between them are measured. Target comparison information of the target image is acquired. The method of acquiring the target comparison information is consistent with the processing method of the image to be compared. The target image is a known standard image, and its comparison information includes the target first line segment, target sub-contour points, target angle, and target length ratio, etc. Furthermore, by comparing the angle deviation and length ratio deviation between the image to be compared and the target image, the shape similarity of the two images is comprehensively evaluated. In this method, a smaller angular deviation indicates a greater similarity in shape between the two images. A smaller length ratio deviation also indicates a greater similarity. Combining angular and length ratio deviations yields a comprehensive similarity score. This can be achieved in several ways, such as: Weighted averaging: Assigning a weight to each deviation and then averaging them. The choice of weights depends on the perceived importance of angle and length ratio in similarity assessment. Thresholding: Setting thresholds for both angular and length ratio deviations. Images are considered similar only when both deviations are below their respective thresholds. Standardization: Standardizing angular and length ratio deviations to the same scale and then directly adding or averaging them. A shape similarity threshold can then be set. If the overall similarity score is higher than this threshold, the image to be compared is considered similar to the target image in shape. This method comprehensively considers the deviations in both angle and length ratio between the image to be compared and the target image, thus providing a more comprehensive assessment of the shape similarity between the two images.
[0079] Step 207: If the shape similarity is greater than a preset threshold, then the image to be compared is determined to be a similar closed graphic image of the target image, and the photographed object corresponding to the image to be compared is determined to be a qualified object, wherein the photographed object corresponding to the target image is a standard object.
[0080] Step 208: If the shape similarity is less than or equal to the preset threshold, then the image to be compared is determined not to be a similar closed image of the target image, and the photographed object corresponding to the image to be compared is determined to be an unqualified object.
[0081] In this embodiment, if the shape similarity is greater than a preset threshold, the image to be compared is determined to be a similar closed graphic image to the target image, and the photographed object corresponding to the image to be compared is considered a qualified object. Conversely, the photographed object corresponding to the image to be compared is considered an unqualified object. This method can be used to perform quality inspection on manufactured products with closed graphics, for example, by photographing images of parts and implementing the above method to perform quality inspection on the parts.
[0082] Optionally, in this embodiment of the application, determining that the image to be compared belongs to a similar closed graphic image of the target image if the shape similarity is greater than a preset threshold includes: if the shape similarity is greater than the preset threshold, sequentially connecting the four endpoints of the first line segment and the second line segment to form four line segments, calculating the second length ratio between the four line segments, and determining whether the image to be compared belongs to a similar closed graphic image of the target image based on the second length ratio and the target second length ratio in the target comparison information.
[0083] In this embodiment, when the shape similarity meets a certain condition (i.e., greater than a preset threshold), the system further verifies whether the image to be compared is indeed a similar closed graphic image of the target image. The specific steps are as follows: First, the shape similarity between the image to be compared and the target image is compared with a preset threshold. This threshold is usually set according to actual needs and application scenarios to determine the minimum acceptable standard for shape similarity. If the shape similarity is greater than the preset threshold, the system will further verify whether the image to be compared is indeed a similar closed graphic image of the target image. At this time, the system will select two key line segments in the image to be compared (assumed to be the first line segment and the second line segment) and connect the four endpoints of these two line segments in sequence to form four new line segments. Then, the system will calculate the length ratio between these four new line segments, i.e., the second length ratio. In actual application scenarios, the second length ratio can be the length ratio of two adjacent line segments among the four line segments. Next, the system will compare the calculated second length ratio with the target second length ratio in the target comparison information. The target comparison information is usually pre-stored standard information about the target image, including the length ratio of the line segments of its closed boundary, etc. If the second length ratio matches the target second length ratio (i.e., meets a certain error range), the system determines that the image to be compared belongs to a similar closed graphic image of the target image; otherwise, the system considers the image to be compared to be dissimilar to the target image.
[0084] This application's embodiments improve the accuracy of determining whether an image to be compared is similar to a target image by further verifying the line segment length ratio of the closed shape on top of shape similarity. This method can more accurately identify closed shape images with similar shapes to the target image. Relying solely on shape similarity for judgment may result in misjudgments; for example, two images with similar shapes but different sizes or proportions may be incorrectly judged as similar. Verifying the line segment length ratio effectively reduces this misjudgment rate.
[0085] In this embodiment of the application, optionally, the shooting distance and camera parameters corresponding to the image to be compared and the target image are the same; determining that the photographed object corresponding to the image to be compared is a qualified object includes: determining the scaling ratio of the photographed object corresponding to the image to be compared relative to the standard object based on the length of the first line segment and the length of the target first line segment; if the scaling ratio is within a preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be a qualified object; if the scaling ratio is outside the preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be a unqualified object.
[0086] In this embodiment, even the same object may present different image effects, such as size, shape, and sharpness, under different shooting distances or camera parameters. Therefore, capturing the comparison image and the target image at the same shooting distance and camera parameters helps to eliminate errors caused by these two factors, making the judgment on whether the photographed object is qualified more accurate.
[0087] Next, the length of the first line segment in the image to be compared and the length of the corresponding first line segment in the target image are determined. By comparing these two lengths, the scaling ratio of the photographed object in the image to be compared relative to the standard object can be determined. Then, a pre-set preset standard ratio range is obtained. This range is determined according to actual needs and application scenarios and is used to determine whether the scaling ratio is within an acceptable range. If the scaling ratio is within this range, it means that the photographed object in the image to be compared is similar in size to the standard object, and is therefore considered a qualified object. Conversely, if the scaling ratio exceeds this range, it means that the photographed object in the image to be compared has a significant difference in size from the standard object, and is therefore considered an unqualified object. This embodiment of the application eliminates errors caused by these factors by ensuring that the shooting distance and camera parameters are the same, making the comparison results between the image to be compared and the target image more accurate. By setting a preset standard ratio range, the size of the photographed object can be strictly controlled. Only when the scaling ratio is within this range is it considered a qualified object, thereby ensuring the quality and consistency of the product.
[0088] Furthermore, as Figure 1 In a specific implementation of the method, this application provides a device for determining the shape similarity of a closed shape, such as... Figure 3 As shown, the device includes:
[0089] An acquisition module is used to acquire an image to be compared, wherein the image to be compared is a closed graphic image;
[0090] The calculation module is used to identify the graphic contour corresponding to the image to be compared, and determine the two contour points that are farthest apart on the graphic contour, and form a first line segment based on the two contour points; divide the graphic contour into a first graphic sub-contour and a second graphic sub-contour based on the first line segment, and determine a first sub-contour point on the first graphic sub-contour that forms a triangle with the first line segment with the largest area, and determine a second sub-contour point on the second graphic sub-contour that forms a triangle with the first line segment with the largest area.
[0091] The acquisition module is further configured to acquire target comparison information corresponding to the target image, wherein the target comparison information includes a first target line segment, a first target sub-contour point, and a second target sub-contour point corresponding to the target image. The first target line segment is the line segment formed by the two farthest contour points on the target graphic contour of the target image. The first target sub-contour point is the point on the first target graphic sub-contour that forms the largest triangle with the first target line segment. The second target sub-contour point is the point on the second target image sub-contour that forms the largest triangle with the first target line segment. The first target graphic sub-contour and the second target graphic sub-contour are obtained by dividing the target graphic contour based on the first target line segment.
[0092] The calculation module is further configured to determine the shape similarity between the image to be compared and the target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information.
[0093] Optionally, the target comparison information also includes the target included angle between the first target line segment and the second target line segment, and the target first length ratio between the first target line segment and the second target line segment, wherein the second target line segment is a line segment formed by the first target sub-contour point and the second target sub-contour point;
[0094] The computing module is also used for:
[0095] The second line segment is determined based on the first sub-contour point and the second sub-contour point. The angle between the first line segment and the second line segment is measured. The lengths of the first line segment and the second line segment are measured respectively. The first length ratio between the first line segment and the second line segment is calculated.
[0096] Calculate the angle deviation between the included angle and the target included angle, and the first length ratio deviation between the first length ratio and the target first length ratio. Based on the angle deviation and the first length ratio deviation, determine the shape similarity between the image to be compared and the target image.
[0097] Optionally, the computing module is further configured to:
[0098] If the shape similarity is greater than a preset threshold, the image to be compared is determined to be a similar closed graphic image of the target image, and the photographed object corresponding to the image to be compared is determined to be a qualified object, wherein the photographed object corresponding to the target image is a standard object;
[0099] If the shape similarity is less than or equal to the preset threshold, then the image to be compared is determined not to be a similar closed image of the target image, and the photographed object corresponding to the image to be compared is determined to be an unqualified object.
[0100] Optionally, the computing module is further configured to:
[0101] If the shape similarity is greater than the preset threshold, then the four endpoints of the first line segment and the second line segment are connected sequentially to form four line segments, and the second length ratio between the four line segments is calculated. Based on the second length ratio and the target second length ratio in the target comparison information, it is determined whether the image to be compared belongs to a similar closed graphic image of the target image.
[0102] Optionally, the image to be compared and the target image have the same shooting distance and camera parameters; the calculation module is further configured to:
[0103] Based on the length of the first line segment and the length of the target first line segment, the scaling ratio of the photographed object corresponding to the image to be compared relative to the standard object is determined;
[0104] If the scaling ratio is within the preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be a qualified object;
[0105] If the scaling ratio is outside the preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be an unqualified object.
[0106] Optionally, the computing module is further configured to:
[0107] The image to be compared is binarized, and the binarized image to be compared is then subjected to contour recognition to obtain the graphic contour.
[0108] Optionally, the computing module is further configured to:
[0109] Based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information corresponding to each target image, the shape similarity between the image to be compared and each target image is determined respectively.
[0110] Based on the shape similarity between the image to be compared and each of the target images, the image to be compared is divided into an image group with the highest shape similarity to the target image, so as to complete the classification of the image to be compared.
[0111] It should be noted that other corresponding descriptions of the functional units involved in the shape similarity determination device for a closed shape provided in this application embodiment can be found in the following references. Figures 1 to 2 The corresponding descriptions in the method will not be repeated here.
[0112] This application also provides a computer device, specifically a personal computer, server, network device, etc. The computer device includes a bus, processor, memory, and communication interface, and may also include input / output interfaces and a display device. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device stores location information. The network interface of the computer device is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements the steps in the various method embodiments.
[0113] Those skilled in the art will understand that the structure of the computer device described above is only a partial structure related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. A specific computer device may include more or fewer components, or combine certain components, or have different component arrangements.
[0114] In one embodiment, a computer-readable storage medium is provided, which may be non-volatile or volatile, having stored thereon a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0115] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0116] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0117] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0118] 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 are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0119] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. 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 application should be determined by the appended claims.
Claims
1. A method for determining the shape similarity of closed figures, characterized in that, The method includes: Obtain the image to be compared, wherein the image to be compared is a closed graphic image; Identify the graphic contour corresponding to the image to be compared, and determine the two contour points that are farthest apart on the graphic contour, and construct a first line segment based on the two contour points; Based on the first line segment, the graphic outline is divided into a first graphic sub-outline and a second graphic sub-outline. On the first graphic sub-outline, a first sub-outline point that forms the largest triangle with the first line segment is determined, and on the second graphic sub-outline, a second sub-outline point that forms the largest triangle with the first line segment is determined. Obtain target comparison information corresponding to the target image, wherein the target comparison information includes a first target line segment, a first target sub-contour point, and a second target sub-contour point corresponding to the target image. The first target line segment is the line segment formed by the two farthest contour points on the target graphic contour of the target image. The first target sub-contour point is the point on the first target graphic sub-contour that forms the largest triangle with the first target line segment. The second target sub-contour point is the point on the second target graphic sub-contour that forms the largest triangle with the first target line segment. The first target graphic sub-contour and the second target graphic sub-contour are obtained by dividing the target graphic contour based on the first target line segment. The target comparison information also includes the target included angle between the first target line segment and the second target line segment, and the target first length ratio between the first target line segment and the second target line segment. The second target line segment is the line segment formed by the first target sub-contour point and the second target sub-contour point. Determining the shape similarity between the image to be compared and the target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information includes: determining a second line segment based on the first sub-contour point and the second sub-contour point; measuring the included angle between the first line segment and the second line segment; measuring the lengths of the first line segment and the second line segment respectively; calculating a first length ratio between the first line segment and the second line segment; calculating the angle deviation between the included angle and the included angle of the target image, and a first length ratio deviation between the first length ratio and the first length ratio of the target image; and determining the shape similarity between the image to be compared and the target image based on the angle deviation and the first length ratio deviation.
2. The method according to claim 1, characterized in that, After determining the shape similarity between the image to be compared and the target image based on the angle deviation and the first length ratio deviation, the method further includes: If the shape similarity is greater than a preset threshold, the image to be compared is determined to be a similar closed graphic image of the target image, and the photographed object corresponding to the image to be compared is determined to be a qualified object, wherein the photographed object corresponding to the target image is a standard object; If the shape similarity is less than or equal to the preset threshold, then the image to be compared is determined not to be a similar closed image of the target image, and the photographed object corresponding to the image to be compared is determined to be an unqualified object.
3. The method according to claim 2, characterized in that, The step of determining that the image to be compared belongs to a similar closed graphic image of the target image if the shape similarity is greater than a preset threshold includes: If the shape similarity is greater than the preset threshold, then the four endpoints of the first line segment and the second line segment are connected sequentially to form four line segments, and the second length ratio between the four line segments is calculated. Based on the second length ratio and the target second length ratio in the target comparison information, it is determined whether the image to be compared belongs to a similar closed graphic image of the target image.
4. The method according to claim 2 or 3, characterized in that, The image to be compared and the target image have the same shooting distance and camera parameters; Determining that the photographed object corresponding to the image to be compared is a qualified object includes: Based on the length of the first line segment and the length of the target first line segment, the scaling ratio of the photographed object corresponding to the image to be compared relative to the standard object is determined; If the scaling ratio is within the preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be a qualified object; If the scaling ratio is outside the preset standard ratio range, then the photographed object corresponding to the image to be compared is determined to be an unqualified object.
5. The method according to claim 4, characterized in that, The process of identifying the graphic contour corresponding to the image to be compared includes: The image to be compared is binarized, and the binarized image to be compared is then subjected to contour recognition to obtain the graphic contour.
6. The method according to claim 4, characterized in that, The target image includes multiple images; determining the shape similarity between the image to be compared and the target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information includes: Based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information corresponding to each target image, the shape similarity between the image to be compared and each target image is determined respectively. Based on the shape similarity between the image to be compared and each of the target images, the image to be compared is divided into an image group with the highest shape similarity to the target image, so as to complete the classification of the image to be compared.
7. A device for determining the shape similarity of a closed figure, characterized in that, The device includes: An acquisition module is used to acquire an image to be compared, wherein the image to be compared is a closed graphic image; The calculation module is used to identify the graphic contour corresponding to the image to be compared, and determine the two contour points that are farthest apart on the graphic contour, and form a first line segment based on the two contour points; divide the graphic contour into a first graphic sub-contour and a second graphic sub-contour based on the first line segment, and determine a first sub-contour point on the first graphic sub-contour that forms a triangle with the first line segment with the largest area, and determine a second sub-contour point on the second graphic sub-contour that forms a triangle with the first line segment with the largest area. The acquisition module is further configured to acquire target comparison information corresponding to the target image, wherein the target comparison information includes a first target line segment, a first target sub-contour point, and a second target sub-contour point corresponding to the target image. The first target line segment is the line segment formed by the two farthest contour points on the target graphic contour of the target image. The first target sub-contour point is the point on the first target graphic sub-contour that forms the largest triangle with the first target line segment. The second target sub-contour point is the point on the second target graphic sub-contour that forms the largest triangle with the first target line segment. The first target graphic sub-contour and the second target graphic sub-contour are obtained by dividing the target graphic contour based on the first target line segment. The target comparison information also includes the target included angle between the first target line segment and the second target line segment, and the target first length ratio between the first target line segment and the second target line segment. The second target line segment is the line segment formed by the first target sub-contour point and the second target sub-contour point. The calculation module is further configured to determine the shape similarity between the image to be compared and the target image based on the first line segment, the first sub-contour point, the second sub-contour point, and the target comparison information; wherein, a second line segment is determined based on the first sub-contour point and the second sub-contour point; the included angle between the first line segment and the second line segment is measured; the lengths of the first line segment and the second line segment are measured respectively; and a first length ratio between the first line segment and the second line segment is calculated; the angle deviation between the included angle and the included angle of the target image is calculated, as well as the first length ratio deviation between the first length ratio and the first length ratio of the target image; and the shape similarity between the image to be compared and the target image is determined based on the angle deviation and the first length ratio deviation.
8. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 6.
9. A computer device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 6.
Citation Information
Patent Citations
Road matching method and device
CN115014367A