System and method for accelerating morphological operations on point clouds with start-stop encoding in machine vision systems

By using start-stop encoding to accelerate point cloud data processing, the data is converted into binary images and subjected to row and column operations. This solves the problem of high complexity in point cloud data processing in existing technologies and enables efficient point cloud morphological operations and feature extraction.

CN117314950BActive Publication Date: 2026-04-21SHANGHAI JIAOTONG UNIV
View PDF 6 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANGHAI JIAOTONG UNIV
Filing Date
2023-09-27
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing image processing algorithms for point cloud data are highly complex, especially since the second step of run-length encoding for acceleration is not adequately considered, resulting in computational efficiency failing to meet expectations.

Method used

A start-end encoding acceleration method is adopted. The point cloud data is converted into a binary image through the point cloud projection module. The start-end encoding module restores the pixel row and column coordinates. Dilation, erosion, and adjacency check are implemented in the travel operation module and the row and column operation module. Combined with the image morphology operation module, the point cloud morphology operation is accelerated.

Benefits of technology

It significantly reduces the complexity of point cloud morphological operations from O(mn) to O(3RARB), improves computational efficiency, and enables effective processing and feature extraction of point cloud data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117314950B_ABST
    Figure CN117314950B_ABST
Patent Text Reader

Abstract

This invention provides a system and method for accelerating point cloud morphological operations using start-end encoding in a machine vision system, comprising: a point cloud projection module: receiving point cloud data, converting it into a binary image and outputting it to a run-length encoding module, receiving the pixel coordinates of the binary image, and grouping the point cloud according to the pixel coordinates; a start-end encoding module: receiving the binary image from the point cloud projection module, traversing it, and restoring the corresponding pixel row and column coordinates in the binary image; a run-length operation module: receiving the start and end encodings of the run-length operation and outputting the operation results; a row and column operation module: receiving rows or columns in the start-end encoding format, calculating and outputting the row and column logic; and an image morphological operation module: receiving the start and end encoding data of the binary image output by the start-end encoding module, and performing image morphological operations by calling the run-length operation module and the row and column operation module. This invention solves the problem that point cloud data cannot be used for graphic operations and allows point clouds to be grouped according to pixel coordinates.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing, and more specifically, to a system and method for accelerating point cloud morphological operations using start-stop encoding in a machine vision system. Background Technology

[0002] Most run-length encoding algorithms are designed for binary images, and very few are suitable for point cloud data. The primary difference between this patent and other patents is that it accepts point clouds rather than images as the data format.

[0003] Patent applications CN201611262646.2 and CN201611018601.0 disclose a "Fast Region Expansion Algorithm and Device Based on Run-Length Encoding". The region expansion algorithms in these patents are similar to those in this case, both consisting of two steps: step one modifies the start and end run-length encoding to achieve intra-row and inter-column expansion, and step two uses a logical "OR" operation between rows and columns to achieve inter-row and inter-column expansion. However, the aforementioned patents only disclose accelerating step one with start and end run-length encoding, omitting the acceleration of step two, which is equally important for algorithm complexity. The patents acknowledge that without acceleration using start and end run-length encoding, the complexity of point-by-point calculation for m×n pixels is O(mn), while only with acceleration using start and end run-length encoding does the complexity decrease to O(3RARB). Simply relying on the disclosures of the aforementioned patents without addressing the acceleration issue in step two cannot achieve the claimed computational acceleration effect. This patent discloses a method for accelerating the second step of start and end encoding, which includes both the logical "OR" operation of two processes by comparing start and end encodings (see process "OR" operation submodule) and the logical "OR" operation of two rows or two columns by traversing all start and end encodings of the processes in the row and column (see row and column "OR" operation submodule), thus filling the gap in this aspect of the aforementioned patent.

[0004] Patent applications CN201611264813.7 and CN201611033311.3 disclose a "Fast Region Erosion Algorithm and Device Based on Run-Length Encoding". The region erosion algorithms in these patents are similar to those in this case, both consisting of two steps: step one modifies the run-length start and end encoding to achieve intra-row / column erosion, and step two uses a logical AND operation between rows and columns to achieve inter-row / column erosion. However, the aforementioned patents only disclose accelerating step one with start and end encoding, omitting the acceleration of step two, which is equally important for algorithm complexity. The patents acknowledge that without start and end encoding acceleration, the complexity of point-by-point computation for m×n pixels is O(mn), while only with start and end encoding acceleration does the computational complexity decrease to O(3RARB). Simply relying on the disclosures of the aforementioned patents without addressing the acceleration issue in step two cannot achieve the claimed computational acceleration effect. This patent discloses a method for accelerating the second step of start and end encoding, which includes both the logical AND operation of two runs by comparing start and end encodings (see the run AND operation submodule) and the logical AND operation of two rows or two columns by traversing all start and end encodings of the runs (see the row AND operation submodule), thus filling the gap in this aspect of the aforementioned patent. Summary of the Invention

[0005] To address the shortcomings of existing technologies, the purpose of this invention is to provide a system and method for accelerating point cloud morphological computation through start-stop encoding in a machine vision system.

[0006] According to the present invention, a start-end encoding acceleration point cloud morphological computing system in a machine vision system includes:

[0007] Point cloud projection module: Receives point cloud data, converts it into a binary image and outputs it to the run-length encoding module. It receives the pixel coordinates of the binary image and groups the point cloud according to the pixel coordinates for output.

[0008] Start and end encoding module: Receives the binary image from the point cloud projection module, traverses it, and restores the corresponding pixel row and column coordinates in the binary image;

[0009] Travel calculation module: Receives the start and end codes of the travel route and outputs the calculation result;

[0010] Row and column operation module: Accepts rows or columns with start and end encoding formats, calculates and outputs row and column logic;

[0011] Image morphology operation module: Receives the start and end encoded data of the binary image output by the start and end encoding module, and performs image morphology operations by calling the run-length operation module and the row and column operation module.

[0012] Preferably, in the point cloud projection module:

[0013] The system includes a point cloud input interface and a coordinate input interface. The point cloud input interface receives point cloud data sampled by a visual sensor, constructs a grid composed of rectangular units according to a set resolution, projects the point cloud data into the grid, and records the corresponding points of each rectangular unit. Based on a set threshold, rectangular units with more than a threshold of corresponding points are designated as black pixels, and rectangular units with fewer than a threshold of corresponding points are designated as white pixels. The grid is then converted into a binary image and output to the run-length encoding module. The coordinate input interface receives the pixel coordinates of the binary image, finds the corresponding points of the rectangular units within the grid, and groups and outputs the point cloud according to the pixel coordinates.

[0014] In the start and end encoding module:

[0015] The start-end encoding module includes a start-end encoding interface and an inverse encoding interface. The start-end encoding interface receives a binary image from the point cloud projection module, and traverses by row or column according to the selection. It takes a row or column of consecutive black pixels as a journey, records the start position s and end position e of each journey, and converts the binary image into a data pair composed of s and e row by row or column by column. The inverse encoding interface receives the row start-end encoding data pair and restores it to the corresponding pixel row and column coordinates in the binary image.

[0016] Preferably, in the travel calculation module:

[0017] The travel calculation module receives the start and end codes of the travel and outputs the calculation results, including dilation, erosion, 4-adjacency check, 8-adjacency check, logical OR and logical AND operations.

[0018] The stroke expansion submodule accepts the stroke start and end code data pair s, e and the width value w, takes sw as the start position and e+w as the end position, and outputs the expanded stroke start and end code.

[0019] The stroke erosion submodule accepts the stroke start and end code data pair s, e and the width value w, compares the values ​​of s+w and ew, and outputs the stroke start and end code with s+w as the start and ew as the end when s+w is not greater than ew; otherwise, it outputs an empty stroke.

[0020] The 4-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 4-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment:

[0021] Step X1: Compare s1 and s2. If s1 >= s2, proceed to step X2; otherwise, proceed to step X3.

[0022] Step X2: Compare s1 and e2. If s1 <= e2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0023] Step X3: Compare e1 and s2. If e1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0024] The 8-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 8-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment:

[0025] Step Y1: Compare s1 and s2-1. If s1 >= s2-1, proceed to step Y2; otherwise, proceed to step Y3.

[0026] Step Y2: Compare s1 and e2+1. If s1<=e2+1, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0027] Step Y3: Compare e1+1 and s2. If e1+1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0028] The process and operation submodule receives the start and end codes of two processes, outputs the union of the two processes, calls the 4-adjacency check submodule, and if the 4-adjacency check passes, outputs a new start and end code consisting of the larger start number and the smaller end code; otherwise, it throws an error warning.

[0029] The process or operation submodule receives the start and end codes of two processes, outputs the intersection result of the two processes, calls the 8-adjacency check submodule, and if the 8-adjacency check passes, outputs a new start and end code consisting of the smaller start number and the larger end code; otherwise, it throws an error warning.

[0030] Preferably, in the row and column operation module:

[0031] The row and column operation module accepts rows or columns with start and end encoding formats, calculates and outputs row and column logical OR operations, row and column logical AND operations, row and column logical NOT operations, row and column expansion operations, and row and column erosion operations.

[0032] The row / column or operation submodule takes two rows or two columns in start-end encoding format as input and outputs the union of the start-end encoding format. It sorts the start-end encodings in the two rows or columns in ascending order, denoted as A1 and A2. It sets three Boolean flags, BoolA1, BoolA2, and BoolA3, and initializes them to "No". It sets an integer variable sA to record the start-end number of the journey and initializes it to 0. It prepares an empty set A3 of start-end encodings to store the operation results. The operation is completed according to the following pseudocode flow:

[0033] Step Z1: Compare the current values ​​of A1 and A2. If the current value of A1 is smaller, proceed to step Z2. If the current value of A2 is smaller, proceed to step Z8.

[0034] Step Z2: Invert BoolA1 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z3; otherwise, proceed to step Z5.

[0035] Step Z3: If BoolA3 is negative, then set sA equal to the current value of A1;

[0036] Step Z4: Set BoolA3 to Yes, then proceed to step Z7;

[0037] Step Z5: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A1;

[0038] Step Z6: Set Bool A3 to No;

[0039] Step Z7: If A1 iterates to the end, execute step Z14; otherwise, A1 takes the next value and returns to step Z1.

[0040] Step Z8: Invert BoolA2 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z9; otherwise, proceed to step Z11.

[0041] Step Z9: If BoolA3 is negative, then set sA equal to the current value of A2;

[0042] Step Z10: Set BoolA3 to Yes, then proceed to step Z13;

[0043] Step Z11: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A2;

[0044] Step Z12: Set Bool A3 to No;

[0045] Step Z13: If A2 iterates to the end, execute step Z14; otherwise, A2 takes the next value and returns to step Z1.

[0046] Step Z14: Add the remaining start and end codes from A1 or A2 to A3;

[0047] Step Z15: Output the result of a row-column logical OR operation on the processes contained in A3;

[0048] The row-column intersection submodule takes two rows or two columns in start-end encoding format as input and outputs the row-column intersection result of the start-end encoding format. It sorts the start-end codes contained in the two rows or columns in ascending order, denoted as B1 and B2. It sets three Boolean flags, BoolB1, BoolB2, and BoolB3, and initializes them to "No". It sets an integer variable sB to record the start-end number of the journey and initializes it to 0. It prepares an empty set B3 of start-end codes to store the operation result. The operation is completed according to the following pseudocode flow:

[0049] Step F1: Compare the current values ​​of B1 and B2. If the current value of B1 is smaller, proceed to step F2. If the current value of B2 is smaller, proceed to step F8.

[0050] Step F2: Invert BoolB1 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F3; otherwise, proceed to step F5.

[0051] Step F3: If BoolB3 is negative, then set sB equal to the current value of B1;

[0052] Step F4: Set BoolB3 to Yes, then proceed to step F7;

[0053] Step F5: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B1;

[0054] Step F6: Set BoolB3 to No;

[0055] Step F7: If B1 iterates to the end, execute step F14; otherwise, B1 takes the next value and returns to step F1.

[0056] Step F8: Invert BoolB2 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F9; otherwise, proceed to step F11.

[0057] Step F9: If BoolB3 is not true, then set sB equal to the current value of B2;

[0058] Step F10: Set BoolB3 to Yes, then proceed to step F13;

[0059] Step F11: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B2;

[0060] Step F12: Set BoolB3 to No;

[0061] Step F13: If B2 iterates to the end, execute step F14; otherwise, B2 takes the next value and returns to step F1.

[0062] Step F14: Add the remaining start and end codes from B1 or B2 to B3;

[0063] Step F15: Output the result of the row-column logical AND operation of the process contained in B3;

[0064] The row-column NOT operation submodule receives rows or columns with start and end encoding formats, outputs the row and column complement results of the start and end encoding formats, prepares an empty set C1 of start and end encodings, sorts the start and end encodings contained in the rows or columns in ascending order C2, checks whether the first value of C2 is 0, if it is 0, starts traversing from the second value of C2, otherwise inserts the value 0 at the beginning of C2 and starts traversing, takes two values ​​from C2 in each traversal, the first is denoted as sC, which is the end position of the previous traversal, and the second is denoted as eC, which is the start position of the next traversal, adds the traversal with sC as the start and eC as the end to C1 until C2 is traversed, and outputs the members contained in C1 as the result of the logical NOT operation;

[0065] The row and column expansion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the expansion operation, and outputs it according to the start and end encoding format. It traverses the routes contained in the row or column one by one, calls the route expansion submodule to expand them one by one and saves them to the temporary storage set D1. It traverses the routes in D1 in ascending or descending order, calls the 8-adjacency check submodule to perform 8-adjacency check on the previous route and the next route. Routes without adjacency are directly saved to the result set D2. Routes that are 8-adjacent to each other are ORed and saved to D2. The members contained in D2 are output as the row and column expansion calculation result.

[0066] The row and column erosion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the erosion operation, and outputs it according to the start and end encoding format. It iterates through the runs contained in the row or column one by one, calls the run erosion submodule to erode each run and saves it to the temporary set E, iterates through E to check the run length, discards runs with negative length, and outputs the members contained in E as the row and column erosion calculation result.

[0067] Preferably, in the image morphology operation module:

[0068] The image morphology operation module receives the start and end encoding data of the binary image output by the start and end encoding module. By calling the run-length operation module and the row and column operation module, it completes the image morphology operation and outputs the start and end encoding format results. The image morphology operation module works in conjunction with the point cloud projection module and the start and end encoding module to achieve the morphological operation effect of the point cloud.

[0069] The image dilation submodule accepts a binary image in start and end encoding format and a width value w, and implements an accelerated image dilation algorithm according to the following pseudocode:

[0070] A binary image F with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Fi;

[0071] Iterate through Fi, call the row and column expansion submodule to expand Fi by a width of w, record the expansion result as Gi, and store it in the set G;

[0072] Iterate through Gi, call the row and column OR operation submodule, calculate the logical OR operation result from Gi to Gi+w, denoted as Hi, and store it in set H;

[0073] The set H is used as the start and end encoding format for the dilated image output;

[0074] The image erosion submodule accepts a binary image with start and end encoding formats and a width value w, and implements an accelerated image erosion algorithm according to the following pseudocode:

[0075] A binary image I with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ii;

[0076] Iterate through Ii, call the row and column erosion submodule to perform an erosion operation of width w on Ii, record the erosion result as Ji, and store it in set J;

[0077] Iterate through Ji, call the row and column AND operation submodule, calculate the logical AND operation result from Ji to Ji+w, denoted as Ki, and store it in set K;

[0078] The set K is used as the output of the eroded image with the start and end encoding formats;

[0079] The image opening operation submodule accepts a binary image L with start and end encoding formats and a width value w, and implements the image opening operation according to the following pseudocode:

[0080] Input L and w into the image erosion submodule to obtain the result M;

[0081] Input M and w into the image dilation submodule to obtain the result N, and output N;

[0082] Users can remove outliers and smooth burrs in point clouds by calling the image opening operation submodule, thus achieving a smooth denoising effect.

[0083] The image closing operation submodule accepts a binary image O with start and end encoding formats and a width value w, and implements the image closing operation according to the following pseudocode:

[0084] Input O and w into the image dilation submodule to obtain the result P;

[0085] Input P and w into the image erosion submodule to obtain the result Q, and output Q;

[0086] Users can eliminate holes in point clouds by calling the image closing operation submodule, thus achieving the effect of smooth defect repair.

[0087] The image top-hat module accepts a binary image R with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0088] A binary image R with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ri;

[0089] Input R and w into the image opening operation submodule to obtain the result S composed of rows or columns, where the data in the i-th row or i-th column is denoted as Si;

[0090] Traverse Si, input row and column NOT operation submodules, the result is Ti, and store it in set T;

[0091] Iterate through Ri and Ti, input the row and column AND operation submodule, the result is Ui, and store it in set U;

[0092] Set U is used as the top-hat operation image output for the start and end encoding format;

[0093] Users can use the image top hat module to filter out small protrusions in the point cloud, achieving the effect of separating small targets from large background areas.

[0094] The image black hat module accepts a binary image V with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0095] A binary image V with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Vi;

[0096] Input V and w into the image closing operation submodule to obtain the result W composed of rows or columns, where the data in the i-th row or i-th column is denoted as Wi;

[0097] Traverse Vi, input row and column NOT operation submodules, the result is Xi, and store it in set X;

[0098] Iterate through Wi and Xi, input the row and column AND operation submodule, the result is Yi, and store it in set Y;

[0099] Set Y is used as the black hat computation image output for the start and end encoding formats;

[0100] Users can use the image black hat module to filter out small holes in the point cloud, thereby capturing pore features such as screw holes and gaps.

[0101] A method for accelerating point cloud morphological operations in a machine vision system according to the present invention includes:

[0102] Step M1: The point cloud projection module receives point cloud data, converts it into a binary image, and outputs it to the run-length encoding module. It receives the pixel coordinates of the binary image and groups the point cloud according to the pixel coordinates for output.

[0103] Step M2: The start and end encoding module receives the binary image from the point cloud projection module, traverses it, and restores the corresponding pixel row and column coordinates in the binary image;

[0104] Step M3: The travel calculation module receives the start and end codes of the travel and outputs the calculation results;

[0105] Step M4: The row and column operation module receives the row or column with the start and end encoding format, calculates and outputs the row and column logic;

[0106] Step M5: The image morphology operation module receives the start and end encoding data of the binary image output by the start and end encoding module, and completes the image morphology operation by calling the run-length operation module and the row and column operation module.

[0107] Preferably, in the point cloud projection module:

[0108] The system includes a point cloud input interface and a coordinate input interface. The point cloud input interface receives point cloud data sampled by a visual sensor, constructs a grid composed of rectangular units according to a set resolution, projects the point cloud data into the grid, and records the corresponding points of each rectangular unit. Based on a set threshold, rectangular units with more than a threshold of corresponding points are designated as black pixels, and rectangular units with fewer than a threshold of corresponding points are designated as white pixels. The grid is then converted into a binary image and output to the run-length encoding module. The coordinate input interface receives the pixel coordinates of the binary image, finds the corresponding points of the rectangular units within the grid, and groups and outputs the point cloud according to the pixel coordinates.

[0109] In the start and end encoding module:

[0110] The start-end encoding module includes a start-end encoding interface and an inverse encoding interface. The start-end encoding interface receives a binary image from the point cloud projection module, and traverses by row or column according to the selection. It takes a row or column of consecutive black pixels as a journey, records the start position s and end position e of each journey, and converts the binary image into a data pair composed of s and e row by row or column by column. The inverse encoding interface receives the row start-end encoding data pair and restores it to the corresponding pixel row and column coordinates in the binary image.

[0111] Preferably, in the travel calculation module:

[0112] The travel calculation module receives the start and end codes of the travel and outputs the calculation results, including dilation, erosion, 4-adjacency check, 8-adjacency check, logical OR and logical AND operations.

[0113] The stroke expansion submodule accepts the stroke start and end code data pair s, e and the width value w, takes sw as the start position and e+w as the end position, and outputs the expanded stroke start and end code.

[0114] The stroke erosion submodule accepts the stroke start and end code data pair s, e and the width value w, compares the values ​​of s+w and ew, and outputs the stroke start and end code with s+w as the start and ew as the end when s+w is not greater than ew; otherwise, it outputs an empty stroke.

[0115] The 4-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 4-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment:

[0116] Step X1: Compare s1 and s2. If s1 >= s2, proceed to step X2; otherwise, proceed to step X3.

[0117] Step X2: Compare s1 and e2. If s1 <= e2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0118] Step X3: Compare e1 and s2. If e1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0119] The 8-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 8-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment:

[0120] Step Y1: Compare s1 and s2-1. If s1 >= s2-1, proceed to step Y2; otherwise, proceed to step Y3.

[0121] Step Y2: Compare s1 and e2+1. If s1<=e2+1, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0122] Step Y3: Compare e1+1 and s2. If e1+1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0123] The process and operation submodule receives the start and end codes of two processes, outputs the union of the two processes, calls the 4-adjacency check submodule, and if the 4-adjacency check passes, outputs a new start and end code consisting of the larger start number and the smaller end code; otherwise, it throws an error warning.

[0124] The process or operation submodule receives the start and end codes of two processes, outputs the intersection result of the two processes, calls the 8-adjacency check submodule, and if the 8-adjacency check passes, outputs a new start and end code consisting of the smaller start number and the larger end code; otherwise, it throws an error warning.

[0125] Preferably, in the row and column operation module:

[0126] The row and column operation module accepts rows or columns with start and end encoding formats, calculates and outputs row and column logical OR operations, row and column logical AND operations, row and column logical NOT operations, row and column expansion operations, and row and column erosion operations.

[0127] The row / column or operation submodule takes two rows or two columns in start-end encoding format as input and outputs the union of the start-end encoding format. It sorts the start-end encodings in the two rows or columns in ascending order, denoted as A1 and A2. It sets three Boolean flags, BoolA1, BoolA2, and BoolA3, and initializes them to "No". It sets an integer variable sA to record the start-end number of the journey and initializes it to 0. It prepares an empty set A3 of start-end encodings to store the operation results. The operation is completed according to the following pseudocode flow:

[0128] Step Z1: Compare the current values ​​of A1 and A2. If the current value of A1 is smaller, proceed to step Z2. If the current value of A2 is smaller, proceed to step Z8.

[0129] Step Z2: Invert BoolA1 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z3; otherwise, proceed to step Z5.

[0130] Step Z3: If BoolA3 is negative, then set sA equal to the current value of A1;

[0131] Step Z4: Set BoolA3 to Yes, then proceed to step Z7;

[0132] Step Z5: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A1;

[0133] Step Z6: Set Bool A3 to No;

[0134] Step Z7: If A1 iterates to the end, execute step Z14; otherwise, A1 takes the next value and returns to step Z1.

[0135] Step Z8: Invert BoolA2 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z9; otherwise, proceed to step Z11.

[0136] Step Z9: If BoolA3 is negative, then set sA equal to the current value of A2;

[0137] Step Z10: Set BoolA3 to Yes, then proceed to step Z13;

[0138] Step Z11: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A2;

[0139] Step Z12: Set Bool A3 to No;

[0140] Step Z13: If A2 iterates to the end, execute step Z14; otherwise, A2 takes the next value and returns to step Z1.

[0141] Step Z14: Add the remaining start and end codes from A1 or A2 to A3;

[0142] Step Z15: Output the result of a row-column logical OR operation on the processes contained in A3;

[0143] The row-column intersection submodule takes two rows or two columns in start-end encoding format as input and outputs the row-column intersection result of the start-end encoding format. It sorts the start-end codes contained in the two rows or columns in ascending order, denoted as B1 and B2. It sets three Boolean flags, BoolB1, BoolB2, and BoolB3, and initializes them to "No". It sets an integer variable sB to record the start-end number of the journey and initializes it to 0. It prepares an empty set B3 of start-end codes to store the operation result. The operation is completed according to the following pseudocode flow:

[0144] Step F1: Compare the current values ​​of B1 and B2. If the current value of B1 is smaller, proceed to step F2. If the current value of B2 is smaller, proceed to step F8.

[0145] Step F2: Invert BoolB1 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F3; otherwise, proceed to step F5.

[0146] Step F3: If BoolB3 is negative, then set sB equal to the current value of B1;

[0147] Step F4: Set BoolB3 to Yes, then proceed to step F7;

[0148] Step F5: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B1;

[0149] Step F6: Set BoolB3 to No;

[0150] Step F7: If B1 iterates to the end, execute step F14; otherwise, B1 takes the next value and returns to step F1.

[0151] Step F8: Invert BoolB2 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F9; otherwise, proceed to step F11.

[0152] Step F9: If BoolB3 is not true, then set sB equal to the current value of B2;

[0153] Step F10: Set BoolB3 to Yes, then proceed to step F13;

[0154] Step F11: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B2;

[0155] Step F12: Set BoolB3 to No;

[0156] Step F13: If B2 iterates to the end, execute step F14; otherwise, B2 takes the next value and returns to step F1.

[0157] Step F14: Add the remaining start and end codes from B1 or B2 to B3;

[0158] Step F15: Output the result of the row-column logical AND operation of the process contained in B3;

[0159] The row-column NOT operation submodule receives rows or columns with start and end encoding formats, outputs the row and column complement results of the start and end encoding formats, prepares an empty set C1 of start and end encodings, sorts the start and end encodings contained in the rows or columns in ascending order C2, checks whether the first value of C2 is 0, if it is 0, starts traversing from the second value of C2, otherwise inserts the value 0 at the beginning of C2 and starts traversing, takes two values ​​from C2 in each traversal, the first is denoted as sC, which is the end position of the previous traversal, and the second is denoted as eC, which is the start position of the next traversal, adds the traversal with sC as the start and eC as the end to C1 until C2 is traversed, and outputs the members contained in C1 as the result of the logical NOT operation;

[0160] The row and column expansion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the expansion operation, and outputs it according to the start and end encoding format. It traverses the routes contained in the row or column one by one, calls the route expansion submodule to expand them one by one and saves them to the temporary storage set D1. It traverses the routes in D1 in ascending or descending order, calls the 8-adjacency check submodule to perform 8-adjacency check on the previous route and the next route. Routes without adjacency are directly saved to the result set D2. Routes that are 8-adjacent to each other are ORed and saved to D2. The members contained in D2 are output as the row and column expansion calculation result.

[0161] The row and column erosion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the erosion operation, and outputs it according to the start and end encoding format. It iterates through the runs contained in the row or column one by one, calls the run erosion submodule to erode each run and saves it to the temporary set E, iterates through E to check the run length, discards runs with negative length, and outputs the members contained in E as the row and column erosion calculation result.

[0162] Preferably, in the image morphology operation module:

[0163] The image morphology operation module receives the start and end encoding data of the binary image output by the start and end encoding module. By calling the run-length operation module and the row and column operation module, it completes the image morphology operation and outputs the start and end encoding format results. The image morphology operation module works in conjunction with the point cloud projection module and the start and end encoding module to achieve the morphological operation effect of the point cloud.

[0164] The image dilation submodule accepts a binary image in start and end encoding format and a width value w, and implements an accelerated image dilation algorithm according to the following pseudocode:

[0165] A binary image F with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Fi;

[0166] Iterate through Fi, call the row and column expansion submodule to expand Fi by a width of w, record the expansion result as Gi, and store it in the set G;

[0167] Iterate through Gi, call the row and column OR operation submodule, calculate the logical OR operation result from Gi to Gi+w, denoted as Hi, and store it in set H;

[0168] The set H is used as the start and end encoding format for the dilated image output;

[0169] The image erosion submodule accepts a binary image with start and end encoding formats and a width value w, and implements an accelerated image erosion algorithm according to the following pseudocode:

[0170] A binary image I with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ii;

[0171] Iterate through Ii, call the row and column erosion submodule to perform an erosion operation of width w on Ii, record the erosion result as Ji, and store it in set J;

[0172] Iterate through Ji, call the row and column AND operation submodule, calculate the logical AND operation result from Ji to Ji+w, denoted as Ki, and store it in set K;

[0173] The set K is used as the output of the eroded image with the start and end encoding formats;

[0174] The image opening operation submodule accepts a binary image L with start and end encoding formats and a width value w, and implements the image opening operation according to the following pseudocode:

[0175] Input L and w into the image erosion submodule to obtain the result M;

[0176] Input M and w into the image dilation submodule to obtain the result N, and output N;

[0177] Users can remove outliers and smooth burrs in point clouds by calling the image opening operation submodule, thus achieving a smooth denoising effect.

[0178] The image closing operation submodule accepts a binary image O with start and end encoding formats and a width value w, and implements the image closing operation according to the following pseudocode:

[0179] Input O and w into the image dilation submodule to obtain the result P;

[0180] Input P and w into the image erosion submodule to obtain the result Q, and output Q;

[0181] Users can eliminate holes in point clouds by calling the image closing operation submodule, thus achieving the effect of smooth defect repair.

[0182] The image top-hat module accepts a binary image R with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0183] A binary image R with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ri;

[0184] Input R and w into the image opening operation submodule to obtain the result S composed of rows or columns, where the data in the i-th row or i-th column is denoted as Si;

[0185] Traverse Si, input row and column NOT operation submodules, the result is Ti, and store it in set T;

[0186] Iterate through Ri and Ti, input the row and column AND operation submodule, the result is Ui, and store it in set U;

[0187] Set U is used as the top-hat operation image output for the start and end encoding format;

[0188] Users can use the image top hat module to filter out small protrusions in the point cloud, achieving the effect of separating small targets from large background areas.

[0189] The image black hat module accepts a binary image V with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0190] A binary image V with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Vi;

[0191] Input V and w into the image closing operation submodule to obtain the result W composed of rows or columns, where the data in the i-th row or i-th column is denoted as Wi;

[0192] Traverse Vi, input row and column NOT operation submodules, the result is Xi, and store it in set X;

[0193] Iterate through Wi and Xi, input the row and column AND operation submodule, the result is Yi, and store it in set Y;

[0194] Set Y is used as the black hat computation image output for the start and end encoding formats;

[0195] Users can use the image black hat module to filter out small holes in the point cloud, thereby capturing pore features such as screw holes and gaps.

[0196] Compared with the prior art, the present invention has the following beneficial effects:

[0197] 1. This invention solves the problem that point cloud data cannot be used for graphic calculations by projecting point clouds onto a grid composed of rectangular units, and can group point clouds according to pixel coordinates.

[0198] 2. This invention uses a run-length encoding method to convert consecutive pixels within a row and column into a start-end encoding format, which greatly compresses the amount of data stored in the image. The run-length calculation module solves the six basic morphological operation problems of the start-end encoding format, avoids the problem of pixel-by-pixel calculation, and achieves the effect of improving computational efficiency.

[0199] 3. The row and column operation module of this invention solves the problem of morphological operation of the entire row or column in the start and end encoding format, eliminating the need for 4-adjacency or 8-adjacency determination calculations between rows and columns involved in morphological operations in other methods, and further improving the calculation efficiency of the start and end encoding format.

[0200] 4. The image morphology module of this invention, together with the point cloud projection module and the start-end encoding module, solves the problem of morphological operations on disordered point clouds, and can achieve the effects of smoothing and denoising point clouds, smoothing and repairing defects, separating small targets from large backgrounds, and capturing pore features. Attached Figure Description

[0201] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0202] Figure 1 A schematic diagram of the run-length expansion operation to accelerate start and end encoding;

[0203] Figure 2 A schematic diagram of the run-length erosion operation to accelerate the start and end of encoding;

[0204] Figure 3 A schematic diagram of the 4-step adjacency check for accelerating the start and end of encoding;

[0205] Figure 4 A schematic diagram of the 8-step adjacency check for accelerating the start and end of encoding;

[0206] Figure 5 This is a schematic diagram of the AND operation in the process logic;

[0207] Figure 6 This is a schematic diagram of the OR operation in the process logic;

[0208] Figure 7 A diagram illustrating the row-column logical OR operation;

[0209] Figure 8 This is a diagram illustrating the AND operation between rows and columns.

[0210] Figure 9 This is a diagram illustrating the row and column logical NOT operation.

[0211] Figure 10 This is a diagram illustrating row and column expansion operations;

[0212] Figure 11 This is a schematic diagram of row and column erosion operations. Detailed Implementation

[0213] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the scope of protection of the present invention.

[0214] Example 1:

[0215] This invention discloses a method for point cloud morphological operations applicable to machine vision systems. This method uses mesh projection to classify and index point cloud data, thereby converting the point cloud into a binary image. It employs run-length encoding to implement an accelerated algorithm for morphological operations on the binary image, covering basic operations such as dilation, erosion, 4-adjacency, 8-adjacency, logical OR, AND, and NOT. Compared to conventional pixel-by-pixel morphological operation methods, this method significantly reduces both data volume and computational complexity.

[0216] According to the present invention, a method for accelerating point cloud morphological operations by start-end encoding in a machine vision system is provided, such as... Figures 1-11 As shown, it includes:

[0217] Step M1: The point cloud projection module receives point cloud data, converts it into a binary image, and outputs it to the run-length encoding module. It receives the pixel coordinates of the binary image and groups the point cloud according to the pixel coordinates for output.

[0218] Step M2: The start and end encoding module receives the binary image from the point cloud projection module, traverses it, and restores the corresponding pixel row and column coordinates in the binary image;

[0219] Step M3: The travel calculation module receives the start and end codes of the travel and outputs the calculation results;

[0220] Step M4: The row and column operation module receives the row or column with the start and end encoding format, calculates and outputs the row and column logic;

[0221] Step M5: The image morphology operation module receives the start and end encoding data of the binary image output by the start and end encoding module, and completes the image morphology operation by calling the run-length operation module and the row and column operation module.

[0222] Specifically, in the point cloud projection module:

[0223] The system includes a point cloud input interface and a coordinate input interface. The point cloud input interface receives point cloud data sampled by a visual sensor, constructs a grid composed of rectangular units according to a set resolution, projects the point cloud data into the grid, and records the corresponding points of each rectangular unit. Based on a set threshold, rectangular units with more than a threshold of corresponding points are designated as black pixels, and rectangular units with fewer than a threshold of corresponding points are designated as white pixels. The grid is then converted into a binary image and output to the run-length encoding module. The coordinate input interface receives the pixel coordinates of the binary image, finds the corresponding points of the rectangular units within the grid, and groups and outputs the point cloud according to the pixel coordinates.

[0224] In the start and end encoding module:

[0225] The start-end encoding module includes a start-end encoding interface and an inverse encoding interface. The start-end encoding interface receives a binary image from the point cloud projection module, and traverses by row or column according to the selection. It takes a row or column of consecutive black pixels as a journey, records the start position s and end position e of each journey, and converts the binary image into a data pair composed of s and e row by row or column by column. The inverse encoding interface receives the row start-end encoding data pair and restores it to the corresponding pixel row and column coordinates in the binary image.

[0226] Specifically, in the travel calculation module:

[0227] The travel calculation module receives the start and end codes of the travel and outputs the calculation results, including dilation, erosion, 4-adjacency check, 8-adjacency check, logical OR and logical AND operations.

[0228] The stroke expansion submodule accepts the stroke start and end code data pair s, e and the width value w, takes sw as the start position and e+w as the end position, and outputs the expanded stroke start and end code.

[0229] The stroke erosion submodule accepts the stroke start and end code data pair s, e and the width value w, compares the values ​​of s+w and ew, and outputs the stroke start and end code with s+w as the start and ew as the end when s+w is not greater than ew; otherwise, it outputs an empty stroke.

[0230] The 4-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 4-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment:

[0231] Step X1: Compare s1 and s2. If s1 >= s2, proceed to step X2; otherwise, proceed to step X3.

[0232] Step X2: Compare s1 and e2. If s1 <= e2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0233] Step X3: Compare e1 and s2. If e1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0234] The 8-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 8-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment:

[0235] Step Y1: Compare s1 and s2-1. If s1 >= s2-1, proceed to step Y2; otherwise, proceed to step Y3.

[0236] Step Y2: Compare s1 and e2+1. If s1<=e2+1, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0237] Step Y3: Compare e1+1 and s2. If e1+1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0238] The process and operation submodule receives the start and end codes of two processes, outputs the union of the two processes, calls the 4-adjacency check submodule, and if the 4-adjacency check passes, outputs a new start and end code consisting of the larger start number and the smaller end code; otherwise, it throws an error warning.

[0239] The process or operation submodule receives the start and end codes of two processes, outputs the intersection result of the two processes, calls the 8-adjacency check submodule, and if the 8-adjacency check passes, outputs a new start and end code consisting of the smaller start number and the larger end code; otherwise, it throws an error warning.

[0240] Specifically, in the row and column operation module:

[0241] The row and column operation module accepts rows or columns with start and end encoding formats, calculates and outputs row and column logical OR operations, row and column logical AND operations, row and column logical NOT operations, row and column expansion operations, and row and column erosion operations.

[0242] The row / column or operation submodule takes two rows or two columns in start-end encoding format as input and outputs the union of the start-end encoding format. It sorts the start-end encodings in the two rows or columns in ascending order, denoted as A1 and A2. It sets three Boolean flags, BoolA1, BoolA2, and BoolA3, and initializes them to "No". It sets an integer variable sA to record the start-end number of the journey and initializes it to 0. It prepares an empty set A3 of start-end encodings to store the operation results. The operation is completed according to the following pseudocode flow:

[0243] Step Z1: Compare the current values ​​of A1 and A2. If the current value of A1 is smaller, proceed to step Z2. If the current value of A2 is smaller, proceed to step Z8.

[0244] Step Z2: Invert BoolA1 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z3; otherwise, proceed to step Z5.

[0245] Step Z3: If BoolA3 is negative, then set sA equal to the current value of A1;

[0246] Step Z4: Set BoolA3 to Yes, then proceed to step Z7;

[0247] Step Z5: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A1;

[0248] Step Z6: Set Bool A3 to No;

[0249] Step Z7: If A1 iterates to the end, execute step Z14; otherwise, A1 takes the next value and returns to step Z1.

[0250] Step Z8: Invert BoolA2 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z9; otherwise, proceed to step Z11.

[0251] Step Z9: If BoolA3 is negative, then set sA equal to the current value of A2;

[0252] Step Z10: Set BoolA3 to Yes, then proceed to step Z13;

[0253] Step Z11: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A2;

[0254] Step Z12: Set Bool A3 to No;

[0255] Step Z13: If A2 iterates to the end, execute step Z14; otherwise, A2 takes the next value and returns to step Z1.

[0256] Step Z14: Add the remaining start and end codes from A1 or A2 to A3;

[0257] Step Z15: Output the result of a row-column logical OR operation on the processes contained in A3;

[0258] The row-column intersection submodule takes two rows or two columns in start-end encoding format as input and outputs the row-column intersection result of the start-end encoding format. It sorts the start-end codes contained in the two rows or columns in ascending order, denoted as B1 and B2. It sets three Boolean flags, BoolB1, BoolB2, and BoolB3, and initializes them to "No". It sets an integer variable sB to record the start-end number of the journey and initializes it to 0. It prepares an empty set B3 of start-end codes to store the operation result. The operation is completed according to the following pseudocode flow:

[0259] Step F1: Compare the current values ​​of B1 and B2. If the current value of B1 is smaller, proceed to step F2. If the current value of B2 is smaller, proceed to step F8.

[0260] Step F2: Invert BoolB1 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F3; otherwise, proceed to step F5.

[0261] Step F3: If BoolB3 is negative, then set sB equal to the current value of B1;

[0262] Step F4: Set BoolB3 to Yes, then proceed to step F7;

[0263] Step F5: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B1;

[0264] Step F6: Set BoolB3 to No;

[0265] Step F7: If B1 iterates to the end, execute step F14; otherwise, B1 takes the next value and returns to step F1.

[0266] Step F8: Invert BoolB2 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F9; otherwise, proceed to step F11.

[0267] Step F9: If BoolB3 is not true, then set sB equal to the current value of B2;

[0268] Step F10: Set BoolB3 to Yes, then proceed to step F13;

[0269] Step F11: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B2;

[0270] Step F12: Set BoolB3 to No;

[0271] Step F13: If B2 iterates to the end, execute step F14; otherwise, B2 takes the next value and returns to step F1.

[0272] Step F14: Add the remaining start and end codes from B1 or B2 to B3;

[0273] Step F15: Output the result of the row-column logical AND operation of the process contained in B3;

[0274] The row-column NOT operation submodule receives rows or columns with start and end encoding formats, outputs the row and column complement results of the start and end encoding formats, prepares an empty set C1 of start and end encodings, sorts the start and end encodings contained in the rows or columns in ascending order C2, checks whether the first value of C2 is 0, if it is 0, starts traversing from the second value of C2, otherwise inserts the value 0 at the beginning of C2 and starts traversing, takes two values ​​from C2 in each traversal, the first is denoted as sC, which is the end position of the previous traversal, and the second is denoted as eC, which is the start position of the next traversal, adds the traversal with sC as the start and eC as the end to C1 until C2 is traversed, and outputs the members contained in C1 as the result of the logical NOT operation;

[0275] The row and column expansion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the expansion operation, and outputs it according to the start and end encoding format. It traverses the routes contained in the row or column one by one, calls the route expansion submodule to expand them one by one and saves them to the temporary storage set D1. It traverses the routes in D1 in ascending or descending order, calls the 8-adjacency check submodule to perform 8-adjacency check on the previous route and the next route. Routes without adjacency are directly saved to the result set D2. Routes that are 8-adjacent to each other are ORed and saved to D2. The members contained in D2 are output as the row and column expansion calculation result.

[0276] The row and column erosion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the erosion operation, and outputs it according to the start and end encoding format. It iterates through the runs contained in the row or column one by one, calls the run erosion submodule to erode each run and saves it to the temporary set E, iterates through E to check the run length, discards runs with negative length, and outputs the members contained in E as the row and column erosion calculation result.

[0277] Specifically, in the image morphology operation module:

[0278] The image morphology operation module receives the start and end encoding data of the binary image output by the start and end encoding module. By calling the run-length operation module and the row and column operation module, it completes the image morphology operation and outputs the start and end encoding format results. The image morphology operation module works in conjunction with the point cloud projection module and the start and end encoding module to achieve the morphological operation effect of the point cloud.

[0279] The image dilation submodule accepts a binary image in start and end encoding format and a width value w, and implements an accelerated image dilation algorithm according to the following pseudocode:

[0280] A binary image F with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Fi;

[0281] Iterate through Fi, call the row and column expansion submodule to expand Fi by a width of w, record the expansion result as Gi, and store it in the set G;

[0282] Iterate through Gi, call the row and column OR operation submodule, calculate the logical OR operation result from Gi to Gi+w, denoted as Hi, and store it in set H;

[0283] The set H is used as the start and end encoding format for the dilated image output;

[0284] The image erosion submodule accepts a binary image with start and end encoding formats and a width value w, and implements an accelerated image erosion algorithm according to the following pseudocode:

[0285] A binary image I with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ii;

[0286] Iterate through Ii, call the row and column erosion submodule to perform an erosion operation of width w on Ii, record the erosion result as Ji, and store it in set J;

[0287] Iterate through Ji, call the row and column AND operation submodule, calculate the logical AND operation result from Ji to Ji+w, denoted as Ki, and store it in set K;

[0288] The set K is used as the output of the eroded image with the start and end encoding formats;

[0289] The image opening operation submodule accepts a binary image L with start and end encoding formats and a width value w, and implements the image opening operation according to the following pseudocode:

[0290] Input L and w into the image erosion submodule to obtain the result M;

[0291] Input M and w into the image dilation submodule to obtain the result N, and output N;

[0292] Users can remove outliers and smooth burrs in point clouds by calling the image opening operation submodule, thus achieving a smooth denoising effect.

[0293] The image closing operation submodule accepts a binary image O with start and end encoding formats and a width value w, and implements the image closing operation according to the following pseudocode:

[0294] Input O and w into the image dilation submodule to obtain the result P;

[0295] Input P and w into the image erosion submodule to obtain the result Q, and output Q;

[0296] Users can eliminate holes in point clouds by calling the image closing operation submodule, thus achieving the effect of smooth defect repair.

[0297] The image top-hat module accepts a binary image R with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0298] A binary image R with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ri;

[0299] Input R and w into the image opening operation submodule to obtain the result S composed of rows or columns, where the data in the i-th row or i-th column is denoted as Si;

[0300] Traverse Si, input row and column NOT operation submodules, the result is Ti, and store it in set T;

[0301] Iterate through Ri and Ti, input the row and column AND operation submodule, the result is Ui, and store it in set U;

[0302] Set U is used as the top-hat operation image output for the start and end encoding format;

[0303] Users can use the image top hat module to filter out small protrusions in the point cloud, achieving the effect of separating small targets from large background areas.

[0304] The image black hat module accepts a binary image V with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0305] A binary image V with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Vi;

[0306] Input V and w into the image closing operation submodule to obtain the result W composed of rows or columns, where the data in the i-th row or i-th column is denoted as Wi;

[0307] Traverse Vi, input row and column NOT operation submodules, the result is Xi, and store it in set X;

[0308] Iterate through Wi and Xi, input the row and column AND operation submodule, the result is Yi, and store it in set Y;

[0309] Set Y is used as the black hat computation image output for the start and end encoding formats;

[0310] Users can use the image black hat module to filter out small holes in the point cloud, thereby capturing pore features such as screw holes and gaps.

[0311] Example 2:

[0312] Example 2 is a preferred embodiment of Example 1, and is used to illustrate the present invention in more detail.

[0313] The present invention also provides a start-stop coding acceleration point cloud morphological operation system in a machine vision system. The start-stop coding acceleration point cloud morphological operation system in the machine vision system can be implemented by executing the process steps of the start-stop coding acceleration point cloud morphological operation method in the machine vision system. That is, those skilled in the art can understand the start-stop coding acceleration point cloud morphological operation method in the machine vision system as a preferred embodiment of the start-stop coding acceleration point cloud morphological operation system in the machine vision system.

[0314] According to the present invention, a start-end encoding acceleration point cloud morphological computing system in a machine vision system includes:

[0315] Point cloud projection module: Receives point cloud data, converts it into a binary image and outputs it to the run-length encoding module. It receives the pixel coordinates of the binary image and groups the point cloud according to the pixel coordinates for output.

[0316] Specifically, in the point cloud projection module:

[0317] The system includes a point cloud input interface and a coordinate input interface. The point cloud input interface receives point cloud data sampled by a visual sensor, constructs a grid composed of rectangular units according to a set resolution, projects the point cloud data into the grid, and records the corresponding points of each rectangular unit. Based on a set threshold, rectangular units with more than a threshold of corresponding points are designated as black pixels, and rectangular units with fewer than a threshold of corresponding points are designated as white pixels. The grid is then converted into a binary image and output to the run-length encoding module. The coordinate input interface receives the pixel coordinates of the binary image, finds the corresponding points of the rectangular units within the grid, and groups and outputs the point cloud according to the pixel coordinates.

[0318] Start and end encoding module: Receives the binary image from the point cloud projection module, traverses it, and restores the corresponding pixel row and column coordinates in the binary image;

[0319] In the start and end encoding module:

[0320] The start-end encoding module includes a start-end encoding interface and an inverse encoding interface. The start-end encoding interface receives a binary image from the point cloud projection module, and traverses by row or column according to the selection. It takes a row or column of consecutive black pixels as a journey, records the start position s and end position e of each journey, and converts the binary image into a data pair composed of s and e row by row or column by column. The inverse encoding interface receives the row start-end encoding data pair and restores it to the corresponding pixel row and column coordinates in the binary image.

[0321] Travel calculation module: Receives the start and end codes of the travel route and outputs the calculation result;

[0322] Specifically, in the travel calculation module:

[0323] The travel calculation module receives the start and end codes of the travel and outputs the calculation results, including dilation, erosion, 4-adjacency check, 8-adjacency check, logical OR and logical AND operations.

[0324] The stroke expansion submodule accepts the stroke start and end code data pair s, e and the width value w, takes sw as the start position and e+w as the end position, and outputs the expanded stroke start and end code.

[0325] The stroke erosion submodule accepts the stroke start and end code data pair s, e and the width value w, compares the values ​​of s+w and ew, and outputs the stroke start and end code with s+w as the start and ew as the end when s+w is not greater than ew; otherwise, it outputs an empty stroke.

[0326] The 4-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 4-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment:

[0327] Step X1: Compare s1 and s2. If s1 >= s2, proceed to step X2; otherwise, proceed to step X3.

[0328] Step X2: Compare s1 and e2. If s1 <= e2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0329] Step X3: Compare e1 and s2. If e1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0330] The 8-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 8-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment:

[0331] Step Y1: Compare s1 and s2-1. If s1 >= s2-1, proceed to step Y2; otherwise, proceed to step Y3.

[0332] Step Y2: Compare s1 and e2+1. If s1<=e2+1, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0333] Step Y3: Compare e1+1 and s2. If e1+1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends.

[0334] The process and operation submodule receives the start and end codes of two processes, outputs the union of the two processes, calls the 4-adjacency check submodule, and if the 4-adjacency check passes, outputs a new start and end code consisting of the larger start number and the smaller end code; otherwise, it throws an error warning.

[0335] The process or operation submodule receives the start and end codes of two processes, outputs the intersection result of the two processes, calls the 8-adjacency check submodule, and if the 8-adjacency check passes, outputs a new start and end code consisting of the smaller start number and the larger end code; otherwise, it throws an error warning.

[0336] Row and column operation module: Accepts rows or columns with start and end encoding formats, calculates and outputs row and column logic;

[0337] Specifically, in the row and column operation module:

[0338] The row and column operation module accepts rows or columns with start and end encoding formats, calculates and outputs row and column logical OR operations, row and column logical AND operations, row and column logical NOT operations, row and column expansion operations, and row and column erosion operations.

[0339] The row / column or operation submodule takes two rows or two columns in start-end encoding format as input and outputs the union of the start-end encoding format. It sorts the start-end encodings in the two rows or columns in ascending order, denoted as A1 and A2. It sets three Boolean flags, BoolA1, BoolA2, and BoolA3, and initializes them to "No". It sets an integer variable sA to record the start-end number of the journey and initializes it to 0. It prepares an empty set A3 of start-end encodings to store the operation results. The operation is completed according to the following pseudocode flow:

[0340] Step Z1: Compare the current values ​​of A1 and A2. If the current value of A1 is smaller, proceed to step Z2. If the current value of A2 is smaller, proceed to step Z8.

[0341] Step Z2: Invert BoolA1 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z3; otherwise, proceed to step Z5.

[0342] Step Z3: If BoolA3 is negative, then set sA equal to the current value of A1;

[0343] Step Z4: Set BoolA3 to Yes, then proceed to step Z7;

[0344] Step Z5: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A1;

[0345] Step Z6: Set Bool A3 to No;

[0346] Step Z7: If A1 iterates to the end, execute step Z14; otherwise, A1 takes the next value and returns to step Z1.

[0347] Step Z8: Invert BoolA2 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z9; otherwise, proceed to step Z11.

[0348] Step Z9: If BoolA3 is negative, then set sA equal to the current value of A2;

[0349] Step Z10: Set BoolA3 to Yes, then proceed to step Z13;

[0350] Step Z11: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A2;

[0351] Step Z12: Set Bool A3 to No;

[0352] Step Z13: If A2 iterates to the end, execute step Z14; otherwise, A2 takes the next value and returns to step Z1.

[0353] Step Z14: Add the remaining start and end codes from A1 or A2 to A3;

[0354] Step Z15: Output the result of a row-column logical OR operation on the processes contained in A3;

[0355] The row-column intersection submodule takes two rows or two columns in start-end encoding format as input and outputs the row-column intersection result of the start-end encoding format. It sorts the start-end codes contained in the two rows or columns in ascending order, denoted as B1 and B2. It sets three Boolean flags, BoolB1, BoolB2, and BoolB3, and initializes them to "No". It sets an integer variable sB to record the start-end number of the journey and initializes it to 0. It prepares an empty set B3 of start-end codes to store the operation result. The operation is completed according to the following pseudocode flow:

[0356] Step F1: Compare the current values ​​of B1 and B2. If the current value of B1 is smaller, proceed to step F2. If the current value of B2 is smaller, proceed to step F8.

[0357] Step F2: Invert BoolB1 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F3; otherwise, proceed to step F5.

[0358] Step F3: If BoolB3 is negative, then set sB equal to the current value of B1;

[0359] Step F4: Set BoolB3 to Yes, then proceed to step F7;

[0360] Step F5: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B1;

[0361] Step F6: Set BoolB3 to No;

[0362] Step F7: If B1 iterates to the end, execute step F14; otherwise, B1 takes the next value and returns to step F1.

[0363] Step F8: Invert BoolB2 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F9; otherwise, proceed to step F11.

[0364] Step F9: If BoolB3 is not true, then set sB equal to the current value of B2;

[0365] Step F10: Set BoolB3 to Yes, then proceed to step F13;

[0366] Step F11: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B2;

[0367] Step F12: Set BoolB3 to No;

[0368] Step F13: If B2 iterates to the end, execute step F14; otherwise, B2 takes the next value and returns to step F1.

[0369] Step F14: Add the remaining start and end codes from B1 or B2 to B3;

[0370] Step F15: Output the result of the row-column logical AND operation of the process contained in B3;

[0371] The row-column NOT operation submodule receives rows or columns with start and end encoding formats, outputs the row and column complement results of the start and end encoding formats, prepares an empty set C1 of start and end encodings, sorts the start and end encodings contained in the rows or columns in ascending order C2, checks whether the first value of C2 is 0, if it is 0, starts traversing from the second value of C2, otherwise inserts the value 0 at the beginning of C2 and starts traversing, takes two values ​​from C2 in each traversal, the first is denoted as sC, which is the end position of the previous traversal, and the second is denoted as eC, which is the start position of the next traversal, adds the traversal with sC as the start and eC as the end to C1 until C2 is traversed, and outputs the members contained in C1 as the result of the logical NOT operation;

[0372] The row and column expansion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the expansion operation, and outputs it according to the start and end encoding format. It traverses the routes contained in the row or column one by one, calls the route expansion submodule to expand them one by one and saves them to the temporary storage set D1. It traverses the routes in D1 in ascending or descending order, calls the 8-adjacency check submodule to perform 8-adjacency check on the previous route and the next route. Routes without adjacency are directly saved to the result set D2. Routes that are 8-adjacent to each other are ORed and saved to D2. The members contained in D2 are output as the row and column expansion calculation result.

[0373] The row and column erosion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the erosion operation, and outputs it according to the start and end encoding format. It iterates through the runs contained in the row or column one by one, calls the run erosion submodule to erode each run and saves it to the temporary set E, iterates through E to check the run length, discards runs with negative length, and outputs the members contained in E as the row and column erosion calculation result.

[0374] Image morphology operation module: Receives the start and end encoded data of the binary image output by the start and end encoding module, and performs image morphology operations by calling the run-length operation module and the row and column operation module.

[0375] Specifically, in the image morphology operation module:

[0376] The image morphology operation module receives the start and end encoding data of the binary image output by the start and end encoding module. By calling the run-length operation module and the row and column operation module, it completes the image morphology operation and outputs the start and end encoding format results. The image morphology operation module works in conjunction with the point cloud projection module and the start and end encoding module to achieve the morphological operation effect of the point cloud.

[0377] The image dilation submodule accepts a binary image in start and end encoding format and a width value w, and implements an accelerated image dilation algorithm according to the following pseudocode:

[0378] A binary image F with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Fi;

[0379] Iterate through Fi, call the row and column expansion submodule to expand Fi by a width of w, record the expansion result as Gi, and store it in the set G;

[0380] Iterate through Gi, call the row and column OR operation submodule, calculate the logical OR operation result from Gi to Gi+w, denoted as Hi, and store it in set H;

[0381] The set H is used as the start and end encoding format for the dilated image output;

[0382] The image erosion submodule accepts a binary image with start and end encoding formats and a width value w, and implements an accelerated image erosion algorithm according to the following pseudocode:

[0383] A binary image I with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ii;

[0384] Iterate through Ii, call the row and column erosion submodule to perform an erosion operation of width w on Ii, record the erosion result as Ji, and store it in set J;

[0385] Iterate through Ji, call the row and column AND operation submodule, calculate the logical AND operation result from Ji to Ji+w, denoted as Ki, and store it in set K;

[0386] The set K is used as the output of the eroded image with the start and end encoding formats;

[0387] The image opening operation submodule accepts a binary image L with start and end encoding formats and a width value w, and implements the image opening operation according to the following pseudocode:

[0388] Input L and w into the image erosion submodule to obtain the result M;

[0389] Input M and w into the image dilation submodule to obtain the result N, and output N;

[0390] Users can remove outliers and smooth burrs in point clouds by calling the image opening operation submodule, thus achieving a smooth denoising effect.

[0391] The image closing operation submodule accepts a binary image O with start and end encoding formats and a width value w, and implements the image closing operation according to the following pseudocode:

[0392] Input O and w into the image dilation submodule to obtain the result P;

[0393] Input P and w into the image erosion submodule to obtain the result Q, and output Q;

[0394] Users can eliminate holes in point clouds by calling the image closing operation submodule, thus achieving the effect of smooth defect repair.

[0395] The image top-hat module accepts a binary image R with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0396] A binary image R with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ri;

[0397] Input R and w into the image opening operation submodule to obtain the result S composed of rows or columns, where the data in the i-th row or i-th column is denoted as Si;

[0398] Traverse Si, input row and column NOT operation submodules, the result is Ti, and store it in set T;

[0399] Iterate through Ri and Ti, input the row and column AND operation submodule, the result is Ui, and store it in set U;

[0400] Set U is used as the top-hat operation image output for the start and end encoding format;

[0401] Users can use the image top hat module to filter out small protrusions in the point cloud, achieving the effect of separating small targets from large background areas.

[0402] The image black hat module accepts a binary image V with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0403] A binary image V with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Vi;

[0404] Input V and w into the image closing operation submodule to obtain the result W composed of rows or columns, where the data in the i-th row or i-th column is denoted as Wi;

[0405] Traverse Vi, input row and column NOT operation submodules, the result is Xi, and store it in set X;

[0406] Iterate through Wi and Xi, input the row and column AND operation submodule, the result is Yi, and store it in set Y;

[0407] Set Y is used as the black hat computation image output for the start and end encoding formats;

[0408] Users can use the image black hat module to filter out small holes in the point cloud, thereby capturing pore features such as screw holes and gaps.

[0409] Example 3:

[0410] Example 3 is a preferred example of Example 1, and is used to illustrate the present invention in more detail.

[0411] A method for accelerating point cloud morphology calculations using start-end encoding includes:

[0412] The point cloud projection module includes a point cloud input interface and a coordinate input interface. The point cloud input interface receives point cloud data sampled by a vision sensor, constructs a grid composed of rectangular cells according to a user-defined resolution, projects the point cloud data onto the grid, and records the corresponding points of each rectangular cell. Based on a user-defined threshold, rectangular cells with more than a certain number of corresponding points are designated as black pixels, and those with fewer than the threshold are designated as white pixels. The grid is then converted into a binary image and output to the run-length encoding module. The coordinate input interface receives the pixel coordinates of the binary image, finds the corresponding points of the rectangular cells within the grid, and groups the point cloud according to the pixel coordinates before outputting it.

[0413] The start-end encoding module includes a start-end encoding interface and a reverse encoding interface. The run-length encoding interface receives a binary image from the point cloud projection module, and then, based on the user's selection, traverses the image row-wise or column-wise, treating a row or column of consecutive black pixels as a run. It records the start position `s` and end position `e` for each run, and outputs the binary image row-wise or column-wise as data pairs consisting of `s` and `e`. The reverse encoding interface receives the row start-end encoded data pairs and restores them to the corresponding pixel row and column coordinates in the binary image.

[0414] The travel operation module receives the start and end codes of the travel sequence and outputs six operation results: expansion, erosion, 4-adjacency check, 8-adjacency check, logical OR, and logical AND. This module comprises six sub-modules: travel expansion sub-module, travel erosion sub-module, 4-adjacency check sub-module, 8-adjacency check sub-module, travel AND operation sub-module, and travel OR operation sub-module.

[0415] like Figure 1 As shown, the stroke expansion submodule accepts the stroke start and end code data pair (s and e) and the width value w, takes sw as the start position and e+w as the end position, and outputs the expanded stroke start and end code.

[0416] like Figure 2 As shown, the stroke erosion submodule accepts the stroke start and end code data pair (s and e) and the width value w, compares the values ​​of s+w and ew, and outputs the stroke start and end code with s+w as the start point and ew as the end point when s+w is not greater than ew; otherwise, it outputs an empty stroke.

[0417] The 4-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 4-adjacent. For example... Figure 3 As shown, this submodule records the start and end codes of trip one as s1 and e1, and the start and end codes of trip two as s2 and e2, and then executes the following pseudocode flow to complete the judgment:

[0418] 1. Compare s1 and s2. If s1 >= s2, proceed to step 2; otherwise, proceed to step 3.

[0419] 2. Compare s1 and e2. If s1 <= e2, the result is "Yes" and the process ends; otherwise, the result is "No" and the process ends.

[0420] 3. Compare e1 and s2. If e1>=s2, the result is "Yes" and the process ends; otherwise, the result is "No" and the process ends.

[0421] The 8-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 8-adjacent. For example... Figure 4 As shown, this submodule records the start and end codes of trip one as s1 and e1, and the start and end codes of trip two as s2 and e2, and then executes the following pseudocode flow to complete the judgment:

[0422] 1. Compare s1 and s2-1. If s1 >= s2-1, proceed to step 2; otherwise, proceed to step 3.

[0423] 2. Compare s1 and e2+1. If s1<=e2+1, the result is "Yes" and the process ends; otherwise, the result is "No" and the process ends.

[0424] 3. Compare e1+1 and s2. If e1+1>=s2, the result is "yes" and the process ends; otherwise, the result is "no" and the process ends.

[0425] like Figure 5 As shown, the process AND operation submodule receives the start and end codes of two processes and outputs the union of the two processes. This submodule first calls the 4-adjacency check submodule. If the 4-adjacency check passes, it outputs a new start and end code consisting of the larger start number and the smaller end code; otherwise, it throws an error warning.

[0426] like Figure 6 As shown, the trip OR operation submodule receives the start and end codes of two trips and outputs the intersection result of the two trips. This submodule calls the 8-adjacency check submodule. If the 8-adjacency check passes, it outputs a new start and end code composed of the smaller start number and the larger end code; otherwise, it throws an error warning.

[0427] The row and column operation module accepts rows or columns with start and end encoding formats, calculates and outputs five results: row and column logical "OR", row and column logical "AND", row and column logical "NOT", row and column expansion, and row and column erosion. This module includes five sub-modules: row and column "OR", row and column "AND", row and column "NOT", row and column expansion, and row and column erosion.

[0428] The row-column OR operation submodule takes two rows or two columns in the start-end encoding format as input and outputs the row-column union result in the start-end encoding format, such as... Figure 7 As shown in the diagram. This module first sorts the start and end codes contained in the two rows or columns in ascending order (hereinafter referred to as A1 and A2), sets three Boolean flags BoolA1, BoolA2, and BoolA3, and initializes them to "No". It also sets an integer variable sA to record the start and end code numbers and initializes it to 0. An empty set A3 of start and end codes is prepared to store the calculation results. Then, the calculation is completed according to the following pseudocode flow:

[0429] 1. Compare the current values ​​of A1 and A2. If the current value of A1 is smaller, proceed to step 2. If the current value of A2 is smaller, proceed to step 8.

[0430] 2. Invert BoolA1 and calculate the logical OR of BoolA1 with BoolA2. If the result is "yes", proceed to step 3; if the result is "no", proceed to step 5.

[0431] 3. If BoolA3 is "No", then set sA equal to the current value of A1;

[0432] 4. Set BoolA3 to "Yes" and proceed to step 7;

[0433] 5. If BoolA3 is "Yes", then add a journey to A3 starting from sA and ending at the current value of A1;

[0434] 6. Set Bool A3 to "No";

[0435] 7. If A1 iterates to the end, execute step 14; otherwise, A1 takes the next value and returns to step 1.

[0436] 8. Invert BoolA2 and calculate the logical OR of BoolA1 with BoolA2. If the result is "yes", proceed to step 9; if the result is "no", proceed to step 11.

[0437] 9. If BoolA3 is "No", then set sA equal to the current value of A2;

[0438] 10. Set BoolA3 to "Yes" and proceed to step 13;

[0439] 11. If BoolA3 is "Yes", then add a journey to A3 starting from sA and ending at the current value of A2;

[0440] 12. Set Bool A3 to "No";

[0441] 13. If A2 iterates to the end, proceed to step 14; otherwise, A2 takes the next value and returns to step 1.

[0442] 14. Add the remaining start and end codes from A1 or A2 to A3;

[0443] 15. Output the results of a row-column logical OR operation on the processes contained in A3.

[0444] The row-column AND operation submodule takes two rows or two columns in the start and end encoding format as input and outputs the row-column intersection result in the start and end encoding format, such as... Figure 8 As shown in the diagram. This module first sorts the start and end codes contained in the two rows or two columns in ascending order (hereinafter referred to as B1 and B2), sets three Boolean flags BoolB1, BoolB2, and BoolB3, and initializes them to "No". It also sets an integer variable sB to record the start-point number of the journey and initializes it to 0. An empty set B3 of start and end codes is prepared to store the calculation results. Then, the calculation is completed according to the following pseudocode flow:

[0445] 1. Compare the current values ​​of B1 and B2. If the current value of B1 is smaller, proceed to step 2; if the current value of B2 is smaller, proceed to step 8.

[0446] 2. Invert BoolB1 and calculate the result of the logical AND operation between BoolB1 and BoolB2. If the result is "yes", proceed to step 3; if the result is "no", proceed to step 5.

[0447] 3. If BoolB3 is "No", then set sB equal to the current value of B1;

[0448] 4. Set BoolB3 to "Yes" and proceed to step 7;

[0449] 5. If BoolB3 is "Yes", then add a journey to B3 starting from sB and ending at the current value of B1;

[0450] 6. Set BoolB3 to "No";

[0451] 7. If B1 iterates to the end, proceed to step 14; otherwise, B1 takes the next value and returns to step 1.

[0452] 8. Invert BoolB2 and calculate the logical AND of BoolB1 with BoolB2. If the result is "yes", proceed to step 9; if the result is "no", proceed to step 11.

[0453] 9. If BoolB3 is "No", then set sB to the current value of B2;

[0454] 10. Set BoolB3 to "Yes" and proceed to step 13;

[0455] 11. If BoolB3 is "Yes", then add a journey to B3 starting from sB and ending at the current value of B2;

[0456] 12. Set BoolB3 to "No";

[0457] 13. If B2 iterates to the end, proceed to step 14; otherwise, B2 takes the next value and returns to step 1.

[0458] 14. Add the remaining start and end codes from B1 or B2 to B3;

[0459] 15. Output the results of a row-column logical AND operation on the processes contained in B3.

[0460] The row and column NOT operation submodule receives the row or column in the start and end encoding format and outputs the row and column complement result in the start and end encoding format, such as... Figure 9 As shown. When this module runs, it first prepares an empty set C1 containing start and end codes. It then sorts the start and end codes contained in rows or columns in ascending order (hereinafter referred to as C2). Next, it checks if the first value of C2 is 0. If it is 0, it starts traversing from the second value in C2; otherwise, it inserts a 0 at the beginning of C2 and starts traversing. Each traversal takes two values ​​from C2, the first denoted as sC (the end position of the previous traversal) and the second as eC (the start position of the next traversal). A traversal starting at sC and ending at eC is added to C1 until C2 is completely traversed. Finally, the members contained in C1 are output as the result of a logical NOT operation.

[0461] The row and column expansion submodule receives the row or column in the start and end encoding format, as well as the width value w, calculates the result of the expansion operation, and outputs it according to the start and end encoding format, such as... Figure 10As shown, this module iterates through the rows or columns containing each trip, calling the trip expansion submodule to expand each trip and saving the results to a temporary set D1. Then, it iterates through the trips in D1 in ascending or descending order, calling the 8-adjacency check submodule to perform an 8-adjacency check on the previous and next trips. Trips without adjacency are directly saved to the result set D2, while trips that are 8-adjacent to each other are ORed and saved to D2. Finally, the members contained in D2 are output as the row and column expansion calculation results.

[0462] The row and column erosion submodule receives the row or column in the start and end encoding format, as well as the width value w, calculates the result of the erosion operation, and outputs it according to the start and end encoding format, such as... Figure 11 As shown, this module iterates through the runs contained in each row or column, calling the run erosion submodule to erode each run and saving the results to a temporary set E. Then, it iterates through E to check the run length, discarding runs with negative lengths. Finally, the members contained in E are output as the row and column erosion calculation results.

[0463] The image morphology operation module receives the start and end encoded data of the binary image from the start and end encoding module. By calling the run-length calculation module and the row and column calculation module, it performs six image morphology operations (dilation, erosion, opening, closing, top-hat, and black-hat) and outputs the results in the start and end encoded format. This module includes six sub-modules: image dilation, image erosion, image opening, image closing, image top-hat, and image black-hat. This module, used in conjunction with the point cloud projection module and the start and end encoding module, can achieve morphological operation effects on point clouds.

[0464] The image dilation submodule accepts a binary image in start and end encoding format and a width value w, and implements an accelerated image dilation algorithm according to the following pseudocode:

[0465] 1. A binary image F with start-end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Fi;

[0466] 2. Traverse Fi, call the row and column expansion submodule to expand Fi by a width of w, record the expansion result as Gi, and store it in the set G;

[0467] 3. Traverse Gi, call the row and column "OR" operation submodule, calculate the logical "OR" operation result from Gi to Gi+w, denoted as Hi, and store it in set H;

[0468] 4. Output the dilated image with set H as the start and end encoding format.

[0469] The image erosion submodule accepts a binary image with start and end encoding formats and a width value w, and implements an accelerated image erosion algorithm according to the following pseudocode:

[0470] 1. A binary image I with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ii;

[0471] 2. Traverse Ii, call the row and column erosion submodule to perform erosion operation on Ii with a width of w, record the erosion result as Ji, and store it in set J;

[0472] 3. Traverse Ji, call the row and column AND operation submodule, calculate the logical AND operation result from Ji to Ji+w, denoted as Ki, and store it in set K;

[0473] 4. Output the eroded image with set K as the start and end encoding format.

[0474] The image opening operation submodule accepts a binary image L with start and end encoding formats and a width value w, and implements the image opening operation according to the following pseudocode:

[0475] 1. Input L and w into the image erosion submodule to obtain the result M;

[0476] 2. Input M and w into the image dilation submodule to obtain the result N, and output N.

[0477] Users can remove outliers and smooth out spikes in point clouds by calling the image opening operation submodule, achieving a smooth denoising effect.

[0478] The image closing operation submodule accepts a binary image O with start and end encoding formats and a width value w, and implements the image closing operation according to the following pseudocode:

[0479] 1. Input O and w into the image dilation submodule to obtain the result P;

[0480] 2. Input P and w into the image erosion submodule to obtain the result Q, and output Q.

[0481] Users can eliminate holes in point clouds and achieve smooth defect repair by calling the image closing operation submodule.

[0482] The image top-hat module accepts a binary image R with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0483] 1. A binary image R with start and end encoding format consists of n rows or n columns, where the data in the i-th row or i-th column is denoted as Ri;

[0484] 2. Input R and w into the image opening operation submodule to obtain the result S composed of rows or columns, where the data in the i-th row or i-th column is denoted as Si;

[0485] 3. Traverse Si, input the row and column NOT operation submodule, the result is Ti, and store it in set T;

[0486] 4. Traverse Ri and Ti, input the row and column AND operation submodule, the result is Ui, and store it in set U;

[0487] 5. Output the top-hat operation image of set U as the start and end encoding format.

[0488] By calling the image top hat module, users can filter out small protrusions in the point cloud, achieving the effect of separating small targets from large background areas.

[0489] The image black hat module accepts a binary image V with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow:

[0490] 1. A binary image V with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Vi;

[0491] 2. Input V and w into the image closing operation submodule to obtain the result W composed of rows or columns, where the data in the i-th row or i-th column is denoted as Wi;

[0492] 3. Traverse Vi, input the row and column NOT operation submodule, the result is Xi, and store it in set X;

[0493] 4. Traverse Wi and Xi, input the row and column AND operation submodule, the result is Yi, and store it in set Y;

[0494] 5. Output the black hat computation image with set Y as the start and end encoding format.

[0495] By calling the image black hat module, users can filter out small holes in point clouds and capture pore features such as screw holes and gaps.

[0496] Those skilled in the art will understand that, besides implementing the system and its various devices, modules, and units provided by this invention in the form of purely computer-readable program code, the same functions can be achieved entirely through logical programming of the method steps, making the system and its various devices, modules, and units of this invention function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, the system and its various devices, modules, and units provided by this invention can be considered as a hardware component, and the devices, modules, and units included therein for implementing various functions can also be considered as structures within the hardware component; alternatively, the devices, modules, and units for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0497] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.

Claims

1. A start-end encoding acceleration point cloud morphological computation system in a machine vision system, characterized in that, include: Point cloud projection module: Receives point cloud data, converts it into a binary image and outputs it to the run-length encoding module. It receives the pixel coordinates of the binary image and groups the point cloud according to the pixel coordinates for output. Start and end encoding module: Receives the binary image from the point cloud projection module, traverses it, and restores the corresponding pixel row and column coordinates in the binary image; Travel calculation module: Receives the start and end codes of the travel route and outputs the calculation result; Row and column operation module: Receives rows or columns with start and end encoding formats, calculates and outputs row and column logic; Image morphology operation module: Receives the start and end encoded data of the binary image output by the start and end encoding module, and completes image morphology operations by calling the run-length operation module and the row and column operation module; In the travel calculation module: The travel calculation module receives the start and end codes of the travel and outputs the calculation results, including dilation, erosion, 4-adjacency check, 8-adjacency check, logical OR and logical AND operations. The stroke expansion submodule accepts the stroke start and end code data pair s, e and the width value w, takes sw as the start position and e+w as the end position, and outputs the expanded stroke start and end code. The stroke erosion submodule accepts the stroke start and end code data pair s, e and the width value w, compares the values ​​of s+w and ew, and outputs the stroke start and end code with s+w as the start and ew as the end when s+w is not greater than ew; otherwise, it outputs an empty stroke. The 4-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 4-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment: Step X1: Compare s1 and s2. If s1 >= s2, proceed to step X2; otherwise, proceed to step X3. Step X2: Compare s1 and e2. If s1 <= e2, the result is yes and the process ends; otherwise, the result is no and the process ends. Step X3: Compare e1 and s2. If e1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends. The 8-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 8-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment: Step Y1: Compare s1 and s2-1. If s1>=s2-1, proceed to step Y2; otherwise, proceed to step Y3. Step Y2: Compare s1 and e2+1. If s1<=e2+1, the result is yes and the process ends; otherwise, the result is no and the process ends. Step Y3: Compare e1+1 and s2. If e1+1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends. The process and operation submodule receives the start and end codes of two processes, outputs the union of the two processes, calls the 4-adjacency check submodule, and if the 4-adjacency check passes, outputs a new start and end code consisting of the larger start number and the smaller end code; otherwise, it throws an error warning. The process or operation submodule receives the start and end codes of two processes, outputs the intersection result of the two processes, calls the 8-adjacency check submodule, and if the 8-adjacency check passes, outputs a new start and end code consisting of the smaller start number and the larger end code; otherwise, it throws an error warning.

2. The start-stop encoding accelerated point cloud morphological operation system in the machine vision system according to claim 1, characterized in that: In the point cloud projection module: The system includes a point cloud input interface and a coordinate input interface. The point cloud input interface receives point cloud data sampled by a visual sensor, constructs a grid composed of rectangular units according to a set resolution, projects the point cloud data into the grid, and records the corresponding points of each rectangular unit. Based on a set threshold, rectangular units with more than a threshold of corresponding points are designated as black pixels, and rectangular units with fewer than a threshold of corresponding points are designated as white pixels. The grid is then converted into a binary image and output to the run-length encoding module. The coordinate input interface receives the pixel coordinates of the binary image, finds the corresponding points of the rectangular units within the grid, and groups and outputs the point cloud according to the pixel coordinates. In the start and end encoding module: The start-end encoding module includes a start-end encoding interface and an inverse encoding interface. The start-end encoding interface receives a binary image from the point cloud projection module, and traverses by row or column according to the selection. It takes a row or column of consecutive black pixels as a journey, records the start position s and end position e of each journey, and converts the binary image into a data pair composed of s and e row by row or column by column. The inverse encoding interface receives the row start-end encoding data pair and restores it to the corresponding pixel row and column coordinates in the binary image.

3. The start-stop encoding accelerated point cloud morphological operation system in the machine vision system according to claim 1, characterized in that, In the row and column operation module: The row and column operation module receives rows or columns with start and end encoding formats, calculates and outputs row and column logical OR operations, row and column logical AND operations, row and column logical NOT operations, row and column expansion, and row and column erosion. The row / column or operation submodule takes two rows or two columns in start-end encoding format as input and outputs the union of the start-end encoding format. It sorts the start-end encodings in the two rows or columns in ascending order, denoted as A1 and A2. It sets three Boolean flags, BoolA1, BoolA2, and BoolA3, and initializes them to "No". It sets an integer variable sA to record the start-end number of the journey and initializes it to 0. It prepares an empty set A3 of start-end encodings to store the operation results. The operation is completed according to the following pseudocode flow: Step Z1: Compare the current values ​​of A1 and A2. If the current value of A1 is smaller, proceed to step Z2. If the current value of A2 is smaller, proceed to step Z8. Step Z2: Invert BoolA1 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z3; otherwise, proceed to step Z5. Step Z3: If BoolA3 is negative, then set sA equal to the current value of A1; Step Z4: Set BoolA3 to Yes, then proceed to step Z7; Step Z5: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A1; Step Z6: Set Bool A3 to No; Step Z7: If A1 iterates to the end, execute step Z14; otherwise, A1 takes the next value and returns to step Z1. Step Z8: Invert BoolA2 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z9; otherwise, proceed to step Z11. Step Z9: If BoolA3 is negative, then set sA equal to the current value of A2; Step Z10: Set BoolA3 to Yes, then proceed to step Z13; Step Z11: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A2; Step Z12: Set BoolA3 to No; Step Z13: If A2 iterates to the end, execute step Z14; otherwise, A2 takes the next value and returns to step Z1. Step Z14: Add the remaining start and end codes from A1 or A2 to A3; Step Z15: Output the result of a row-column logical OR operation on the processes contained in A3; The row-column intersection submodule takes two rows or two columns in start-end encoding format as input and outputs the row-column intersection result of the start-end encoding format. It sorts the start-end codes contained in the two rows or columns in ascending order, denoted as B1 and B2. It sets three Boolean flags, BoolB1, BoolB2, and BoolB3, and initializes them to "No". It sets an integer variable sB to record the start-end number of the journey and initializes it to 0. It prepares an empty set B3 of start-end codes to store the operation result. The operation is completed according to the following pseudocode flow: Step F1: Compare the current values ​​of B1 and B2. If the current value of B1 is smaller, proceed to step F2. If the current value of B2 is smaller, proceed to step F8. Step F2: Invert BoolB1 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F3; otherwise, proceed to step F5. Step F3: If BoolB3 is negative, then set sB equal to the current value of B1; Step F4: Set BoolB3 to Yes, then proceed to step F7; Step F5: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B1; Step F6: Set BoolB3 to No; Step F7: If B1 iterates to the end, execute step F14; otherwise, B1 takes the next value and returns to step F1. Step F8: Invert BoolB2 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F9; otherwise, proceed to step F11. Step F9: If BoolB3 is not true, then set sB equal to the current value of B2; Step F10: Set BoolB3 to Yes, then proceed to step F13; Step F11: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B2; Step F12: Set BoolB3 to No; Step F13: If B2 iterates to the end, execute step F14; otherwise, B2 takes the next value and returns to step F1. Step F14: Add the remaining start and end codes from B1 or B2 to B3; Step F15: Output the result of the row-column logical AND operation of the process contained in B3; The row-column NOT operation submodule receives rows or columns with start and end encoding formats, outputs the row and column complement results of the start and end encoding formats, prepares an empty set C1 of start and end encodings, sorts the start and end encodings contained in the rows or columns in ascending order C2, checks whether the first value of C2 is 0, if it is 0, starts traversing from the second value of C2, otherwise inserts the value 0 at the beginning of C2 and starts traversing, takes two values ​​from C2 in each traversal, the first is denoted as sC, which is the end position of the previous traversal, and the second is denoted as eC, which is the start position of the next traversal, adds the traversal with sC as the start and eC as the end to C1 until C2 is traversed, and outputs the members contained in C1 as the result of the logical NOT operation; The row and column expansion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the expansion operation, and outputs it according to the start and end encoding format. It traverses the routes contained in the row or column one by one, calls the route expansion submodule to expand them one by one and saves them to the temporary storage set D1. It traverses the routes in D1 in ascending or descending order, calls the 8-adjacency check submodule to perform 8-adjacency check on the previous route and the next route. Routes without adjacency are directly saved to the result set D2. Routes that are 8-adjacent to each other are ORed and saved to D2. The members contained in D2 are output as the row and column expansion calculation result. The row and column erosion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the erosion operation, and outputs it according to the start and end encoding format. It iterates through the runs contained in the row or column one by one, calls the run erosion submodule to erode each run and saves it to the temporary set E, iterates through E to check the run length, discards runs with negative length, and outputs the members contained in E as the row and column erosion calculation result.

4. The start-stop encoding accelerated point cloud morphological operation system in the machine vision system according to claim 1, characterized in that, In the image morphology operation module: The image morphology operation module receives the start and end encoding data of the binary image output by the start and end encoding module. By calling the run-length operation module and the row and column operation module, it completes the image morphology operation and outputs the start and end encoding format results. The image morphology operation module works in conjunction with the point cloud projection module and the start and end encoding module to achieve the morphology operation effect of the point cloud. The image dilation submodule accepts a binary image in start and end encoding format and a width value w, and implements an accelerated image dilation algorithm according to the following pseudocode flow: A binary image F with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Fi; Iterate through Fi, call the row and column expansion submodule to expand Fi by a width of w, record the expansion result as Gi, and store it in the set G; Iterate through Gi, call the row and column OR operation submodule, calculate the logical OR operation result from Gi to Gi+w, denoted as Hi, and store it in set H; The set H is used as the start and end encoding format for the dilated image output; The image erosion submodule accepts a binary image with start and end encoding formats and a width value w, and implements an accelerated image erosion algorithm according to the following pseudocode flow: A binary image I with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ii; Iterate through Ii, call the row and column erosion submodule to perform an erosion operation of width w on Ii, record the erosion result as Ji, and store it in set J; Iterate through Ji, call the row and column AND operation submodule, calculate the logical AND operation result from Ji to Ji+w, denoted as Ki, and store it in set K; The set K is used as the output of the eroded image with the start and end encoding formats; The image opening operation submodule accepts a binary image L with start and end encoding formats and a width value w, and implements the image opening operation according to the following pseudocode flow: Input L and w into the image erosion submodule to obtain the result M; Input M and w into the image dilation submodule to obtain the result N, and output N; By calling the image opening operation submodule, outliers and smoothing spikes in the point cloud are removed, achieving a smooth denoising effect; The image closing operation submodule accepts a binary image O with start and end encoding formats and a width value w, and implements the image closing operation according to the following pseudocode flow: Input O and w into the image dilation submodule to obtain the result P; Input P and w into the image erosion submodule to obtain the result Q, and output Q; By calling the image closing operation submodule, holes in the point cloud are eliminated, achieving the effect of smooth defect repair; The image top-hat module accepts a binary image R with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow: A binary image R with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ri; Input R and w into the image opening operation submodule to obtain the result S composed of rows or columns, where the data in the i-th row or i-th column is denoted as Si; Traverse Si, input row and column NOT operation submodules, the result is Ti, and store it in set T; Iterate through Ri and Ti, input the row and column AND operation submodule, the result is Ui, and store it in set U; Set U is used as the top-hat operation image output for the start and end encoding format; By calling the image top hat module, small protrusions in the point cloud are filtered out, achieving the effect of separating small targets from large background areas; The image black hat module accepts a binary image V with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow: A binary image V with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Vi; Input V and w into the image closing operation submodule to obtain the result W composed of rows or columns, where the data in the i-th row or i-th column is denoted as Wi; Traverse Vi, input row and column NOT operation submodules, the result is Xi, and store it in set X; Iterate through Wi and Xi, input the row and column "AND" operation submodule, the result is Yi, and store it in set Y; Set Y is used as the black hat computation image output for the start and end encoding formats; By calling the image black hat module, small holes in the point cloud are filtered out to capture pore features.

5. A method for accelerating point cloud morphological operations using start-end encoding in a machine vision system, characterized in that, include: Step M1: The point cloud projection module receives point cloud data, converts it into a binary image, and outputs it to the run-length encoding module. It receives the pixel coordinates of the binary image and groups the point cloud according to the pixel coordinates for output. Step M2: The start and end encoding module receives the binary image from the point cloud projection module, traverses it, and restores the corresponding pixel row and column coordinates in the binary image; Step M3: The travel calculation module receives the start and end codes of the travel and outputs the calculation results; Step M4: The row and column operation module receives the row or column with the start and end encoding format, calculates and outputs the row and column logic; Step M5: The image morphology operation module receives the start and end encoding data of the binary image output by the start and end encoding module, and completes the image morphology operation by calling the run-length operation module and the row and column operation module; In the travel calculation module: The travel calculation module receives the start and end codes of the travel and outputs the calculation results, including dilation, erosion, 4-adjacency check, 8-adjacency check, logical OR and logical AND operations. The stroke expansion submodule accepts the stroke start and end code data pair s, e and the width value w, takes sw as the start position and e+w as the end position, and outputs the expanded stroke start and end code. The stroke erosion submodule accepts the stroke start and end code data pair s, e and the width value w, compares the values ​​of s+w and ew, and outputs the stroke start and end code with s+w as the start and ew as the end when s+w is not greater than ew; otherwise, it outputs an empty stroke. The 4-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 4-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment: Step X1: Compare s1 and s2. If s1 >= s2, proceed to step X2; otherwise, proceed to step X3. Step X2: Compare s1 and e2. If s1 <= e2, the result is yes and the process ends; otherwise, the result is no and the process ends. Step X3: Compare e1 and s2. If e1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends. The 8-adjacency check submodule accepts the start and end codes of two runs and outputs whether the pixels of the two runs are 8-adjacent. The start and end codes of run one are denoted as s1 and e1, and the start and end codes of run two are denoted as s2 and e2. The following pseudocode flow completes the judgment: Step Y1: Compare s1 and s2-1. If s1>=s2-1, proceed to step Y2; otherwise, proceed to step Y3. Step Y2: Compare s1 and e2+1. If s1<=e2+1, the result is yes and the process ends; otherwise, the result is no and the process ends. Step Y3: Compare e1+1 and s2. If e1+1>=s2, the result is yes and the process ends; otherwise, the result is no and the process ends. The process and operation submodule receives the start and end codes of two processes, outputs the union of the two processes, calls the 4-adjacency check submodule, and if the 4-adjacency check passes, outputs a new start and end code consisting of the larger start number and the smaller end code; otherwise, it throws an error warning. The process or operation submodule receives the start and end codes of two processes, outputs the intersection result of the two processes, calls the 8-adjacency check submodule, and if the 8-adjacency check passes, outputs a new start and end code consisting of the smaller start number and the larger end code; otherwise, it throws an error warning.

6. The method for accelerating point cloud morphological operations by start and stop encoding in a machine vision system according to claim 5, characterized in that: In the point cloud projection module: The system includes a point cloud input interface and a coordinate input interface. The point cloud input interface receives point cloud data sampled by a visual sensor, constructs a grid composed of rectangular units according to a set resolution, projects the point cloud data into the grid, and records the corresponding points of each rectangular unit. Based on a set threshold, rectangular units with more than a threshold of corresponding points are designated as black pixels, and rectangular units with fewer than a threshold of corresponding points are designated as white pixels. The grid is then converted into a binary image and output to the run-length encoding module. The coordinate input interface receives the pixel coordinates of the binary image, finds the corresponding points of the rectangular units within the grid, and groups and outputs the point cloud according to the pixel coordinates. In the start and end encoding module: The start-end encoding module includes a start-end encoding interface and an inverse encoding interface. The start-end encoding interface receives a binary image from the point cloud projection module, and traverses by row or column according to the selection. It takes a row or column of consecutive black pixels as a journey, records the start position s and end position e of each journey, and converts the binary image into a data pair composed of s and e row by row or column by column. The inverse encoding interface receives the row start-end encoding data pair and restores it to the corresponding pixel row and column coordinates in the binary image.

7. The method for accelerating point cloud morphological operations by start and stop encoding in a machine vision system according to claim 5, characterized in that: In the row and column operation module: The row and column operation module receives rows or columns with start and end encoding formats, calculates and outputs row and column logical OR operations, row and column logical AND operations, row and column logical NOT operations, row and column expansion, and row and column erosion. The row / column or operation submodule takes two rows or two columns in start-end encoding format as input and outputs the union of the start-end encoding format. It sorts the start-end encodings in the two rows or columns in ascending order, denoted as A1 and A2. It sets three Boolean flags, BoolA1, BoolA2, and BoolA3, and initializes them to "No". It sets an integer variable sA to record the start-end number of the journey and initializes it to 0. It prepares an empty set A3 of start-end encodings to store the operation results. The operation is completed according to the following pseudocode flow: Step Z1: Compare the current values ​​of A1 and A2. If the current value of A1 is smaller, proceed to step Z2. If the current value of A2 is smaller, proceed to step Z8. Step Z2: Invert BoolA1 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z3; otherwise, proceed to step Z5. Step Z3: If BoolA3 is negative, then set sA equal to the current value of A1; Step Z4: Set BoolA3 to Yes, then proceed to step Z7; Step Z5: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A1; Step Z6: Set Bool A3 to No; Step Z7: If A1 iterates to the end, execute step Z14; otherwise, A1 takes the next value and returns to step Z1. Step Z8: Invert BoolA2 and calculate the logical OR of BoolA1 and BoolA2. If yes, proceed to step Z9; otherwise, proceed to step Z11. Step Z9: If BoolA3 is negative, then set sA equal to the current value of A2; Step Z10: Set BoolA3 to Yes, then proceed to step Z13; Step Z11: If BoolA3 is yes, then add a journey to A3 starting from sA and ending at the current value of A2; Step Z12: Set BoolA3 to No; Step Z13: If A2 iterates to the end, execute step Z14; otherwise, A2 takes the next value and returns to step Z1. Step Z14: Add the remaining start and end codes from A1 or A2 to A3; Step Z15: Output the result of a row-column logical OR operation on the processes contained in A3; The row-column intersection submodule takes two rows or two columns in start-end encoding format as input and outputs the row-column intersection result of the start-end encoding format. It sorts the start-end codes contained in the two rows or columns in ascending order, denoted as B1 and B2. It sets three Boolean flags, BoolB1, BoolB2, and BoolB3, and initializes them to "No". It sets an integer variable sB to record the start-end number of the journey and initializes it to 0. It prepares an empty set B3 of start-end codes to store the operation result. The operation is completed according to the following pseudocode flow: Step F1: Compare the current values ​​of B1 and B2. If the current value of B1 is smaller, proceed to step F2. If the current value of B2 is smaller, proceed to step F8. Step F2: Invert BoolB1 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F3; otherwise, proceed to step F5. Step F3: If BoolB3 is negative, then set sB equal to the current value of B1; Step F4: Set BoolB3 to Yes, then proceed to step F7; Step F5: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B1; Step F6: Set BoolB3 to No; Step F7: If B1 iterates to the end, execute step F14; otherwise, B1 takes the next value and returns to step F1. Step F8: Invert BoolB2 and calculate the logical AND result of BoolB1 and BoolB2. If yes, proceed to step F9; otherwise, proceed to step F11. Step F9: If BoolB3 is not true, then set sB equal to the current value of B2; Step F10: Set BoolB3 to Yes, then proceed to step F13; Step F11: If BoolB3 is yes, then add a journey to B3 starting from sB and ending at the current value of B2; Step F12: Set BoolB3 to No; Step F13: If B2 iterates to the end, execute step F14; otherwise, B2 takes the next value and returns to step F1. Step F14: Add the remaining start and end codes from B1 or B2 to B3; Step F15: Output the result of the row-column logical AND operation of the process contained in B3; The row-column NOT operation submodule receives rows or columns with start and end encoding formats, outputs the row and column complement results of the start and end encoding formats, prepares an empty set C1 of start and end encodings, sorts the start and end encodings contained in the rows or columns in ascending order C2, checks whether the first value of C2 is 0, if it is 0, starts traversing from the second value of C2, otherwise inserts the value 0 at the beginning of C2 and starts traversing, takes two values ​​from C2 in each traversal, the first is denoted as sC, which is the end position of the previous traversal, and the second is denoted as eC, which is the start position of the next traversal, adds the traversal with sC as the start and eC as the end to C1 until C2 is traversed, and outputs the members contained in C1 as the result of the logical NOT operation; The row and column expansion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the expansion operation, and outputs it according to the start and end encoding format. It traverses the routes contained in the row or column one by one, calls the route expansion submodule to expand them one by one and saves them to the temporary storage set D1. It traverses the routes in D1 in ascending or descending order, calls the 8-adjacency check submodule to perform 8-adjacency check on the previous route and the next route. Routes without adjacency are directly saved to the result set D2. Routes that are 8-adjacent to each other are ORed and saved to D2. The members contained in D2 are output as the row and column expansion calculation result. The row and column erosion submodule receives the row or column with start and end encoding format and the width value w, calculates the result of the erosion operation, and outputs it according to the start and end encoding format. It iterates through the runs contained in the row or column one by one, calls the run erosion submodule to erode each run and saves it to the temporary set E, iterates through E to check the run length, discards runs with negative length, and outputs the members contained in E as the row and column erosion calculation result.

8. The method for accelerating point cloud morphological operations by start and stop encoding in a machine vision system according to claim 5, characterized in that: In the image morphology operation module: The image morphology operation module receives the start and end encoding data of the binary image output by the start and end encoding module. By calling the run-length operation module and the row and column operation module, it completes the image morphology operation and outputs the start and end encoding format results. The image morphology operation module works in conjunction with the point cloud projection module and the start and end encoding module to achieve the morphology operation effect of the point cloud. The image dilation submodule accepts a binary image in start and end encoding format and a width value w, and implements an accelerated image dilation algorithm according to the following pseudocode flow: A binary image F with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Fi; Iterate through Fi, call the row and column expansion submodule to expand Fi by a width of w, record the expansion result as Gi, and store it in the set G; Iterate through Gi, call the row and column OR operation submodule, calculate the logical OR operation result from Gi to Gi+w, denoted as Hi, and store it in set H; The set H is used as the start and end encoding format for the dilated image output; The image erosion submodule accepts a binary image with start and end encoding formats and a width value w, and implements an accelerated image erosion algorithm according to the following pseudocode flow: A binary image I with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ii; Iterate through Ii, call the row and column erosion submodule to perform an erosion operation of width w on Ii, record the erosion result as Ji, and store it in set J; Iterate through Ji, call the row and column AND operation submodule, calculate the logical AND operation result from Ji to Ji+w, denoted as Ki, and store it in set K; The set K is used as the output of the eroded image with the start and end encoding formats; The image opening operation submodule accepts a binary image L with start and end encoding formats and a width value w, and implements the image opening operation according to the following pseudocode flow: Input L and w into the image erosion submodule to obtain the result M; Input M and w into the image dilation submodule to obtain the result N, and output N; By calling the image opening operation submodule, outliers and smoothing spikes in the point cloud are removed, achieving a smooth denoising effect; The image closing operation submodule accepts a binary image O with start and end encoding formats and a width value w, and implements the image closing operation according to the following pseudocode flow: Input O and w into the image dilation submodule to obtain the result P; Input P and w into the image erosion submodule to obtain the result Q, and output Q; By calling the image closing operation submodule, holes in the point cloud are eliminated, achieving the effect of smooth defect repair; The image top-hat module accepts a binary image R with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow: A binary image R with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Ri; Input R and w into the image opening operation submodule to obtain the result S composed of rows or columns, where the data in the i-th row or i-th column is denoted as Si; Traverse Si, input row and column NOT operation submodules, the result is Ti, and store it in set T; Iterate through Ri and Ti, input the row and column AND operation submodule, the result is Ui, and store it in set U; Set U is used as the top-hat operation image output for the start and end encoding format; By calling the image top hat module, small protrusions in the point cloud are filtered out, achieving the effect of separating small targets from large background areas; The image black hat module accepts a binary image V with start and end encoding formats and a width value w, and performs calculations according to the following pseudocode flow: A binary image V with start and end encoding format consists of n rows or n columns, and the data in the i-th row or i-th column is denoted as Vi; Input V and w into the image closing operation submodule to obtain the result W composed of rows or columns, where the data in the i-th row or i-th column is denoted as Wi; Traverse Vi, input row and column NOT operation submodules, the result is Xi, and store it in set X; Iterate through Wi and Xi, input the row and column "AND" operation submodule, the result is Yi, and store it in set Y; Set Y is used as the black hat computation image output for the start and end encoding formats; By calling the image black hat module, small holes in the point cloud are filtered out to capture pore features.

Citation Information

Patent Citations

  • Rapid area erosion algorithm and device based on random structural element of run-length encoding

    CN106600655A

  • Rapid region expansion algorithm and device of any structure element based on stroke coding

    CN106709892A

  • Run-length encoding-based quick region expansion algorithm and apparatus

    CN106846424A

  • Fast region corrosion algorithm based on run length encoding and device

    CN106875453A

  • Obstacle detection method and device applied to automatic driving system, and storage medium

    CN110286387A