Measuring line fitting method and device, equipment and computer readable storage medium
By using edge detection and pre-set calipers to remove outliers, the problem of low accuracy in measurement line fitting in existing technologies is solved, achieving higher accuracy and robustness in measurement line fitting.
Patent Information
- Application Number
- CN202410865273.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2025-12-30
AI Technical Summary
Existing measurement line fitting methods have low robustness, resulting in low measurement line fitting accuracy for high-precision detection requirements.
By performing edge detection on the acquired raw image, determining edge points, establishing edge standard lines, removing outliers using preset calipers, and performing multiple screenings and fitting point determinations, the accuracy and robustness of the measurement line are improved.
By reducing the impact of outliers on line fitting, the fitting accuracy and overall robustness of the measurement line are improved, ensuring high-precision measurement line fitting results.
Smart Images

Figure CN121235933A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision, and in particular to a method, apparatus, device, and computer-readable storage medium for fitting measurement lines. Background Technology
[0002] In image sensor visual inspection, whether in the 3C, semiconductor, or new energy fields, straight line extraction and fitting are necessary and particularly important steps, especially in positioning and measurement, where high accuracy is often required.
[0003] Common methods for fitting measurement lines include Hough transform line extraction, one-dimensional linear calipers, and two-dimensional linear calipers. However, their robustness is relatively low, and they suffer from over-correction and loss of accuracy for high-precision detection, resulting in low fitting accuracy of the measurement lines. Summary of the Invention
[0004] This application aims to provide a method, apparatus, device, and computer-readable storage medium for fitting measurement lines, which can improve the fitting accuracy of measurement lines.
[0005] The technical solution of this application is implemented as follows:
[0006] Edge detection is performed on the foreground image in the acquired original image to determine at least two edge points;
[0007] Based on the at least two edge points, determine the edge reference line of the foreground image;
[0008] Based on the edge standard line and the preset caliper, anomaly points are removed from the foreground image to determine the first fitting point;
[0009] A straight line is fitted using the first fitting point to determine the measurement line for the foreground image.
[0010] Understandably, the server performs edge detection on the foreground image in the acquired original image to determine at least two edge points. Based on these two edge points, an edge reference line for the foreground image is determined. Based on the edge reference line and a preset caliper, outlier removal is performed on the foreground image to determine the first fitting point. A straight line is then fitted using this first fitting point to determine the measurement line for the foreground image. During this process, outliers can interfere with the point-to-line fitting. Therefore, by establishing an edge reference line and removing outliers from the measurement points in the foreground image, the impact of outliers on the straight line fitting can be reduced, thereby improving the fitting accuracy of the measurement line for the foreground image.
[0011] In the above scheme, the step of removing outliers from the foreground image and determining the first fitting point based on the edge standard line and the preset caliper includes:
[0012] By calling the preset calipers, the foreground image is measured to obtain multiple measurement points;
[0013] Based on the edge standard line, outlier points are removed from the plurality of measurement points to determine the first fitting point.
[0014] Understandably, the server uses a preset caliper to measure the foreground image, obtaining multiple measurement points. Then, it uses edge standard lines to remove outliers from these measurement points and determines the first fitting point. This reduces the impact of outliers on the straight line fitting, thereby improving the fitting accuracy of the measurement line.
[0015] In the above scheme, after removing outliers from the plurality of measurement points based on the edge standard line and determining the first fitting point, the method further includes:
[0016] According to the preset filtering range, the first fitting point is filtered to remove outliers and determine the second fitting point in the foreground image;
[0017] By performing a straight line fit using the second fitting point, the measurement line for the foreground image is determined.
[0018] Understandably, the server filters the first fitting point within a preset selection range to remove outliers, determines the second fitting point in the foreground image, and performs a second outlier filtering, thus making the second fitting point more accurate. A straight line is then fitted onto the foreground image using the second fitting point to determine the measurement line for the foreground image, resulting in higher accuracy for the measurement line and improving the overall robustness of the fitting algorithm.
[0019] In the above scheme, the step of removing outliers from the plurality of measurement points based on the edge standard line to determine the first fitting point includes:
[0020] Based on the edge standard line, determine a plurality of first distances between the plurality of measurement points;
[0021] By using a preset distance and the plurality of first distances, outliers are removed from the plurality of measurement points to determine the first fitting point.
[0022] Understandably, the server determines multiple first distances between multiple measurement points using edge standard lines; by using preset distances and multiple first distances, outliers are removed from multiple measurement points to determine the first fitting point. This process can filter out outliers, reduce their impact on line fitting, and thus improve the fitting accuracy of the measurement line.
[0023] In the above scheme, the step of filtering the first fitting point according to a preset filtering range, removing outliers, and determining the second fitting point in the foreground image includes:
[0024] Along the first direction, the first fitting point is filtered through the preset filtering range to remove abnormal points outside the preset filtering range, and a second fitting point in the foreground image is determined; the first direction represents a dimension direction in two-dimensional coordinates.
[0025] Understandably, the server filters the first fitting point along the first direction using a preset filtering range, removes outliers outside the preset filtering range, determines the second fitting point in the foreground image, and performs a second outlier filtering on the measurement point, thereby making the second fitting point more accurate.
[0026] In the above scheme, the step of performing edge detection on the foreground image in the acquired original image to determine at least two edge points of the foreground image includes:
[0027] Based on the original image, grayscale projection processing is performed to determine the foreground image and the at least two edge points of the foreground image.
[0028] Understandably, the server performs grayscale projection processing on the original image to determine the foreground image and at least two edge points of the foreground image, which can facilitate the determination of edge reference lines through at least two edge points.
[0029] In the above scheme, the step of performing grayscale projection processing based on the original image to determine the foreground image and the at least two edge points of the foreground image includes:
[0030] The acquired original image is cropped to determine a first image containing the foreground object;
[0031] Based on the first image, grayscale projection processing is performed to determine the foreground image and the at least two edge points of the foreground image.
[0032] Understandably, the server crops the acquired original image to determine a first image containing the foreground object. Based on the first image, grayscale projection processing is performed to determine the foreground image and at least two edge points of the foreground image. Since the first image is smaller than the original image, calculations on invalid regions can be reduced, thereby improving the fitting accuracy of the measurement line.
[0033] In the above scheme, the step of performing grayscale projection processing based on the first image to determine the foreground image and the at least two edge points of the foreground image includes:
[0034] The first image is subjected to image enhancement and overlay processing according to the number of loops to obtain the first enhanced image;
[0035] Perform at least one grayscale operation on the first enhanced image to obtain the foreground image; wherein the at least one grayscale operation includes: grayscale opening operation, grayscale closing operation, grayscale opening and closing operation, and grayscale closing and opening operation;
[0036] For the foreground image, grayscale calculation is performed along a second direction to determine the at least two edge points; the second direction is different from the first direction.
[0037] Understandably, the server performs image enhancement and overlay processing on the first image according to a certain number of loops to obtain the first enhanced image; then, it performs at least one grayscale operation on the first enhanced image to obtain the foreground image. By performing cyclic image enhancement and grayscale processing on the first image, the image clarity can be improved. For the foreground image, grayscale calculations are performed along the second direction to determine at least two edge points, which facilitates subsequent determination of edge reference lines and screening of outliers.
[0038] In the above scheme, the step of performing grayscale calculations on the foreground image along the second direction to determine the at least two edge points includes:
[0039] The foreground image is divided into regions according to the second direction to obtain at least two region images;
[0040] Grayscale calculations are performed on the at least two region images to obtain the extreme points corresponding to each of the at least two region images;
[0041] The at least two edge points are determined based on the extreme points corresponding to the at least two region images.
[0042] Understandably, the server divides the foreground image into regions along the second direction to obtain at least two region images; grayscale calculations are performed on the at least two region images to obtain the extreme points corresponding to each of the at least two region images; based on the extreme points corresponding to each of the at least two region images, at least two edge points are determined, which facilitates the subsequent determination of edge standard lines and the screening of outliers, thereby improving the fitting accuracy of the measurement line.
[0043] In the above scheme, the step of performing grayscale calculations on the at least two region images to obtain the extreme points corresponding to each of the at least two region images includes:
[0044] For each region of the image, the mean gray level per unit in the second direction is calculated to determine the total mean gray level of each region of the image; wherein, the mean gray level per unit represents the mean gray level in the corresponding dimension of the first direction;
[0045] Based on the total grayscale mean of each region image, the extreme points corresponding to each region image are determined by establishing a discrete function and performing smoothing and differentiation processing.
[0046] Understandably, the server determines the extreme points corresponding to each region of the image, which facilitates the identification of at least two edge points. This makes it easier to subsequently determine the edge standard line and screen outliers, thereby improving the fitting accuracy of the measurement line.
[0047] In the above scheme, the step of performing image enhancement and overlay processing on the first image according to the number of loops to obtain the first enhanced image includes:
[0048] Determine the first grayscale value and the second grayscale value of the first image in different directions;
[0049] Multiply the first gray value and the second gray value to determine the gray value of the initial enhanced image;
[0050] Based on the grayscale value of the initial enhanced image, image enhancement and overlay processing continues until the specified number of iterations is reached, and the first enhanced image is determined.
[0051] Understandably, the server determines the first grayscale value and the second grayscale value of the first image in different directions; the first grayscale value and the second grayscale value are multiplied to determine the grayscale value of the initial enhanced image.
[0052] Based on the grayscale values of the initial enhanced image, image enhancement and overlay processing continues until the desired number of iterations is reached, at which point the first enhanced image is determined. During this process, a for loop is used to process the image, keeping the Mult value constant. The loop count is set, and the overlay process is performed on this value. Furthermore, for example, when the image enhancement coefficient Mult increases from 0.1 to 0.2, the result increases exponentially, with a large jump, which may exceed the expected effect. This method can increase the value proportionally or exponentially.
[0053] The method in the above scheme further includes:
[0054] Determine the first position information of the first point corresponding to the original image and the second position information of the second point corresponding to the first image;
[0055] Based on the first position information and the second position information, the rotation angle and translation distance are calculated to determine the position transformation relationship.
[0056] Understandably, the server determines the first position information of the first point corresponding to the original image and the second position information of the second point corresponding to the first image; using the first and second position information, it calculates the rotation angle and translation distance to determine the position transformation relationship, which facilitates the subsequent transformation of the fitted image of the foreground image into the measurement line of the original image for the foreground image through the position transformation relationship.
[0057] In the above scheme, the step of calculating the rotation angle and translation distance based on the first position information and the second position information to determine the position transformation relationship includes:
[0058] Based on the first position information and the second position information, calculate the rotation angle and determine the rotation matrix;
[0059] Based on the first position information and the second position information, calculate the translation distance and determine the translation vector;
[0060] The position transformation relationship is determined by multiplying the rotation matrix and the translation vector.
[0061] Understandably, the server can calculate the rotation angle and determine the rotation matrix based on the first and second position information; calculate the translation distance and determine the translation vector based on the first and second position information; multiply the rotation matrix and translation vector to determine the position transformation relationship and establish the position transformation relationship between the first image and the original image, which facilitates the subsequent conversion of the fitted image of the foreground image into the measurement line of the foreground image in the original image.
[0062] In the above scheme, the step of determining the measurement line for the foreground image by performing straight line fitting through the first fitting point includes:
[0063] By fitting a straight line to the foreground image through the first fitting point, the fitted image of the foreground image is determined.
[0064] By transforming the position information of the fitted image of the foreground image through position transformation relationship, the measurement line is determined.
[0065] Understandably, the server uses the first fitting point to perform a straight line fitting on the foreground image, determining the fitted image of the foreground. Then, through positional transformation relationships, the fitted image of the foreground image undergoes positional information transformation to determine the measurement line for the foreground image. Since the first fitting point is a selected measurement point, performing straight line fitting through it improves the accuracy of the fitted image of the foreground. Simultaneously, because the foreground image is determined by cropping the original image, its area is smaller than the original image, resulting in a more accurate fitted image when performing straight line fitting on it. By using the positional transformation relationship between the original and foreground images, a coordinate transformation is performed on the more accurate fitted image of the foreground, obtaining the measurement line for the foreground in the original image. This transformation process preserves the high accuracy of the fitted image of the foreground, ensuring that the measurement line for the foreground in the original image also has high accuracy, thereby improving the fitting accuracy of the measurement line for the foreground in the original image.
[0066] The method in the above scheme further includes:
[0067] By calling the preset calipers, the foreground image in the acquired original image is measured to obtain multiple measurement points;
[0068] According to the preset filtering range, the multiple measurement points are filtered to remove outliers and determine the third fitting point in the foreground image;
[0069] A straight line is fitted using the third fitting point to determine the measurement line for the foreground image.
[0070] Understandably, the server filters multiple measurement points through a preset selection range, removes outliers, determines a third fitting point in the foreground image, and performs a secondary outlier filtering, thereby increasing the accuracy of the third fitting point. Then, by fitting a straight line to the foreground image using this third fitting point, the measurement line of the foreground image is determined, resulting in higher precision for the measurement line and improving the overall robustness of the fitting algorithm.
[0071] This application provides a fitting device for a measurement line, which includes: a determining unit, a filtering unit, and a fitting unit, wherein...
[0072] The determining unit is used to perform edge detection on the foreground image in the acquired original image to determine at least two edge points; and to determine the edge reference line of the foreground image based on the at least two edge points.
[0073] The filtering unit is used to remove outliers from the foreground image based on the edge standard line and the preset caliper, and determine the first fitting point;
[0074] The fitting unit is used to perform straight line fitting through the first fitting point to determine a measurement line for the foreground image.
[0075] This application provides a fitting device for a measurement line, comprising: a processor and a memory, wherein,
[0076] The memory is used to store computer programs;
[0077] The processor is configured to call and run the computer program from the memory to perform the above-described method for fitting the measurement line.
[0078] This application provides a computer-readable storage medium storing executable instructions for inducing a processor to execute the above-described method for fitting measurement lines.
[0079] This application provides a method, apparatus, device, and computer-readable storage medium for fitting measurement lines. The method includes: performing edge detection on a foreground image in an acquired original image to determine at least two edge points; determining an edge standard line of the foreground image based on the at least two edge points; removing outliers from the foreground image based on the edge standard line and a preset caliper to determine a first fitting point; and performing straight line fitting through the first fitting point to determine a measurement line for the foreground image. By employing this scheme, since the process of fitting a line from a point can be interfered with by outliers, establishing an edge standard line and removing outliers from the measurement points of the foreground image can reduce the impact of outliers on the straight line fitting, thereby improving the fitting accuracy of the measurement line for the foreground image. Attached Figure Description
[0080] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application. Obviously, the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0081] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0082] Figure 1 An optional flowchart illustrating a method for fitting a measurement line provided in an embodiment of this application. Figure 1 ;
[0083] Figure 2a A schematic diagram of an optional edge standard line for a method of fitting a measurement line provided in an embodiment of this application;
[0084] Figure 2b A schematic diagram of an optional fitting skew for a fitting method of a measurement line provided in an embodiment of this application;
[0085] Figure 3 A schematic diagram of an optional outlier point for a measurement line fitting method provided in an embodiment of this application;
[0086] Figure 4 A schematic diagram of a fitted image of an optional foreground image for a method of fitting a measurement line provided in an embodiment of this application;
[0087] Figure 5 A second optional flowchart illustrating a method for fitting a measurement line provided in an embodiment of this application;
[0088] Figure 6 A schematic diagram of an optional one-dimensional caliper fitting method for a measurement line provided in this application embodiment;
[0089] Figure 7 An optional flowchart illustrating a method for fitting a measurement line provided in an embodiment of this application. Figure 3 ;
[0090] Figure 8 An optional flowchart illustrating a method for fitting a measurement line provided in an embodiment of this application. Figure 4 ;
[0091] Figure 9 An optional flowchart illustrating a method for fitting a measurement line provided in an embodiment of this application. Figure 5 ;
[0092] Figure 10a A schematic diagram of an optional vertical projection of a method for fitting a measurement line provided in an embodiment of this application;
[0093] Figure 10b A schematic diagram of an optional segmented projection for a method of fitting a measurement line provided in an embodiment of this application;
[0094] Figure 10c A schematic diagram of an optional discrete function for a method of fitting a measurement line provided in an embodiment of this application;
[0095] Figure 10d A schematic diagram of an optional discrete function smoothing method for fitting a measurement line provided in an embodiment of this application;
[0096] Figure 10eA schematic diagram of an optional discrete function extremum point for a measurement line fitting method provided in an embodiment of this application;
[0097] Figure 11 An optional flowchart illustrating a method for fitting a measurement line provided in an embodiment of this application. Figure 6 ;
[0098] Figure 12 This is a schematic diagram of the structure of a fitting device for a measurement line provided in an embodiment of this application;
[0099] Figure 13 This is a schematic diagram of the structure of a fitting device for a measurement line provided in an embodiment of this application. Detailed Implementation
[0100] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the specific technical solutions of this application will be further described in detail below with reference to the accompanying drawings of the embodiments of this application. The following embodiments are used to illustrate this application, but are not intended to limit the scope of this application.
[0101] Unless otherwise defined, all technical and scientific terms used in this application have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used in this application is for the purpose of describing embodiments of this application only and is not intended to be limiting of this application.
[0102] In the following description, references to "some embodiments," "this embodiment," "this application embodiment," and examples, etc., describe a subset of all possible embodiments. However, it is understood that "some embodiments" may be the same subset or different subset of all possible embodiments and may be combined with each other without conflict.
[0103] If the application documents contain similar descriptions such as "first / second", the following explanation shall be added: In the following description, the terms "first / second / third" are used only to distinguish similar objects and do not represent a specific order of objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0104] Figure 1 An optional flowchart illustrating a method for fitting a measurement line provided in an embodiment of this application. Figure 1 ,like Figure 1 As shown, the fitting method for the measurement line includes the following steps:
[0105] S101. Perform edge detection on the foreground image in the acquired original image to determine at least two edge points.
[0106] The measurement line fitting method provided in this application embodiment can be applied to the fitting of measurement lines for various objects, thereby enabling positioning and measurement based on the determined measurement lines, such as battery images, vehicle part images, and aircraft part images, etc. This application embodiment does not impose any limitations.
[0107] In the following embodiments, the application of the measurement line fitting method to battery images will be used as an example for illustration. Battery images are images containing battery components obtained through different production processes in the power battery production process.
[0108] In this embodiment, the original image is obtained directly from the battery production process, by taking photos on the battery production line. The original image includes the battery components and is mainly used to determine whether the quality of the battery components in the image meets the standards.
[0109] In some embodiments of this application, the measurement line fitting method is mainly applied to the fitting of measurement lines of original images containing battery components in the semiconductor or new energy fields.
[0110] In some embodiments of this application, the entity executing the measurement line fitting method is a measurement line fitting device; wherein, the measurement line fitting device may be a server. This application does not impose specific limitations on this aspect.
[0111] In some embodiments of this application, the server can perform image correlation processing on the foreground image in the acquired original image to determine the foreground image and at least two edge points of the foreground image. Image correlation processing can include binarization, erosion / dilation, and grayscale projection, etc. This application does not impose specific limitations on this aspect.
[0112] The following embodiments will be illustrated by taking the grayscale projection processing of the foreground image in the acquired original image as an example.
[0113] In some embodiments of this application, the server can perform grayscale projection processing based on the original image to determine the foreground image and at least two edge points of the foreground image.
[0114] In some embodiments of this application, the server crops the acquired original image to determine a first image containing a foreground object; based on the first image, grayscale projection processing is performed to determine a foreground image and at least two edge points of the foreground image.
[0115] In some embodiments of this application, the server crops the acquired original image to determine a first image. Since the area of the first image is smaller than that of the original image, it is easier to fit measurement lines for the image using the first image.
[0116] Understandably, the server crops the acquired original image to determine a first image containing the foreground object. Based on the first image, grayscale projection processing is performed to determine the foreground image and at least two edge points of the foreground image. Since the first image is smaller than the original image, calculations on invalid regions can be reduced, thereby improving the fitting accuracy of the measurement line.
[0117] In some embodiments of this application, edge points represent boundary points of brightness changes, which are points in the foreground image obtained after grayscale projection processing of the first image.
[0118] In some embodiments of this application, the server can perform grayscale projection processing on the first image to obtain a foreground image. By performing grayscale calculations on the foreground image, at least two edge points in the foreground image are determined.
[0119] It should be noted that at least two edge points can be used to determine the edge baseline.
[0120] In some embodiments of this application, the server may preprocess the first image to determine a foreground image. Grayscale calculations are performed on the foreground image to determine at least two extreme points, thereby determining at least two edge points in the foreground image based on these extreme points.
[0121] It should be noted that the preprocessing methods for the first image include image enhancement and overlay processing, gray-level opening operation, gray-level closing operation, gray-level opening operation followed by gray-level closing operation, and gray-level closing operation followed by gray-level opening operation.
[0122] In some embodiments of this application, after performing grayscale projection processing based on the first image to determine the foreground image, it is determined whether there are extreme points in the foreground image. If extreme points exist, at least two edge points in the foreground image are determined. If no extreme points exist, a preset caliper is directly used to measure the foreground image to obtain the measurement points of the foreground image. Abnormal points are removed through a preset filtering range, and then straight line fitting is performed on the filtered measurement points to determine the measurement line for the foreground image.
[0123] Understandably, after performing grayscale projection processing based on the first image to determine the foreground image, it is determined whether there are extreme points in the foreground image. If there are no extreme points, a preset caliper is directly called to measure the foreground image to obtain the measurement points of the foreground image. Abnormal points are removed through a preset filtering range. Since abnormal points will interfere with line fitting, after removing abnormal points, line fitting is performed through the filtered measurement points, which can improve the accuracy of the measurement line for the foreground image.
[0124] S102. Determine the edge reference line of the foreground image based on at least two edge points.
[0125] In some embodiments of this application, the edge reference line is a straight line fitted to the boundary of the battery component in the first image, mainly used to filter edge points in the foreground image and remove abnormal points.
[0126] In some embodiments of this application, the server can determine the edge reference line of the foreground image based on two of the at least two edge points, by determining a straight line from the two points.
[0127] For example, such as Figure 2a As shown, the edge reference line of the foreground image, i.e. Figure 2a Line 1 in the image. Existing methods for fitting images, such as... Figure 2b As shown. From Figure 2b You can see that the straight line is skewed.
[0128] S103. Based on the edge standard line and preset calipers, remove outliers from the foreground image and determine the first fitting point.
[0129] In some embodiments of this application, the server can invoke a preset caliper to measure the foreground image and obtain multiple measurement points of the foreground image. Outlier points are removed from these multiple measurement points using edge reference lines to determine a first fitting point.
[0130] In some embodiments of this application, after obtaining multiple measurement points of the foreground image, the server calculates multiple first distances between the edge standard line and the multiple measurement points of the foreground image; by comparing the preset distance and the multiple first distances, outliers are removed from the multiple measurement points to determine the first fitting point.
[0131] It should be noted that outliers are points that are relatively far from the edge standard line, that is, the distance between an outlier and the edge standard line is greater than the preset distance.
[0132] For example, such as Figure 3 As shown, the outlier is... Figure 3 The measurement point is in white box 2.
[0133] S104. Perform straight line fitting through the first fitting point to determine the measurement line for the foreground image.
[0134] In some embodiments of this application, the server can perform straight line fitting on the foreground image using a first fitting point to obtain a fitted image of the foreground image. Then, the fitted image of the foreground image is transformed to determine the measurement line for the foreground image.
[0135] It should be noted that the foreground image originates from the first image, which is cropped from the original image. Therefore, a positional transformation relationship between the first image and the original image can be established. This positional transformation relationship also applies to the foreground image and the original image.
[0136] Understandably, since the first fitting point is a selected measurement point, fitting a straight line through the first fitting point can improve the accuracy of the fitted image of the foreground image. Simultaneously, because the foreground image is determined by cropping the original image, its area is smaller than the original image. Therefore, fitting a straight line on the foreground image yields a more accurate fitted image. By transforming the coordinates of the more accurate fitted image of the foreground image based on the positional transformation relationship between the original and foreground images, the measurement line in the original image corresponding to the foreground image is obtained. This transformation process preserves the high accuracy of the fitted image of the foreground image, ensuring that the measurement line in the original image corresponding to the foreground image also has high accuracy, thereby improving the fitting accuracy of the measurement line in the original image corresponding to the foreground image.
[0137] For example, such as Figure 4 As shown, the measurement line for the foreground image, i.e. Figure 4 Area 3 is within the white box.
[0138] Understandably, the server performs edge detection on the foreground image in the acquired original image to determine at least two edge points. Based on these two edge points, an edge reference line for the foreground image is determined. Based on the edge reference line and a preset caliper, outlier removal is performed on the foreground image to determine the first fitting point. A straight line is then fitted using this first fitting point to determine the measurement line for the foreground image. During this process, outliers can interfere with the point-to-line fitting. Therefore, by establishing the edge reference line and removing outliers from the measurement points in the foreground image, the impact of outliers on the straight line fitting can be reduced, thereby improving the fitting accuracy of the measurement line for the foreground image.
[0139] In some embodiments of this application, such as Figure 5 As shown, S103 can be implemented through S201 and S202, as follows:
[0140] S201. By calling the preset calipers, the foreground image is measured to obtain multiple measurement points.
[0141] In some embodiments of this application, the preset calipers are divided into one-dimensional calipers and two-dimensional calipers; wherein, one-dimensional calipers are typically used to measure the length or position of an object in one direction, such as the length in the horizontal or vertical direction. Two-dimensional calipers can measure in both the horizontal and vertical directions simultaneously, thus obtaining the length, width, and position information of an object on a plane.
[0142] In some embodiments of this application, the server can invoke a one-dimensional caliper to measure the foreground image and obtain multiple measurement points.
[0143] For example, a one-dimensional caliper is invoked to measure the foreground image, obtaining multiple measurement points, such as... Figure 6 As shown, the small rectangle formed by the white horizontal lines is a one-dimensional caliper.
[0144] S202. Based on the edge standard line, outlier points are removed from multiple measurement points to determine the first fitting point.
[0145] In some embodiments of this application, the server can remove outliers from multiple measurement points in the foreground image using edge reference lines to obtain a first fitted point.
[0146] In some embodiments of this application, the server can determine multiple first distances between multiple measurement points based on edge standard lines; and remove outliers from multiple measurement points by using preset distances and multiple first distances to determine a first fitting point.
[0147] Understandably, the server uses a preset caliper to measure the foreground image, obtaining multiple measurement points. Then, it uses edge standard lines to remove outliers from these measurement points and determines the first fitting point. This process can filter out outliers, reduce their impact on line fitting, and thus improve the fitting accuracy of the measurement line.
[0148] In some embodiments of this application, the server can calculate multiple first distances between an edge reference line and multiple measurement points. These first distances are compared with a preset distance, and measurement points corresponding to at least one first distance greater than the preset distance are identified as outliers. Outliers are removed from the multiple measurement points, and the remaining measurement points are identified as first fitting points.
[0149] Understandably, the server determines multiple first distances between multiple measurement points using edge standard lines; by using preset distances and multiple first distances, outliers are removed from multiple measurement points to determine the first fitting point. This process can filter out outliers, reduce their impact on line fitting, and thus improve the fitting accuracy of the measurement line.
[0150] In some embodiments of this application, such as Figure 7 As shown, after S202, S301 and S302 are also executed, as follows:
[0151] S301. According to the preset filtering range, filter the first fitting point, remove outliers, and determine the second fitting point in the foreground image.
[0152] In some embodiments of this application, the server can sort the first fitting points to obtain sorted first fitting points, and then remove outliers from the sorted first fitting points through a preset filtering range to obtain second fitting points in the foreground image.
[0153] In some embodiments of this application, the server can filter the first fitting point along a first direction and through a preset filtering range to remove abnormal points outside the preset filtering range and determine the second fitting point in the foreground image; the first direction represents a dimension direction in two-dimensional coordinates.
[0154] In some embodiments of this application, the server sorts the first fitting points along a first direction using the location information of the first fitting points to obtain sorted first fitting points; from the sorted first fitting points, abnormal points outside a preset filtering range are removed to determine the second fitting points in the foreground image.
[0155] It should be noted that the location information of the first fitting point can be the coordinates of the first fitting point, and this application embodiment does not specifically limit this.
[0156] In some embodiments of this application, the first direction can be horizontal. The server can sort the first fitting points in ascending order using their x-coordinates to obtain sorted first fitting points. Anomalies outside the preset filtering range are removed from the sorted first fitting points using a preset filtering range to determine the second fitting points in the foreground image.
[0157] For example, the preset filtering range can be 10%-90%. The preset order criterion is an ascending order. The Points (i.e., the first fitting points) after grayscale projection filtering are arranged in ascending order (along the x-axis coordinate) to obtain the sorted first fitting points. The measurement points between 10% and 90% of the sorted first fitting points are selected as the second fitting points.
[0158] Understandably, the server filters the first fitting point along the first direction using a preset filtering range, removes outliers outside the preset filtering range, determines the second fitting point in the foreground image, and performs a second outlier filtering on the measurement point, thereby making the second fitting point more accurate.
[0159] S302 performs straight line fitting through the second fitting point to determine the measurement line for the foreground image.
[0160] In some embodiments of this application, the server can determine a fitted image of the foreground image by sorting the second fitting points and fitting a measurement line to the sorted second fitting points on the foreground image. Through positional transformation relationships, the fitted image of the foreground image is transformed to determine the measurement line for the foreground image.
[0161] Understandably, the server filters the first fitting point within a preset selection range to remove outliers, determines the second fitting point in the foreground image, and performs a second outlier filtering, thus making the second fitting point more accurate. A straight line is then fitted onto the foreground image using the second fitting point to determine the measurement line for the foreground image, resulting in higher accuracy for the measurement line and improving the overall robustness of the fitting algorithm.
[0162] In some embodiments of this application, S101 can be implemented by S401, as follows:
[0163] S401. Based on the original image, perform grayscale projection processing to determine the foreground image and at least two edge points of the foreground image.
[0164] In some embodiments of this application, the server crops the acquired original image to determine a first image containing a foreground object; based on the first image, grayscale projection processing is performed to determine a foreground image and at least two edge points of the foreground image.
[0165] Understandably, the server performs grayscale projection processing on the original image to determine the foreground image and at least two edge points of the foreground image, which can facilitate the determination of edge reference lines through at least two edge points.
[0166] In some embodiments of this application, S401 can be implemented by S4011, S4012, and S4013, as follows:
[0167] S4011. Crop the acquired original image to determine the first image containing the foreground object.
[0168] In some embodiments of this application, the server can acquire the original image, determine the target region of the original image, and crop the original image according to the target region to obtain a first image containing the foreground object.
[0169] It should be noted that the target area is the area that contains the foreground object, which can be a battery component.
[0170] S4012. Based on the first image, perform grayscale projection processing to determine the foreground image.
[0171] S4013. Perform grayscale calculation on the foreground image to determine at least two edge points of the foreground image.
[0172] In some embodiments of this application, grayscale calculations are performed on the foreground image to determine at least two extreme points of the foreground image, thereby determining at least two edge points in the foreground image based on the at least two extreme points of the foreground image.
[0173] Understandably, the server crops the acquired original image to determine a first image containing the foreground object. Based on the first image, grayscale projection processing is performed to determine the foreground image and at least two edge points of the foreground image. Since the first image is smaller than the original image, calculations on invalid regions can be reduced, thereby improving the fitting accuracy of the measurement line.
[0174] In some embodiments of this application, after S4012, such as Figure 8 As shown, S501, S502, and S503 are also executed, as follows:
[0175] S501. By calling the preset calipers, the foreground image in the acquired original image is measured to obtain multiple measurement points.
[0176] In some embodiments of this application, the server can determine the orientation of the two-dimensional caliper; and by calling the two-dimensional caliper, measure the foreground image in the acquired original image to obtain multiple measurement points; or, call the one-dimensional caliper to measure the foreground image in the acquired original image to obtain multiple measurement points.
[0177] S502. According to the preset filtering range, filter multiple measurement points, remove abnormal points, and determine the third fitting point in the foreground image.
[0178] In some embodiments of this application, the server sorts the multiple measurement points along a first direction using the location information of multiple measurement points to obtain sorted multiple measurement points; from the sorted multiple measurement points, abnormal points outside the preset filtering range are removed to determine the third fitting point in the foreground image.
[0179] It should be noted that the principle of filtering multiple measurement points according to the preset filtering range to remove outliers and determine the third fitting point in the foreground image is similar to that of filtering the first fitting point according to the preset filtering range to remove outliers and determine the second fitting point in the foreground image, and will not be elaborated here.
[0180] S503. Perform a straight line fitting on the foreground image using the third fitting point to determine the measurement line for the foreground image.
[0181] In some embodiments of this application, the server can determine the fitted image of the foreground image by sorting the third fitting points and performing linear fitting on the sorted third fitting points on the foreground image. Through positional transformation relationships, the fitted image of the foreground image is transformed to determine the measurement line for the foreground image.
[0182] Understandably, the server filters multiple measurement points through a preset selection range, removes outliers, determines a third fitting point in the foreground image, and performs a secondary outlier filtering, thereby increasing the accuracy of the third fitting point. Then, a straight line is fitted onto the foreground image using this third fitting point to determine the measurement line for the foreground image, resulting in higher precision for the measurement line and improving the overall robustness of the fitting algorithm.
[0183] In some embodiments of this application, grayscale projection processing is performed based on the first image to determine the foreground image, and at least two edge points of the foreground image can be implemented through S601, S602, and S603, as follows:
[0184] S601. For the first image, perform image enhancement and overlay processing according to the number of loops to obtain the first enhanced image.
[0185] In some embodiments of this application, the server may perform image enhancement and overlay processing on the first image until the number of times the image enhancement and overlay is performed reaches the loop count, at which point the processing stops and the first enhanced image is obtained.
[0186] In some embodiments of this application, the server determines a first grayscale value and a second grayscale value of the first image in different directions; multiplies the first grayscale value and the second grayscale value to determine the grayscale value of the initial enhanced image; based on the grayscale value of the initial enhanced image, the image enhancement overlay process continues until the number of loops is reached to determine the first enhanced image.
[0187] In some embodiments of this application, the server can determine the first grayscale value and the second grayscale value of the first image in different directions, perform image enhancement using the first grayscale value and the second grayscale value to obtain the grayscale value of the initial enhanced image; based on the grayscale value of the initial enhanced image, continue to perform image enhancement overlay processing until the number of loops is reached, and determine the first enhanced image.
[0188] It should be noted that the grayscale values of the initial enhanced image are also divided into the first initial grayscale value and the second initial grayscale value of the initial enhanced image.
[0189] For example, a multiplication operation is performed on an image. The gray values (g1, g2) of the first image are input and converted according to formula (1) to obtain the first enhanced image, as follows:
[0190] g'=g1*g2*Mult+Add (1)
[0191] Where g1 and g2 are the gray values of the first image in different directions, respectively; Mult is the multi-step value; Add indicates the overlay process; and g' represents the gray value of the first enhanced image.
[0192] Understandably, the server determines the first and second grayscale values of the first image in different directions; the first and second grayscale values are multiplied to determine the grayscale values of the initial enhanced image. Based on the grayscale values of the initial enhanced image, image enhancement and overlay processing continues until the required number of iterations is reached, thus determining the first enhanced image. During this process, using a FOR loop to process the image keeps the Mult value constant; the number of iterations is set, and the value is then overlaid. Furthermore, when the image enhancement coefficient Mult increases from 0.1 to 0.2, the result increases exponentially, with a large range, which may exceed the expected effect. This method can increase the value proportionally or exponentially.
[0193] S602. Perform at least one grayscale operation on the first enhanced image to obtain a foreground image; wherein, the at least one grayscale operation includes: grayscale opening operation, grayscale closing operation, grayscale opening and closing operation and grayscale closing and opening operation.
[0194] In some embodiments of this application, the grayscale opening operation first performs an erosion operation on the image, and then dilates the erosion result. This operation is mainly used to remove bright details that are relatively small relative to the structuring elements in the image, while maintaining the overall grayscale and large bright areas unchanged. The grayscale closing operation, on the other hand, performs a dilation operation first, and then an erosion operation. It is mainly used to remove dark details that are relatively small relative to the structuring elements in the image, while maintaining the overall grayscale and large dark areas unchanged.
[0195] In some embodiments of this application, the server can perform a grayscale opening operation on the first enhanced image to obtain a foreground image; or, the server can perform a grayscale closing operation on the first enhanced image to obtain a foreground image; or, the server can first perform a grayscale closing operation and then a grayscale opening operation on the first enhanced image to obtain a foreground image; or, the server can first perform a grayscale opening operation and then a grayscale closing operation on the first enhanced image to obtain a foreground image. In addition, the first enhanced image can be subjected to four grayscale operations, and the results can be fused or filtered to obtain the foreground image.
[0196] For example, the first image is subjected to image enhancement overlay processing according to the number of loops to obtain a first enhanced image. At least one grayscale operation is then performed on the first enhanced image to obtain a foreground image. Figure 9 To achieve this, as follows:
[0197] S1, Crop the region of interest.
[0198] In some embodiments of this application, after the server acquires the original image, the original image is preprocessed. The first step is to determine the region of interest, which is the region containing the battery component (i.e., the foreground object). The region of interest is then cropped to obtain the first image.
[0199] S2. Apply a FOR loop to the cropped first image to multiply proportionally and enhance contrast.
[0200] In some embodiments of this application, the server can determine the first grayscale value and the second grayscale value of the first image in different directions, perform image enhancement using the first grayscale value and the second grayscale value to obtain the grayscale value of the initial enhanced image, and continue to perform image enhancement overlay processing until the number of loops is reached to determine the first enhanced image. The number of loops is the number of FOR cycles.
[0201] S3, grayscale opening operation.
[0202] In some embodiments of this application, after obtaining the first enhanced image, the server performs grayscale opening operation on the first enhanced image to obtain the foreground image.
[0203] S4, grayscale closing operation.
[0204] In some embodiments of this application, after obtaining the first enhanced image, the server performs grayscale calculations on the first enhanced image to obtain the foreground image.
[0205] In some embodiments of this application, S3 or S4 can be executed after S2, and this application does not impose specific restrictions on this. After executing S3 or S4, S5 can be executed directly. Alternatively, S4 can be executed after S3, and then S5 can be executed; or S3 can be executed after S4, and then S5 can be executed.
[0206] S5. Obtain the foreground image.
[0207] In some embodiments of this application, the server can obtain the foreground image after performing a grayscale opening operation on the first enhanced image; or it can obtain the foreground image after performing a grayscale closing operation on the first enhanced image; or it can obtain the foreground image after performing a grayscale closing operation on the first enhanced image and then performing a grayscale opening operation; or it can obtain the foreground image after performing a grayscale opening operation on the first enhanced image and then performing a grayscale closing operation.
[0208] S603. For the foreground image, perform grayscale calculation along the second direction to determine at least two edge points; the second direction is different from the first direction.
[0209] In some embodiments of this application, the server can divide the foreground image into regions along a second direction to obtain multiple region images, perform grayscale calculations on the multiple region images to obtain multiple extreme points, and then determine multiple edge points based on the multiple extreme points; the second direction is different from the first direction.
[0210] In some embodiments of this application, the server divides the foreground image according to a second direction to obtain at least two region images; performs grayscale calculations on the at least two region images to obtain the extreme points corresponding to each of the at least two region images; and determines at least two edge points based on the extreme points corresponding to each of the at least two region images.
[0211] Understandably, the server divides the foreground image into regions along the second direction to obtain at least two region images; grayscale calculations are performed on the at least two region images to obtain the extreme points corresponding to each of the at least two region images; based on the extreme points corresponding to each of the at least two region images, at least two edge points are determined, which facilitates the subsequent determination of edge standard lines and the screening of outliers, thereby improving the fitting accuracy of the measurement line.
[0212] In some embodiments of this application, the server calculates the unit gray-level mean in the second direction for each region image to determine the total gray-level mean of each region image; wherein, the unit gray-level mean represents the gray-level mean of each row or the gray-level mean of each column in the corresponding dimension of the first direction; based on the total gray-level mean of each region image, the extreme points corresponding to each region image are determined by establishing a discrete function and performing smoothing and differentiation processing respectively.
[0213] It should be noted that the first direction is the vertical direction, and the unit grayscale mean is the grayscale mean of each row; the second direction is the horizontal direction, and the unit grayscale mean is the grayscale mean of each column.
[0214] Understandably, the server determines the extreme points corresponding to each region of the image, which facilitates the identification of at least two edge points. This makes it easier to subsequently determine the edge standard line and screen outliers, thereby improving the fitting accuracy of the measurement line for the foreground image.
[0215] For example, let's take dividing the foreground image into two regions along a second direction as an example. The foreground image is divided along the vertical direction (e.g., ... Figure 10a The image is divided into two regions (as shown in the direction) Figure 10b As shown), sum all gray levels in a certain direction (each row in the horizontal direction or each column in the vertical direction) and calculate the mean. Then, summarize the mean gray levels of all rows or columns within the two image regions, transforming the original data into a one-dimensional discrete function (e.g., ...). Figure 10c As shown), and smooth it to achieve noise reduction (e.g. Figure 10d (As shown), then calculate the zeros of the first derivative of the function to obtain the maxima and minima (as shown). Figure 10e (As shown). The maximum value represents the change from dark to light (positive), and the minimum value represents the change from light to dark (negative). Based on the extreme points, two edge points are obtained, and these edge points form the edge baseline (e.g., ...). Figure 2a (Line 1 in the middle).
[0216] It should be noted that a one-dimensional discrete function can be smoothed by applying the mean filter multiple times.
[0217] Understandably, the server performs image enhancement and overlay processing on the first image according to a certain number of loops to obtain the first enhanced image; then, it performs at least one grayscale operation on the first enhanced image to obtain the foreground image. By performing cyclic image enhancement and grayscale processing on the first image, the image clarity can be improved. For the foreground image, grayscale calculations are performed along the second direction to determine at least two edge points, which facilitates subsequent determination of edge reference lines and screening of outliers.
[0218] In some embodiments of this application, the method for fitting the measurement line further includes the following steps:
[0219] S701. Determine the first position information of the first point corresponding to the original image and the second position information of the second point corresponding to the first image.
[0220] In some embodiments of this application, the server can determine the position information corresponding to the center point in the original image as the first position information corresponding to the first point in the original image, and determine the position information corresponding to the center point of the first image as the second position information corresponding to the second point in the first image.
[0221] S702. Based on the first position information and the second position information, calculate the rotation angle and translation distance to determine the position transformation relationship.
[0222] In some embodiments of this application, the server can calculate the rotation angle and determine the rotation matrix based on the first position information and the second position information; calculate the translation distance and determine the translation vector based on the first position information and the second position information; and multiply the rotation matrix and the translation vector to determine the position transformation relationship.
[0223] It should be noted that the first and second position information can be two-dimensional coordinates.
[0224] Understandably, the server can calculate the rotation angle and determine the rotation matrix based on the first and second position information; calculate the translation distance and determine the translation vector based on the first and second position information; multiply the rotation matrix and translation vector to determine the position transformation relationship and establish the position transformation relationship between the first image and the original image, which facilitates the subsequent conversion of the fitted image of the foreground image into the measurement line of the foreground image in the original image.
[0225] In some embodiments of this application, after determining the coordinates of the first point and the second point, the server can establish a point correspondence and two corresponding angles, calculate a rigid affine transformation (i.e., a transformation consisting of rotation and translation), and return it as a homogeneous transformation matrix. The point correspondence can be selected as the center point of the original image ((Weight-1) / 2, (Height-1) / 2) and the center point (X,Y) of the first image. The homogeneous transformation matrix represents the positional transformation relationship.
[0226] For example, the coordinates of the first point in the original image are (T x ,T y The coordinates of the second point in the first image are (O). x O y Based on these two points, the position transformation relationship can be determined using formula (2), as follows:
[0227]
[0228] Where M is the position transformation relationship, R is the rotation matrix, T is the translation vector, and 1 represents the angle. R can be calculated using formula (3), and T can be calculated using formula (4), as follows:
[0229]
[0230] T = (T x -O x ,T y -O y (4)
[0231] Where θ is the rotation angle.
[0232] Understandably, the server determines the first position information of the first point corresponding to the original image and the second position information of the second point corresponding to the first image; using the first and second position information, it calculates the rotation angle and translation distance to determine the position transformation relationship, which facilitates the subsequent transformation of the fitted image of the foreground image into the measurement line of the original image for the foreground image through the position transformation relationship.
[0233] In some embodiments of this application, S104 can be implemented by S1041 and S1042, as follows:
[0234] S1041. Using the first fitting point, perform a straight line fitting on the foreground image to determine the fitted image of the foreground image.
[0235] In some embodiments of this application, the server fits a measurement line on the foreground image using a first fitting point to obtain a fitted image of the foreground image.
[0236] S1042. By transforming the position information of the fitted image of the foreground image through the position transformation relationship, the measurement line is determined.
[0237] In some embodiments of this application, the server can transform the position information of the fitted image of the foreground image through position transformation relationship to determine the measurement line for the foreground image.
[0238] Understandably, the server uses the first fitting point to fit a measurement line onto the foreground image, determining the fitted image of the foreground. Through positional transformation, the fitted image of the foreground is transformed to determine the measurement line for the foreground. Since the first fitting point is a selected measurement point, fitting a straight line through it improves the accuracy of the fitted image of the foreground. Simultaneously, because the foreground image is determined by cropping the original image, its area is smaller than the original image, resulting in a more accurate fitted image when fitting a straight line onto it. By using the positional transformation relationship between the original and foreground images, a coordinate transformation is performed on the more accurate fitted image of the foreground, obtaining the measurement line for the foreground in the original image. This transformation preserves the high accuracy of the fitted image of the foreground, ensuring that the measurement line for the foreground in the original image also has high accuracy, thus improving the fitting accuracy of the measurement line for the foreground in the original image.
[0239] In some embodiments of this application, the server may be designed to encapsulate a function interface. The input parameters mainly include the original image and several control parameters, and the output parameters include the measurement lines in the original image for the foreground image.
[0240] It should be noted that several control parameters include: projected extrema (i.e., the extreme points corresponding to at least two regions of the image), and caliper threshold (i.e., the measurement range of the calipers, for example...). Figure 6 The parameters include the position of the white grid in the image, the caliper direction (i.e., the second direction, such as the vertical direction of the foreground image), the cropped target region (i.e., the region of interest, such as the region containing the battery components), etc. In addition to the measurement lines for the foreground image in the original image, the output parameters can also include two extreme points.
[0241] In some embodiments of this application, Figure 11An optional flowchart illustrating a method for fitting a measurement line provided in an embodiment of this application. Figure 6 The steps for implementing the measurement line fitting method are as follows:
[0242] S11, Image sensor captures images.
[0243] In some embodiments of this application, an image sensor captures images to obtain raw images.
[0244] S12, coarse positioning.
[0245] In some embodiments of this application, the server can perform coarse positioning on the original image.
[0246] S13. Locate the target detection area, trim, and preprocess.
[0247] In some embodiments of this application, the server can locate the target detection area, i.e., the region containing the battery component, in the original image. The original image is then cropped using the region containing the battery component to obtain a first image. The first image is then preprocessed to obtain a foreground image.
[0248] It should be noted that preprocessing includes image enhancement and grayscale processing. Grayscale processing includes: grayscale opening, grayscale closing, grayscale opening followed by grayscale closing, and grayscale closing followed by grayscale opening.
[0249] In some embodiments of this application, after executing S13, S14 can be executed, and S21 can also be executed. There is no specific order between the two; they are executed according to the actual situation.
[0250] S14. Determine if there are extreme values.
[0251] In some embodiments of this application, the server can perform grayscale calculations on the foreground image to determine whether there are extreme values.
[0252] In some embodiments of this application, when S14 is executed, if yes, then S15 is executed; otherwise, S16, S23, S24 and S25 are executed.
[0253] S15. Determine the target edge points and fit the target edge points to a standard line.
[0254] In some embodiments of this application, the server can determine the measurement point corresponding to the extreme value as the target edge point, and fit an edge standard line based on the target edge point.
[0255] It should be noted that the target edge point is at least two edge points; the edge standard line is the standard line.
[0256] S16. Call the one-dimensional caliper to obtain a series of grayscale points.
[0257] In some embodiments of this application, the server can call a one-dimensional caliper on the foreground image to obtain a series of grayscale points.
[0258] It should be noted that the grayscale point is the measurement point.
[0259] S17. Calculate the distance from the grayscale point to the standard line.
[0260] In some embodiments of this application, the server can calculate the distance between a series of grayscale points and the edge standard line to obtain the distance between multiple point lines.
[0261] S18. Based on the distance between the dots and lines, filter the grayscale points to obtain the first grayscale point.
[0262] In some embodiments of this application, the server can filter a series of grayscale points based on the distance between multiple points and a preset distance to obtain the first grayscale point.
[0263] S19. Sort the first grayscale points and truncate them by percentage to obtain the second grayscale points.
[0264] In some embodiments of this application, the server can sort the first grayscale points to obtain the sorted first grayscale points, and then truncate the sorted first grayscale points according to a percentage to obtain the second grayscale points.
[0265] S20. Arrange the second grayscale points.
[0266] In some embodiments of this application, the server can arrange the second grayscale points.
[0267] In some embodiments of this application, S25 is executed after S20.
[0268] S21, Direction selection settings (U2B\B2U\L2R\R2L).
[0269] In some embodiments of this application, the server can be oriented in one of the following ways: from left to right, from right to left, from top to bottom, or from bottom to top.
[0270] S22. Use the two-dimensional caliper to obtain a series of grayscale points.
[0271] In some embodiments of this application, the server can invoke a two-dimensional caliper to obtain a series of grayscale points.
[0272] In some embodiments of this application, S23, S24 and S25 are executed after S22 is executed.
[0273] S23. Sort a series of grayscale points and truncate them by percentage to obtain the third grayscale point.
[0274] S24. Arrange the third grayscale points.
[0275] In some embodiments of this application, S25 is executed after S24.
[0276] S25. Obtain the final grayscale points, fit an ideal straight line, and obtain the measurement line for the foreground image.
[0277] In some embodiments of this application, the server can arrange the second grayscale points according to S20 to obtain the final grayscale points. The final grayscale points are then used to fit a measurement line to obtain an ideal straight line, thereby obtaining a measurement line for the foreground image.
[0278] It should be noted that the final grayscale point can be the first fitted point, the second fitted point, or the third fitted point.
[0279] Understandably, in the process of fitting measurement lines to an image, this application can perform two screenings, using edge standard lines and percentage truncation, to remove outliers and improve the fitting accuracy of measurement lines for the foreground image, in the face of interference such as complex backgrounds and dirt.
[0280] This application also provides a fitting device for a measurement line. Figure 12 This is a schematic diagram of the structure of a fitting device for a measurement line provided in an embodiment of this application, as shown below. Figure 12 As shown, the fitting device 12 for the measurement line includes: a determining unit 1201, a filtering unit 1202, and a fitting unit 1203, wherein,
[0281] The determining unit 1201 is used to perform edge detection on the foreground image in the acquired original image to determine at least two edge points; and to determine the edge reference line of the foreground image based on the at least two edge points.
[0282] The filtering unit 1202 is used to remove outliers from the foreground image based on the edge standard line and the preset caliper, and determine the first fitting point;
[0283] The fitting unit 1203 is used to perform straight line fitting through the first fitting point to determine a measurement line for the foreground image.
[0284] In some embodiments of this application, the fitting device 12 for the measuring line further includes: a measuring unit 1204;
[0285] The measuring unit 1204 is used to measure the foreground image by calling the preset calipers to obtain multiple measurement points;
[0286] The filtering unit 1202 is further configured to remove outliers from the plurality of measurement points based on the edge standard line, and determine the first fitting point.
[0287] In some embodiments of this application, the filtering unit 1202 is further configured to remove outliers from the plurality of measurement points based on the edge standard line, and after determining the first fitting point, filter the first fitting point according to a preset filtering range to remove outliers and determine the second fitting point in the foreground image.
[0288] The fitting unit 1203 is further configured to perform straight line fitting through the second fitting point to determine the measurement line for the foreground image.
[0289] In some embodiments of this application, the determining unit 1201 is further configured to determine a plurality of first distances between the plurality of measurement points based on the edge standard line;
[0290] The filtering unit 1202 is further configured to remove outliers from the plurality of measurement points by using a preset distance and the plurality of first distances, and determine the first fitting point.
[0291] In some embodiments of this application, the filtering unit 1202 is further configured to filter the first fitting point along a first direction through the preset filtering range, remove abnormal points outside the preset filtering range, and determine the second fitting point in the foreground image; the first direction represents a dimension direction in two-dimensional coordinates.
[0292] In some embodiments of this application, the determining unit 1201 is further configured to perform grayscale projection processing based on the original image to determine the foreground image and the at least two edge points of the foreground image.
[0293] In some embodiments of this application, the fitting device 12 for the measuring line further includes: a trimming unit 1205; wherein,
[0294] The cropping unit 1205 is used to crop the acquired original image to determine a first image containing a foreground object;
[0295] The determining unit 1201 is further configured to perform grayscale projection processing based on the first image to determine the foreground image and the at least two edge points of the foreground image.
[0296] In some embodiments of this application, the fitting device 12 for the measurement line further includes: an enhancement unit 1206; wherein,
[0297] The enhancement unit 1206 is further configured to perform image enhancement and overlay processing on the first image according to the number of loops to obtain a first enhanced image; and to perform at least one grayscale operation on the first enhanced image to obtain the foreground image; wherein the at least one grayscale operation includes: grayscale opening operation, grayscale closing operation, grayscale opening and closing operation and grayscale closing and opening operation.
[0298] The determining unit 1202 is further configured to perform grayscale calculation on the foreground image along a second direction to determine the at least two edge points; the second direction is different from the first direction.
[0299] In some embodiments of this application, the fitting device 12 for the measurement line further includes: a calculation unit 1207; wherein,
[0300] The calculation unit 1207 is further configured to divide the foreground image into regions according to the second direction to obtain at least two region images; and to perform grayscale calculations on the at least two region images to obtain the extreme points corresponding to each of the at least two region images.
[0301] The determining unit 1202 is further configured to determine the at least two edge points based on the extreme points corresponding to the at least two region images.
[0302] In some embodiments of this application, the calculation unit 1207 is further configured to calculate the unit gray-level mean in the second direction for each region image, and determine the total gray-level mean of each region image; wherein, the unit gray-level mean represents the gray-level mean in the corresponding dimension of the first direction; based on the total gray-level mean of each region image, the extreme points corresponding to each region image are determined by establishing a discrete function and performing smoothing and differentiation processing respectively.
[0303] In some embodiments of this application, the calculation unit 1207 is further configured to determine a first grayscale value and a second grayscale value of the first image in different directions; multiply the first grayscale value and the second grayscale value to determine the grayscale value of the initial enhanced image; and based on the grayscale value of the initial enhanced image, continue to perform image enhancement overlay processing until the number of iterations is reached to determine the first enhanced image.
[0304] In some embodiments of this application, the calculation unit 1207 is further configured to determine the first position information of the first point corresponding to the original image and the second position information of the second point corresponding to the first image; and to calculate the rotation angle and translation distance based on the first position information and the second position information to determine the position transformation relationship.
[0305] In some embodiments of this application, the calculation unit 1207 is further configured to calculate a rotation angle and determine a rotation matrix based on the first position information and the second position information; calculate a translation distance and determine a translation vector based on the first position information and the second position information; and multiply the rotation matrix and the translation vector to determine the position transformation relationship.
[0306] In some embodiments of this application, the fitting unit 1203 is further configured to perform straight line fitting on the foreground image through the first fitting point to determine the fitted image of the foreground image; and to perform position information transformation on the fitted image of the foreground image through position transformation relationship to determine the measurement line.
[0307] In some embodiments of this application, the measurement unit 1204 is further configured to, after performing grayscale projection processing based on the first image to determine the foreground image, use the preset caliper to measure the foreground image in the acquired original image to obtain multiple measurement points.
[0308] The filtering unit 1202 is further configured to filter the plurality of measurement points according to a preset filtering range, remove abnormal points, and determine a third fitting point in the foreground image; and to perform linear fitting on the foreground image using the third fitting point to determine a measurement line for the foreground image.
[0309] Based on the measurement line fitting method of the above embodiments, this application also provides a measurement line fitting device, such as... Figure 13 As shown, Figure 13 This is a schematic diagram of a measurement line fitting device provided in an embodiment of this application. The measurement line fitting device 13 includes a processor 1301 and a memory 1302. The memory 1302 is used to store a computer program; the processor 1301 is used to call and run the computer program from the memory to execute the measurement line fitting method as described in the above embodiment.
[0310] In the embodiments of this application, the processor 1301 described above can be at least one of the following: Application-Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), Central Processing Unit (CPU), Controller, Microcontroller, and Microprocessor. It is understood that for different devices, the electronic device used to implement the above processor function can also be other types, and the embodiments of this application do not specifically limit it.
[0311] This application provides a computer-readable storage medium storing a computer program for implementing the measurement line fitting method as described in any of the above embodiments when executed by a processor.
[0312] For example, the program instructions corresponding to a measurement line fitting method in this embodiment can be stored on a storage medium such as an optical disc, hard disk, or USB flash drive. When the program instructions corresponding to a measurement line fitting method in the storage medium are read or executed by an electronic device, the measurement line fitting method as described in any of the above embodiments can be implemented.
[0313] If the integrated unit is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method of this embodiment.
[0314] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0315] The modules described above as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules. They may be located in one place or distributed across multiple network units. Some or all of the modules may be selected to achieve the purpose of this embodiment according to actual needs.
[0316] Furthermore, the functional modules in the various embodiments of this application can all be integrated into one processing unit, or each module can be a separate unit, or two or more modules can be integrated into one unit; the integrated modules can be implemented in hardware or in a combination of hardware and software functional units. It should be understood that "an embodiment" or "one embodiment" mentioned in this application means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this disclosure. Therefore, "in one embodiment" or "in one embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Moreover, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.
[0317] It should be understood that in the various embodiments of this application, the sequence numbers of the above steps / processes do not imply the order of execution. The execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this disclosure. The sequence numbers of the above embodiments of this disclosure are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments.
[0318] It should be noted that, in this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0319] In the embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0320] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0321] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0322] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.
[0323] The above description is merely an embodiment of this application, but the protection scope of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.
Claims
1. A method of fitting a measurement line, characterized by, The method comprises: Edge detection is performed on the foreground image in the acquired original image to determine at least two edge points; Based on the at least two edge points, an edge standard line of the foreground image is determined; Based on the edge standard line and a preset caliper, an abnormal point of the foreground image is removed to determine a first fitting point; A straight line fitting is performed through the first fitting point to determine a measurement line for the foreground image.
2. The method of claim 1, wherein, The method further comprises: A plurality of measurement points are obtained by calling the preset caliper to measure the foreground image; Based on the edge standard line, the plurality of measurement points are subjected to abnormal point removal to determine the first fitting point.
3. The method of claim 2, wherein, The method further comprises: According to a preset screening range, the first fitting point is screened to remove abnormal points to determine a second fitting point in the foreground image; A straight line fitting is performed through the second fitting point to determine the measurement line for the foreground image.
4. The method according to claim 2 or 3, characterized in that, The method further comprises: Based on the edge standard line, a plurality of first distances between the plurality of measurement points are determined; Through a preset distance and the plurality of first distances, abnormal points are removed from the plurality of measurement points to determine the first fitting point.
5. The method of claim 3, wherein, The method further comprises: Along a first direction, the first fitting point is screened through the preset screening range to remove abnormal points outside the preset screening range to determine the second fitting point in the foreground image; the first direction comprises a dimension direction in a two-dimensional coordinate.
6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: Based on the original image, a gray projection processing is performed to determine a foreground image and the at least two edge points of the foreground image.
7. The method of claim 6, wherein, The method further comprises: The original image is cropped to determine a first image containing a foreground object; Based on the first image, a gray projection processing is performed to determine the foreground image and the at least two edge points of the foreground image.
8. The method of claim 7, wherein, The method further comprises: The first image is subjected to image enhancement superposition processing according to a cycle number to obtain a first enhanced image; At least one gray operation is performed on the first enhanced image to obtain the foreground image; the at least one gray operation comprises a gray open operation, a gray close operation, a gray open-close operation, and a gray close-open operation; The foreground image is calculated in a second direction to determine the at least two edge points, the second direction being different from the first direction.
9. The method of claim 8, wherein, The foreground image is calculated in a second direction to determine the at least two edge points, the second direction being different from the first direction. The foreground image is divided into at least two region images according to the second direction; The at least two region images are respectively calculated to obtain the extreme points corresponding to the at least two region images respectively; The at least two edge points are determined based on the extreme points corresponding to the at least two region images respectively.
10. The method of claim 9, wherein, The at least two region images are respectively calculated to obtain the extreme points corresponding to the at least two region images respectively, including: For each region image, a unit gray mean value in the second direction is calculated to determine a total gray mean value of the each region image, wherein the unit gray mean value represents a gray mean value in a first direction corresponding dimension; Based on the total gray mean value of the each region image, the extreme points corresponding to the each region image are determined by establishing a discrete function and performing smoothing processing and derivation processing respectively.
11. The method according to any one of claims 8-10, characterized in that, The first image is enhanced and superimposed according to a cycle number to obtain a first enhanced image, including: First and second gray values of the first image in different directions are determined; The first and second gray values are multiplied to determine a gray value of an initial enhanced image; Based on the gray value of the initial enhanced image, image enhancement superimposition processing is continued until the cycle number is reached to determine the first enhanced image.
12. The method according to any one of claims 7-10, characterized in that, The method further includes: First position information of a first point corresponding to the original image and second position information of a second point corresponding to the first image are determined; Based on the first position information and the second position information, a rotation angle and a translation distance are calculated to determine a position transformation relationship.
13. The method of claim 12, wherein, Based on the first position information and the second position information, a rotation angle is calculated to determine a rotation matrix; Based on the first position information and the second position information, a translation distance is calculated to determine a translation vector; The rotation matrix and the translation vector are multiplied to determine the position transformation relationship. The first fitting point is used for linear fitting to determine a measurement line for the foreground image, including:
14. The method according to claim 12 or 13, characterized in that, The first fitting point is used for linear fitting on the foreground image to determine a fitting image of the foreground image; The fitting image of the foreground image is position information transformed by the position transformation relationship to determine the measurement line. The method further includes:
15. The method of claim 1, wherein, The foreground image in the obtained original image is measured by calling the preset caliper to obtain a plurality of measurement points; The plurality of measurement points are screened according to a preset screening range to remove abnormal points to determine a third fitting point in the foreground image; The third fitting point is used for linear fitting to determine a measurement line for the foreground image. 16. A fitting device for measuring a line, characterized in that The fitting device of the measurement line comprises a determining unit, a screening unit and a fitting unit, wherein The determining unit is configured to perform edge detection on a foreground image in the acquired original image to determine at least two edge points; and determine an edge standard line of the foreground image based on the at least two edge points; The screening unit is configured to remove abnormal points from the foreground image based on the edge standard line and a preset caliper to determine first fitting points; The fitting unit is configured to perform straight line fitting through the first fitting points to determine a measurement line for the foreground image.
17. A fitting device for measuring a line, characterized in that Comprise: A processor and a memory, wherein The memory is configured to store a computer program; The processor is configured to call and run the computer program from the memory to execute the measurement line fitting method according to any one of claims 1 to 15.
18. A computer-readable storage medium, characterized in that, Executable instructions are stored for causing the processor to execute the measurement line fitting method according to any one of claims 1 to 15 when executed.