A method for automatically connecting discontinuous edges in contour edge finding
Through the automatic connection method of discontinuous edges during industrial laser cutting, the cutting waste and manual screening problems caused by discontinuity are solved, and the effect of reducing waste and saving costs is achieved.
Patent Information
- Application Number
- CN202510048393.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2045-01-13
AI Technical Summary
During the industrial laser cutting process, noise and material pollution exist during the image acquisition process, resulting in discontinuity of the edges, resulting in waste of cutting and the problem of manual secondary screening.
By preprocessing the detection image, an edge binary graph is obtained, the number of jumps of adjacent pixel points in the eight neighborhoods of each pixel point is calculated, the endpoints are determined, and the endpoints are matched and verified. The discontinuous edges are automatically connected based on the preset distance threshold and whether the connection line is blocked.
Reduced failure of edge search results, reduced waste and manual secondary screening, saved costs, and optimized outline edge search results.
Smart Images

Figure CN119444785B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and more specifically, to a method for automatically connecting discontinuous edges in contour edge finding. Background Art
[0002] Contour edge finding algorithms are often used in industrial laser cutting. On a closed machine tool workbench, workers only need to press the "edge finding" button, and the equipment will find the edge of the material to be cut within a few seconds. Due to the noise in the image acquisition process and the dirt on the cutting material itself, if there is an edge discontinuity problem, it may cause waste during cutting or require manual secondary screening. If the partially disconnected edges can be automatically connected during the edge finding process, the impact of edge discontinuity can be reduced, and the cutting process can be adjusted to avoid waste. The contour edge finding automatic connection algorithm came into being.
[0003] Therefore, the prior art has defects and is in urgent need of improvement. Summary of the invention
[0004] In view of the above problems, the purpose of the present invention is to provide a method for automatically connecting discontinuous edges in contour edge finding, which can optimize the contour edge finding result by judging the endpoints, calculating the distance between the endpoints, connecting the nearest endpoints that meet the conditions, and then optimizing the contour edge finding result. By automatically connecting discontinuous edges, the failure of edge finding results is reduced, waste and manual secondary screening are reduced, and costs are saved.
[0005] A first aspect of the present invention provides a method for automatically connecting discontinuous edges in contour edge finding, comprising:
[0006] Acquire detection images;
[0007] Preprocessing the detection image to obtain an edge binary image;
[0008] Calculate the number of jumps of adjacent pixels in the eight neighborhoods of each pixel in the edge binary image, and determine the pixel with two jumps as the endpoint;
[0009] An endpoint point set is formed based on all endpoints in the edge binary graph; the endpoints in the endpoint point set are sorted in order from left to right and from top to bottom according to the image coordinate system;
[0010] Analyze the endpoints in the endpoint point set in sequence, match the endpoints in the endpoint point set in pairs, and obtain one or more groups of first point pair data;
[0011] Verifying the one or more sets of first point pair data by historical comparison data to determine one or more sets of second point pair data;
[0012] Filtering the one or more sets of second point pair data based on a preset distance threshold and whether the connection line is blocked, and filtering the second point pair data that meets the filtering condition;
[0013] Automatically connect the connecting lines of the remaining second point pairs of data.
[0014] In this solution, the detection image is preprocessed to obtain an edge binary image, including:
[0015] Performing grayscale processing on the detection image to obtain a grayscale image;
[0016] The edge of the grayscale image is extracted by using a canny edge detection algorithm to obtain an edge binary image.
[0017] In this solution, the step of calculating the number of transitions of adjacent pixels in the eight neighborhoods of each pixel in the edge binary image and determining the pixel with two transitions as the endpoint includes:
[0018] Determine a pixel point with a pixel value of 255 in the edge binary image as an edge point;
[0019] Analyze the pixel values of the adjacent pixels in the eight neighborhoods of the pixel in a clockwise manner. When the pixel values of the adjacent pixels are 0 and 255 respectively, it is recorded as one transition.
[0020] The number of jumps of adjacent pixel points in the eight neighborhoods of the edge point is counted, and when the number of jumps is two, the edge point is determined as an endpoint.
[0021] In this solution, the endpoints in the endpoint point set are analyzed in sequence, and the endpoints in the endpoint point set are matched in pairs to obtain one or more sets of first point pair data, including:
[0022] Determine the endpoint to be analyzed as a first endpoint, and determine the endpoint after the first endpoint is sorted as a subsequent endpoint;
[0023] Calculating the first pixel distance between the first endpoint and each subsequent endpoint in the endpoint point set, and determining the subsequent endpoints whose first pixel distance is less than or equal to a preset distance threshold as the candidate endpoints;
[0024] When the first pixel distance between the first endpoint and the subsequent endpoint is greater than a preset distance threshold, the calculation ends;
[0025] Sort the endpoints to be selected in ascending order according to the first pixel distance;
[0026] The candidate endpoint with the smallest first pixel distance is bound to the first endpoint to determine first point pair data corresponding to the first endpoint.
[0027] In this solution, verifying the one or more sets of first point pair data by historical comparison data to determine one or more sets of second point pair data includes:
[0028] Acquire historical point pair data formed by the first endpoint and the compared endpoints through historical comparison data; the historical point pair data is the first point pair data or the second point pair data where the first endpoint is a subsequent endpoint;
[0029] When the first endpoint has both historical point pair data and first point pair data, compare the first pixel distance in the historical point pair data with the first pixel distance in the first point pair data; otherwise, determine the first point pair data as the second point pair data;
[0030] When the first pixel distance in the historical point pair data is smaller than the first pixel distance in the first point pair data, the historical point pair data is determined as the second point pair data; otherwise, the first point pair data is determined as the second point pair data.
[0031] This plan also includes:
[0032] When the subsequent endpoint of the historical point pair data is the same as the first endpoint of the second point pair data, the historical point pair data is unbound, and the first endpoint of the historical point pair data and the next subsequent endpoint are bound based on the ascending sort order of the first pixel distance.
[0033] In this solution, the one or more sets of second point pair data are screened based on the preset distance threshold and whether the connection line is blocked, and the second point pair data that meets the screening condition is filtered, including:
[0034] Calculate the pixel distance between the two endpoints of the second point pair in the data to obtain the second pixel distance;
[0035] Filtering the data of the second point whose second pixel distance is greater than a preset distance threshold;
[0036] Connect the two endpoints in the second point pair data to obtain a connecting line;
[0037] The analysis is performed based on the connection line, and the data is filtered at the second point where the connection line is blocked.
[0038] In this solution, the analysis is performed based on the connection line, and the data is filtered at the second point where the connection line is blocked, including:
[0039] Obtaining pixel values of pixel points on the connecting line;
[0040] When there is a pixel point with a pixel value of 255 on the connection line, it is determined that the connection line is blocked, and the data of the second point corresponding to the connection line is filtered;
[0041] Otherwise, no processing is done.
[0042] In this solution, automatically connecting the connection lines of the remaining second point pair data includes:
[0043] Adjust the pixel value of the pixel on the data connection line of the second point pair to 255.
[0044] The present invention discloses a method for automatically connecting discontinuous edges in contour edge finding, the method comprising: preprocessing a detection image to obtain an edge binary map; calculating the number of jumps of adjacent pixel points in an eight-neighborhood region of a pixel point in the edge binary map, and determining the pixel point with two jumps as an endpoint; forming all endpoints into an endpoint point set; performing pairwise matching of the endpoints in the endpoint point set to obtain first point pair data; verifying the first point pair data through historical comparison data to determine second point pair data; screening the second point pair data based on a preset distance threshold and whether the connecting line is blocked, filtering the second point pair data that meets the screening condition; and automatically connecting the connecting lines of the remaining second point pair data. The present invention reduces the failure of edge finding results, reduces waste and manual secondary screening, and saves costs by automatically connecting discontinuous edges. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A flow chart of a method for automatically connecting discontinuous edges in contour edge finding provided by the present invention is shown;
[0046] Figure 2 A flow chart of a method for determining an endpoint by the number of transitions of adjacent pixels in an eight-neighborhood region provided by the present invention is shown;
[0047] Figure 3 A flow chart of a method for determining a first point pair data through an endpoint provided by the present invention is shown;
[0048] Figure 4 It shows a schematic diagram of the transition of adjacent pixels in the eight-neighborhood of an endpoint provided by the present invention;
[0049] Figure 5 A schematic diagram of endpoint matching provided by the present invention is shown;
[0050] Figure 6 A schematic diagram of verifying the pixel distance between endpoints in point-to-point data provided by the present invention is shown;
[0051] Figure 7 It shows a schematic diagram of the point-to-point data connection line blocking verification provided by the present invention;
[0052] Figure 8 The edge binary value of the discontinuous edge in the contour edge finding process provided by the present invention is shown. Figure 1 ;
[0053] Fig. 9 The edge binary value of the discontinuous edge in the contour edge finding process provided by the present invention is shown. Figure 2 ;
[0054] Fig.10 The edge binary value after the discontinuous edges are automatically connected in the contour edge finding process provided by the present invention is shown. Figure 1 ;
[0055] Fig.11 The edge binary value after the discontinuous edges are automatically connected in the contour edge finding process provided by the present invention is shown. Figure 2 . DETAILED DESCRIPTION
[0056] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0057] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0058] Figure 1 A flow chart of a method for automatically connecting discontinuous edges in contour edge finding provided by the present invention is shown.
[0059] like Figure 1 As shown, the present invention discloses a method for automatically connecting discontinuous edges in contour edge finding, comprising:
[0060] S102, acquiring a detection image;
[0061] S104, preprocessing the detection image to obtain an edge binary image;
[0062] S106, calculating the number of transitions of adjacent pixels in the eight neighborhoods of each pixel in the edge binary map, and determining the pixel with two transitions as an endpoint;
[0063] S108, forming an endpoint point set based on all endpoints in the edge binary graph; and sorting the endpoints in the endpoint point set in order from left to right and from top to bottom according to the image coordinate system;
[0064] S110, analyzing endpoints in the endpoint point set in sequence, matching endpoints in the endpoint point set in pairs, and obtaining one or more groups of first point pair data;
[0065] S112, verifying one or more sets of first point pair data through historical comparison data to determine one or more sets of second point pair data;
[0066] S114, screening one or more groups of second point pair data based on a preset distance threshold and whether the connection line is blocked, and filtering the second point pair data that meets the screening condition;
[0067] S116, automatically connecting the connection lines of the remaining second point pair data.
[0068] According to an embodiment of the present invention, the non-connected endpoints of the contour edge are automatically connected through an image acquisition module, a laser motion control module and a PC control module. Among them, the image acquisition module is composed of a camera and a lens, the laser motion control module is composed of a motor shaft and a motion control card to form a two-dimensional platform motion machine, and the laser motion control module and the PC control module are electrically connected to control the camera to perform image acquisition to obtain a detection image. After the image acquisition is completed, the detection image is searched for edges through the "edge search" function in the PC control module, and the image edges found are processed through the canny edge detection algorithm to obtain an edge binary image. Figure 8 and Fig. 9 As shown in FIG. 1 , it is the edge binary image of the discontinuous edge in the contour edge finding process.
[0069] Analyze each pixel point in the edge binary image in turn, and filter the endpoints in the edge binary image by the number of jumps of adjacent pixels in the eight neighborhoods around each pixel point in the edge binary image, and find all the endpoints of the image to form an endpoint point set. Sort the endpoints in the endpoint point click from left to right and from top to bottom in the image coordinate system, and analyze each endpoint in turn in this order, compare the pixel distance between each endpoint and the subsequent endpoint, select the subsequent endpoint with the smallest pixel distance for mutual matching, and determine the first point pair data corresponding to each endpoint.
[0070] Verify the first point pair data corresponding to the endpoint, select the historical point pair data (including the first point data and the second point pair data) containing the endpoint in the historical comparison data, compare the pixel distances of the two endpoints in the first point pair data and the historical point pair data, and determine the first point pair data or the historical point pair data with the closest pixel distance as the final second point pair data. When the pixel distance of the first point pair data corresponding to the endpoint is the smallest, update the historical point pair data containing the endpoint, and bind the other endpoint in the historical point pair data to the subsequent endpoint with the closest pixel distance.
[0071] When all endpoints in the edge binary image are matched, one or more sets of second point pair data are obtained, and the obtained one or more sets of second point pair data are screened, and the point pair data that meet the system preset screening conditions are filtered, such as the pixel distance between the endpoints is greater than the preset distance threshold, the connection line between the endpoints is blocked, etc. The pixel values of all pixels on the connection line of the remaining second point pair data after screening are adjusted to 255 to complete the automatic connection of the disconnected edge endpoints.
[0072] like Fig.10 and Fig.11 As shown, they are the edge binary images after the discontinuous edges are automatically connected.
[0073] According to an embodiment of the present invention, the detection image is preprocessed to obtain an edge binary image, including:
[0074] Grayscale the detected image to obtain a grayscale image;
[0075] The edge of the grayscale image is extracted using the Canny edge detection algorithm to obtain an edge binary image.
[0076] It should be noted that the detection image is grayed out by the graying processing method preset by the system (such as the maximum value method, the average value method or the weighted average method, etc.), and the detection image is converted into a grayscale image. If the collected detection image is a grayscale image, skip this step. Then Gaussian filtering is performed on the grayscale image to smooth the image and reduce the noise in the image. The gradient amplitude and direction of each pixel in the grayscale image are calculated, the gradient amplitude image is non-maximum suppressed, the edge is determined by double threshold detection, and the broken edges are connected to obtain an edge binary image.
[0077] Figure 2 The flowchart of the method for determining the endpoints by the number of jumps of adjacent pixels in eight neighborhoods provided by the present invention is shown.
[0078] like Figure 2 As shown, according to an embodiment of the present invention, the number of jumps of adjacent pixels in the eight neighborhoods of each pixel in the edge binary image is calculated, and the pixel with two jumps is determined as an endpoint, including:
[0079] S202, determining a pixel point with a pixel value of 255 in the edge binary image as an edge point;
[0080] S204, analyzing the pixel values of adjacent pixels in the eight neighborhoods of the pixel point in a clockwise manner, and when the pixel values of the adjacent pixels are 0 and 255 respectively, it is recorded as one transition;
[0081] S206, counting the number of jumps of adjacent pixel points in the eight neighborhoods of the edge point, and when the number of jumps is two, determining the edge point as an endpoint.
[0082] It should be noted that if Figure 4 As shown in the figure, when judging whether the edge point X is an endpoint, the pixel values of the pixels in its eight neighborhoods are different by clockwise. Since the pixel points of the edge binary image have only two pixel values, 0 and 255, 0 represents the background and 255 represents the edge point considered by the edge detection algorithm. So when one of the two pixel values is 0 and the other is 255, they are different. For example, Figure 5 When A is 0 and B is 255, AB is considered as a jump, and BC is also considered as a jump. Count the jump times of adjacent pixels in the eight neighborhoods around pixel point X. If the jump times are 2, the edge point X is determined to be an endpoint.
[0083] Figure 3 The flowchart of the method for determining the first point pair data through the endpoint provided by the present invention is shown.
[0084] like Figure 3 As shown, according to an embodiment of the present invention, endpoints in the endpoint point set are analyzed in sequence, and the endpoints in the endpoint point set are matched in pairs to obtain one or more groups of first point pair data, including:
[0085] S302, determining the endpoint to be analyzed as the first endpoint, and determining the endpoint after the first endpoint is sorted as the subsequent endpoint;
[0086] S304, calculating a first pixel distance between the first endpoint and each subsequent endpoint in the endpoint point set, and determining subsequent endpoints whose first pixel distances are less than or equal to a preset distance threshold as candidate endpoints;
[0087] S306, when the first pixel distance between the first endpoint and the subsequent endpoint is greater than a preset distance threshold, end the calculation;
[0088] S308, sorting the endpoints to be selected in ascending order according to the first pixel distance;
[0089] S310, binding the candidate endpoint with the smallest first pixel distance to the first endpoint, and determining first point pair data corresponding to the first endpoint.
[0090] It should be noted that the endpoints in the endpoint point set are sorted from left to right and from top to bottom according to the image coordinate system, and the endpoints in the endpoint point set are analyzed in turn according to this sorting, and the endpoint to be analyzed is determined as the first endpoint, and the endpoints after the first endpoint are determined as subsequent endpoints. Figure 5As shown, taking endpoints X, Y and Z as an example, endpoint X is analyzed first, and the first pixel distances of subsequent endpoints of the endpoint point set (such as endpoints Y and Z) are compared cyclically starting from endpoint X, and subsequent endpoints whose first pixel distances are less than or equal to the preset distance threshold are determined as candidate endpoints. When the pixel distance between the first endpoint and a subsequent endpoint exceeds the preset distance threshold, the subsequent endpoints of the endpoint point set are no longer compared, and the candidate endpoint (endpoint Y) closest to endpoint X is found according to the pixel distance, and endpoints X and endpoint Y are combined into the first point pair data (X, Y). Each endpoint is analyzed separately with the corresponding subsequent endpoint to determine the corresponding first point pair data of each endpoint.
[0091] The preset distance threshold is set by those skilled in the art according to actual needs.
[0092] According to an embodiment of the present invention, verifying one or more sets of first point pair data by historical comparison data to determine one or more sets of second point pair data includes:
[0093] Acquire historical point pair data formed by the first endpoint and the compared endpoints through historical comparison data; the historical point pair data is the first point pair data or the second point pair data where the first endpoint is the subsequent endpoint;
[0094] When the first endpoint has both historical point pair data and first point pair data, compare the magnitude relationship between the first pixel distance in the historical point pair data and the first pixel distance in the first point pair data; otherwise, determine the first point pair data as the second point pair data;
[0095] When the first pixel distance in the historical point pair data is smaller than the first pixel distance in the first point pair data, the historical point pair data is determined as the second point pair data; otherwise, the first point pair data is determined as the second point pair data.
[0096] It should be noted that there are generally no bifurcation points in contour search, so each endpoint will only form point pair data with a unique endpoint. Once an endpoint forms a point pair data, it will not form new point pair data with other endpoints.
[0097] After the first endpoint determines the corresponding first point pair data, determine whether there is any historical point pair data (already formed point pair data, including the first point pair data and the second point pair data) containing the first endpoint. Filter the historical comparison data based on the first endpoint, obtain the historical point pair data containing the endpoint, compare the pixel distance between the first endpoint and another endpoint in the first point pair data and the historical point pair data, and select a group of endpoints with a closer pixel distance to form the second point pair data corresponding to the first endpoint.
[0098] like Figure 5As shown in the figure, after the first endpoint data (Y, Z) is matched, it is found that the Y point is repeated in the historical endpoint data (X, Y) (because the subsequent points will not be compared with the previous points, which can save efficiency. When the Y point looks for the nearest point, it will not compare X again, so it can only compare which point pair between (X, Y) and (Y, Z) is closer by finding whether the previous point pair is repeated). By comparing the pixel distances of the point pairs (X, Y) and (Y, Z), it can be seen that the subsequent Z point is closer to Y, and the point pair data corresponding to the first endpoint Y is updated to the second point pair data (Z, Y), and all endpoints are compared until all point pairs are matched.
[0099] According to an embodiment of the present invention, it also includes:
[0100] When the subsequent endpoint of the historical point pair data is the same as the first endpoint of the second point pair data, the historical point pair data is unbound, and the first endpoint of the historical point pair data and the next subsequent endpoint are bound based on the ascending sort order of the first pixel distance.
[0101] It should be noted that since each endpoint will only form point pair data with a unique endpoint, after determining the second point pair data of each first endpoint through historical comparison data, the historical point pair data with the first endpoint as the subsequent endpoint is unbound, and the first endpoint in the historical point pair data is bound to the subsequent endpoint closest to the next pixel, and the historical point pair data is updated.
[0102] According to an embodiment of the present invention, one or more sets of second point pair data are screened based on a preset distance threshold and whether the connection line is blocked, and the second point pair data that meets the screening condition is filtered, including:
[0103] Calculate the pixel distance between the two endpoints of the second point pair in the data to obtain the second pixel distance;
[0104] filtering the data of the second point whose second pixel distance is greater than a preset distance threshold;
[0105] Connect the two endpoints in the second point pair data to obtain a connecting line;
[0106] The analysis is performed based on the connection line, and the data is filtered at the second point where the connection line is blocked.
[0107] It should be noted that after all the second point pair data in the detection image are determined, the second point pair data needs to be screened again to filter the second point pair data that meets the system preset screening conditions (the pixel distance between the endpoints is greater than the preset distance threshold, the connecting line between the endpoints is blocked, etc.). First, filter the second point pair data whose pixel distance is greater than the preset distance threshold. Figure 6As shown, taking endpoint a as an example, when endpoint a is compared with endpoint c, the distance in the horizontal direction has exceeded the preset distance threshold of the set connection. At this time, the subsequent endpoint d of endpoint c does not need to be compared, and the subsequent endpoint f in the vertical direction does not need to be compared. By calculating the pixel distance between the two endpoints in the second point pair data, the second point pair data with a pixel distance greater than the preset distance threshold is filtered, and the second point pair data with a pixel distance less than the preset distance threshold is retained to complete the first screening.
[0108] Although the pixel distance between the two endpoints in some second point pairs is close, they will be blocked by other edges during the connection process. These point pairs cannot be connected and need to be removed. Figure 7 As shown, endpoints X and Y are blocked by a straight line, so the second point pair data (X, Y) does not meet the connection condition and needs to be filtered to complete the second screening.
[0109] According to an embodiment of the present invention, performing analysis based on the connection line and filtering the data at the second point where the connection line is blocked includes:
[0110] Get the pixel value of the pixel point on the connection line;
[0111] When there is a pixel point with a pixel value of 255 on the connection line, it is determined that the connection line is blocked, and the data of the second point corresponding to the connection line is filtered;
[0112] Otherwise, no processing is done.
[0113] It should be noted that the pixel coordinates of all the pixels on the connecting line are analyzed to determine whether the pixel values of these pixels on the edge binary map are 255. If the pixel value of one pixel is 255, it means that the connecting line between the two endpoints is blocked and is not connected.
[0114] According to an embodiment of the present invention, automatically connecting the connection lines of the remaining second point pair data includes:
[0115] Adjust the pixel value of the pixel on the data connection line of the second point pair to 255.
[0116] It should be noted that, after all the second point pair data on the edge binary image are screened, the pixel values of all pixels on the connecting lines in the remaining second point pair data are adjusted to 255, that is, the automatic connection of the second point pair data is completed.
[0117] The information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals (including but not limited to signals transmitted between user terminals and other devices, etc.) involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions. For example, the "detection images" and "historical comparison data" involved in this disclosure are all obtained with full authorization.
[0118] The present invention discloses a method for automatically connecting discontinuous edges in contour edge finding, the method comprising: preprocessing a detection image to obtain an edge binary map; calculating the number of jumps of adjacent pixel points in an eight-neighborhood region of a pixel point in the edge binary map, and determining the pixel point with two jumps as an endpoint; forming all endpoints into an endpoint point set; performing pairwise matching of the endpoints in the endpoint point set to obtain first point pair data; verifying the first point pair data through historical comparison data to determine second point pair data; screening the second point pair data based on a preset distance threshold and whether the connecting line is blocked, filtering the second point pair data that meets the screening condition; and automatically connecting the connecting lines of the remaining second point pair data. The present invention reduces the failure of edge finding results, reduces waste and manual secondary screening, and saves costs by automatically connecting discontinuous edges.
[0119] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0120] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0121] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0122] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: a mobile storage device, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0123] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
Claims
1. A method for automatically connecting discontinuous edges in contour edge finding, characterized in that: include: Acquire detection images; Preprocessing the detection image to obtain an edge binary image; Calculate the number of jumps of adjacent pixels in the eight neighborhoods of each pixel in the edge binary image, and determine the pixel with two jumps as the endpoint; Forming an endpoint point set based on all endpoints in the edge binary graph; The endpoints in the endpoint point set are sorted in order from left to right and from top to bottom according to the image coordinate system; Analyze the endpoints in the endpoint point set in sequence, match the endpoints in the endpoint point set in pairs, and obtain one or more groups of first point pair data; Verifying the one or more sets of first point pair data by historical comparison data to determine one or more sets of second point pair data; Filtering the one or more sets of second point pair data based on a preset distance threshold and whether the connection line is blocked, and filtering the second point pair data that meets the filtering condition; Automatically connect the connection lines of the remaining second point pairs of data; The verifying the one or more sets of first point pair data by using historical comparison data to determine one or more sets of second point pair data includes: Determine the endpoint to be analyzed as a first endpoint, and determine the endpoint after the first endpoint is sorted as a subsequent endpoint; Acquire historical point pair data formed by the first endpoint and the compared endpoints through historical comparison data; the historical point pair data is the first point pair data or the second point pair data where the first endpoint is a subsequent endpoint; When the first endpoint has both historical point pair data and first point pair data, compare the first pixel distance in the historical point pair data with the first pixel distance in the first point pair data; otherwise, determine the first point pair data as the second point pair data; When the first pixel distance in the historical point pair data is smaller than the first pixel distance in the first point pair data, the historical point pair data is determined as the second point pair data; otherwise, the first point pair data is determined as the second point pair data.
2. The method for automatically connecting discontinuous edges in contour edge finding according to claim 1, characterized in that: The preprocessing of the detection image to obtain an edge binary image includes: Performing grayscale processing on the detection image to obtain a grayscale image; The edge of the grayscale image is extracted by using a canny edge detection algorithm to obtain an edge binary image.
3. The method for automatically connecting discontinuous edges in contour edge finding according to claim 1, characterized in that: The step of calculating the number of transitions of adjacent pixels in the eight neighborhoods of each pixel in the edge binary image and determining the pixel with two transitions as an endpoint comprises: Determine a pixel point with a pixel value of 255 in the edge binary image as an edge point; Analyze the pixel values of the adjacent pixels in the eight neighborhoods of the pixel in a clockwise manner. When the pixel values of the adjacent pixels are 0 and 255 respectively, it is recorded as one transition. The number of jumps of adjacent pixel points in the eight neighborhoods of the edge point is counted, and when the number of jumps is two, the edge point is determined as an endpoint.
4. The method for automatically connecting discontinuous edges in contour edge finding according to claim 1, characterized in that: The step of sequentially analyzing the endpoints in the endpoint point set and performing pairwise matching on the endpoints in the endpoint point set to obtain one or more sets of first point pair data includes: Calculating the first pixel distance between the first endpoint and each subsequent endpoint in the endpoint point set, and determining the subsequent endpoints whose first pixel distance is less than or equal to a preset distance threshold as the candidate endpoints; When the first pixel distance between the first endpoint and the subsequent endpoint is greater than a preset distance threshold, the calculation ends; Sort the endpoints to be selected in ascending order according to the first pixel distance; The candidate endpoint with the smallest first pixel distance is bound to the first endpoint to determine first point pair data corresponding to the first endpoint.
5. The method for automatically connecting discontinuous edges in contour edge finding according to claim 1, characterized in that: Also includes: When the subsequent endpoint of the historical point pair data is the same as the first endpoint of the second point pair data, the historical point pair data is unbound, and the first endpoint of the historical point pair data and the next subsequent endpoint are bound based on the ascending sort order of the first pixel distance.
6. The method for automatically connecting discontinuous edges in contour edge finding according to claim 1, characterized in that: The step of screening the one or more sets of second point pair data based on a preset distance threshold and whether the connection line is blocked, and filtering the second point pair data that meets the screening condition, includes: Calculate the pixel distance between the two endpoints of the second point pair in the data to obtain the second pixel distance; Filtering the data of the second point whose second pixel distance is greater than a preset distance threshold; Connect the two endpoints in the second point pair data to obtain a connecting line; The analysis is performed based on the connection line, and the data is filtered at the second point where the connection line is blocked.
7. The method for automatically connecting discontinuous edges in contour edge finding according to claim 6, characterized in that: The analyzing according to the connection line and filtering the data at the second point where the connection line is blocked includes: Obtaining pixel values of pixel points on the connecting line; When there is a pixel point with a pixel value of 255 on the connection line, it is determined that the connection line is blocked, and the data of the second point corresponding to the connection line is filtered; Otherwise, no processing is done.
8. The method for automatically connecting discontinuous edges in contour edge finding according to claim 1, characterized in that: The automatically connecting the connection lines of the remaining second point pair data includes: Adjust the pixel value of the pixel on the data connection line of the second point pair to 255.
Citation Information
Patent Citations
Image processing apparatus, image processing method, and computer-readable storage device
US20120076420A1
Image edge detection method, image processing device, and computer storage medium
WO2020051746A1