Connected domain fusion method for binary image data
By performing adjacent difference processing and parallel search on binarized image data, a neighboring row matching matrix is generated, which solves the problem of low fusion efficiency of binarized image data connection domain, and realizes efficient and fast image data processing.
Patent Information
- Application Number
- CN202510474714.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-08-05
AI Technical Summary
The existing binary image data communication domain fusion processing efficiency is low and cannot meet the task execution requirements of high-speed and low-latency.
By processing adjacent difference values for the vector of the fusion image, a difference value array is generated, and a parallel search of the difference value array is generated to generate a adjacent row matching matrix. The hardware parallel processing capability is used to quickly locate the index array of foreground pixel blocks, and simplify the fusion logic of the connected domain.
It significantly improves the communication domain fusion efficiency of binary image data, reduces the computational complexity and processing delay, and meets the needs of high-speed and low-latency visual tasks.
Smart Images

Figure CN120431429A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image data processing, and in particular to a connected domain fusion method for binary image data. Background Art
[0002] Connected domain fusion of binary images is an important technique in computer vision, effectively extracting information about target regions within an image. When performing visual tasks such as target detection, tracking, and classification, it is often necessary to fuse connected domains within a binary image to obtain the coordinates of the target's minimum bounding box, typically the top-left and bottom-right coordinates of the location box.
[0003] In related technologies, connected domain fusion processing for binary image data is typically based on a secondary scan of the image and maintaining a label mapping table of connected regions using a union-find structure, or a single scan that traverses run-length information to achieve fusion. However, both methods require pixel-by-pixel image scanning, accompanied by complex label maintenance operations, and the process of traversing run-length information can only be serial. As a result, the existing connected domain fusion processing of binary image data is inefficient and cannot meet the requirements of high-speed and low-latency task execution. Summary of the Invention
[0004] The embodiments of the present application provide a connected domain fusion method for binary image data, which can improve the connected domain fusion efficiency of binary image data.
[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a connected domain fusion method for binary image data, the method comprising:
[0006] Extracting row data one by one from the binary image matrix to be fused to obtain an image vector to be fused, and performing adjacent difference processing on the image vector to be fused to obtain a difference array, wherein the difference array includes at least a first value and a second value, where the first value is 1 and the second value is -1;
[0007] Splitting the difference array into a plurality of difference sub-arrays, performing parallel searches on the plurality of difference sub-arrays to obtain a first index array of the first value and a second index array of the second value in the difference array;
[0008] generating a neighboring row matching matrix based on the first index array and the second index array;
[0009] Based on the matrix characteristics of the adjacent row matching matrix, a connected domain fusion process is performed on the binary image matrix to be fused to obtain a target fusion result.
[0010] In some embodiments, performing parallel searches on the plurality of difference sub-arrays to obtain a first index array of the first value and a second index array of the second value in the difference array includes:
[0011] Sending each of the difference sub-arrays to a corresponding hardware processing component for parallel search to obtain a first index sub-array corresponding to the first value and a second index sub-array corresponding to the second value in each difference sub-array;
[0012] generating a first numerical data sending identifier based on the first index subarray, and generating a second numerical data sending identifier based on the second index subarray;
[0013] Based on the first numerical data sending identifier, obtaining the first index array based on the first index sub-array corresponding to each of the difference sub-arrays one by one;
[0014] Based on the second numerical data sending identifier, the second index array is obtained based on the second index sub-array corresponding to each of the difference sub-arrays one by one.
[0015] In some embodiments, generating a first numerical data sending identifier based on the first index subarray includes:
[0016] When the first numerical data does not exist in the difference sub-array corresponding to the first index sub-array representation, generating the first numerical data sending flag based on zero;
[0017] When at least one first numerical data exists in the difference sub-array corresponding to the first index sub-array representation, a first numerical data sending identifier is generated based on one.
[0018] In some embodiments, the sending of the identifier based on the first numerical data, and obtaining the first index array based on the first index sub-array corresponding to each of the difference sub-arrays, includes:
[0019] Calculating the number of current sending request signals corresponding to each of the difference sub-arrays based on the first numerical data sending identifier;
[0020] Setting the data output state of the hardware processing component corresponding to each difference sub-array whose first numerical data sending identifier is one to waiting for output, the data output state being the state of the data output channel corresponding to the hardware processing component;
[0021] When the number of currently sent request signals of the difference sub-array is consistent with the number of completed request signals, selecting the corresponding data output channel in the hardware processing component corresponding to the difference sub-array, and outputting the first index sub-array of the difference sub-array;
[0022] The first index array is updated based on the output first index subarray, and the first index array is obtained based on the updated initial first index array.
[0023] In some embodiments, the updating of the initial first index array based on the output first index subarray and obtaining the first index array based on the updated initial first index array include:
[0024] Adding the subarray identifiers corresponding to the output first index subarray and the difference subarray selected by the data output channel to the initial first index array;
[0025] After the initial first index array is updated based on all the difference sub-arrays, the first index array is obtained based on the updated initial first index array.
[0026] In some embodiments, generating a neighboring row matching matrix based on the first index array and the second index array includes:
[0027] Obtain the first index array and the second index array corresponding to the fused image vector of the preceding row data;
[0028] Traversing the first index array and the second index array based on a first traversal parameter, and traversing the pre-order first index array and the pre-order second index array based on a second traversal parameter;
[0029] When the element corresponding to the first traversal parameter in the first index array is not greater than the element corresponding to the second traversal parameter in the pre-order second index array, and the element corresponding to the first traversal parameter in the second index array is not less than the element corresponding to the second traversal parameter in the pre-order first index array, adjacent row matching elements corresponding to the first traversal parameter and the second traversal parameter are generated based on a;
[0030] The adjacent row matching matrix is generated based on all the adjacent row matching elements.
[0031] In some embodiments, performing connected domain fusion processing on the binary image matrix to be fused based on the matrix characteristics of the adjacent row matching matrix to obtain a target fusion result includes:
[0032] Based on the matrix characteristics of the adjacent row matching matrix, performing connected domain fusion processing on the fused binary image matrix of the binary image matrix to be fused and the image vector to be fused;
[0033] The fused binary image matrix and the image vector to be fused after the connected domain fusion process are used as the new fused binary image matrix;
[0034] After the connected domain fusion processing is performed based on all row data in the binary image matrix to be fused, the target fusion result is obtained.
[0035] In some embodiments, the matrix characteristic includes a first matrix characteristic, and the performing of connected domain fusion processing on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector based on the matrix characteristic of the adjacent row matching matrix includes:
[0036] Based on the first matrix characteristic indicating the presence of newly added foreground data, a row element vector containing all zeros in the adjacent row matching matrix is used as a first target row vector, and a row index of the first target row vector is used as a first target index;
[0037] Selecting a target data block from the image vector to be fused as newly added foreground data based on the first target index;
[0038] Based on the newly added foreground data, a connected domain fusion process is performed on the fused binary image matrix of the binary image matrix to be fused and the image vector to be fused.
[0039] In some embodiments, the matrix characteristic includes a second matrix characteristic, and the performing of connected domain fusion processing on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector based on the matrix characteristic of the adjacent row matching matrix includes:
[0040] Based on the second matrix characteristic indicating the end of the connected domain, a column element vector of all zeros in the adjacent row matching matrix is used as a first target column vector, and a column index of the first target column vector is used as a second target index;
[0041] Selecting a target data block from the image vector to be fused based on the second target index as connected domain end data;
[0042] Based on the connected domain end data, a connected domain fusion process is performed on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector.
[0043] In some embodiments, the matrix characteristic includes a third matrix characteristic, and the connected domain fusion processing is performed on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector based on the matrix characteristic of the adjacent row matching matrix, including:
[0044] Based on the third matrix characteristic indicating the existence of a continuous connected domain, a plurality of consecutive column element vectors equal to one in the adjacent row matching matrix are used as the second target column vector, or a plurality of consecutive row element vectors equal to one in the adjacent row matching matrix are used as the second target row vector, and the column index of the second target column vector or the row index of the second target row vector is used as the third target index;
[0045] Selecting a target data block from the image vector to be fused as connected domain continuous data based on the third target index;
[0046] Based on the connected domain continuous data, a connected domain fusion process is performed on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector.
[0047] In some embodiments, performing adjacent difference processing on the image vectors to be fused to obtain a difference array includes:
[0048] Filling the leading row elements and the trailing row elements of the to-be-fused image vector with zeros to obtain a filled to-be-fused image vector;
[0049] Obtaining adjacent differences based on the difference between every two adjacent vector elements in the filled image vector to be fused;
[0050] The difference value array is obtained based on all the adjacent difference values.
[0051] The connected domain fusion method of binary image data proposed in an embodiment of the present application includes: first, extracting row data one by one from the binary image matrix to be fused to obtain the image vector to be fused, and performing adjacent difference processing on the image vector to be fused to obtain a difference array, the difference array including at least a first value and a second value, the first value is 1, and the second value is -1; then, splitting the difference array into multiple difference sub-arrays, performing parallel search on the multiple difference sub-arrays to obtain a first index array of the first value and a second index array of the second value in the difference array; next, generating a neighboring row matching matrix based on the first index array and the second index array; finally, based on the matrix characteristics of the neighboring row matching matrix, performing connected domain fusion processing on the binary image matrix to be fused to obtain a target fusion result. The embodiment of the present application performs adjacent difference processing on the image vector to be fused, and the generated difference array can quickly identify the boundary information of the connected area in the image, converting the connected domain fusion problem of the two-dimensional image into the processing of a one-dimensional vector, avoiding pixel-by-pixel scanning, and utilizing the parallel processing capability of hardware to group and parallelly search the difference array, quickly locating the index array of the first value and the second value corresponding to the start and end positions of the foreground pixel block, significantly improving the search speed. Compared with the traditional serial scanning method, the processing time is greatly shortened. Then, based on the index array, a neighboring row matching matrix is generated to express the connectivity relationship of the foreground pixel blocks between adjacent rows in a concise form, avoiding complex label maintenance and union-find operations, and utilizing the characteristics of the neighboring row matching matrix to quickly perform connected domain fusion. The merging and ending of the connected domain can be determined by simple judgment of the matrix elements, further simplifying the fusion logic, thereby significantly reducing the computational complexity and processing delay, and thus achieving efficient and fast connected domain fusion of binary image data, so that the requirements of high-speed and low-latency visual tasks can be better met.
[0052] Other features and advantages of the present application will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present application. The purposes and other advantages of the present application can be achieved and obtained through the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 This is a flowchart of a connected domain fusion method for binary image data provided by one embodiment of the present application.
[0054] Figure 2 yes Figure 1 Flowchart of step 101 in FIG.
[0055] Figure 3 This is a schematic diagram of multiple difference sub-arrays provided in another embodiment of the present application.
[0056] Figure 4 yes Figure 1 Flowchart of step 102 in FIG.
[0057] Figure 5 yes Figure 4 Flowchart of step 402 in FIG.
[0058] Figure 6 yes Figure 4 Flowchart of step 403 in FIG.
[0059] Figure 7 This is a state transition diagram of a hardware processing component provided in another embodiment of the present application.
[0060] Figure 8 yes Figure 6 Flowchart of step 603 in FIG.
[0061] Figure 9 This is a schematic diagram of a process for generating a first index array provided in another embodiment of the present application.
[0062] Figure 10 yes Figure 1 Flowchart of step 103 in FIG.
[0063] Figure 11 yes Figure 1 Flowchart of step 104 in FIG.
[0064] Figure 12 yes Figure 11 Flowchart of step 1101 in FIG.
[0065] Figure 13 yes Figure 11 Another flowchart of step 1101 in .
[0066] Figure 14 yes Figure 11 Another flowchart of step 1101 in .
[0067] Figure 15 This is a flowchart of a specific embodiment of connected domain fusion of binary image data provided by another embodiment of the present application.
[0068] Figure 16 This is a schematic diagram of a fusion structure of a binarized image matrix provided in another embodiment of the present application.
[0069] Figure 17 This is a structural diagram of connected domain fusion of binary image data provided by another embodiment of the present application.
[0070] Figure 18 This is a schematic diagram of the hardware structure of an electronic device provided in another embodiment of the present application. DETAILED DESCRIPTION
[0071] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0072] It should be noted that although the functional modules are divided in the device schematic and the logical order is shown in the flowchart, in some cases, the steps shown or described can be performed in a different order than the module division in the device or the order in the flowchart.
[0073] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0074] Connected domain fusion of binary images is an important technique in computer vision, effectively extracting information about target regions within an image. When performing visual tasks such as target detection, tracking, and classification, it is often necessary to fuse connected domains within a binary image to obtain the coordinates of the target's minimum bounding box, typically the top-left and bottom-right coordinates of the location box.
[0075] In related technologies, connected domain fusion processing for binary image data is typically based on a secondary scan of the image and maintaining a label mapping table of connected regions using a union-find structure, or a single scan that traverses run-length information to achieve fusion. However, both methods require pixel-by-pixel image scanning, accompanied by complex label maintenance operations, and the process of traversing run-length information can only be serial. As a result, the existing connected domain fusion processing of binary image data is inefficient and cannot meet the requirements of high-speed and low-latency task execution.
[0076] To improve the efficiency of connected domain fusion of binary image data, the embodiment of the present application performs adjacent difference processing on the image vector to be fused. The generated difference array can quickly identify the boundary information of the connected area in the image, converting the connected domain fusion problem of the two-dimensional image into the processing of a one-dimensional vector, avoiding pixel-by-pixel scanning, and utilizing the parallel processing capability of hardware to group and search the difference array in parallel, quickly locating the index arrays of the first and second values corresponding to the start and end positions of the foreground pixel block, significantly improving the search speed. Compared with the traditional serial scanning method, the processing time is greatly shortened. Then, based on the index array, a neighboring row matching matrix is generated to express the connectivity relationship of the foreground pixel blocks between adjacent rows in a concise form, avoiding complex label maintenance and union-find operations, and utilizing the characteristics of the neighboring row matching matrix for fast connected domain fusion. The merging and ending of the connected domain can be determined by simple judgment of the matrix elements, further simplifying the fusion logic, thereby significantly reducing the computational complexity and processing delay, thereby achieving efficient and fast connected domain fusion of binary image data, so that the requirements of high-speed and low-latency vision tasks can be better met.
[0077] The following will further describe the connected domain fusion method of binary image data provided by the embodiment of the present application. Figure 1 , which is an optional flowchart of the connected domain fusion method for binary image data provided in an embodiment of the present application, Figure 1 The method may include but is not limited to steps 101 to 104. It is also understood that this embodiment is for Figure 1 The order of steps 101 to 104 is not specifically limited, and the order of steps can be adjusted or some steps can be reduced or added according to actual needs. The connected domain fusion method of binary image data provided in the embodiment of the present application can be applied to any server or processor related to image data processing.
[0078] Step 101: extract row data one by one from the binary image matrix to be fused to obtain the image vector to be fused, and perform adjacent difference processing on the image vector to be fused to obtain a difference array.
[0079] Step 101 is described in detail below.
[0080] In some embodiments, first, for the binary image matrix I to be fused, the pixel values of the row data are read row by row from top to bottom in the order of rows, as the image vector DI to be fused, such as the i-th row data DI. For example, starting from the first row of the binary image matrix I to be fused, all the pixel values of the row are read, and these binary pixel values (usually 0 or 1) are combined into a one-dimensional vector, i.e., the image vector DI to be fused. Then, the difference of adjacent elements of this image vector to be fused is calculated to obtain the corresponding difference data. In this way, the two-dimensional image matrix information is converted into a one-dimensional difference array to prepare for subsequent processing. The difference array can reflect the trend and position of the pixel value change in the image, wherein the difference array generally includes 1, 0, and -1. In this embodiment, 1 is used as the first value and -1 is used as the second value.
[0081] The following will further describe how to perform adjacent difference processing on the image vector DI to be fused.
[0082] Reference Figure 2 , performing adjacent difference processing on the image vector to be fused to obtain a difference array, including the following steps 201 to 203.
[0083] Step 201: Fill the leading row elements and the trailing row elements of the image vector to be fused with zero to obtain a filled image vector to be fused.
[0084] Step 202: Obtain adjacent differences based on the difference between every two adjacent vector elements in the image vector to be fused.
[0085] Step 203: Obtain a difference value array based on all adjacent difference values.
[0086] Steps 201 to 203 are described in detail below.
[0087] In some embodiments, in order to handle boundary conditions and maintain consistency in difference calculations, the original image vector DI to be fused needs to be padded with zeros to obtain a padded image vector DI′ to be fused. Specifically, a zero-value padding method is used to add a row of zero-value elements to the leading and trailing row elements of the image vector to be fused. That is, the fused image vector DI′ = [0, DI, 0]. For example, if the original image vector to be fused is [1, 0, 1, 1, 0], then after zero-value padding, the padded image vector to be fused will become [0, 1, 0, 1, 1, 0, 0]. This padding method ensures that the first and last elements of the vector can also participate in the calculation of adjacent differences, avoiding information loss.
[0088] Next, based on the padded image vector DI′, the adjacent element differences are calculated. Specifically, starting with the second element of the padded image vector, the difference between the current element and the previous element is calculated, and this difference is used as the adjacent difference. For example, for the padded vector [0, 1, 0, 1, 1, 0, 0], the adjacent differences are: 1-0 = 1, 0-1 = -1, 1-0 = 1, 1-1 = 0, 0-1 = -1, 0-0 = 0.
[0089] Finally, all adjacent differences are arranged in the order in which they were calculated, forming a one-dimensional array, which is the final difference array. Continuing with the above example, the final difference array DI_delta is [1, -1, 1, 0, -1, 0]. This difference array reflects the pattern of pixel value changes in the original image vector. For example, a positive value indicates an increase in pixel value, a negative value indicates a decrease in pixel value, and a zero value indicates no change in pixel value. This is shown in the following formula (1).
[0090] DI_delta=DI′(2:end)-DI′(1:end-1) (1)
[0091] Through the above steps 201 to 203, zero-filling of the image vector to be fused ensures that the boundary pixels can also participate in the difference calculation, avoiding the loss of edge information. The adjacent difference calculation is used to highlight the changing trend of the pixel value. A positive value indicates that the pixel value increases (for example, from background to foreground), a negative value indicates that the pixel value decreases (for example, from foreground to background), and a zero value indicates that the pixel value remains unchanged. The final difference array can more effectively capture the edge, texture and other detailed features in the image than the original pixel value vector, because these features are often reflected in the sudden change of pixel values. This conversion is beneficial to subsequent image fusion, feature extraction, target detection and other processing, thereby providing a more discriminative representation of the content of the binary image data, reducing the impact of background noise, and highlighting the important structural information in the binary image data.
[0092] Step 102: Split the difference array into multiple difference sub-arrays, perform parallel searches on the multiple difference sub-arrays, and obtain a first index array of the first value and a second index array of the second value in the difference array.
[0093] Step 102 is described in detail below.
[0094] In some embodiments, to improve the efficiency of connected domain fusion of binary image data, after obtaining the difference array corresponding to each row of data, the difference array is split into multiple smaller difference sub-arrays. This splitting can be done in a variety of ways, for example, by fixed length, or evenly based on the total length of the difference array and a preset degree of parallelism. The purpose of this splitting is to enable parallel processing and improve search efficiency.
[0095] Reference Figure 3 , is a schematic diagram of a plurality of difference sub-arrays provided in an embodiment of the present application. Figure 3 As shown in , a difference matrix is divided into four large groups (for example, the first large group contains elements with indices 1-100). Each large group is then further subdivided into multiple small groups corresponding to difference sub-arrays (for example, the first large group is divided into 20 small groups, each containing 5 elements). This allows parallel processing hardware components to simultaneously perform corresponding parallel data processing on multiple difference sub-arrays. This grouping and parallel search strategy can significantly improve the efficiency of searching for specific values in the large-scale difference array DI_delta, fully utilizing computing resources and shortening processing time.
[0096] Then, a search operation is performed in parallel for each difference subarray. The goal of the search is to find the index of a specific value (for example, the first value is 1; the second value is -1) in the difference array DI_delta. For each subarray, the search process records the indexes of all elements with the first value and stores these indexes in the first index array ind_pos; at the same time, it also records the indexes of all elements with the second value and stores these indexes in the second index array ind_neg. Since the search is performed in parallel on multiple difference subarrays, the overall search time can be significantly reduced. Finally, the search results of all difference subarrays are merged to obtain the first index array ind_pos of the first value and the second index array ind_neg of the second value of the entire difference array DI_delta. This parallel search strategy fully utilizes the advantages of multi-core processors or distributed computing environments to improve the efficiency of processing large-scale image data.
[0097] The following further describes how to perform parallel searches on multiple difference sub-arrays to obtain the first index array and the second index array.
[0098] Reference Figure 4 , performing parallel searches on multiple difference sub-arrays to obtain a first index array of the first value and a second index array of the second value in the difference array, including the following steps 401 to 404.
[0099] Step 401: Send each difference subarray to the corresponding hardware processing component for parallel search to obtain a first index subarray corresponding to the first value and a second index subarray corresponding to the second value in each difference subarray.
[0100] Step 402: Generate a first numerical data sending identifier based on the first index subarray, and generate a second numerical data sending identifier based on the second index subarray.
[0101] Steps 401 to 402 are described in detail below.
[0102] In some embodiments, the multiple (e.g., n) difference sub-arrays previously split are assigned to different hardware processing components for direct statistical processing. These hardware processing components can be different cores in a multi-core CPU, different computing units in a GPU, or different logic blocks in an FPGA, etc. Each hardware processing component independently searches the difference sub-array assigned to it for the target value (e.g., the first value 1 and the second value -1). After the search is completed, each hardware processing component generates two index sub-arrays: a first index sub-array ind_pos_sub containing the indexes of all first values 1 in the difference sub-array i And its number num_sub i , and another subarray ind_neg_sub containing all the subarrays with the second value -1 indexed in that subarray i This parallel processing method fully utilizes hardware resources and significantly improves the search speed, especially when processing large image data.
[0103] After each hardware processing component completes the search and generates the first index subarray ind_pos_sub of the corresponding difference subarray (such as the i-th difference subarray group) i and the second index subarray ind_neg_sub i After that, the corresponding data sending identifier will be generated according to the two sub-arrays, such as rq i , namely the first numerical data sending identifier and the second numerical data sending identifier.
[0104] How to generate the data sending identifier will be further described below.
[0105] Reference Figure 5 , generating a first numerical data sending identifier based on a first index subarray, including the following steps 501 to 502.
[0106] Step 501: When the first numerical data does not exist in the difference sub-array corresponding to the first index sub-array representation, a first numerical data sending flag is generated based on zero.
[0107] Step 502: When at least one first numerical data exists in the difference sub-array corresponding to the first index sub-array representation, a first numerical data sending flag is generated based on one.
[0108] Steps 501 to 502 are described in detail below.
[0109] In some embodiments, after a hardware processing component completes searching a difference sub-array (such as the i-th difference sub-array group), if it finds that the first index sub-array ind_pos_sub i Is empty. That is, the corresponding number num_sub i If it is 0, that is, no first value 1 is found in the subarray, then a first value data sending identifier rq with a value of zero is generated. i = 0, indicating "no data to send." Upon receiving this flag, the hardware processing component knows it does not need to output data, and the corresponding data processing component does not need to wait for the index data about the first value from the hardware processing component. This mechanism avoids unnecessary data transmission and waiting, improving efficiency.
[0110] Conversely, if the first index subarray ind_pos_sub i is not empty, that is, the difference sub-array contains at least one first value 1, then a first value data sending identifier with a value of 1 is generated, that is, rq i =1, indicating "data to be sent." Upon receiving this flag, the hardware processing component knows it needs to output data, and the corresponding data processing component knows it needs to wait for and receive the index data for the first value (i.e., the first index subarray) from the hardware processing component. This simple binary flag (0 or 1) enables efficient data transmission control.
[0111] Similarly, the process of each hardware processing component generating the second numerical data sending identifier according to the corresponding second index subarray is similar to the process of generating the first numerical data sending identifier.
[0112] Through the above steps 501 to 502, by introducing a simple binary identifier (0 or 1), efficient data transmission control is achieved, and the system communication overhead and processing delay are significantly reduced. When the first value or the second value does not exist in the difference sub-array, a zero-value identifier is generated to avoid unnecessary data transmission and invalid waiting of subsequent processing units; when the target value exists, a one-value identifier is generated to facilitate the subsequent use of the binary identifier to generate the number of completed application signals and the number of currently sent application signals, and based on the comparison of the number of completed application signals and the number of currently sent application signals, the first index sub-array / second index sub-array of the hardware processing component of each required output data is quickly output to ensure that the subsequent processing unit can receive the required index data in a timely manner. This mechanism reduces redundant data transmission, reduces system bandwidth occupancy, and avoids waste of processing resources, thereby improving the efficiency and response speed of the entire binary image data processing process, and further improving the connection domain fusion efficiency of the binary image data.
[0113] Step 403: Based on the first numerical data sending identifier, a first index array is obtained based on the first index sub-array corresponding to each difference sub-array one by one.
[0114] Step 404: Based on the second numerical data sending identifier, obtain a second index array based on the second index sub-array corresponding to each difference sub-array one by one.
[0115] Steps 403 to 404 are described in detail below.
[0116] Next, according to the first numerical data sending identifier and the second numerical data sending identifier corresponding to the first numerical value and the second numerical value respectively, valid index information is extracted from the corresponding first index sub-array and the second index sub-array, and merged into a complete first index array and a second index array for subsequent data processing and image fusion.
[0117] How to generate the completed first index array and second index array is further described below.
[0118] Reference Figure 6 , based on the first numerical data sending identifier, obtaining the first index array based on the first index sub-array corresponding to each difference sub-array one by one, including the following steps 601 to 603.
[0119] Step 601: Based on the first numerical data sending identifier, the number of current sending request signals corresponding to each difference sub-array is calculated.
[0120] Step 602: Set the data output state of the hardware processing component corresponding to each difference sub-array whose first numerical data sending identifier is one to waiting for output.
[0121] Step 603: When the number of currently sent request signals of the difference sub-array is consistent with the number of completed request signals, the corresponding data output channel in the hardware processing component corresponding to the difference sub-array is selected, and the first index sub-array of the difference sub-array is output.
[0122] Step 604: Update the initial first index array based on the output first index subarray, and obtain the first index array based on the updated initial first index array.
[0123] Steps 601 to 604 are described in detail below.
[0124] In this embodiment, after obtaining the first numerical data corresponding to the difference sub-array, the identifier rq is sent. i Afterwards, using rq_tot i Indicates the sum of the data sending request signals of the 1st to n-1th difference sub-arrays, rq_tot n It is represented by the number of current sending application signals that need to be identified for sending corresponding to the nth difference sub-array, as shown in the following formula (2).
[0125]
[0126] Thus, based on the current number of sending request signals, the total number rq_sum of data sending request signals in the difference matrix corresponding to the entire row of image vectors to be fused is calculated as shown in the following formula (3).
[0127] rq_sum=rq_tot n +rq n (3)
[0128] Taking the generation of the first index array as an example, in this embodiment, firstly, the first numerical data in all difference sub-arrays corresponding to the image vector to be fused in the current row is sent with the identifier 1 (ie, rq i =1) The data output status of the data output channel of the corresponding hardware processing component is transferred from the "idle" setting to the "waiting for output" (or "waiting for application").
[0129] When outputting data, the number of currently selected difference sub-arrays sending application signals rq_tot n The judgment is made based on the number of completed application signals rq_num_done corresponding to the completed data transmission, wherein the number of completed application signals rq_num_done is updated after each completion of a data transmission request of a difference sub-array, that is, the number of completed application signals rq_num_done+=1.
[0130] When the current number of request signals sent by the currently selected difference sub-array is rq_totn When the number of completed request signals corresponding to the completed data transmission is consistent with rq_num_done, the corresponding data output channel in the hardware processing component corresponding to the difference sub-array is selected (that is, the output state rq_success i Set to 1) and output the first index subarray of the difference subarray. If they are not equal, wait for sending.
[0131] Next, for the current difference sub-array (such as the ith difference sub-array), further check the corresponding first numerical data sending identifier rq i If the flag is "1" (indicating that the first value exists in the subarray), it will wait for rq_tot n Equal to the completed rq_num_done, further, rq_success i Set to 1, thereby activating (or selecting) the data output channel of the hardware processing component corresponding to the difference sub-array. This is equivalent to turning on a data transmission switch, allowing the hardware processing component to output the first index sub-array it calculated to the subsequent data processing component. i "0" (indicates that the target value does not exist in the sub-array) or rq_success i If it is not 1 (indicating that the target before the i-th difference subarray has not been sent yet), the data output channel will not be activated, thereby avoiding the transmission of invalid data.
[0132] Reference Figure 7 , is a state transition diagram of a hardware processing component provided by an embodiment of the present application. The state machines of the hardware processing components corresponding to n difference sub-arrays are instantiated, and the group index number of the transmission data of the next hardware processing component (i.e., the group number of the difference sub-array) is obtained in parallel. Figure 7 As shown in FIG, the state transition principle of the state machine of each hardware processing component is as follows: When the i-th (i=1, ..., n) group queries the request signal rq i =1, the state machine transfers from "idle" to "waiting for application"; when it detects that the number of currently completed requests rq_num_done = rq_tot i After that, the status is transferred to "application successful" and the application success flag signal rq_succ i If set to 1, it means that the i-th group will occupy the transmission bus. Otherwise, it will continue to wait for application.
[0133] Afterwards, the subsequent data processing component updates all received first index sub-arrays into an initial first index array (which may be a vector corresponding to an empty set), thereby constructing a complete result to obtain the first index array, as described below.
[0134] Reference Figure 8 , updating the initial first index array based on the output first index subarray, and obtaining the first index array based on the updated initial first index array, including the following steps 801 to 802.
[0135] Step 801: Add the subarray identifiers corresponding to the output first index subarray and the difference subarray selected by the data output channel to the initial first index array.
[0136] Step 802: After updating the initial first index array based on all difference sub-arrays, obtain a first index array based on the updated initial first index array.
[0137] Steps 801 to 802 are described in detail below.
[0138] In some embodiments, when each hardware processing component outputs a first index subarray, the subsequent data processing component not only adds the index information in the first index subarray to the initial first index array, but also adds a subarray identifier (such as Figure 3 This sub-array identifier is used to record which difference sub-array the index information comes from.
[0139] After processing all difference sub-arrays, the initial first index array contains the index information for all detected first values in the difference array. The data processing component then uses this updated initial first index array as the final first index array. This first index array contains the index position information for all first values of interest in the difference array and can trace the image region from which this information originated, providing a complete data foundation for subsequent image fusion and analysis.
[0140] Similarly, the generation process of the second index array corresponding to the second value in the difference matrix is similar to the generation process of the first index array.
[0141] Through the above steps 601 to 604, and steps 801 to 802, efficient index array construction is achieved by processing each difference sub-array in parallel and selectively collecting index data, and the number of currently sent application signals generated by the first numerical data sending identifier is compared with the number of completed application signals. Gating is performed through the numerical data sending identifier, and only the index of the sub-array containing the target numerical value is transmitted, avoiding unnecessary data transmission and processing, thereby saving time and resources. Adding the sub-array identifier ensures the traceability of the index and facilitates subsequent processing. This combined strategy is particularly effective in processing large-scale data and parallel computing environments, and significantly improves the connection domain fusion efficiency of binary image data.
[0142] Reference Figure 9 , is a schematic diagram of a generation process of a first index array provided in an embodiment of the present application. Figure 9 As shown in , the input difference matrix DI_delta is divided into multiple difference sub-arrays, which are sent to their respective hardware processing components in parallel ( Figure 9 These hardware processing components perform parallel searches to find the indices of the first value 1 and the second value -1 in each subarray, generating the first index subarray (ind_pos_sub_i) and the second index subarray (ind_neg_sub_i), respectively, containing the subarray identifier num_sub_i. Subsequently, the finite state machine (fsm_i) generates the first / second value data transmission identifier (rq_succ_i) based on whether the index subarray is empty and the number of requests currently completed, rq_num_done. The output switching selector is controlled based on these transmission identifiers (rq_succ_i), sequentially selecting and outputting only those subarrays (ind_pos, ind_neg) containing valid indexes to the final storage unit. This storage unit is responsible for collecting and integrating index information from different subarrays to ultimately construct the complete first index array and second index array. The entire architecture embodies parallel processing and identifier-based on-demand data transmission to improve the efficiency of index search and construction.
[0143] Step 103: Generate a neighboring row matching matrix based on the first index array and the second index array.
[0144] Step 103 is described in detail below.
[0145] After obtaining the first index array ind_pos and the second index array ind_neg corresponding to the difference matrix corresponding to the row data of the binary image matrix to be fused, the matching degree of the edge or texture features between adjacent image data is analyzed based on these two index arrays, and a neighboring row matching matrix M is constructed based on the matching results. This matrix is used to guide the subsequent image fusion process to ensure smooth transition and feature alignment between adjacent rows.
[0146] How to generate the adjacent row matching matrix M will be further described below.
[0147] Reference Figure 10 , generating a neighboring row matching matrix based on the first index array and the second index array, including the following steps 1001 to 1004.
[0148] Step 1001: Obtain the first index array and the second index array corresponding to the fused image vector of the first row data.
[0149] Step 1002: traverse the first index array and the second index array based on the first traversal parameter, and traverse the pre-order first index array and the pre-order second index array based on the second traversal parameter.
[0150] Step 1003: When the element corresponding to the first traversal parameter in the first index array is not greater than the element corresponding to the second traversal parameter in the pre-order second index array, and the element corresponding to the first traversal parameter in the second index array is not less than the element corresponding to the second traversal parameter in the pre-order first index array, adjacent row matching elements corresponding to the first traversal parameter and the second traversal parameter are generated based on one.
[0151] Step 1004: Generate a neighboring row matching matrix based on all neighboring row matching elements.
[0152] Steps 1001 to 1004 are described in detail below.
[0153] For the total number of elements len representing the first value in the first index value of the current row element, when len=0, it means that there is no foreground data in the image vector to be fused corresponding to the row data, then let i=i+1, and perform the connection domain fusion processing of the next row of data of the binary image matrix to be fused.
[0154] If the total number of elements of the first value represented by the first index value of the current row of elements is greater than 0, it indicates that there is a foreground element. At this time, the first index array (i.e., the first index array of the first value, ind_pos_last) and the second index array (i.e., the second index array of the second value, ind_neg_last) of the fused image vector corresponding to the previous row of data of the current image vector to be fused, which has already been processed, are retrieved from the memory or cache. These first index arrays represent the edge and texture feature information of the previous row of image data, which is used for comparison and matching with the feature information of the current row.
[0155] Next, a neighborhood matching judgment is performed using each pair of data in the first index array ind_pos and the second index array ind_neg with each pair of data in the previous first index array ind_pos_last and the previous second index array ind_neg_last. That is, a check is performed to determine whether each data block in the current row is connected to all data blocks in the previous row in an 8-neighborhood manner. If so, the value is assigned to 1, otherwise 0. In other words, two nested loops (including j and k) are used to traverse the first index array and second index array of the current row (using the first traversal parameter j) and the previous first index array and the previous second index array (using the second traversal parameter k), respectively. During the traversal process, for each pair of index values (current row index and previous row index), the following judgment is made: if the index position of the first value of the current row is not greater than the index position of the second value of the previous row, and the index position of the second value of the current row is not less than the index position of the first value of the previous row, then it is considered that the edge or texture features of the current row and the features of the previous row are spatially matched. At this time, in the adjacent row matching matrix, the elements corresponding to the current row index and the previous row index are set to "1", as shown in the following formula (3).
[0156] if ind_neg(j)≥ind_pos_last(k)&&ind_pos(j)≤ind_neg_last(k) j∈[1,len],k∈[1,len_last]
[0157] M(j,k)=1;
[0158] else
[0159] M(j,k)=0;
[0160] 4 After the traversal is completed, all matching elements constitute the adjacent row matching matrix M.
[0161] Through the above steps 1001 to 1004, the pixel value change point information stored in the first index array and the second index array is used to determine whether there is an overlapping feature interval between the current row and the previous row in the binary image matrix to be fused. By traversing all possible combinations and recording the matching results, the adjacent row matching matrix finally generated can clearly express the matching degree of adjacent row features, providing key structural information for subsequent advanced image processing tasks such as image fusion, target detection or recognition, thereby improving processing accuracy and efficiency.
[0162] Step 104: Based on the matrix characteristics of the adjacent row matching matrix, the connected domain fusion process is performed on the binary image matrix to be fused to obtain the target fusion result.
[0163] Step 104 is described in detail below.
[0164] Next, by utilizing the matrix characteristics of the adjacent row matching matrix, the image vector to be fused corresponding to the current row data of the binary image matrix to be fused and the fused binary image matrix of the binary image matrix to be fused (that is, all row data that have been subjected to the connection domain fusion processing before the current row data) are subjected to the connection domain fusion processing. After all the row data have been subjected to the connection domain fusion processing, the target fusion result of the connection domain fusion of the binary image matrix data is efficiently obtained.
[0165] Among them, the matrix characteristics of the adjacent row matching matrix are used to quickly fuse the foreground data blocks, including obtaining the number of connected domains currently being fused match_cnt, the position coordinate buffer match_cnt×4 =[top t ,bot t ,left t ,right t ], and save the left and right limit coordinate values of the bottom row of each connected domain to ind_pos_last and ind_neg_last, as the first index array and second index array corresponding to the next row of data, and write the position coordinates of the connected domain that has been fused into the target matrix result synchronously, so as to facilitate the final output of the target fusion result. t ,bot t ,left t ,right t A set of values representing the top row, bottom row, leftmost column, and rightmost column of the minimum bounding rectangle of the connected region being fused.
[0166] Reference Figure 11Based on the matrix characteristics of the adjacent row matching matrix, the connected domain fusion processing is performed on the binary image matrix to be fused to obtain the target fusion result, including the following steps 1001 to 1004.
[0167] Step 1101: Based on the matrix characteristics of the adjacent row matching matrix, a connected domain fusion process is performed on the fused binary image matrix and the image vector to be fused of the binary image matrix to be fused.
[0168] Step 1101 is described in detail below.
[0169] In some embodiments, the matrix characteristics of the adjacent row matching matrix include the following four properties.
[0170] First property: If the entire j-th row of M is 0, it means that the j-th data block of the current image row cannot match all the data blocks of the previous image row, and is a newly appeared foreground data, which is used to indicate that there is new foreground data in the current row data.
[0171] Second property: If the entire k-th column of M is zero, it means that the k-th data block in the previous row of the image cannot be matched with all the data blocks in the current row of the image. Furthermore, it means that the target connected domain fusion operation corresponding to this data block in the previous row has been completed, which is used to indicate that the existence of a connected domain in the current row of data has ended.
[0172] The third property: If there are multiple consecutive elements in M with the value 1 in the row or column direction, it means that these data blocks with the value 1 belong to the same connected domain. For example, M(j,k) == 1 and M(j+1,k) == 1, it means that the data blocks corresponding to (ind_pos(j), ind_neg(j)), (ind_pos(j+1), ind_neg(j+1)), and (ind_pos_last(k), ind_neg_last(k)) belong to the same connected domain, which is used to indicate that the connected domain of the current row data is continuous.
[0173] Fourth property: If an element of M is 1, then at most one of its adjacent elements to the right and below it can be 1. For example, if M(j,k) == 1, then only one of M(j+1,k) and M(j,k+1) can be 1.
[0174] Next, the fusion operation of the current row data in the binary image data to be fused and the fused binary image matrix will be further performed according to the above four properties.
[0175] Reference Figure 12 Based on the matrix characteristics of the adjacent row matching matrix, the connected domain fusion processing is performed on the fused binary image matrix and the image vector to be fused of the binary image matrix to be fused, including:
[0176] The following steps are from step 1201 to step 1203.
[0177] Step 1201: Based on the first matrix characteristic indicating the presence of newly added foreground data, a row element vector containing all zeros in the adjacent row matching matrix is used as a first target row vector, and a row index of the first target row vector is used as a first target index.
[0178] Step 1202: Select a target data block from the image vector to be fused based on the first target index as newly added foreground data.
[0179] Step 1203: Based on the newly added foreground data, a connected domain fusion process is performed on the fused binary image matrix and the image vector to be fused of the binary image matrix to be fused.
[0180] Steps 1201 to 1203 are described in detail below.
[0181] Based on the first property of the adjacent row matching matrix, the newly added foreground area is identified by examining the adjacent row matching matrix. If all elements in a row of the matrix are zero, it means that the image feature corresponding to that row has no matching counterpart in the previous row. This row is then considered to represent newly added foreground information, and its row index is recorded as the first target index. Then, based on the first target index, the corresponding image data block is extracted from the image vector to be fused. This data block is then identified as newly added foreground data.
[0182] Finally, the newly extracted foreground data is used to perform connected domain fusion on the fused binary image matrix and the vector of the image to be fused. This step aims to integrate the newly added foreground data with the existing image information to ensure image integrity and coherence. Fusion methods may include, but are not limited to, directly adding the newly added foreground data to the fused image or merging or adjusting overlapping regions according to specific rules.
[0183] Reference Figure 13 Based on the matrix characteristics of the adjacent row matching matrix, the connected domain fusion processing is performed on the fused binary image matrix and the image vector to be fused of the binary image matrix to be fused, including:
[0184] The following steps are from step 1301 to step 1303.
[0185] Step 1301: Based on the second matrix characteristic indicating the end of the connected domain, a column element vector of all zeros in the adjacent row matching matrix is used as a first target column vector, and a column index of the first target column vector is used as a second target index.
[0186] Step 1302: Select a target data block from the image vector to be fused based on the second target index as the connected component end data.
[0187] Step 1303: Based on the connected domain end data, a connected domain fusion process is performed on the fused binary image matrix and the image vector to be fused of the binary image matrix to be fused.
[0188] Steps 1301 to 1303 are described in detail below.
[0189] Regarding the second property of the adjacent row matching matrix, if there is a column in the matrix with all zero elements, it means that the pixels corresponding to the column are no longer connected to the next row, marking the end of a connected domain. The all-zero column vector is designated as the first target column vector, and its column index in the matrix is recorded as the second target index. This index will be used to extract the corresponding image data in the next step. Next, the obtained second target index extracts the corresponding data block from the image vector to be fused, that is, the connected domain end data. This data block represents the end part of the connected domain. The image vector to be fused stores the image information to be processed, and the second target index indicates the specific data location that needs to be extracted.
[0190] The image is then subjected to connected domain fusion processing using the extracted connected domain end data. This data is integrated into the fused binary image matrix, and the image vector to be fused is updated to reflect the processed data. This step involves writing the pixel values of the connected domain end data to the corresponding positions in the fused binary image matrix and marking or removing the processed data from the image vector to be fused.
[0191] Reference Figure 14 Based on the matrix characteristics of the adjacent row matching matrix, the connected domain fusion processing is performed on the fused binary image matrix and the image vector to be fused of the binary image matrix to be fused, including:
[0192] The following steps are from step 1401 to step 1403.
[0193] Step 1401: Based on the third matrix characteristic that characterizes the existence of a continuous connected domain, a plurality of consecutive column element vectors equal to one in the adjacent row matching matrix are used as the second target column vector, or a plurality of consecutive row element vectors equal to one in the adjacent row matching matrix are used as the second target row vector, and the column index of the second target column vector or the row index of the second target row vector is used as the third target index.
[0194] Step 1402: Select a target data block from the image vector to be fused based on the third target index as connected component continuous data.
[0195] Step 1403: Based on the connected domain continuous data, a connected domain fusion process is performed on the fused binary image matrix and the image vector to be fused of the binary image matrix to be fused.
[0196] Steps 1401 to 1403 are described in detail below.
[0197] To address the third property of the adjacent row matching matrix, the program analyzes the adjacent row matching matrix to find column vectors or row vectors with multiple consecutive values of 1. These consecutive 1s indicate the existence of pixel connections between adjacent rows or columns, indicating the continuation of a connected domain. The program calls the column vector with consecutive values of 1 the second target column vector, and its corresponding row vector the second target row vector. The program then extracts the column index of the second target column vector or the row index of the second target row vector and records it as the third target index. This index will be used in the next step to extract the corresponding image data.
[0198] The third target index is then used to extract the corresponding data block, known as the connected domain continuous data, from the image vector to be fused. This data block represents a continuous connected domain and is referred to as the connected domain continuous data. The image vector to be fused stores the image information to be processed, while the third target index indicates the specific data location to be extracted.
[0199] Then, the connected domain continuous data extracted is used to perform connected domain fusion processing on the fused binary image matrix and the image vector to be fused. That is, the connected domain continuous data is integrated into the fused binary image matrix, and the image vector to be fused is updated to reflect the processed data.
[0200] Regarding the fourth property of the adjacent row matching matrix, similar to the processing of the first, second and fourth properties mentioned above, the data of the adjacent row matching matrix is analyzed to determine the data blocks matching the fourth property and thus perform connected domain fusion processing.
[0201] The following code shows how to merge two rows of data using the above four properties. Let j (row iterator) = 1 and k (column iterator) = 1, and scan the matrix M starting from the top left corner until either j or k exceeds the boundaries of the matrix M.
[0202]
[0203]
[0204]
[0205] Through the above steps 1201 to 1203, 1301 to 1303, and 1401 to 1403, by analyzing the different characteristics of the adjacent row matching matrix, multiple situations such as newly added foreground data, the end of a connected domain, and the continuity of a connected domain are effectively identified and processed. By respectively mapping matrix features (all-zero row vectors, all-zero column vectors, and row and column vectors that are consecutively one) to newly added foreground data, the end of a connected domain, and the continuity of a connected domain, and using the corresponding index to extract the target data block from the image vector to be fused, the connected domain fusion processing of the binary image is finally achieved, thereby improving the efficiency and accuracy of connected domain fusion in image processing, avoiding complex iterative calculations, and being able to effectively process various connected domain situations.
[0206] Step 1102: The fused binary image matrix after the connected component fusion process and the image vector to be fused are used as a new fused binary image matrix.
[0207] Step 1103: After performing connected domain fusion processing based on all row data in the binary image matrix to be fused, a target fusion result is obtained.
[0208] Steps 1102 to 1103 are described in detail below.
[0209] In some embodiments, after completing the connected domain fusion processing for the image vector to be fused corresponding to the current row of data, the program updates the processing results to the "fused binary image matrix," i.e., buffer_last = buffer. Then, if the entire binary image matrix to be fused I has not yet been traversed, i is set to i + 1, and buffer is cleared, and match_cnt is reset to zero. At the same time, since some data has been processed, the binary image matrix to be fused is also updated accordingly, removing the processed data or marking it so that the remaining data can be processed in subsequent steps. This step ensures that the processed data is correctly saved and prepared for subsequent processing.
[0210] When all rows of data in the binary image matrix to be fused have been processed by the connected domain fusion, the program will output the final fused binary image matrix as the target fusion result. This means that all connected domains have been correctly identified and merged, and finally a complete fused binary image is generated. The number of connected domains ob_cnt and the position coordinates buffer of the binary image matrix to be fused I are obtained. match_cnt×4 =[top t ,bot t ,left t ,right t ].
[0211] Through steps 1101 to 1103, this matrix-based processing method gradually merges connected domains into the fused image matrix and dynamically updates the image vectors to be fused, ultimately yielding a complete target fusion result. This method avoids complex image traversal and iterative calculations, improving the efficiency and accuracy of connected domain fusion. It can also effectively handle various connected domain scenarios, such as the addition of a new foreground, the end of a connected domain, and continuity.
[0212] Reference Figure 15 , is a flow chart of a specific embodiment of the connected domain fusion of binary image data provided by the embodiment of the present application. Figure 15 As shown in , an overall description is given using one embodiment.
[0213] Assuming that the binary image matrix to be fused is a binary image with a resolution of 250x400 (height 250, width 400), the specific implementation steps of the present invention are described in detail below. The definitions of unspecified variables are consistent with the definitions of the variables with the same name in the technical solution.
[0214] From top to bottom, scan the binary image matrix I to be fused in units of rows (background element value is 0, foreground element value is 1). Initialize necessary variables, such as ind_pos_last, ind_neg_last, buffer_last, etc.
[0215] Step 1: Take the i-th row of data and let DI′ i =[0, I(i, 1:400), 0], and calculate the difference matrix as shown in the following formula (5).
[0216] DI_delta=DI′(2:402)-DI′(1:401) (5)
[0217] DI_delta_pos and DI_delta_neg are calculated by the following formula (6).
[0218] DI_delta_pos(n)=NOT(DI'(n))AND(DI'(n+1)) 1≤n≤400
[0219] DI_delta_neg(n-1)=(DI′(n))AND(NOT(DI′(n+1))) 2≤n≤401(6)
[0220] Step 2: Get ind_pos, ind_neg and len. Divide DI_delta_pos into 4 large groups, each with 100 data; each large group is further divided into 20 small groups, each with 5 data, refer to Figure 3As shown in the figure, 20 modules are instantiated and run in parallel. Using the parallel hardware computing components described in the technical solution, the position index array DI_delta_pos for the "1" element is obtained. The same method is applied to DI_delta_neg to obtain the position index array ind_neg for the "-1" element. After completing the search of the first group of 100 elements, the search switches to groups 2, 3, and 4 in sequence. With appropriate pipelining, the time consumption associated with grouping can be further reduced, thereby achieving the greatest balance between resources and search speed.
[0221] Step 3: Obtain the neighboring row matching matrix M. If len = 0, set i = i + 1 and jump to step (1); when len > 0, it indicates that there is a foreground element. The matching matrix is obtained as follows: use each pair of data in the (ind_pos, ind_neg) array pair and each pair of data in (ind_pos_last, ind_neg_last) to perform neighborhood matching judgment, that is, to determine whether each data block in the current row is connected to all data blocks in the previous row in the 8-neighborhood. If so, assign a value of 1, otherwise 0. This is shown in the following formula (7).
[0222] if ind_neg(j)≥ind_pos_last(k)&&ind_pos(j)≤ind_neg_last(k) j∈[1,len],k∈[1,len_last]
[0223] M(j,k)=1;
[0224] else
[0225] M(j,k)=0; (7)
[0227] Step 4: Using the M matrix characteristics, quickly fuse the foreground data blocks to obtain the number of connected domains currently being fused match_cnt and the position coordinate buffer match_cnt×4 =[top t ,bot t , left t , right t ], save the left and right limit coordinate values of the bottom row of the connected domain to ind_pos_last and ind_neg_last, and synchronously write the position coordinates of the connected domain that has been fused into the matrix result.
[0228] Reference Figure 16 , is a schematic diagram of the fusion structure of a binary image matrix provided in an embodiment of the present application. Figure 16As shown in , the fusion process is now described with an example. For example, the target foreground pixels in row i-1 and row i are arranged as follows Figure 16 Assume that there is no foreground data in row i-2, ind_pos_last and ind_neg_last can be directly obtained as shown in the following formula (8).
[0229] ind_pos_last=[6,9,14,21] ind_neg_last=[7,9,14,21] (8)
[0230] The i-th row is the current row, and the ind_pos and ind_neg arrays are as shown in the following formula (9).
[0231] ind_pos=[2,7,11] ind_neg=[3,9,15] (9)
[0232] According to Step 3, the M matrix can be calculated as shown in the following formula (10).
[0233]
[0234] Reference Figure 17 , is a schematic diagram of the structure of the connected domain fusion of binary image data provided by the embodiment of the present application. Figure 17 As shown in , the process of using M to fuse connected domains is as follows.
[0235] I. Start scanning from M(1,1), which has a value of 0. Now, we first look at the entire row and find that all elements in the first row are 0. Based on the property ① of the M matrix in Step 4 of the technical solution, the first data block (2,3) in row i is the newly appeared foreground data. We then perform the following operations while moving one step downward. Looking at the entire column again, we find that there is a non-zero element in column 1, so we jump to the next judgment.
[0236] buffer(1,1)=i;
[0237] buffer(1,3)=2; / / ind_pos(j);
[0238] buffer(1,4)=3; / / ind_neg(j);
[0239] ind_pos_last(1)=2; / / ind_pos(j);
[0240] ind_neg_last(1)=3; / / ind_neg(j);
[0241] II. Scan M(2,1), whose value is 1. Since it is the first match (match_start == 0), perform the following operations.
[0242] buffer(2,1)=i-1;
[0243] buffer(2,2)=i;
[0244] buffer(2,3)=6; / / min(7(ind_pos(j)),6(buffer_last(k,3)));
[0245] buffer(2,4)=9; / / max(9(ind_neg(j)),7(buffer_last(k,4)));
[0246] ind_pos_last(2)=7; / / ind_pos(j);
[0247] ind_neg_last(2)=9; / / ind_neg(j);
[0248] At this time, looking to the right, we find that M(2,2) is 1. According to property ④, there is at most one "1" to the right and downward, so we take a step to the right, set match_start high, and jump to the next judgment.
[0249] III. Scan M(2,2). According to property ③, M(2,2) and M(2,1) belong to the same connected domain and should be fused. Therefore, perform the following operations:
[0250] buffer(2,1)=i-1; / / min(i-1(data stored in buffer),i-1(top value of the second connected domain in row i-1))
[0251] buffer(2,2)=i;
[0252] buffer(2,3)=6; / / min(6(data stored in buffer),9(left value of the second connected domain in row i-1));
[0253] buffer(2,4)=11; / / max(9(data stored in buffer),11(right value of the second connected domain in row i-1));
[0254] At this time, looking to the right, we find that M(2,3) is 0, then looking down, we find that M(3,2) is 1, so we take a step down and jump to the next judgment.
[0255] iv. Scan M(3,2) and perform fusion again:
[0256] buffer(2,1)=i-1; / / min(i-1(data stored in buffer),i(top value of the third data block in row i))
[0257] buffer(2,2)=i;
[0258] buffer(2,3)=6; / / min(6 (data stored in the buffer), 11 (left value of the third data block in the i-th row))
[0259] buffer(2,4)=15; / / max(11(data stored in buffer),15(right value of the third data block in row i))
[0260] ind_pos_last(2)=7; / / min(7,11);
[0261] ind_neg_last(2)=15; / / max(9,15);
[0262] At this time, looking to the right, we find that M(3,3) is 1, so we move one step to the right and jump to the next judgment.
[0263] v. Scan M(3,3) and fuse again:
[0264] buffer(2,1)=i-1; / / min(i-1(data stored in buffer),i-1(top value of the third connected domain in row i-1))
[0265] buffer(2,2)=i;
[0266] buffer(2,3)=6; / / min(6 (data stored in buffer), 14 (left value of the third connected domain in row i-1))
[0267] buffer(2,4)=17; / / max(15 (data stored in buffer), 17 (right value of the third connected domain in row i-1))
[0268] Now look to the right and find that M(3,4) is 0. Look down again and you have reached the bottom edge of the M matrix. You cannot look down any further. Set match_start to 0 and move one step to the right.
[0269] vi. Scan M(3,4), whose value is 0. First, look at the entire row and find that there is a non-zero element in the third row. Then look at the entire column and find that the elements in the fourth column are all 0. Therefore, according to property ②, the fourth connected domain in the i-1th row has been matched. Write the upper, lower, left, and right values of this connected domain into result, that is:
[0270] result(1,1)=buffer_last(4,1); / / The row number of the upper edge of the fourth connected region in the i-1th row
[0271] result(1,2)=i-1; / / row number of the bottom edge of the fourth connected region in row i-1
[0272] result(1,3)=buffer_last(4,3); / / The left edge row number of the fourth connected region in row i-1
[0273] result(1,4)=buffer_last(4,4); / / Row number of the right edge of the fourth connected region in row i-1
[0274] So far, the scanning of the M matrix has been completed. Figure 6 Indicated by the red arrow.
[0275] Step 5. After completing the scan of the entire M matrix,
[0276] buffer_last=buffer
[0277] Update buffer_last. If the entire image I has not been traversed, set i = i + 1, clear the buffer, clear match_cnt, and jump to Step 1. Otherwise, jump to Step 6.
[0278] Step 6. End the connected domain fusion and get the number of connected domains ob_cnt and position coordinate buffer of image I match_cnt×4 =[top t ,bot t ,left t ,right t ].
[0279] In particular, in some cases, if the distance between two foreground elements does not exceed a certain set distance, they can be considered to belong to the same connected domain. In this case, the target image can be divided into multiple sub-blocks. After performing simple foreground pixel fusion within the sub-blocks, the overall fusion is performed using this scheme.
[0280] The connected domain fusion method of binary image data improved by the embodiment of the present application uses behavior as the operation unit, does not require pixel-by-pixel scanning, and can achieve ultra-low latency connected domain fusion operations; the group active application search method can quickly and directly locate the target element coordinates. Furthermore, if the system resources are limited, multi-level grouping can be performed to achieve a balance between resources and search speed. This method can also be used in situations where "multi-channel data arbitration" is required, and can quickly respond to channel data read and write requests, effectively reducing the time resources consumed by polling; it is also suitable for situations with complex connectivity relationships, and can use the adjacent row matching matrix M and its multiple features to quickly and efficiently perform connected domain fusion. The logic is relatively simple, without complex label fusion and frequent memory read and write operations. When deployed on hardware such as FPGA, it is easier to achieve timing convergence.
[0281] An embodiment of the present application further provides an electronic device, including:
[0282] at least one memory;
[0283] at least one processor;
[0284] at least one program;
[0285] The program is stored in the memory, and the processor executes the at least one program to implement the connected domain fusion method of the binary image data implemented in the present application. The electronic device can be any smart terminal including a mobile phone, a tablet computer, a personal digital assistant (PDA), an in-vehicle computer, etc.
[0286] See also Figure 18 , Figure 18 The hardware structure of an electronic device according to another embodiment is shown. The electronic device includes:
[0287] The processor 1801 may be implemented as a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is configured to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0288] The memory 1802 can be implemented in the form of ROM (Read Only Memory), static storage device, dynamic storage device, or RAM (Random Access Memory). The memory 1802 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1802 and is called by the processor 1801 to execute the connected domain fusion method for binary image data in the embodiments of this application.
[0289] Input / output interface 1803, used to implement information input and output;
[0290] Communication interface 1804, used to implement communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WiFi, Bluetooth, etc.);
[0291] Bus 1805 , which transmits information between various components of the device (e.g., processor 1801 , memory 1802 , input / output interface 1803 , and communication interface 1804 );
[0292] The processor 1801 , the memory 1802 , the input / output interface 1803 and the communication interface 1804 are connected to each other in communication within the device via the bus 1805 .
[0293] An embodiment of the present application also provides a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the connected domain fusion method of the above-mentioned binary image data is implemented.
[0294] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0295] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0296] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0297] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.
[0298] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0299] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0300] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0301] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0302] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0303] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0304] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0305] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A connected domain fusion method for binary image data, characterized in that: The method comprises: Extracting row data one by one from the binary image matrix to be fused to obtain an image vector to be fused, and performing adjacent difference processing on the image vector to be fused to obtain a difference array, wherein the difference array includes at least a first value and a second value, where the first value is 1 and the second value is -1; Splitting the difference array into a plurality of difference sub-arrays, performing parallel searches on the plurality of difference sub-arrays to obtain a first index array of the first value and a second index array of the second value in the difference array; generating a neighboring row matching matrix based on the first index array and the second index array; Based on the matrix characteristics of the adjacent row matching matrix, a connected domain fusion process is performed on the binary image matrix to be fused to obtain a target fusion result.
2. The connected domain fusion method for binary image data according to claim 1, characterized in that: The parallel searching of the plurality of difference sub-arrays to obtain a first index array of the first value and a second index array of the second value in the difference array includes: Sending each of the difference sub-arrays to a corresponding hardware processing component for parallel search to obtain a first index sub-array corresponding to the first value and a second index sub-array corresponding to the second value in each difference sub-array; generating a first numerical data sending identifier based on the first index subarray, and generating a second numerical data sending identifier based on the second index subarray; Based on the first numerical data sending identifier, obtaining the first index array based on the first index sub-array corresponding to each of the difference sub-arrays one by one; Based on the second numerical data sending identifier, the second index array is obtained based on the second index sub-array corresponding to each of the difference sub-arrays one by one.
3. The connected domain fusion method for binary image data according to claim 2, characterized in that: The generating a first numerical data sending identifier based on the first index subarray includes: When the first numerical data does not exist in the difference sub-array corresponding to the first index sub-array representation, generating the first numerical data sending flag based on zero; When at least one first numerical data exists in the difference sub-array corresponding to the first index sub-array representation, a first numerical data sending identifier is generated based on one.
4. The connected domain fusion method for binary image data according to claim 3, characterized in that: The sending identifier based on the first numerical data, and obtaining the first index array based on the first index sub-array corresponding to each of the difference sub-arrays, includes: Calculating the number of current sending request signals corresponding to each of the difference sub-arrays based on the first numerical data sending identifier; Setting the data output state of the hardware processing component corresponding to each difference sub-array whose first numerical data sending identifier is one to waiting for output, the data output state being the state of the data output channel corresponding to the hardware processing component; When the number of currently sent request signals of the difference sub-array is consistent with the number of completed request signals, selecting the corresponding data output channel in the hardware processing component corresponding to the difference sub-array, and outputting the first index sub-array of the difference sub-array; The first index array is updated based on the output first index subarray, and the first index array is obtained based on the updated initial first index array.
5. The connected domain fusion method for binary image data according to claim 4, characterized in that: The updating of the initial first index array based on the output first index subarray and obtaining the first index array based on the updated initial first index array include: Adding the subarray identifiers corresponding to the output first index subarray and the difference subarray selected by the data output channel to the initial first index array; After the initial first index array is updated based on all the difference sub-arrays, the first index array is obtained based on the updated initial first index array.
6. The connected domain fusion method for binary image data according to claim 1, characterized in that: Generating a neighboring row matching matrix based on the first index array and the second index array includes: Obtain the first index array and the second index array corresponding to the fused image vector of the preceding row data; Traversing the first index array and the second index array based on a first traversal parameter, and traversing the pre-order first index array and the pre-order second index array based on a second traversal parameter; When the element corresponding to the first traversal parameter in the first index array is not greater than the element corresponding to the second traversal parameter in the pre-order second index array, and the element corresponding to the first traversal parameter in the second index array is not less than the element corresponding to the second traversal parameter in the pre-order first index array, adjacent row matching elements corresponding to the first traversal parameter and the second traversal parameter are generated based on a; The adjacent row matching matrix is generated based on all the adjacent row matching elements.
7. The connected domain fusion method for binary image data according to claim 1, characterized in that: The method of performing connected domain fusion processing on the binary image matrix to be fused based on the matrix characteristics of the adjacent row matching matrix to obtain a target fusion result includes: Based on the matrix characteristics of the adjacent row matching matrix, performing connected domain fusion processing on the fused binary image matrix of the binary image matrix to be fused and the image vector to be fused; The fused binary image matrix and the image vector to be fused after the connected domain fusion process are used as the new fused binary image matrix; After the connected domain fusion processing is performed based on all row data in the binary image matrix to be fused, the target fusion result is obtained.
8. The connected domain fusion method for binary image data according to claim 7, characterized in that: The matrix characteristic includes a first matrix characteristic, and the connected domain fusion processing is performed on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector based on the matrix characteristic of the adjacent row matching matrix, including: Based on the first matrix characteristic indicating the presence of newly added foreground data, a row element vector containing all zeros in the adjacent row matching matrix is used as a first target row vector, and a row index of the first target row vector is used as a first target index; Selecting a target data block from the image vector to be fused as newly added foreground data based on the first target index; Based on the newly added foreground data, a connected domain fusion process is performed on the fused binary image matrix of the binary image matrix to be fused and the image vector to be fused.
9. The connected domain fusion method for binary image data according to claim 7, characterized in that: The matrix characteristic includes a second matrix characteristic, and the connected domain fusion processing is performed on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector based on the matrix characteristic of the adjacent row matching matrix, including: Based on the second matrix characteristic indicating the end of the connected domain, a column element vector of all zeros in the adjacent row matching matrix is used as a first target column vector, and a column index of the first target column vector is used as a second target index; Selecting a target data block from the image vector to be fused based on the second target index as connected domain end data; Based on the connected domain end data, a connected domain fusion process is performed on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector.
10. The connected domain fusion method for binary image data according to claim 7, characterized in that: The matrix characteristics include a third matrix characteristic, and the matrix characteristics based on the adjacent row matching matrix are used to perform connected domain fusion processing on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector, including: Based on the third matrix characteristic indicating the existence of a continuous connected domain, a plurality of consecutive column element vectors equal to one in the adjacent row matching matrix are used as the second target column vector, or a plurality of consecutive row element vectors equal to one in the adjacent row matching matrix are used as the second target row vector, and the column index of the second target column vector or the row index of the second target row vector is used as the third target index; Selecting a target data block from the image vector to be fused as connected domain continuous data based on the third target index; Based on the connected domain continuous data, a connected domain fusion process is performed on the fused binary image matrix of the to-be-fused binary image matrix and the to-be-fused image vector.
11. The connected domain fusion method for binary image data according to claim 1, characterized in that: The performing adjacent difference processing on the image vector to be fused to obtain a difference array includes: Filling the leading row elements and the trailing row elements of the to-be-fused image vector with zeros to obtain a filled to-be-fused image vector; Obtaining adjacent differences based on the difference between every two adjacent vector elements in the filled image vector to be fused; The difference value array is obtained based on all the adjacent difference values.
