Connected domain fast marking method, device, electronic device and storage medium
By storing and merging the connected domain labeling algorithm in an address-pointing manner in FPGA, the problems of large storage space consumption and long processing time of the connected domain labeling algorithm are solved, and more efficient image connected domain labeling is achieved.
Patent Information
- Application Number
- CN202510903837.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-01
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-07-01
AI Technical Summary
Existing connected domain labeling algorithms have the problems of large storage space consumption and long algorithm processing time. In particular, insufficient storage space leads to data loss when processing large connected domains, while storage resources are wasted when processing small connected domains.
By storing the information of marked pixels in an address-pointing manner in FPGA, and when different connected domain labels are detected for marked pixels in the same connected domain, the later marked connected domain is merged into the earlier marked connected domain by modifying the address pointing. Combined with the data storage structure implemented by address pointing, the management and storage requirements of temporary labels are optimized.
The execution time of the algorithm is reduced, the efficiency of marking the connected domain of the image and the utilization of storage resources are improved, and the problems of large storage space consumption and long processing time are solved.
Smart Images

Figure CN120411542B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image information processing, and in particular to a method, device, electronic device and storage medium for rapid labeling of connected domains. Background Art
[0002] The connected domain labeling algorithm is widely used in various scenarios such as image analysis, image understanding, pattern recognition and computer vision. Its principle is to judge the connection between a pixel and its adjacent pixels in the image based on the relationship between the pixel values and the preset background pixel range, and obtain all pixels belonging to the same target in the image through connected domain labeling and connected domain equivalence processing, so as to realize the labeling of connected domains.
[0003] The existing connected domain labeling algorithm is mainly divided into two steps. The first step is to scan the entire image and temporarily label the pixels according to the connection relationship between adjacent pixels. The second step is to perform equivalent processing on the temporary labels to eliminate the situation where multiple temporary labels appear in a connected domain. This step usually requires scanning the image twice or more.
[0004] During the connected component labeling algorithm, pixels must be temporarily labeled. Typically, the size and number of connected domains in an image cannot be determined in advance, so sufficient storage space must be reserved to cache temporarily labeled pixel data. The amount of storage space required depends on the amount of pixel data contained in the largest connected domain in the image. For example, for a 1024*1024 image with an 8-bit bit depth, to meet all application scenarios with varying connected domain sizes and numbers, 524,288 temporary labels must be reserved. Each temporary label requires 1MB of storage space, resulting in a total storage requirement of 512GB, which is excessive. Insufficient storage space can lead to data loss when processing large connected domains, resulting in an overflow of data. However, reserving a large amount of storage space when processing small connected domains can waste storage resources. When performing label equivalence processing on temporary labels, typical connected domain labeling algorithms employ multiple scans, replacing labels with equivalent labels until no equivalent connected domains are found. Alternatively, pixels with equivalent labels can be stored together through multiple data transfers. Both of these methods will increase image processing time and affect the real-time performance of the algorithm.
[0005] Therefore, in order to solve the technical problems of the existing connected domain marking algorithm, such as large storage space consumption and long algorithm processing time, a connected domain fast marking method, device, electronic device and storage medium are urgently needed. Summary of the Invention
[0006] The purpose of the present application is to provide a method, device, electronic device and storage medium for fast marking of connected domains. After the pixel information of marked pixels is stored in an FPGA in an address-pointing manner, when it is detected that marked pixels belonging to the same connected domain have different connected domain labels, the later marked connected domain is merged into the earlier marked connected domain by modifying the address pointing, so as to distinguish the connected domains in the image to be marked by different connected domain labels, and obtain the connected domain marking results corresponding to the image to be marked, thereby solving the problems of large storage space consumption and long algorithm processing time in existing connected domain marking algorithms. By executing this real-time label adjustment process in the FPGA, the parallel processing capability of the hardware is utilized to accelerate the processing speed and reduce the execution time of the algorithm. At the same time, by instantly processing equivalence relations and combining the data storage structure implemented by address pointing, the management and storage requirements of temporary labels are optimized, and the marking efficiency of the image connected domain and the utilization of storage resources are improved.
[0007] In a first aspect, the present application provides a method for quickly marking connected domains, comprising:
[0008] Get the image to be marked;
[0009] Based on the pixel value of each pixel and the pixel values of adjacent pixels, the pixels in the image to be marked are marked in connected domains to obtain marked pixels;
[0010] Storing the pixel information of the marked pixel point in a preset storage space of the FPGA in an address-pointing manner;
[0011] Each time pixel information is stored, pixel information of adjacent pixels of the currently marked pixel is detected. When it is detected that the marked pixels belonging to the same connected domain have different connected domain labels, the connected domain marked later is connected to the connected domain marked earlier in the preset storage space by modifying the address pointing, so as to merge the connected domain marked later into the connected domain marked earlier.
[0012] All pixels in the image to be labeled are traversed to distinguish connected domains in the image to be labeled by using different connected domain labels, and obtain connected domain labeling results corresponding to the image to be labeled.
[0013] The connected domain fast marking method provided in the present application can mark the connected domain of an image. After the pixel information of the marked pixel points is stored in the FPGA in an address-pointing manner, when it is detected that the marked pixel points belonging to the same connected domain have different connected domain labels, the later marked connected domain is merged into the earlier marked connected domain by modifying the address pointing, so as to distinguish the connected domains in the image to be marked by different connected domain labels, and obtain the connected domain marking results corresponding to the image to be marked, thereby solving the problems of large storage space consumption and long algorithm processing time in the existing connected domain marking algorithm. By executing this real-time label adjustment process in the FPGA, the parallel processing capability of the hardware is utilized to accelerate the processing speed and reduce the execution time of the algorithm. At the same time, by instantly processing the equivalence relationship and combining the data storage structure implemented by address pointing, the management and storage requirements of temporary labels are optimized, and the marking efficiency of the image connected domain and the utilization of storage resources are improved.
[0014] Optionally, based on the pixel value of each pixel and the pixel values of adjacent pixels, sequentially marking the pixels in the image to be marked as connected components to obtain marked pixels includes:
[0015] A1, obtaining pixel values of a current pixel and adjacent pixels in the image to be marked according to a preset marking order;
[0016] A2, based on the pixel value of the current pixel and the pixel values of the adjacent pixels, in accordance with the preset marking order, sequentially determines whether the current pixel is connected to the adjacent pixels; if not, marks a new connected domain label for the current pixel; if so, marks the connected domain label of the current pixel as the connected domain label of the first marked adjacent pixel;
[0017] A3: Determine the current pixel marked with the connected component label as a marked pixel.
[0018] The connected domain fast labeling method provided in this application can realize the labeling of image connected domains. By scanning and preliminarily labeling the pixels in the labeled image point by point, the pixels with connection relationships are assigned the same temporary connected domain label. This process generates labeled pixels and their corresponding temporary connected domain labels, laying the foundation for subsequent storage of pixel information and label equivalence processing in FPGA.
[0019] Optionally, judging whether the current pixel is connected to the adjacent pixels in sequence according to the preset marking order based on the pixel value of the current pixel and the pixel values of the adjacent pixels includes:
[0020] Determine whether the pixel value of the current pixel is within the preset background pixel range;
[0021] If yes, the current pixel is determined to be a background pixel, the marking operation is not performed, the next pixel is reselected as the current pixel, and the process returns to step A1;
[0022] If not, then according to the preset marking order, determine in turn whether the pixel values of the adjacent pixels of the current pixel are located in the preset background pixel range to determine whether the current pixel is connected to the adjacent pixels; when the adjacent pixels are not located in the preset background pixel range, determine that the current pixel and the adjacent pixels belong to the same connected domain.
[0023] Optionally, the pixel information includes pixel coordinates, pixel values, connected domain labels and pointing addresses of marked pixel points; wherein each pixel point corresponds to a connected domain label and a pointing address.
[0024] Optionally, the preset storage space includes a first storage unit and a second storage unit; the first storage unit is used to store the connected domain label and index information, and the index information includes the pixel point pointing address of the pixel point; the second storage unit is used to store pixel coordinates, pixel values and the pointing address of adjacent pixels.
[0025] The connected domain fast labeling method provided in this application can label connected domains in images. Through a dual-structure storage approach, it allows the system to efficiently search and access new pixels or detect pixels belonging to the same connected domain with different connected domain labels. This structure facilitates finding pixels whose labels need updating and enables label association and connected domain merging by modifying address pointers, avoiding the movement of large amounts of pixel data, improving processing efficiency, and optimizing storage management within the FPGA, thereby increasing the efficiency of labeling connected domains in images.
[0026] Optionally, after the later-marked connected domain is connected to the earlier-marked connected domain in the preset storage space by modifying the address pointing to merge the later-marked connected domain into the earlier-marked connected domain, the method further includes:
[0027] The pixel data of the pixel points merged into the same connected domain are recorded in the second storage unit in a manner pointing to adjacent pixels.
[0028] Optionally, traversing all pixels in the image to be labeled to distinguish connected domains in the image to be labeled by address pointing to different connected domain labels, and obtaining a connected domain labeling result corresponding to the image to be labeled, includes:
[0029] Traversing all pixels in the image to be marked to mark all pixels with connected domain labels;
[0030] The pixel points whose addresses point to connected connected domain labels are determined to be the same connected domain, and a connected domain labeling result corresponding to the image to be labeled is obtained.
[0031] In a second aspect, the present application provides a device for quickly marking a connected domain, comprising:
[0032] An acquisition module, used to acquire the image to be marked;
[0033] a marking module, configured to mark connected domains of pixels in the image to be marked in sequence based on the pixel value of each pixel and the pixel values of adjacent pixels, to obtain marked pixels;
[0034] A storage module, configured to store the pixel information of the marked pixel points in a preset storage space of the FPGA in an address-pointing manner;
[0035] an equivalent processing module configured to detect pixel information of adjacent pixels of a currently marked pixel each time pixel information is stored, and when it is detected that marked pixels belonging to the same connected domain have different connected domain labels, connect the later marked connected domain with the earlier marked connected domain in the preset storage space by modifying the address pointing, so as to merge the later marked connected domain into the earlier marked connected domain;
[0036] The traversal module is used to traverse all pixels in the image to be labeled, so as to distinguish the connected domains in the image to be labeled by different connected domain labels, and obtain the connected domain labeling result corresponding to the image to be labeled.
[0037] The connected domain fast marking device stores the pixel information of marked pixels in an FPGA in an address-pointing manner. When it is detected that marked pixels belonging to the same connected domain have different connected domain labels, the later marked connected domain is merged into the earlier marked connected domain by modifying the address pointing, so as to distinguish the connected domains in the image to be marked by the different connected domain labels, and obtain the connected domain marking result corresponding to the image to be marked. The shortcomings of the existing connected domain marking algorithm, such as large storage space consumption and long algorithm processing time, are solved. By executing this real-time label adjustment process in the FPGA, the parallel processing capability of the hardware is utilized to accelerate the processing speed and reduce the execution time of the algorithm. At the same time, by instantly processing the equivalence relationship and combining the data storage structure realized by address pointing, the management and storage requirements of temporary labels are optimized, and the marking efficiency of the image connected domain and the utilization rate of storage resources are improved.
[0038] In a third aspect, the present application provides an electronic device comprising a processor and a memory, wherein the memory stores a computer program executable by the processor, and when the processor executes the computer program, it runs the steps in the method for fast marking of connected domains as described above.
[0039] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, executes the steps of the method for fast marking of connected domains as described above.
[0040] Beneficial effects: The connected domain fast marking method, device, electronic device and storage medium provided by the present application, after storing the pixel information of the marked pixel points in the FPGA in an address-pointing manner, when it is detected that the marked pixel points belonging to the same connected domain have different connected domain labels, the later marked connected domain is merged into the earlier marked connected domain by modifying the address pointing, so as to distinguish the connected domains in the image to be marked by different connected domain labels, and obtain the connected domain marking results corresponding to the image to be marked, thereby solving the problems of large storage space consumption and long algorithm processing time in the existing connected domain marking algorithm. By executing this real-time label adjustment process in the FPGA, the parallel processing capability of the hardware is utilized to accelerate the processing speed and reduce the execution time of the algorithm. At the same time, by instantly processing the equivalence relationship and combining the data storage structure implemented by address pointing, the management and storage requirements of temporary labels are optimized, and the marking efficiency of the image connected domain and the utilization of storage resources are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 Flowchart of the method for quickly marking connected domains provided in an embodiment of the present application.
[0042] Figure 2 A schematic diagram of the structure of a connected domain rapid marking device provided in an embodiment of the present application.
[0043] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0044] Figure 4 Schematic diagram of the structure of the first storage unit.
[0045] Figure 5 Schematic diagram of the structure of the second storage unit.
[0046] Explanation of reference numerals: 1. Acquisition module; 2. Marking module; 3. Storage module; 4. Equivalent processing module; 5. Traversal module; 301. Processor; 302. Memory; 303. Communication bus. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work fall within the scope of protection of the present application.
[0048] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and should not be understood as indicating or implying relative importance.
[0049] Please refer to Figure 1 , Figure 1 A method for quickly marking connected domains in some embodiments of the present application is used to mark connected domains in an image, comprising the steps of:
[0050] Step S101, obtaining an image to be marked;
[0051] Step S102, based on the pixel value of each pixel and the pixel values of adjacent pixels, the pixels in the image to be marked are marked with connected components to obtain marked pixels;
[0052] Step S103, storing the pixel information of the marked pixel point in a preset storage space of the FPGA (FPGA is a field programmable gate array) in an address-pointing manner;
[0053] Step S104: Each time pixel information is stored, pixel information of adjacent pixels of the currently marked pixel is detected. When it is detected that the marked pixels belonging to the same connected domain have different connected domain labels, the later marked connected domain is connected to the earlier marked connected domain in a preset storage space by modifying the address pointing, so as to merge the later marked connected domain into the earlier marked connected domain.
[0054] Step S105 , traversing all pixels in the image to be labeled to distinguish connected domains in the image to be labeled by using different connected domain labels, and obtaining a connected domain labeling result corresponding to the image to be labeled.
[0055] This connected domain fast labeling method stores the pixel information of the marked pixels in the FPGA in an address-pointing manner. When it is detected that the marked pixels belonging to the same connected domain have different connected domain labels, the later marked connected domain is merged into the earlier marked connected domain by modifying the address pointing. The connected domains in the image to be marked are distinguished by the different connected domain labels, and the connected domain labeling results corresponding to the image to be marked are obtained. This method solves the problems of large storage space consumption and long algorithm processing time in existing connected domain labeling algorithms. By executing this real-time label adjustment process in the FPGA, the parallel processing capability of the hardware is utilized to accelerate the processing speed and reduce the execution time of the algorithm. At the same time, by instantly processing equivalence relations and combining the data storage structure implemented by address pointing, the management and storage requirements of temporary labels are optimized, thereby improving the labeling efficiency of image connected domains and the utilization of storage resources.
[0056] Specifically, in step S101, an image to be labeled is obtained, wherein the input image to be labeled can be received by the FPGA, and the pixels in the image to be labeled are cached in a data buffer area inside the FPGA according to a preset buffer quantity (such as two rows of pixels), so that the connected domains of the pixels can be labeled in sequence later, thereby improving the efficiency of connected domain labeling.
[0057] Specifically, in step S102, based on the pixel value of each pixel and the pixel values of adjacent pixels, the pixels in the image to be marked are marked with connected components in sequence to obtain marked pixels, including:
[0058] A1, according to the preset marking order, obtain the pixel values of the current pixel and the adjacent pixels in the image to be marked;
[0059] A2, based on the pixel value of the current pixel and the pixel values of the adjacent pixels, in accordance with the preset marking order, determines whether the current pixel is connected to the adjacent pixels; if not, a new connected domain label is marked for the current pixel; if so, the connected domain label of the current pixel is marked as the connected domain label of the adjacent pixels that was marked first;
[0060] A3: Determine the current pixel marked with the connected component label as a marked pixel.
[0061] In step S102, the image to be marked is pixel-wise scanned and preliminarily labeled through steps A1 to A3. The pixel values of the current pixel and its marked adjacent pixels are obtained in a preset order (e.g., row-by-row scanning). The pixel values of the current pixel and its adjacent pixels are used to determine whether they meet the preset connectivity conditions. If so, the connected domain label of the first marked adjacent pixel is assigned to the current pixel; if not, a new connected domain label is assigned to the current pixel. Thus, the pixels in the image are sequentially assigned temporary connected domain labels, generating a set of marked pixels and their corresponding label information. This process systematically performs a preliminary connected domain division of the image based on local connectivity judgment, providing basic data for subsequent label equivalence processing.
[0062] Specifically, in step S102, based on the pixel value of the current pixel and the pixel values of the adjacent pixels, whether the current pixel is connected to the adjacent pixels is determined in sequence according to a preset marking order, including:
[0063] Determine whether the pixel value of the current pixel is within the preset background pixel range;
[0064] If yes, the current pixel is determined to be a background pixel, the marking operation is not performed, the next pixel is reselected as the current pixel, and the process returns to step A1;
[0065] If not, then according to the preset marking order, determine in turn whether the pixel values of the adjacent pixels of the current pixel are located in the preset background pixel range to determine whether the current pixel is connected to the adjacent pixels; when the adjacent pixels are not located in the preset background pixel range, determine that the current pixel and the adjacent pixels belong to the same connected domain.
[0066] In step S102, when marking connected domains for pixels in an image, the pixel value of the pixel currently being processed is first obtained. This pixel value is compared with a preset background pixel value range. If the pixel value of the current pixel falls within this background pixel range, the pixel is determined to be a background pixel. Once it is determined to be a background pixel, no connectivity determination or connected domain label assignment operations are performed on the pixel, and the processing focus is directly shifted to the next pixel to be processed in the image. This avoids unnecessary calculations and processing of pixels in the background area, reducing the processing burden. Only when the pixel value of the current pixel is not within the preset background pixel range is it considered that the pixel may belong to a foreground connected domain. At this point, the subsequent steps are continued to check the pixel value sizes of the neighboring pixels of the current pixel (these neighboring pixels must have been processed and marked) in a preset scanning order (e.g., from left to right, from top to bottom). Determine whether the pixel values of adjacent pixels fall within the background pixel range. If a connected domain label is found for an adjacent pixel, the two pixels are considered connected and the current pixel is labeled with the same connected domain label as the adjacent pixel that was first labeled. If the pixel values of all adjacent pixels fall within the background pixel range (i.e., all adjacent pixels are unlabeled), a new connected domain label is assigned to the current pixel. This method excludes background pixels from the connected domain labeling process, improving processing efficiency. The preset background pixel range can be set according to actual needs.
[0067] Specifically, the pixel information includes the pixel coordinates, pixel values, connected domain labels and pointing addresses of the marked pixel points; wherein each pixel point corresponds to a connected domain label and a pointing address; the preset storage space includes a first storage unit and a second storage unit; the first storage unit is used to store the connected domain label and index information, and the index information includes the pixel point pointing address of the pixel point; the second storage unit is used to store the pixel coordinates, pixel values and pointing addresses of adjacent pixels.
[0068] Specifically, in step S103, a specific FPGA storage structure is constructed to support data management during the connected domain labeling process. After a pixel is labeled and its connected domain label is determined, its pixel coordinates, pixel value, and connected domain label information need to be stored. The pixel coordinates are recorded, and the address of its storage location is updated to the index information of its connected domain label in the first storage unit. It is also associated with another pixel data belonging to the same connected domain in the second storage unit. For example, the head and tail addresses stored in the first storage unit point to the addresses of the memory areas in the second storage unit used to store the first and last pixels of the pixel data string. The second storage unit can be implemented as a lookup table with a unidirectional index based on the storage address. Each pixel data entry contains a list that stores the pixel coordinates and the address pointers of adjacent data belonging to the same connected domain in the second storage unit. If different labels are found, label equivalence processing is required (for example, the connected domain marked later is connected to the connected domain marked earlier by modifying the address pointer). This connected domain merging can be achieved by modifying the address pointing or index information. For example, in the first storage unit, the address pointing of the pixel coordinates originally belonging to the later-marked number is transferred to the index information of the earlier-marked number. At the same time, in the second storage unit, the first pixel data of the later-marked number is connected to the last pixel data of the earlier-marked number through the address pointing, thereby realizing the merging of the connected domain of the later-marked number with the connected domain of the earlier-marked number without moving the actual pixel coordinate data or performing a large amount of data transfer operations, thereby improving processing efficiency, reducing data transfer overhead, and solving the problems of large storage space consumption and long processing time in existing methods.
[0069] In step S103, the data for all marked pixels is stored in the same storage area in the order in which they were processed. Pixels in the same connected domain are linked by pointing addresses. This allows for pixel data to be stored using limited storage space, eliminating the need to reserve significant storage space for an unknown number of connected domains or their sizes, thus improving storage efficiency.
[0070] like Figure 4 As shown, Figure 4 is a structural diagram of the first storage unit, wherein: is the connected domain label, q is the total number of connected domains, the arrow represents the index information, A is the connectivity flag, which is used to mark whether the current connected domain label is valid, B is the connectivity flag, which is used to mark equivalent connected domain labels. The address pointing corresponding to the pixel coordinates of the marked pixel point is used to search for all the pixel points of the same connected domain in the first storage unit; or, in the first storage unit, only the address pointing corresponding to the first pixel point and the last pixel point of the same connected domain is recorded, and the position of the last pixel point in the second storage unit can be accessed through the address pointing, and then the previous pixel data is searched in the second storage unit according to the pointing address of the adjacent pixel data stored in the pixel data, until the first pixel of the same connected domain is found, thereby finding all the pixel points of the same connected domain in the second storage unit.
[0071] like Figure 5 As shown, Figure 5 is a schematic structural diagram of the second storage unit, wherein: is the pixel value, and the arrows indicate the corresponding information. is the pixel coordinate. In the second storage unit, the pixel points of the same connected domain form a data string in the form of address pointing.
[0072] Specifically, in step S104, each time a pixel information is stored, the logic inside the FPGA will immediately start the detection mechanism and scan the currently stored label situation to detect the pixel information of the adjacent pixels of the currently marked pixel. If it is found that the pixels belonging to the same connected domain are assigned different connected domain labels, this indicates that these labels are equivalent and need to be merged. Determine which label is assigned first and which is assigned later, and connect the index information corresponding to the two connected domains by modifying the address pointing to merge the connected domain marked later into the connected domain marked earlier. This real-time equivalent processing process is completed directly at the FPGA hardware level by modifying the address pointing step, avoiding the delay of transmitting the data out for software processing and then transmitting it back, and also avoiding the time-consuming problem of multiple full-image scans to solve the label equivalence, thereby greatly improving the processing speed. In this way, the equivalence relation of connected domains is solved dynamically and in real time during the labeling process, so that the pixel data of different connected domains can be stored sequentially in the same storage area. There is no need to reserve a large amount of temporary storage space for the connected domain labels, which reduces the dependence on a large amount of temporary storage space and optimizes the use of storage resources.
[0073] In some optional embodiments, the later-assigned labels can be adjusted to the earlier-assigned labels. After the connected domain labels are adjusted, the pixel coordinates (represented as address pointers) of the marked pixels originally associated with the later-assigned connected domain labels are retrieved from the index information corresponding to the later-assigned connected domain labels and transferred to the index information corresponding to the earlier-assigned connected domain labels. This technical feature ensures that while connected domains are merged (equal processing), it avoids the need for subsequent rescanning or searching to integrate scattered pixel information, simplifies the data structure, and improves the efficiency of subsequent traversal and identification of connected domains.
[0074] Specifically, in step S104, after the connected domain marked later is connected to the connected domain marked earlier in the preset storage space by modifying the address pointing manner to merge the connected domain marked later into the connected domain marked earlier, the method further includes:
[0075] The pixel data of the pixel points merged into the same connected domain are recorded in the second storage unit in a manner pointing to adjacent pixels.
[0076] In step S104, after the data of the two connected domains is merged by modifying the pointing addresses, the pixel coordinates of the marked pixel points originally associated with the later-marked connected domain label (the pixel coordinates are represented by address pointing forms) are recorded in the storage location of the same connected domain in the second storage unit in a manner that points to adjacent pixels. This technical feature ensures that while the connected domains are merged (equivalent processing), the need for subsequent rescanning or searching to integrate the scattered pixel information is avoided, simplifying the data structure and improving the efficiency of subsequent traversal and differentiation of connected domains. This technical feature also allows pixel data from different connected domains to be stored sequentially in the same storage area, eliminating the need to reserve a large amount of temporary storage space for connected domain labels, thereby optimizing the use of storage resources.
[0077] Specifically, in step S105, all pixels in the image to be labeled are traversed to distinguish connected domains in the image to be labeled by different connected domain labels, and a connected domain labeling result corresponding to the image to be labeled is obtained, including:
[0078] Traverse all pixels in the image to be marked to mark all pixels with connected domain labels;
[0079] The pixel points whose addresses point to the connected connected domain labels are determined to be the same connected domain, and the connected domain labeling result corresponding to the image to be labeled is obtained.
[0080] In step S105, all pixels in the image to be marked are traversed in sequence according to the preset marking order. For each pixel, the connected domain label that the pixel should eventually be marked with is determined based on the pixel information stored in the FPGA, including pixel coordinates, pixel value, address pointing, and the connected domain label index after equivalent processing. This step ensures that each pixel in the image is assigned a clear connected domain label. Subsequently, the pixels whose addresses point to connected connected domain labels are identified and classified as the same connected domain. In this way, all pixels in the image that belong to the same connected domain are effectively identified and grouped, thereby obtaining the connected domain labeling result corresponding to the image to be marked, and clearly dividing the various connected areas in the image.
[0081] As can be seen from the above, the connected domain fast marking method obtains the image to be marked, and based on the pixel value of each pixel and the pixel value of the adjacent pixel, sequentially marks the pixel points in the image to be marked as connected domains to obtain marked pixel points, and stores the pixel information of the marked pixel points in the preset storage space of the FPGA in an address-pointing manner. Each time a pixel information is stored, the pixel information of the adjacent pixel points of the current marked pixel point is detected. When it is detected that the marked pixel points belonging to the same connected domain have different connected domain labels, the connected domain marked later is connected to the connected domain marked earlier in the preset storage space by modifying the address pointing manner, so as to merge the connected domain marked later into the connected domain marked earlier. In the marked connected domain, all pixels in the image to be marked are traversed to distinguish the connected domains in the image to be marked through different connected domain labels, and the connected domain labeling results corresponding to the image to be marked are obtained; thereby, the shortcomings of existing connected domain labeling algorithms, such as large storage space consumption and long algorithm processing time, are solved. By executing this real-time label adjustment process in FPGA, the parallel processing capability of hardware is utilized to accelerate the processing speed and reduce the execution time of the algorithm. At the same time, by processing equivalence relations in real time and combining data storage sections implemented by address pointing, the management and storage requirements of temporary labels are optimized, thereby improving the labeling efficiency of image connected domains and the utilization of storage resources.
[0082] refer to Figure 2 The present application provides a connected domain fast marking device for marking connected domains in an image, comprising:
[0083] Acquisition module 1, used to acquire the image to be marked;
[0084] A marking module 2 is used to mark the connected domains of the pixels in the image to be marked based on the pixel value of each pixel and the pixel values of adjacent pixels, to obtain marked pixels;
[0085] Storage module 3, used to store pixel information of marked pixels in a preset storage space of FPGA (Field Programmable Gate Array) in an address-directed manner;
[0086] The equivalent processing module 4 is configured to detect pixel information of adjacent pixels of the currently marked pixel each time pixel information is stored. When it is detected that the marked pixels belonging to the same connected domain have different connected domain labels, the connected domain marked later is connected to the connected domain marked earlier in a preset storage space by modifying the address pointing, so as to merge the connected domain marked later into the connected domain marked earlier.
[0087] The traversal module 5 is used to traverse all pixels in the image to be labeled, distinguish the connected domains in the image to be labeled by different connected domain labels, and obtain the connected domain labeling result corresponding to the image to be labeled.
[0088] The connected domain fast marking device stores the pixel information of marked pixels in an FPGA in an address-pointing manner. When it is detected that marked pixels belonging to the same connected domain have different connected domain labels, the later marked connected domain is merged into the earlier marked connected domain by modifying the address pointing, so as to distinguish the connected domains in the image to be marked by the different connected domain labels, and obtain the connected domain marking result corresponding to the image to be marked. The shortcomings of the existing connected domain marking algorithm, such as large storage space consumption and long algorithm processing time, are solved. By executing this real-time label adjustment process in the FPGA, the parallel processing capability of the hardware is utilized to accelerate the processing speed and reduce the execution time of the algorithm. At the same time, by instantly processing the equivalence relationship and combining the data storage structure realized by address pointing, the management and storage requirements of temporary labels are optimized, and the marking efficiency of the image connected domain and the utilization rate of storage resources are improved.
[0089] Specifically, when the acquisition module 1 is executed, it acquires the image to be marked, wherein the input image to be marked can be received through the FPGA, and the pixel points in the image to be marked are cached in the data buffer area inside the FPGA according to a preset buffer quantity (such as two rows of pixels), so that the connected domains of the pixels can be marked in sequence later, thereby improving the efficiency of connected domain marking.
[0090] Specifically, the marking module 2 sequentially marks connected domains of pixels in the image to be marked based on the pixel value of each pixel and the pixel values of adjacent pixels. When the marked pixels are obtained, the marking module 2 executes:
[0091] A1, according to the preset marking order, obtain the pixel values of the current pixel and the adjacent pixels in the image to be marked;
[0092] A2, based on the pixel value of the current pixel and the pixel values of the adjacent pixels, in accordance with the preset marking order, determines whether the current pixel is connected to the adjacent pixels; if not, a new connected domain label is marked for the current pixel; if so, the connected domain label of the current pixel is marked as the connected domain label of the adjacent pixels that was marked first;
[0093] A3: Determine the current pixel marked with the connected component label as a marked pixel.
[0094] When the marking module 2 is executed, it performs pixel scanning and preliminary labeling on the image to be marked through steps A1 to A3. The pixel values of the current pixel and its marked adjacent pixels are obtained in a preset order (for example, row by row scanning). The pixel value size of the current pixel and the pixel value size of the adjacent pixels are used to determine whether they meet the preset connectivity conditions. If they meet the conditions, the connected domain label of the first marked adjacent pixel is assigned to the current pixel; if not, a new connected domain label is assigned to the current pixel. In this way, the pixels in the image are sequentially assigned temporary connected domain labels, generating a set of marked pixels and their corresponding label information. This process systematically performs a preliminary connected domain division on the image based on local connectivity judgment, providing basic data for subsequent label equivalence processing.
[0095] Specifically, when the marking module 2 determines whether the current pixel point is connected to the adjacent pixel points according to the pixel value of the current pixel point and the pixel values of the adjacent pixel points in a preset marking order, it executes:
[0096] Determine whether the pixel value of the current pixel is within the preset background pixel range;
[0097] If yes, the current pixel is determined to be a background pixel, the marking operation is not performed, the next pixel is reselected as the current pixel, and the process returns to step A1;
[0098] If not, then according to the preset marking order, determine in turn whether the pixel values of the adjacent pixels of the current pixel are located in the preset background pixel range to determine whether the current pixel is connected to the adjacent pixels; when the adjacent pixels are not located in the preset background pixel range, determine that the current pixel and the adjacent pixels belong to the same connected domain.
[0099] When marking the connected domain of pixels in the image, marking module 2 is executed. For the pixel currently being processed, its pixel value is first obtained. This pixel value is compared with a preset background pixel value range. If the pixel value of the current pixel falls within this background pixel range, the pixel is determined to be a background pixel. Once it is determined to be a background pixel, no connectivity determination or connected domain label assignment operation is performed on the pixel, and the processing focus is directly shifted to the next pixel to be processed in the image. This avoids unnecessary calculations and processing of pixels in the background area, reducing the processing burden. Only when the pixel value of the current pixel is not within the preset background pixel range is it considered that the pixel may belong to a foreground connected domain. At this point, the subsequent steps are continued to check the pixel values of the current pixel's neighboring pixels (these neighboring pixels must have been processed and marked) in a preset scanning order (e.g., from left to right, from top to bottom). Determine whether the pixel values of adjacent pixels fall within the background pixel range. If a connected domain label is found for an adjacent pixel, the two pixels are considered connected and the current pixel is labeled with the same connected domain label as the adjacent pixel that was first labeled. If the pixel values of all adjacent pixels fall within the background pixel range (i.e., all adjacent pixels are unlabeled), a new connected domain label is assigned to the current pixel. This method excludes background pixels from the connected domain labeling process, improving processing efficiency. The preset background pixel range can be set according to actual needs.
[0100] Specifically, the pixel information includes the pixel coordinates, pixel values, connected domain labels and pointing addresses of the marked pixel points; wherein each pixel point corresponds to a connected domain label and a pointing address; the preset storage space includes a first storage unit and a second storage unit; the first storage unit is used to store the connected domain label and index information, and the index information includes the pixel point pointing address of the pixel point; the second storage unit is used to store the pixel coordinates, pixel values and pointing addresses of adjacent pixels.
[0101] Specifically, during execution, storage module 3 supports data management during the connected domain labeling process by constructing a specific FPGA storage structure. After a pixel is labeled and its connected domain label is determined, its pixel coordinates, pixel value, and connected domain label information need to be stored. The pixel coordinates are recorded, and the address of its storage location is updated to the index information of its connected domain label in the first storage unit. It is also associated with another pixel data belonging to the same connected domain in the second storage unit. For example, the head and tail addresses stored in the first storage unit point to the addresses of the memory areas in the second storage unit used to store the first and last pixels of the pixel data string. The second storage unit can be implemented as a lookup table indexed unidirectionally by storage address. Each pixel data entry contains a list that stores the pixel coordinates and address pointers to adjacent data belonging to the same connected domain in the second storage unit. If different labels are found, label equivalence processing is required (for example, the connected domain marked later is connected to the connected domain marked earlier by modifying the address pointer). This connected domain merging can be achieved by modifying the address pointing or index information. For example, in the first storage unit, the address pointing of the pixel coordinates originally belonging to the later-marked number is transferred to the index information of the earlier-marked number. At the same time, in the second storage unit, the first pixel data of the later-marked number is connected to the last pixel data of the earlier-marked number through the address pointing, thereby realizing the merging of the connected domain of the later-marked number with the connected domain of the earlier-marked number without moving the actual pixel coordinate data or performing a large amount of data transfer operations, thereby improving processing efficiency, reducing data transfer overhead, and solving the problems of large storage space consumption and long processing time in existing methods.
[0102] When storage module 3 is executed, the data of all marked pixels is stored in the same storage area in the order in which they were processed. Pixels in the same connected domain are linked by pointing addresses. Therefore, pixel data can be stored using limited storage space, eliminating the need to reserve large amounts of storage space for an unknown number of connected domains or their sizes, thereby improving storage efficiency.
[0103] like Figure 4 As shown, Figure 4 is a structural diagram of the first storage unit, wherein: is the connected domain label, q is the total number of connected domains, the arrow represents the index information, A is the connectivity flag, which is used to mark whether the current connected domain label is valid, B is the connectivity flag, which is used to mark equivalent connected domain labels. The address pointing corresponding to the pixel coordinates of the marked pixel point is used to search for all the pixel points of the same connected domain in the first storage unit; or, in the first storage unit, only the address pointing corresponding to the first pixel point and the last pixel point of the same connected domain is recorded, and the position of the last pixel point in the second storage unit can be accessed through the address pointing, and then the previous pixel data is searched in the second storage unit according to the pointing address of the adjacent pixel data stored in the pixel data, until the first pixel of the same connected domain is found, thereby finding all the pixel points of the same connected domain in the second storage unit.
[0104] like Figure 5 As shown, Figure 5 is a schematic structural diagram of the second storage unit, wherein: is the pixel value, and the arrows indicate the corresponding information. is the pixel coordinate. In the second storage unit, the pixel points of the same connected domain form a data string in the form of address pointing.
[0105] Specifically, when the equivalent processing module 4 is executed, each time a pixel information is stored, the logic inside the FPGA will immediately start the detection mechanism and scan the currently stored label situation to detect the pixel information of the adjacent pixels of the currently marked pixel. If it is found that the pixels belonging to the same connected domain are assigned different connected domain labels, this indicates that these labels are equivalent and need to be merged. Determine which label is assigned first and which is assigned later, and connect the index information corresponding to the two connected domains by modifying the address pointing to merge the connected domain marked later into the connected domain marked earlier. This real-time equivalent processing process is completed directly at the FPGA hardware level by modifying the address pointing step, avoiding the delay of transmitting the data out for software processing and then transmitting it back, and also avoiding the time-consuming problem of multiple full-image scans to solve the label equivalence, thereby greatly improving the processing speed. In this way, the equivalence relation of connected domains is solved dynamically and in real time during the labeling process, so that the pixel data of different connected domains can be stored sequentially in the same storage area. There is no need to reserve a large amount of temporary storage space for the connected domain labels, which reduces the dependence on a large amount of temporary storage space and optimizes the use of storage resources.
[0106] In some optional embodiments, the later-assigned labels can be adjusted to the earlier-assigned labels. After the connected domain labels are adjusted, the pixel coordinates (represented as address pointers) of the marked pixels originally associated with the later-assigned connected domain labels are retrieved from the index information corresponding to the later-assigned connected domain labels and transferred to the index information corresponding to the earlier-assigned connected domain labels. This technical feature ensures that while connected domains are merged (equal processing), it avoids the need for subsequent rescanning or searching to integrate scattered pixel information, simplifies the data structure, and improves the efficiency of subsequent traversal and identification of connected domains.
[0107] Specifically, after the equivalent processing module 4 connects the later marked connected domain with the earlier marked connected domain in the preset storage space by modifying the address pointing to merge the later marked connected domain into the earlier marked connected domain, it further executes:
[0108] The pixel data of the pixel points merged into the same connected domain are recorded in the second storage unit in a manner pointing to adjacent pixels.
[0109] During execution, equivalence processing module 4, after merging the data of two connected domains by modifying the pointing addresses, records the pixel coordinates (represented by the address pointing form) of the marked pixel points originally associated with the later-marked connected domain label to the storage location of the same connected domain in the second storage unit, using the pixel coordinates as a pointer to an adjacent pixel. This technical feature ensures that while the connected domains are merged (equivalence processing), the need for subsequent rescanning or searching to integrate the scattered pixel information is avoided, simplifying the data structure and improving the efficiency of subsequent traversal and differentiation of connected domains. This technical feature also allows pixel data from different connected domains to be stored sequentially within the same storage area, eliminating the need to reserve a large amount of temporary storage space for connected domain labels and optimizing the use of storage resources.
[0110] Specifically, when the traversal module 5 traverses all pixels in the image to be labeled to distinguish the connected domains in the image to be labeled by different connected domain labels and obtains the connected domain labeling result corresponding to the image to be labeled, it executes:
[0111] Traverse all pixels in the image to be marked to mark all pixels with connected domain labels;
[0112] The pixel points whose addresses point to the connected connected domain labels are determined to be the same connected domain, and the connected domain labeling result corresponding to the image to be labeled is obtained.
[0113] When the traversal module 5 is executed, it traverses all the pixels in the image to be marked in sequence according to the preset marking order. For each pixel, the connected domain label that the pixel should eventually be marked is determined based on the pixel information stored in the FPGA, including pixel coordinates, pixel value, address pointing and connected domain label index after equivalent processing. This step ensures that each pixel in the image is assigned a clear connected domain label. Subsequently, the pixels whose addresses point to connected connected domain labels are identified and classified as the same connected domain. In this way, all pixels in the image belonging to the same connected domain are effectively identified and grouped, thereby obtaining the connected domain labeling result corresponding to the image to be marked, and clearly dividing the various connected areas in the image.
[0114] As can be seen from the above, the connected domain fast marking device obtains the image to be marked, and based on the pixel value of each pixel point and the pixel value of the adjacent pixel points, sequentially marks the pixel points in the image to be marked as connected domains to obtain marked pixel points, and stores the pixel information of the marked pixel points in the preset storage space of the FPGA in an address-pointing manner. Each time a pixel information is stored, the pixel information of the adjacent pixel points of the current marked pixel point is detected. When it is detected that the marked pixel points belonging to the same connected domain have different connected domain labels, the connected domain marked later is connected to the connected domain marked earlier in the preset storage space by modifying the address pointing manner, so as to merge the connected domain marked later into the connected domain marked earlier. In the marked connected domain, all pixels in the image to be marked are traversed to distinguish the connected domains in the image to be marked through different connected domain labels, and the connected domain labeling results corresponding to the image to be marked are obtained; thereby, the shortcomings of existing connected domain labeling algorithms, such as large storage space consumption and long algorithm processing time, are solved. By executing this real-time label adjustment process in FPGA, the parallel processing capability of hardware is utilized to accelerate the processing speed and reduce the execution time of the algorithm. At the same time, by instantly processing equivalence relations and combining the data storage structure implemented by address pointing, the management and storage requirements of temporary labels are optimized, thereby improving the labeling efficiency of image connected domains and the utilization of storage resources.
[0115] Please refer to Figure 3 , Figure 3This is a structural diagram of an electronic device provided in an embodiment of the present application. The present application provides an electronic device, including: a processor 301 and a memory 302. The processor 301 and the memory 302 are interconnected and communicate with each other via a communication bus 303 and / or other forms of connection mechanisms (not shown). The memory 302 stores a computer program executable by the processor 301. When the electronic device is running, the processor 301 executes the computer program to execute the connected domain fast labeling method in any optional implementation of the above embodiment to achieve the following functions: obtain an image to be labeled, and based on the pixel value of each pixel and the pixel values of adjacent pixels, sequentially label the pixels in the image to be labeled. Connected domain marking, obtains marked pixel points, and stores the pixel information of the marked pixel points in the preset storage space of FPGA in an address-pointing manner. Each time a pixel information is stored, the pixel information of the adjacent pixel points of the currently marked pixel point is detected. When it is detected that the marked pixel points belonging to the same connected domain have different connected domain labels, the later marked connected domain is connected with the earlier marked connected domain in the preset storage space by modifying the address pointing manner, so as to merge the later marked connected domain into the earlier marked connected domain, traverse all pixel points in the image to be marked, and distinguish the connected domains in the image to be marked by different connected domain labels to obtain the connected domain marking result corresponding to the image to be marked.
[0116] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the connected domain fast labeling method in any optional implementation of the above embodiment is executed to achieve the following functions: obtaining an image to be labeled, and based on the pixel value of each pixel point and the pixel value of the adjacent pixel points, sequentially labeling the pixels in the image to be labeled as connected domains to obtain labeled pixels; storing the pixel information of the labeled pixels in a preset storage space of an FPGA in an address-pointing manner; each time a pixel information is stored, detecting the pixel information of the adjacent pixels of the currently labeled pixel point; when it is detected that the labeled pixels belonging to the same connected domain have different connected domain labels, connecting the later labeled connected domain with the earlier labeled connected domain in the preset storage space in a modified address-pointing manner to merge the later labeled connected domain into the earlier labeled connected domain; traversing all pixels in the image to be labeled to distinguish the connected domains in the image to be labeled by different connected domain labels, and obtaining a connected domain labeling result corresponding to the image to be labeled. The storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0117] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0118] In addition, the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, and may be located in one place or distributed across multiple network units. Some or all of these units may be selected based on actual needs to achieve the purpose of the solution of this embodiment.
[0119] Furthermore, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0120] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any actual relationship or order between these entities or operations.
[0121] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A connected domain fast marking method for marking connected domains in an image, characterized in that: Including steps: Get the image to be marked; Based on the pixel value of each pixel and the pixel values of adjacent pixels, the pixels in the image to be marked are marked in connected domains to obtain marked pixels; Storing the pixel information of the marked pixel point in a preset storage space of the FPGA in an address-pointing manner; Each time pixel information is stored, pixel information of adjacent pixels of the currently marked pixel is detected. When it is detected that the marked pixels belonging to the same connected domain have different connected domain labels, the connected domain marked later is connected to the connected domain marked earlier in the preset storage space by modifying the address pointing, so as to merge the connected domain marked later into the connected domain marked earlier. Traversing all pixels in the image to be labeled to distinguish connected domains in the image to be labeled by using different connected domain labels, and obtaining connected domain labeling results corresponding to the image to be labeled; Based on the pixel value of each pixel and the pixel values of adjacent pixels, the pixels in the to-be-marked image are sequentially marked as connected domains to obtain marked pixels, including: A1, obtaining pixel values of a current pixel and adjacent pixels in the image to be marked according to a preset marking order; A2, based on the pixel value of the current pixel and the pixel values of the adjacent pixels, in accordance with the preset marking order, sequentially determines whether the current pixel is connected to the adjacent pixels; if not, marks a new connected domain label for the current pixel; if so, marks the connected domain label of the current pixel as the connected domain label of the first marked adjacent pixel; A3, determining the current pixel point marked with the connected component label as a marked pixel point; According to the pixel value of the current pixel and the pixel values of the adjacent pixels, in accordance with the preset marking order, determining whether the current pixel is connected to the adjacent pixels includes: Determine whether the pixel value of the current pixel is within the preset background pixel range; If yes, the current pixel is determined to be a background pixel, the marking operation is not performed, the next pixel is reselected as the current pixel, and the process returns to step A1; If not, then according to the preset marking order, determine in turn whether the pixel values of the adjacent pixels of the current pixel are located in the preset background pixel range to determine whether the current pixel is connected to the adjacent pixels; when the adjacent pixels are not located in the preset background pixel range, determine that the current pixel and the adjacent pixels belong to the same connected domain.
2. The method for fast marking of connected domains according to claim 1, characterized in that: The pixel information includes pixel coordinates, pixel values, connected domain labels and pointing addresses of marked pixel points; wherein each pixel point corresponds to a connected domain label and a pointing address.
3. The method for fast marking connected domains according to claim 2, characterized in that: The preset storage space includes a first storage unit and a second storage unit; the first storage unit is used to store the connected domain label and index information, and the index information includes the pixel point pointing address of the pixel point; the second storage unit is used to store pixel coordinates, pixel values and the pointing address of adjacent pixels.
4. The method for fast marking connected domains according to claim 3, characterized in that: After connecting the later marked connected domain with the earlier marked connected domain in the preset storage space by modifying the address pointing manner so as to merge the later marked connected domain into the earlier marked connected domain, the method further includes: The pixel data of the pixel points merged into the same connected domain are recorded in the second storage unit in a manner pointing to adjacent pixels.
5. The method for fast marking of connected domains according to claim 1, characterized in that: Traversing all pixels in the image to be labeled to distinguish connected domains in the image to be labeled by different connected domain labels, and obtaining connected domain labeling results corresponding to the image to be labeled, including: Traversing all pixels in the image to be marked to mark all pixels with connected domain labels; The pixel points whose addresses point to connected connected domain labels are determined to be the same connected domain, and a connected domain labeling result corresponding to the image to be labeled is obtained.
6. A connected domain fast marking device for marking connected domains in an image, characterized in that: include: An acquisition module, used to acquire the image to be marked; a marking module, configured to mark connected domains of pixels in the image to be marked in sequence based on the pixel value of each pixel and the pixel values of adjacent pixels, to obtain marked pixels; A storage module, configured to store the pixel information of the marked pixel points in a preset storage space of the FPGA in an address-pointing manner; an equivalent processing module configured to detect pixel information of adjacent pixels of a currently marked pixel each time pixel information is stored, and when it is detected that marked pixels belonging to the same connected domain have different connected domain labels, connect the later marked connected domain with the earlier marked connected domain in the preset storage space by modifying the address pointing, so as to merge the later marked connected domain into the earlier marked connected domain; a traversal module, configured to traverse all pixels in the image to be labeled, distinguish connected domains in the image to be labeled by different connected domain labels, and obtain connected domain labeling results corresponding to the image to be labeled; The marking module is used to mark the connected domains of the pixels in the image to be marked in sequence based on the pixel value of each pixel and the pixel values of adjacent pixels to obtain marked pixels, including: A1, obtaining pixel values of a current pixel and adjacent pixels in the image to be marked according to a preset marking order; A2, based on the pixel value of the current pixel and the pixel values of the adjacent pixels, in accordance with the preset marking order, sequentially determines whether the current pixel is connected to the adjacent pixels; if not, marks a new connected domain label for the current pixel; if so, marks the connected domain label of the current pixel as the connected domain label of the first marked adjacent pixel; A3, determining the current pixel point marked with the connected component label as a marked pixel point; According to the pixel value of the current pixel and the pixel values of the adjacent pixels, in accordance with the preset marking order, determining whether the current pixel is connected to the adjacent pixels includes: Determine whether the pixel value of the current pixel is within the preset background pixel range; If yes, the current pixel is determined to be a background pixel, the marking operation is not performed, the next pixel is reselected as the current pixel, and the process returns to step A1; If not, then according to the preset marking order, determine in turn whether the pixel values of the adjacent pixels of the current pixel are located in the preset background pixel range to determine whether the current pixel is connected to the adjacent pixels; when the adjacent pixels are not located in the preset background pixel range, determine that the current pixel and the adjacent pixels belong to the same connected domain.
7. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a computer program executable by the processor, and when the processor executes the computer program, the method runs the steps of the method for fast marking connected domains according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for fast marking connected components according to any one of claims 1 to 5 are executed.
Citation Information
Patent Citations
Maximum connected domain marking method, target tracking method, and augmented reality / virtual reality device
CN107833238A
Connected domain extraction method and device
CN108345888A