Image connected domain connection method and device

By determining and merging pixel labels row by row in image connected component processing, the inefficiency of existing technologies is solved, and efficient connected component connection is achieved.

CN115908473BActive Publication Date: 2026-01-02ZG TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211396444.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-09
Publication Date
2026-01-02
Estimated Expiration
2042-11-09

AI Technical Summary

Technical Problem

Existing technologies have low efficiency in processing connected components of images, resulting in significant delays in output.

Method used

The label number of the pixel to be processed is determined by the binary pixel value of the pixel to be processed in the binary image, the label number of the corresponding pixel in the previous row, and the label number of the pixel in the previous column of the current row. The label numbers are then merged and processed row by row to generate connected components.

Benefits of technology

It improves the efficiency of connected component connection, reduces latency, and achieves efficient image connected component processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115908473B_ABST
    Figure CN115908473B_ABST
Patent Text Reader

Abstract

The application provides an image connected domain connection method and device, and relates to the technical field of image processing. The method determines the label number of a to-be-processed pixel point according to the binary pixel value of the to-be-processed pixel point in a to-be-processed binary image, the label number of a pixel point at a corresponding position in the previous row of the to-be-processed pixel point and the label number of a pixel point in the previous column of the current row. The label numbers are merged according to the label number of the to-be-processed pixel point, the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point and the label number of the pixel point in the previous column of the current row. Multiple pixel points with the same label number are connected to generate multiple connected domains in the to-be-processed binary image. Thus, the label numbers of a row of pixel points can be processed by row-by-row processing, the label numbers of the previous row of pixel points are cached, and the label numbers of adjacent pixel points are merged, so that the pixel point label number assignment is efficiently completed, the efficiency of connecting connected domains is improved, and the delay time is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, in particular to an image connected domain connection method and device. BACKGROUND

[0002] The connected domain algorithm mainly processes and analyzes the binary image, and the pixel points adjacent to each other and having a binary value of "1" are attributed to the same connected domain, and the points not adjacent to each other are attributed to different connected domains. Through analyzing the pixel point number, coordinates and other information in the connected domain, the area and centroid of the connected domain and other characteristic values are finally obtained.

[0003] In the prior art, by scanning the image row by row, the pixels adjacent to each other and having a binary value of "1" in each row are grouped into a sequence called a cluster, and the starting point, the ending point and the row number thereof are recorded. Whether the current cluster has an overlapping area with all the clusters in the previous row is determined to assign a label to each cluster starting from 1; and the label of each cluster is filled into a label image. The clusters having the same label are a connected domain.

[0004] However, in the prior art, the final equivalent sequence can be obtained only after the image is completely scanned, so the result delay time based on the equivalent sequence merging is more than one frame of image, resulting in low efficiency and large delay of the final result output. SUMMARY

[0005] The present application provides an image connected domain connection method and device to solve the problems of low efficiency of image connected domain processing in the prior art.

[0006] To achieve the above object, the technical scheme adopted by the embodiments of the present application is as follows:

[0007] In a first aspect, the embodiments of the present application provide an image connected domain connection method, which comprises:

[0008] According to the binary pixel value of the to-be-processed pixel point in the to-be-processed binary image, the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point and the label number of the pixel point in the previous column of the current row, the label number of the to-be-processed pixel point is determined; wherein the corresponding position in the previous row of the to-be-processed pixel point comprises the pixel position in the previous column of the previous row of the to-be-processed pixel point, the pixel position in the previous row of the to-be-processed pixel point and the pixel position in the next column of the previous row of the to-be-processed pixel point;

[0009] According to the label number of the to-be-processed pixel point, the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point and the label number of the pixel point in the previous column of the current row, the label number is merged;

[0010] Connect multiple pixel points with same label number to generate multiple connected domains in the binary image to be processed.

[0011] Optionally, the label number of the pixel point to be processed is determined according to the binary pixel value of the pixel point to be processed, the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed, and the label number of the pixel point in the previous column of the current row.

[0012] If the binary pixel value of the pixel point to be processed is 0, the label number of the pixel point to be processed is determined as 0.

[0013] If the binary pixel value of the pixel point to be processed is 1, the label number of the pixel point to be processed is determined according to the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed and the label number of the pixel point in the previous column of the current row.

[0014] Optionally, if the binary pixel value of the pixel point to be processed is 1, the label number of the pixel point to be processed is determined according to the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed and the label number of the pixel point in the previous column of the current row.

[0015] If the binary pixel value of the pixel point to be processed is 1, and the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is not 0, the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is determined as the label number of the pixel point to be processed.

[0016] If the binary pixel value of the pixel point to be processed is 1, and the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is 0, the label number of the pixel point to be processed is determined according to the label number of the pixel point in the previous column of the current row.

[0017] Optionally, if the binary pixel value of the pixel point to be processed is 1, and the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is 0,

[0018] The label number of the pixel point to be processed is determined according to the label number of the pixel point in the previous column of the current row.

[0019] If the label number of the pixel point in the previous column of the current row is 0, the label number at the frontmost position in the label number buffer area is determined as the label number of the pixel point to be processed according to the label number arrangement order.

[0020] If the label number of the pixel point in the previous column of the current row is not 0, the label number of the pixel point in the previous column of the current row is determined as the label number of the pixel point to be processed.

[0021] Optionally, if the binarization pixel value of the pixel point to be processed is 1, and the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is not 0;

[0022] The method further includes:

[0023] If the label number of the pixel point in the previous column in the current row of the pixel point to be processed is 0, the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is determined as the label number of the pixel point to be processed.

[0024] If the label number of the pixel point in the previous column in the current row of the pixel point to be processed is not 0, the label number of the pixel point in the previous column in the current row of the pixel point to be processed is determined as the first reference label value of the pixel point to be processed, and the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is determined as the second reference label value of the pixel point to be processed.

[0025] Optionally, the label number merging is performed according to the label number of the pixel point to be processed, the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed, and the label number of the pixel point in the previous column in the current row of the pixel point to be processed, and includes:

[0026] The first reference label value and the second reference label value are compared.

[0027] If the first reference label value is greater than or equal to the second reference label value, the label number of the pixel point to be processed is kept unchanged.

[0028] If the first reference label value is less than the second reference label value, the label number of the pixel point to be processed is updated as the label number of the pixel point in the previous column in the current row of the pixel point to be processed.

[0029] Optionally, after the label number of the pixel point to be processed is updated as the label number of the pixel point in the previous column in the current row of the pixel point to be processed, the method further includes:

[0030] The label number of a pixel point to be merged and the label number of the pixel point in the previous column in the current row and the label number of the pixel point at the corresponding position in the next row of the pixel point to be merged are obtained, wherein the pixel point to be merged is a pixel point at a pixel position in the previous row of the pixel point to be processed, and the corresponding position in the next row of the pixel point to be merged includes a pixel position in the previous column in the next row, a pixel position in the next row, and a pixel position in the next column in the next row.

[0031] If the non-zero label number of the pixel point to be merged and the non-zero label numbers of the pixel point in the previous column of the current row and the pixel point in the corresponding position of the next row are all equal, no merging is performed.

[0032] If at least two of the non-zero label numbers are not equal among the non-zero label number of the pixel point to be merged and the non-zero label numbers of the pixel point in the previous column of the current row and the pixel point in the corresponding position of the next row, all the non-zero label numbers are merged into the smallest label number among them.

[0033] Optionally, before the step of connecting the multiple pixel points with the same label number to generate multiple connected domains in the binary image to be processed, the method further comprises:

[0034] reclaiming the label number without assignment after merging to the label number cache area;

[0035] sorting the reclaimed label number and the original label number in the label number cache area to form a new arrangement order of the label number.

[0036] Optionally, after the step of determining the label number of the pixel point to be processed according to the binary pixel value of the pixel point to be processed in the binary image to be processed, the label number of the pixel point in the corresponding position of the previous row and the label number of the pixel point in the previous column of the current row, the method further comprises:

[0037] writing the label numbers of all pixel points in the current row into a field programmable gate array (FPGA) internal buffer for reading out when determining the label number of the pixel point in the next row.

[0038] In a second aspect, an embodiment of the present application provides an image connected domain connection device, and the device comprises:

[0039] a determining module configured to determine the label number of the pixel point to be processed according to the binary pixel value of the pixel point to be processed in the binary image to be processed, the label number of the pixel point in the corresponding position of the previous row and the label number of the pixel point in the previous column of the current row, wherein the corresponding position of the previous row of the pixel point to be processed comprises a pixel position in the previous column of the previous row, a pixel position in the previous row and a pixel position in the next column of the previous row;

[0040] a merging module configured to perform label number merging according to the label number of the pixel point to be processed, the label number of the pixel point in the corresponding position of the previous row and the label number of the pixel point in the previous column of the current row;

[0041] A connecting module is configured to connect a plurality of pixel points with the same label number, and generate a plurality of connected domains in the to-be-processed binary image.

[0042] Compared with the prior art, the present application has the following beneficial effects:

[0043] The present application provides an image connected domain connecting method and device. The method determines the label number of a to-be-processed pixel point according to the binary pixel value of the to-be-processed pixel point in the to-be-processed binary image, the label number of a pixel point at a corresponding position in the previous row of the to-be-processed pixel point, and the label number of a pixel point in the previous column of the current row. The label number is merged according to the label number of the to-be-processed pixel point, the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point, and the label number of the pixel point in the previous column of the current row. A plurality of pixel points with the same label number are connected to generate a plurality of connected domains in the to-be-processed binary image. Thus, by processing a row of pixel points, the label number of the row of pixel points can be processed, the label number of the previous row of pixel points is cached, and the label numbers of adjacent pixel points are merged, so that the pixel point label number assignment is efficiently completed, the efficiency of connecting the connected domains is improved, and the delay time is reduced. BRIEF DESCRIPTION OF DRAWINGS

[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.

[0045] Figure 1 A binary image provided by the present application is shown in the figure;

[0046] Figure 2 A flowchart of an image connected domain connecting method provided by the present application is shown in the figure;

[0047] Figure 3 A flowchart of a method for determining the label number of a to-be-processed pixel point provided by the present application is shown in the figure;

[0048] Figure 4 A flowchart of another method for determining the label number of a to-be-processed pixel point provided by the present application is shown in the figure;

[0049] Figure 5 A flowchart of still another method for determining the label number of a to-be-processed pixel point provided by the present application is shown in the figure;

[0050] Figure 6 A flowchart of yet another method for determining the label number of a to-be-processed pixel point provided by the present application is shown in the figure;

[0051] Figure 7 A flowchart of a label number merging method provided in the present application is shown in the figure;

[0052] Figure 8 A flowchart of another label number merging method provided in the present application is shown in the figure;

[0053] Figure 9 A label number statistical merging instance diagram provided in the present application is shown in the figure;

[0054] Figure 10 A flowchart of a label number recycling method provided in the present application is shown in the figure;

[0055] Figure 11 A cache diagram based on an internal buffer of an FPGA provided in the present application is shown in the figure;

[0056] Figure 12 A cache diagram based on a dual-port RAM of an internal buffer of an FPGA provided in the present application is shown in the figure;

[0057] Figure 13 A schematic diagram of an image connected domain connecting device provided in an embodiment of the present application is shown in the figure;

[0058] Figure 14 A schematic diagram of an electronic device provided in an embodiment of the present application is shown in the figure.

[0059] Icon: 1301-determining module, 1302-merging module, 1303-connecting module, 1401-processor, 1402-storage medium. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. The components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.

[0061] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without making creative efforts are within the scope of protection of the present application.

[0062] It should be noted that: similar labels and letters represent similar items in the following drawings, therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0063] Furthermore, the terms "first" and "second" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.

[0064] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.

[0065] To improve the efficiency of image connected component processing, this application provides an image connected component connection method and apparatus.

[0066] Before explaining the image connected component connection method provided in this application, the image connected component will be explained. Figure 1 This is a schematic diagram of a binarized image provided in this application.

[0067] like Figure 1 As shown, the image comprises 25 pixels in 5 rows and 5 columns. For ease of understanding, the following labels are used as examples: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y. Each pixel has a corresponding row and column, and its position in the image can be determined based on its row and column.

[0068] by Figure 1 Taking the image shown as an example, let's explain connected components. If the binary pixel values ​​of the 25 pixels in the image are as follows: A = 0, B = 0, C = 1, D = 1, E = 1, F = 0, G = 0, H = 1, I = 1, J = 1, K = 0, L = 0, M = 0, N = 0, O = 0, P = 1, Q = 1, R = 0, S = 1, T = 1, U = 1, V = 1, W = 0, X = 1, Y = 1, then we can assign a label to the pixels with a binary pixel value of 1. For example, we assign a label of 1 to pixels C, D, E, H, I, and J, a label of 2 to pixels P, Q, U, and V, a label of 3 to pixels S, T, X, and Y, and assign a label of 0 to the other pixels (0 is considered an invalid label). As mentioned above, pixels with the same label number are connected. Therefore, connecting pixels with the same label number forms the connected component corresponding to that label number. A label of 0 is invalid, and no processing is performed on labels with a label number of 0. This process creates multiple connected components in a binary image.

[0069] The following specific examples illustrate the image connected component connection method provided in this application. Figure 2A flowchart of an image connected domain connection method provided in the present application is shown. The execution subject of the method is an electronic device, which can be a device with computing processing function, for example, a device embedded with FPGA (Field Programmable Gate Array). As shown in Figure 2 , the method comprises:

[0070] S101, determining the label number of the pixel point to be processed according to the binary pixel value of the pixel point to be processed in the binary image to be processed, the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed, and the label number of the pixel point in the previous column of the current row.

[0071] The corresponding position in the previous row of the pixel point to be processed includes the pixel position in the previous column of the previous row of the pixel point to be processed, the pixel position in the previous row of the pixel point to be processed, and the pixel position in the next column of the previous row of the pixel point to be processed. For example, as shown in Figure 1 , if the pixel point M is the pixel point to be processed, the pixel point L is the pixel point in the previous column of the current row of the pixel point to be processed, the pixel point G is the pixel position in the previous column of the previous row of the pixel point to be processed, the pixel point H is the pixel position in the previous row of the pixel point to be processed, and the pixel point I is the pixel position in the next column of the previous row of the pixel point to be processed.

[0072] It should be noted that the binary image to be processed can be obtained by processing an image, and the image becomes a binary image after binary processing. The binary pixel value of the pixel point on the binary image is only 0 or 1. By scanning the binary image to be processed from left to right and from top to bottom, the label number of each pixel point in each row of the binary image to be processed is assigned row by row. When processing row by row, the label number of a row of pixel points can be processed, and the label number of the previous row of pixel points can be cached.

[0073] When the pixel point (for example, pixel point A in Figure 1 ) in the first column of the first row of the binary image to be processed is the pixel point to be processed, the pixel point has no pixel point in the corresponding position in the previous row, and has no pixel point in the previous column of the current row. According to the binary pixel value of the pixel point, the label number of the pixel point to be processed is directly determined. For example, if the binary pixel value of the pixel point is 1, the label number at the frontmost position is determined as the label number of the pixel point to be processed according to the label number arrangement order in the label number cache area (the arrangement order is the positive integer label number arranged from small to large, and since it is the first assigned label number, the label number at the frontmost position is 1); if the binary pixel value of the pixel point is 0, the label number of the pixel point to be processed is assigned as 0 (0 is regarded as an invalid label).

[0074] In addition to the pixel point in the first row and the first column of the to-be-processed binary image, when other pixel points are taken as the to-be-processed pixel point, the to-be-processed pixel point has a pixel point in a corresponding position in a previous row and / or a pixel point in a previous column in the current row. Therefore, according to the binary pixel value of the to-be-processed pixel point, the label number of the pixel point in the corresponding position in the previous row of the to-be-processed pixel point, and the label number of the pixel point in the previous column in the current row, the label number of the to-be-processed pixel point is determined, so that the label numbers of adjacent pixel points with binary pixel values all being 1 are the same.

[0075] In addition to the pixel point in the first row and the first column of the to-be-processed binary image, when other pixel points are taken as the to-be-processed pixel point, the to-be-processed pixel point has a pixel point in a corresponding position in a previous row and / or a pixel point in a previous column in the current row. Therefore, according to the binary pixel value of the to-be-processed pixel point, the label number of the pixel point in the corresponding position in the previous row of the to-be-processed pixel point, and the label number of the pixel point in the previous column in the current row, the label number of the to-be-processed pixel point is determined, so that the label numbers of adjacent pixel points with binary pixel values all being 1 are the same.

[0076] S102, label number merging is performed according to the label number of the to-be-processed pixel point, the label number of the pixel point in the corresponding position in the previous row of the to-be-processed pixel point, and the label number of the pixel point in the previous column in the current row.

[0077] After the label number of the to-be-processed pixel point is determined, if the pixel point in the corresponding position in the previous row of the to-be-processed pixel point and / or the pixel point in the previous column in the current row also has a label number, it is necessary to check whether the label number of the to-be-processed pixel point, the label number of the pixel point in the corresponding position in the previous row of the to-be-processed pixel point, and the label number of the pixel point in the previous column in the current row are the same. If they are the same, the label number assignment is completed, and the label numbers of adjacent pixel points are all the same. If they are not the same, label number merging needs to be performed according to the label number of the to-be-processed pixel point, the label number of the pixel point in the corresponding position in the previous row of the to-be-processed pixel point, and the label number of the pixel point in the previous column in the current row, so as to merge the label numbers of adjacent pixel points into the same label number.

[0078] S103, multiple pixel points with the same label number are connected to generate multiple connected domains in the to-be-processed binary image.

[0079] After the label number assignment and merging of the pixel points in the to-be-processed binary image are performed row by row, the label numbers of adjacent pixel points in the to-be-processed binary image are all the same. The same label number indicates that the pixel points are adjacent, that is, multiple pixel points with the same non-0 label number are sequentially adjacent. Then, the multiple pixel points with the same non-0 label number are connected to generate multiple connected domains in the to-be-processed binary image.

[0080] By processing row by row, the label number of a row of pixels can be processed, while the label number of the previous row of pixels is cached, and the label numbers of adjacent pixels are merged. After the last row is processed, the delay time is no more than two rows of processing time, and the label numbers of all rows of pixels of the binary image to be processed can be obtained to efficiently complete the pixel label number assignment.

[0081] In summary, in the embodiment, the label number of the pixel to be processed is determined according to the binary pixel value of the pixel to be processed in the binary image to be processed, the label number of the pixel at the corresponding position in the previous row of the pixel to be processed, and the label number of the pixel in the previous column of the current row. The label numbers are merged according to the label number of the pixel to be processed, the label number of the pixel at the corresponding position in the previous row of the pixel to be processed, and the label number of the pixel in the previous column of the current row. Multiple pixels with the same label number are connected to generate multiple connected domains in the binary image to be processed. Thus, by processing row by row, the label number of a row of pixels can be processed, while the label number of the previous row of pixels is cached, and the label numbers of adjacent pixels are merged to efficiently complete the pixel label number assignment, improve the efficiency of connecting connected domains, and reduce the delay time.

[0082] In one embodiment, the application provides a method for determining the label number of a pixel to be processed. Figure 3 A flowchart of a method for determining the label number of a pixel to be processed provided by the application is shown in FIG. 1. As shown in FIG. 1, the determination of the label number of the pixel to be processed in S101 according to the binary pixel value of the pixel to be processed in the binary image to be processed, the label number of the pixel at the corresponding position in the previous row of the pixel to be processed, and the label number of the pixel in the previous column of the current row includes: Figure 3

[0083] S201, if the binary pixel value of the pixel to be processed is 0, the label number of the pixel to be processed is determined as 0.

[0084] When connecting connected domains in an image, only pixels with a binary pixel value of 1 are concerned. Therefore, if the binary pixel value of the pixel to be processed is 0, the label number of the pixel to be processed is determined as 0 (0 is an invalid label). When connecting pixels with the same label number to form connected domains, only pixels with the same non-0 label number are connected, and pixels with a label number of 0 are not connected.

[0085] S202, if the binary pixel value of the pixel to be processed is 1, the label number of the pixel to be processed is determined according to the label number of the pixel at the corresponding position in the previous row of the pixel to be processed and the label number of the pixel in the previous column of the current row.

[0086] If the binary pixel value of the pixel to be processed is 1, a non-0 label number (valid label) can be assigned to the pixel to be processed. ​

[0087] For example, when the pixel point A in the first row and the first column of the to-be-processed binary image (for example, the pixel point A in the first row and the first column of the binary image in FIG. 6) is the to-be-processed pixel point, the tag number of the to-be-processed pixel point is determined according to the tag number arrangement order in the tag number buffer area. In addition to the pixel point in the first row and the first column of the to-be-processed binary image, when other pixel points are to-be-processed pixel points, the tag number of the to-be-processed pixel point is determined according to the tag number of the pixel point in the corresponding position of the previous row of the to-be-processed pixel point and / or the tag number of the pixel point in the previous column of the current row. Figure 1

[0088] Therefore, in the embodiment, if the binary pixel value of the to-be-processed pixel point is 0, the tag number of the to-be-processed pixel point is determined to be 0; if the binary pixel value of the to-be-processed pixel point is 1, the tag number of the to-be-processed pixel point is determined according to the tag number of the pixel point in the corresponding position of the previous row of the to-be-processed pixel point and / or the tag number of the pixel point in the previous column of the current row. Thus, the binary pixel value of the to-be-processed pixel point is used to accurately distinguish the validity of the tag number of the to-be-processed pixel point.

[0089] In an embodiment, the application provides another method for determining the tag number of a to-be-processed pixel point. Figure 4 FIG. 7 is a flowchart of another method for determining the tag number of a to-be-processed pixel point provided by the application. As shown in FIG. 7, if the binary pixel value of the to-be-processed pixel point is 1, the tag number of the to-be-processed pixel point is determined according to the tag number of the pixel point in the corresponding position of the previous row of the to-be-processed pixel point and / or the tag number of the pixel point in the previous column of the current row, including the following steps. Figure 4

[0090] S301, if the binary pixel value of the to-be-processed pixel point is 1, and the tag number of the pixel point in the corresponding position of the previous row of the to-be-processed pixel point is not 0, the tag number of the pixel point in the corresponding position of the previous row of the to-be-processed pixel point is determined as the tag number of the to-be-processed pixel point.

[0091] In the determination of the tag number of the to-be-processed pixel point, the pixel point in the corresponding position of the previous row of the to-be-processed pixel point and the pixel point in the previous column of the current row are both adjacent pixel points of the to-be-processed pixel point, but the application determines the tag number according to the principle that the pixel point in the corresponding position of the previous row of the to-be-processed pixel point is preferred.

[0092] Therefore, the tag number of the pixel point in the corresponding position of the previous row of the to-be-processed pixel point is obtained first. If the binary pixel value of the to-be-processed pixel point is 1, it indicates that a non-0 tag number can be assigned to the to-be-processed pixel point. If the tag number of the pixel point in the corresponding position of the previous row of the to-be-processed pixel point is not 0, it indicates that the tag number is valid. Therefore, the tag number of the pixel point in the corresponding position of the previous row of the to-be-processed pixel point is directly determined as the tag number of the to-be-processed pixel point.

[0093] ​​From the above embodiment, the pixel point in the corresponding position of the last row includes three pixel points in different positions, and at least one of the three pixel points has a label number which is not 0, so that the label number can be determined as the label number of the pixel point to be processed.

[0094] For example, if the label number of the pixel point in the pixel position of the last row of the pixel point to be processed is 0, and the label numbers of the pixel points in the pixel position of the last row of the pixel point to be processed are different from each other, the label number of the pixel point in the pixel position of the last row of the pixel point to be processed is determined as the label number of the pixel point to be processed based on the left-to-right pixel processing principle of the present application. In this case, after the determination, the label number of the pixel point in the pixel position of the last row of the pixel point to be processed is different from the label number of the pixel point to be processed, which will be properly handled in the label number merging in the subsequent embodiment.

[0095] For example, taking the pixel point M as the pixel point to be processed, if the label number of the pixel point H is 0, and the label numbers of the pixel points G and I are different from each other. In this case, the label number of the pixel point G is determined as the label number of the pixel point to be processed. Figure 1

[0096] S302, if the binary pixel value of the pixel point to be processed is 1, and the label number of the pixel point in the corresponding position of the last row of the pixel point to be processed is 0, the label number of the pixel point to be processed is determined according to the label number of the pixel point in the last column of the current row of the pixel point to be processed.

[0097] If the binary pixel value of the pixel point to be processed is 1, it means that the pixel point to be processed can be assigned a non-0 label number. If the label number of the pixel point in the corresponding position of the last row of the pixel point to be processed is 0, it means that the label number is invalid. Therefore, the label number of the pixel point to be processed cannot be determined according to the label number of the pixel point in the corresponding position of the last row of the pixel point to be processed. Therefore, the label number of the pixel point to be processed needs to be further determined according to the label number of the pixel point in the last column of the current row of the pixel point to be processed.

[0098] In summary, in the present embodiment, if the binary pixel value of the pixel point to be processed is 1, and the label number of the pixel point in the corresponding position of the last row of the pixel point to be processed is non-0, the label number of the pixel point in the corresponding position of the last row of the pixel point to be processed is determined as the label number of the pixel point to be processed; if the binary pixel value of the pixel point to be processed is 1, and the label number of the pixel point in the corresponding position of the last row of the pixel point to be processed is 0, the label number of the pixel point to be processed is determined according to the label number of the pixel point in the last column of the current row of the pixel point to be processed. Therefore, the label number of the pixel point to be processed is first determined by the label number of the pixel point in the corresponding position of the last row of the pixel point to be processed, which improves the label number determination efficiency. ​

[0099] In an embodiment, the application provides a method for determining the label number of a pixel point to be processed. Figure 5 A flowchart of the method for determining the label number of a pixel point to be processed is provided in the application. As shown in the figure, if the binary pixel value of the pixel point to be processed is 1, and the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is 0. Figure 5

[0100] Correspondingly, the determination of the label number of the pixel point to be processed according to the label number of the pixel point in the previous column of the current row of the pixel point to be processed in S302 comprises:

[0101] S401, if the label number of the pixel point in the previous column of the current row of the pixel point to be processed is 0, the label number at the frontmost position in the label number buffer area is determined as the label number of the pixel point to be processed according to the label number arrangement order.

[0102] If the label number of the pixel point in the previous column of the current row of the pixel point to be processed is 0, it means that the label number is invalid. In this case, the label numbers of all the processed neighboring pixel points of the pixel point to be processed are invalid. The label number of the pixel point to be processed cannot be determined according to the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed and the label number of the pixel point in the previous column of the current row of the pixel point to be processed.

[0103] However, the binary pixel value of the pixel point to be processed is 1, and the pixel point to be processed needs to be assigned a non-0 label number. Therefore, the label number at the frontmost position in the label number buffer area is determined as the label number of the pixel point to be processed according to the label number arrangement order. The label number of the pixel point to be processed after the determination is a newly acquired label number from the label number buffer area, which is different from the label numbers of the processed pixel points in the binary image to be processed.

[0104] S402, if the label number of the pixel point in the previous column of the current row of the pixel point to be processed is not 0, the label number of the pixel point in the previous column of the current row of the pixel point to be processed is determined as the label number of the pixel point to be processed.

[0105] If the label number of the pixel point in the previous column of the current row of the pixel point to be processed is not 0, it means that the label number is valid. Therefore, the label number of the pixel point in the previous column of the current row of the pixel point to be processed is directly determined as the label number of the pixel point to be processed.

[0106] In summary, in the embodiment, if the label number of the pixel point in the previous column of the current row of the pixel point to be processed is 0, the label number at the frontmost position in the label number buffer area is determined as the label number of the pixel point to be processed according to the label number arrangement order. If the label number of the pixel point in the previous column of the current row of the pixel point to be processed is not 0, the label number of the pixel point in the previous column of the current row of the pixel point to be processed is determined as the label number of the pixel point to be processed. Therefore, by combining the label number of the pixel point in the previous column of the current row, the label number is accurately determined, and the label number determination efficiency is improved.​

[0107] In an embodiment, the application provides a further method for determining a label number of a pixel point to be processed. Figure 6 A flowchart of the further method for determining a label number of a pixel point to be processed is provided in the application. As shown in the figure, if the binarization pixel value of the pixel point to be processed is 1, and the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is not 0. Figure 6

[0108] Correspondingly, the determination of the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed in S301 is the label number of the pixel point to be processed, which includes:

[0109] S501, if the label number of the pixel point in the previous column of the current row of the pixel point to be processed is 0, then the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is determined as the label number of the pixel point to be processed.

[0110] On the basis of the principle of priority of the pixel point at the corresponding position in the previous row of the pixel point to be processed, after the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed has been determined as the label number of the pixel point to be processed, the label number of the pixel point in the previous column of the current row of the pixel point to be processed is also obtained, which can be further referenced for the label number of the pixel point to be processed.

[0111] If the label number of the pixel point in the previous column of the current row of the pixel point to be processed is 0, it indicates that the label number is invalid. The label number of the pixel point to be processed is continued to be kept as the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed.

[0112] S502, if the label number of the pixel point in the previous column of the current row of the pixel point to be processed is not 0, then the label number of the pixel point in the previous column of the current row of the pixel point to be processed is determined as a first reference label number of the pixel point to be processed, and the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed is determined as a second reference label number of the pixel point to be processed.

[0113] If the label number of the pixel point in the previous column of the current row of the pixel point to be processed is not 0, it indicates that the label number is valid. At this time, both the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed and the label number of the pixel point in the previous column of the current row of the pixel point to be processed are valid. According to the principle of priority of the pixel point at the corresponding position in the previous row of the pixel point to be processed, the label number of the pixel point to be processed is continued to be kept as the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed. In this case, there is a case where the label number of the pixel point in the previous column of the current row of the pixel point to be processed is different from the label number of the pixel point to be processed, which will be properly handled in the label number merging in the subsequent embodiments.

[0114] ​To facilitate subsequent merging and data reading, reference label values ​​are set. The label number of the pixel in the previous column of the current row of the pixel to be processed is determined as the first reference label value of the pixel to be processed, and the label number of the pixel in the corresponding position of the previous row of the pixel to be processed is determined as the second reference label value of the pixel to be processed.

[0115] In summary, in this embodiment, if the label number of the pixel in the previous column of the current row of the pixel to be processed is 0, then the label number of the pixel in the corresponding position of the previous row of the pixel to be processed is determined as the label number of the pixel to be processed; if the label number of the pixel in the previous column of the current row of the pixel to be processed is not 0, then the label number of the pixel in the previous column of the current row of the pixel to be processed is determined as the first reference label value of the pixel to be processed, and the label number of the pixel in the corresponding position of the previous row of the pixel to be processed is determined as the second reference label value of the pixel to be processed. Thus, by combining the label number of the pixel in the previous column of the current row, the label number is accurately determined, improving the efficiency of label number determination.

[0116] In one embodiment, this application provides a method for merging tag numbers. Figure 7 This is a flowchart illustrating a method for merging tag numbers provided in this application. Figure 7 As shown, S102, based on the label number of the pixel to be processed, the label number of the corresponding pixel in the row above the pixel to be processed, and the label number of the pixel in the previous column of the current row, the label number is merged, including:

[0117] S601. Compare the first reference label value and the second reference label value.

[0118] S602. If the first reference label value is greater than or equal to the second reference label value, then keep the label number of the pixel to be processed unchanged.

[0119] When merging pixel label numbers, based on the principle of taking the smallest value, if the label numbers of adjacent pixels are different, the label numbers of the adjacent pixels are all assigned the smallest label number.

[0120] If the first reference label value is greater than the second reference label value, then the label number of the pixel in the previous column of the current row of the pixel to be processed is greater than the label number of the corresponding pixel in the previous row of the pixel to be processed. The label number of the pixel to be processed at this point is determined based on the label number of the corresponding pixel in the previous row of the pixel to be processed, and is the same as its label number. If the label number of the pixel to be processed is smaller than the label number of the previous column of the current row of the pixel to be processed, then the label number of the pixel to be processed remains unchanged.

[0121] If the first reference label value is equal to the second reference label value, the label number of the pixel point in the previous column in the current row of the pixel point to be processed is equal to the label number of the pixel point in the corresponding position in the previous row of the pixel point to be processed. At this time, the label number of the pixel point to be processed is determined according to the label number of the pixel point in the corresponding position in the previous row of the pixel point to be processed, and is the same as the label number. The label number of the pixel point in the previous column in the current row of the pixel point to be processed is the same as the label number of the pixel point to be processed, and the label number of the pixel point to be processed is kept unchanged.

[0122] In S603, if the first reference label value is less than the second reference label value, the label number of the pixel point to be processed is updated to the label number of the pixel point in the previous column in the current row of the pixel point to be processed.

[0123] If the first reference label value is less than the second reference label value, the label number of the pixel point in the previous column in the current row of the pixel point to be processed is less than the label number of the pixel point in the corresponding position in the previous row of the pixel point to be processed. At this time, the label number of the pixel point to be processed is determined according to the label number of the pixel point in the corresponding position in the previous row of the pixel point to be processed, and is the same as the label number. Compared with the label number of the pixel point in the previous column in the current row of the pixel point to be processed, the label number of the pixel point to be processed is a large label number, and based on the principle of taking the smaller one, the label number of the pixel point to be processed is updated to the label number of the pixel point in the previous column in the current row of the pixel point to be processed.

[0124] The above steps can be regarded as label number merging in label number merging. In actual application, after label number merging, the label numbers of adjacent pixel points are consistent. If there is still a case that the label numbers of adjacent pixel points are inconsistent, it will be processed in subsequent embodiments.

[0125] In summary, in the embodiment, the first reference label value and the second reference label value are compared. If the first reference label value is greater than or equal to the second reference label value, the label number of the pixel point to be processed is kept unchanged. If the first reference label value is less than the second reference label value, the label number of the pixel point to be processed is updated to the label number of the pixel point in the previous column in the current row of the pixel point to be processed. Thus, after label number merging, the label number of the pixel point is determined more accurately.

[0126] In an embodiment, the present application provides another method for label number merging. Figure 8 A flowchart of another method for label number merging provided by the present application is shown in FIG. 6. As shown in FIG. 6, after the label number of the pixel point to be processed is updated to the label number of the pixel point in the previous column in the current row of the pixel point to be processed in S603, the method further includes: Figure 8

[0127] ​S701, acquire the label number of the pixel point to be merged and the label number of the pixel point in the previous column of the current row of the pixel point to be merged, and the label number of the pixel point in the corresponding position of the next row of the pixel point to be processed.

[0128] The pixel point to be merged is the pixel point in the pixel position of the previous row of the pixel point to be processed, and the corresponding positions in the next row of the pixel point to be merged include the pixel position in the previous column of the next row of the pixel point to be merged, the pixel position in the next row of the pixel point to be merged, and the pixel position in the next column of the next row of the pixel point to be merged. For example, as shown in FIG. 6, if the pixel point M is the pixel point to be processed, the pixel point H is the pixel point to be merged, at this time, the pixel point L is the pixel position in the previous column of the next row of the pixel point to be merged, the pixel point M is the pixel position in the next row of the pixel point to be merged, and the pixel point N is the pixel position in the next column of the next row of the pixel point to be merged. Figure 1

[0129] After the label number assignment and the sequential merging are completed, the label merging is completed from the perspective of the position of the pixel point to be processed. However, there are the following cases in which the label numbers of adjacent pixel points are inconsistent. For example, the label number of the pixel point to be processed is updated to the label number of the pixel point in the previous column of the current row of the pixel point to be processed, and the label number of the pixel point to be processed is inconsistent with the label number of the pixel point in the corresponding position of the previous row of the pixel point to be processed. For another example, the label number of the pixel point in the next column of the previous row of the pixel point to be processed is different from the label number of the pixel point to be processed, and in most cases, the label number of the pixel point to be processed is smaller than the label number of the pixel point in the corresponding position of the previous row of the pixel point to be processed.

[0130] Therefore, in order to keep the label numbers of adjacent pixel points consistent, the label numbers need to be merged again. At this time, the pixel point in the pixel position of the previous row of the pixel point to be processed is taken as the pixel point to be merged for merging processing. That is, after the processing of the pixel point to be processed is completed, the merging processing is immediately performed based on the pixel point to be merged, so as to improve the processing efficiency.

[0131] S702, if the non-0 label number of the pixel point to be merged, the non-0 label number of the pixel point in the previous column of the current row of the pixel point to be merged, and the non-0 label number of the pixel point in the corresponding position of the next row of the pixel point to be merged are all equal, no merging is performed.

[0132] If the non-0 label number of the pixel point to be merged, the non-0 label number of the pixel point in the previous column of the current row of the pixel point to be merged, and the non-0 label number of the pixel point in the corresponding position of the next row of the pixel point to be merged are all equal, the adjacent pixel points satisfy the same label number principle, and no merging is performed. The non-0 label number means that the label number is valid, and in this embodiment, the non-0 valid label number is merged, and the pixel point with the label number of 0 is not considered.

[0133] ​S703. If at least two non-zero label numbers are not equal among the non-zero label numbers of the pixel to be merged, the non-zero label numbers of the pixel in the previous column of the current row, and the non-zero label numbers of the corresponding pixel in the next row, then all non-zero label numbers are merged into the smallest label number.

[0134] If at least two of the non-zero label numbers of the pixel to be merged, the non-zero label numbers of the pixel in the previous column of the current row, and the non-zero label numbers of the corresponding pixel in the next row are different, then the principle of adjacent pixels having the same non-zero label number is not satisfied, and merging is required.

[0135] There are a total of four labels involved, including the non-zero labels of the pixels to be merged, the non-zero labels of the pixels in the previous column of the current row, and the non-zero labels of the corresponding pixels in the next row. In reality, there are usually two. We directly compare the non-zero labels among these four labels, determine the smallest label, and merge all the non-zero labels into the smallest label.

[0136] The above steps can be viewed as a secondary merging of label numbers in label merging. This secondary merging further checks the label numbers of pixels, improving their accuracy. Using the pixel position of the row above the pixel to be processed as the pixel to be merged further improves the efficiency of label merging.

[0137] In summary, this embodiment obtains the tag number of the pixel to be merged, the tag number of the pixel in the previous column of the current row of the pixel to be merged, and the tag number of the pixel in the next row of the pixel to be processed. If the tag number of the pixel to be merged, the tag number of the pixel in the previous column of the current row of the pixel to be merged, and the tag number of the pixel in the next row of the pixel to be processed are all equal, then no merging is performed. If at least two of the tag numbers of the pixel to be merged, the tag number of the pixel in the previous column of the current row of the pixel to be merged, and the tag number of the pixel in the next row of the pixel to be processed are not equal, then all the tag numbers are merged into the smallest tag number. This improves the accuracy of the tag numbers and increases the efficiency of tag number merging.

[0138] Next, with Figure 1 Based on the provided images, examples are used to explain the label number statistical merging in the above embodiments. Figure 9 This is an example diagram of label number statistical merging provided in this application. For example... Figure 9 As shown, there are two instances: Instance 1 and Instance 2. From left to right, the two instances are: tag number statistics (tag number determination), tag number first merging, and tag number second merging.

[0139] Taking example 1, the label number of pixel point K is 2 and the label number of pixel point L is 1, and pixel point K is the pixel point in the previous column of the current row of pixel point L. Therefore, in the first label number merging, the label numbers of pixel point K and pixel point L are both merged into 1. In the second merging, the label numbers are consistent, and no further merging is needed.

[0140] Taking example 2, the label number of pixel point Q is 1 and the label number of pixel point R is 2, and pixel point Q is the pixel point in the previous column of the current row of pixel point R. Therefore, in the first label number merging, the label numbers of pixel point Q and pixel point R are both merged into 1. In the second merging, pixel point R is the pixel point in the previous column of the next row of pixel point N, so the label number of pixel point N is merged into 1; further, pixel point N is the pixel point in the previous column of the current row of pixel point O, so the label number of pixel point O is merged into 1.

[0141] In an embodiment, the present application provides a label number recycling method. Figure 10 A flowchart of a label number recycling method provided by the present application is shown. As shown in the figure, before the step of connecting multiple pixel points with the same label number in S103 to generate multiple connected domains in the to-be-processed binary image, the method further includes: Figure 10

[0142] S801, recycle the label number without assignment after merging to the label number cache area.

[0143] When merging label numbers, small label numbers are assigned, and large label numbers are not used. If the large label numbers are discarded, it will cause waste of label numbers. Therefore, the label number without assignment after merging can be recycled to the label number cache area for reuse.

[0144] S802, sort the recycled label number and the original label number in the label number cache area to form a new arrangement order of label numbers.

[0145] After multiple recycling, if the recycled label number is directly placed in the label number cache area, the label number cache area will become disorganized. Therefore, the recycled label number and the original label number in the label number cache area are sorted to form a new arrangement order of label numbers. Thus, the new label numbers are still arranged in ascending order.

[0146] In summary, in the present embodiment, the label number without assignment after merging is recycled to the label number cache area, and the recycled label number and the original label number in the label number cache area are sorted to form a new arrangement order of label numbers. Thus, by recycling the label number without assignment after merging, the effective utilization rate of label numbers is ensured to save resources.

[0147] ​In an embodiment, after determining the label number of the pixel point to be processed according to the binarization pixel value of the pixel point to be processed in the binarization image to be processed, the label number of the pixel point at the corresponding position in the previous row of the pixel point to be processed, and the label number of the pixel point in the previous column of the current row in S101, the method further comprises:

[0148] The label numbers of all the pixel points in the current row are written into the FPGA internal buffer for reading out when determining the label numbers of the pixel points in the next row.

[0149] In the present application, FPGA can be used for image pixel point label processing, and FPGA internal buffer can be used for caching after processing. For example, FIFO (First In First Out, first-in first-out data buffer) in FPGA.

[0150] The label numbers (including invalid label number 0) of all the pixel points in the current row are written into the FPGA internal buffer FIFO and are not immediately read out. The data is read out after the label numbers of all the pixel points in the next row are counted, so as to prepare for subsequent label number merging. For example, the label numbers of the pixel points in the current row are merged and processed during the process of counting the label numbers of the pixel points in the next row.

[0151] Figure 11 A caching schematic diagram based on the FPGA internal buffer is provided in the present application. As shown in Figure 11 FIFO buffer is used in the label number row caching process, and the reading and writing of row data are different by about the time interval of counting one row of label numbers, so that the data read out when writing the current row data is the data of the previous row, so as to leave enough time for subsequent label number merging operation.

[0152] Further, the FPGA internal buffer dual-port RAM can be used for caching operation. Figure 12 A caching schematic diagram based on the FPGA internal buffer dual-port RAM is provided in the present application. As shown in Figure 12 The data is read out after a row of delay, so as to prepare for subsequent label number merging.

[0153] As shown in Figure 12 Dual-RAM ping-pong operation is used in the row caching process of merging label numbers, RAM1 is read when RAM2 is written, and RAM1 is read when RAM2 is written, so that reading and writing are performed at the same time, so as to maximize the parallel processing advantage of FPGA, so as to reduce the result output delay as much as possible.

[0154] In the writing RAM process, based on the tag number merging process in the above embodiment, the reference tag value is taken as the address and data for writing. Specifically, after comparing the first reference tag value and the second reference tag value, the larger reference tag value is taken as the address, and the smaller reference tag value is taken as the data. In the subsequent merging, the larger reference tag value will be merged back, and the smaller reference tag value is taken as the replacement tag number after merging. In the reading RAM process, the row buffer tag number read from the previous stage tag number row buffer is taken as the read address to read the tag number to be replaced.

[0155] In summary, in the embodiment, the tag numbers of all pixel points in the current row are written into the FPGA internal buffer for reading when determining the tag numbers of the pixel points in the next row. Thus, the FPGA parallel processing capability is fully utilized to quickly perform connected component labeling, merging, and output, thereby improving the processing efficiency.

[0156] The following describes an image connected component connection device, equipment, and storage medium provided by the present application, and the specific implementation process and technical effects are described above, and will not be described again.

[0157] Figure 13 A schematic diagram of an image connected component connection device provided by an embodiment of the present application is shown in FIG. 1, which includes: Figure 13

[0158] The determining module 1301 is configured to determine the tag number of the to-be-processed pixel point according to the binary pixel value of the to-be-processed pixel point in the to-be-processed binary image, the tag number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point, and the tag number of the pixel point in the previous column of the current row. The corresponding position in the previous row of the to-be-processed pixel point includes the pixel position in the previous column of the previous row of the to-be-processed pixel point, the pixel position in the previous row of the to-be-processed pixel point, and the pixel position in the next column of the previous row of the to-be-processed pixel point.

[0159] The merging module 1302 is configured to merge the tag numbers according to the tag number of the to-be-processed pixel point, the tag number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point, and the tag number of the pixel point in the previous column of the current row.

[0160] The connection module 1303 is configured to connect multiple pixel points with the same tag number to generate multiple connected components in the to-be-processed binary image.

[0161] Further, the determining module 1301 is specifically configured to determine the tag number of the to-be-processed pixel point as 0 if the binary pixel value of the to-be-processed pixel point is 0, and determine the tag number of the to-be-processed pixel point according to the tag numbers of the pixel points at the corresponding positions in the previous row of the to-be-processed pixel point and the pixel point in the previous column of the current row if the binary pixel value of the to-be-processed pixel point is 1.

[0162] ​Further, the determining module 1301 is specifically further used for determining that the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point is the label number of the to-be-processed pixel point, if the binarization pixel value of the to-be-processed pixel point is 1 and the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point is not 0; and determining the label number of the to-be-processed pixel point according to the label number of the pixel point in the previous column of the current row of the to-be-processed pixel point, if the binarization pixel value of the to-be-processed pixel point is 1 and the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point is 0.

[0163] Further, the determining module 1301 is specifically further used for determining that the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point is the label number of the to-be-processed pixel point, if the binarization pixel value of the to-be-processed pixel point is 1 and the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point is not 0; and determining the label number of the to-be-processed pixel point according to the label number of the pixel point in the previous column of the current row of the to-be-processed pixel point, if the binarization pixel value of the to-be-processed pixel point is 1 and the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point is 0.

[0164] Further, the determining module 1301 is specifically further used for determining that the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point is the label number of the to-be-processed pixel point, if the binarization pixel value of the to-be-processed pixel point is 1 and the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point is not 0; and determining the label number of the to-be-processed pixel point according to the label number of the pixel point in the previous column of the current row of the to-be-processed pixel point, if the binarization pixel value of the to-be-processed pixel point is 1 and the label number of the pixel point at the corresponding position in the previous row of the to-be-processed pixel point is 0.

[0165] Further, the merging module 1302 is specifically used for comparing the first reference label number and the second reference label number; keeping the label number of the to-be-processed pixel point unchanged, if the first reference label number is greater than or equal to the second reference label number; and updating the label number of the to-be-processed pixel point to the label number of the pixel point in the previous column of the current row of the to-be-processed pixel point, if the first reference label number is less than the second reference label number.

[0166] Further, the merging module 1302 is further configured to acquire the label number of the pixel point to be merged and the label number of the pixel point in the previous column of the current row of the pixel point to be merged and the label number of the pixel point in the corresponding position of the next row; the pixel point to be merged is the pixel point in the pixel position of the previous row of the pixel point to be processed, and the corresponding position of the next row of the pixel point to be merged includes the pixel position of the previous column of the next row of the pixel point to be merged, the pixel position of the next row of the pixel point to be merged, and the pixel position of the next column of the next row of the pixel point to be merged; if the non-zero label numbers of the pixel point to be merged, the pixel point in the previous column of the current row of the pixel point to be merged, and the pixel point in the corresponding position of the next row are all equal, no merging is performed; if at least two non-zero label numbers of the non-zero label numbers of the pixel point to be merged, the pixel point in the previous column of the current row of the pixel point to be merged, and the pixel point in the corresponding position of the next row are not equal, all the non-zero label numbers are merged into the smallest label number.

[0167] Further, the merging module 1302 is further configured to recycle the label number without assignment after merging to the label number cache area, and sort the recycled label number and the original label number in the label number cache area to form a new arrangement order of the label number.

[0168] Further, the determining module 1301 is further configured to write the label numbers of all the pixel points in the current row into an FPGA internal buffer, for reading out when determining the label numbers of the pixel points in the next row.

[0169] Figure 14 A schematic diagram of an electronic device is provided for the embodiments of the present application. The electronic device can be a device with computing processing function. For example, a device embedded with an FPGA.

[0170] The electronic device includes a processor 1401 and a storage medium 1402. The processor 1401 and the storage medium 1402 are connected through a bus.

[0171] The storage medium 1402 is configured to store a program, and the processor 1401 calls the program stored in the storage medium 1402 to execute the above-mentioned method embodiments. The specific implementation manners and technical effects are similar, and will not be described here.

[0172] Optionally, the present application also provides a storage medium comprising a program, which, when executed by a processor, is used to perform the above-mentioned method embodiments. In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method can be implemented in other manners. For example, the described apparatus embodiments are merely schematic. For example, the division of the units is only a logical function division. There can be another division manner for the actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different units, can be indirect couplings or communication connections through some interfaces, devices or units, and can be electric, mechanical or in other forms.

[0173] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0174] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can be physically present separately, or two or more units can be integrated into one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software functional units.

[0175] The integrated unit realized in the form of software functional units can be stored in a storage medium. The software functional unit is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to execute part of the steps of the method described in each embodiment of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (English: Read-Only Memory, abbreviated: ROM), a random access memory (English: Random Access Memory, abbreviated: RAM), a magnetic disk or an optical disk, and various program code storage media.

Claims

1. A method for connecting connected components in an image, characterized in that, The method includes: The label number of the pixel to be processed is determined based on the binarized pixel value of the pixel to be processed in the binarized image, the label number of the pixel at the corresponding position in the row above the pixel to be processed, and the label number of the pixel in the previous column of the current row; wherein, the position corresponding to the row above the pixel to be processed includes: the pixel position in the previous column of the row above the pixel to be processed, the pixel position in the row above the pixel to be processed, and the pixel position in the next column of the row above the pixel to be processed; Write the tag numbers of all pixels in the current row into the internal buffer of the FPGA, so that they can be read out when determining the tag numbers of the pixels in the next row; The tag numbers are merged based on the tag number of the pixel to be processed, the tag number of the pixel at the corresponding position in the row above the pixel to be processed, and the tag number of the pixel in the previous column of the current row; The merged tag numbers that have not been assigned a value will be returned to the tag number cache area; The recovered tag numbers are sorted together with the original tag numbers in the tag number cache to form a new arrangement order of the tag numbers; Connecting multiple pixels with the same label number generates multiple connected components in the binarized image to be processed. The step of merging tag numbers based on the tag number of the pixel to be processed, the tag number of the pixel at the corresponding position in the row above the pixel to be processed, and the tag number of the pixel in the previous column of the current row includes: Compare the first reference label value and the second reference label value; wherein, the first reference label value is the label number of the pixel in the previous column of the current row of the pixel to be processed, and the second reference label value is the label number of the pixel in the previous row of the pixel to be processed; If the first reference label value is greater than or equal to the second reference label value, then the label number of the pixel to be processed remains unchanged; If the first reference label value is less than the second reference label value, then the label number of the pixel to be processed is updated to the label number of the pixel in the previous column of the current row of the pixel to be processed; Obtain the label number of the pixel to be merged, as well as the label number of the pixel in the previous column of the current row and the label number of the pixel in the next row corresponding to the pixel to be merged; wherein, the pixel to be merged is the pixel in the previous row of the pixel to be processed, and the pixel in the next row corresponding to the pixel to be merged includes: the pixel in the previous column of the next row of the pixel to be merged, the pixel in the next row of the pixel to be merged, and the pixel in the next column of the next row of the pixel to be merged; If the non-zero label number of the pixel to be merged, the non-zero label number of the pixel in the previous column of the current row, and the non-zero label number of the corresponding pixel in the next row are all equal, then no merging is performed; If at least two of the non-zero label numbers of the pixel to be merged, the non-zero label numbers of the pixel in the previous column of the current row, and the non-zero label numbers of the corresponding pixel in the next row are not equal, then all the non-zero label numbers are merged into the smallest label number.

2. The method according to claim 1, characterized in that, The step of determining the label number of the pixel to be processed based on the binarized pixel value of the pixel to be processed in the binarized image, the label number of the pixel at the corresponding position in the previous row, and the label number of the pixel in the previous column of the current row includes: If the binarized pixel value of the pixel to be processed is 0, then the label number of the pixel to be processed is determined to be 0; If the binarized pixel value of the pixel to be processed is 1, then the label number of the pixel to be processed is determined according to the label number of the pixel at the corresponding position in the previous row and the label number of the pixel in the previous column of the current row.

3. The method according to claim 2, characterized in that, If the binarized pixel value of the pixel to be processed is 1, then the label number of the pixel to be processed is determined according to the label number of the pixel at the corresponding position in the previous row and the label number of the pixel in the previous column of the current row, including: If the binarized pixel value of the pixel to be processed is 1, and the label number of the pixel at the position corresponding to the previous row of the pixel to be processed is non-zero, then the label number of the pixel at the position corresponding to the previous row of the pixel to be processed is determined to be the label number of the pixel to be processed. If the binarized pixel value of the pixel to be processed is 1, and the label number of the pixel at the position corresponding to the previous row of the pixel to be processed is 0, then the label number of the pixel to be processed is determined according to the label number of the pixel in the previous column of the current row of the pixel to be processed.

4. The method according to claim 3, characterized in that, If the binarized pixel value of the pixel to be processed is 1, and the label number of the pixel in the row above the pixel to be processed is 0; Determining the label number of the pixel to be processed based on the label number of the pixel in the previous column of the current row includes: If the label number of the pixel in the previous column of the current row of the pixel to be processed is 0, then the label number of the first one in the label number cache is determined as the label number of the pixel to be processed according to the label number arrangement order. If the label number of the pixel in the previous column of the current row of the pixel to be processed is not 0, then the label number of the pixel in the previous column of the current row of the pixel to be processed is determined to be the label number of the pixel to be processed.

5. The method according to claim 3, characterized in that, If the binarized pixel value of the pixel to be processed is 1, and the label number of the pixel at the corresponding position in the row above the pixel to be processed is non-zero; The step of determining the label number of the pixel at the position corresponding to the previous row of the pixel to be processed as the label number of the pixel to be processed includes: If the label number of the pixel in the previous column of the current row of the pixel to be processed is 0, then the label number of the pixel in the previous row of the pixel to be processed is determined to be the label number of the pixel to be processed. If the label number of the pixel in the previous column of the current row of the pixel to be processed is not 0, then the label number of the pixel in the previous column of the current row of the pixel to be processed is determined as the first reference label value of the pixel to be processed, and the label number of the pixel in the corresponding position of the previous row of the pixel to be processed is determined as the second reference label value of the pixel to be processed.

6. An image connected component connection device, characterized in that, The device includes: The determining module is used to determine the label number of the pixel to be processed based on the binarized pixel value of the pixel to be processed in the binarized image, the label number of the pixel at the corresponding position in the row above the pixel to be processed, and the label number of the pixel in the previous column of the current row; wherein, the corresponding position in the row above the pixel to be processed includes: the pixel position in the previous column of the row above the pixel to be processed, the pixel position in the row above the pixel to be processed, and the pixel position in the next column of the row above the pixel to be processed; The determining module is also used to write the tag numbers of all pixels in the current row into the internal buffer of the field programmable gate array (FPGA) for reading out when determining the tag numbers of pixels in the next row; The merging module is used to merge the tag numbers based on the tag number of the pixel to be processed, the tag number of the pixel at the corresponding position in the row above the pixel to be processed, and the tag number of the pixel in the previous column of the current row. The merging module is further configured to reclaim the unassigned tag numbers after merging to the tag number cache area; and sort the reclaimed tag numbers with the original tag numbers in the tag number cache area to form a new arrangement order of the tag numbers; A connection module is used to connect multiple pixels with the same label number to generate multiple connected components in the binarized image to be processed. The merging module is further configured to compare a first reference label value and a second reference label value; wherein the first reference label value is the label number of the pixel in the previous column of the current row of the pixel to be processed, and the second reference label value is the label number of the pixel in the previous row of the pixel to be processed; if the first reference label value is greater than or equal to the second reference label value, the label number of the pixel to be processed remains unchanged; if the first reference label value is less than the second reference label value, the label number of the pixel to be processed is updated to the label number of the pixel in the previous column of the current row of the pixel to be processed; The merging module is further configured to obtain the tag number of the pixel to be merged, the tag number of the pixel in the previous column of the current row of the pixel to be merged, and the tag number of the pixel in the next row corresponding to the pixel to be merged; wherein, the pixel to be merged is the pixel in the previous row of the pixel to be processed, and the pixel in the next row corresponding to the pixel to be merged includes: the pixel in the previous column of the next row of the pixel to be merged, the pixel in the next row of the pixel to be merged, and the pixel in the next column of the next row of the pixel to be merged; if the non-zero tag number of the pixel to be merged, the non-zero tag number of the pixel in the previous column of the current row of the pixel to be merged, and the non-zero tag number of the pixel in the next row corresponding to the pixel to be merged are all equal, then no merging is performed; if at least two of the non-zero tag numbers of the pixel to be merged, the non-zero tag numbers of the pixel in the previous column of the current row of the pixel to be merged, and the non-zero tag numbers of the pixel in the next row corresponding to the pixel to be merged are not equal, then all the non-zero tag numbers are merged into the smallest tag number.

Citation Information

Patent Citations

  • Image processing apparatus and image processing method

    CN102387286A

  • Image processing method and image processing device

    CN103313015A