Block analysis method and system based on stroke code binaryzation and medium

By introducing a stroke code binarization method, the block analysis process is optimized, and the problems of high data storage burden and low efficiency in traditional methods are solved, and efficient block counting and feature analysis are achieved, which is suitable for industrial fields.

CN120495384AActive Publication Date: 2025-08-15HANGZHOU HUICUI INTELLIGENT TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510990247.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-18
Publication Date
2025-08-15
Estimated Expiration
2045-07-18

AI Technical Summary

Technical Problem

The prior art has problems such as large data storage burden, frequent memory operations and low efficiency in the binary processing of block counting algorithms, especially for large-size image processing.

Method used

Using a method based on stroke code binarization, a pixel block sequence is obtained, a stroke code sequence is generated using a stroke code structure, and dynamically merged the connection area using and searching the set, block features are calculated and visual output is performed, replacing the traditional binary image generation process.

Benefits of technology

It significantly improves the efficiency of block analysis, reduces memory usage, and reduces the execution time from 100 milliseconds to about 10 milliseconds, providing rich block information to meet the needs of industrial applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120495384A_ABST
    Figure CN120495384A_ABST
Patent Text Reader

Abstract

The invention discloses a block analysis method and system based on stroke code binaryzation and a medium. The method comprises the following steps: acquiring an original image to obtain a pixel block sequence; processing the pixel block sequence based on a preset stroke coding structure to obtain a stroke code sequence; dynamically combining the connected regions by using a union-check set based on the stroke code sequence to obtain a connected domain set; and block feature calculation is carried out on the basis of the connected domain set to obtain an analysis result, the analysis result is visually output, block feature calculation comprises calculation of geometric features, and the geometric features at least comprise the minimum enclosing rectangle, the target diameter, the roundness and the rectangularity. According to the method, the binary process is optimized by introducing the stroke code and parallel computing, the block analysis efficiency and practicability are remarkably improved, meanwhile, rich block information is provided, and the method is suitable for various application scenes in the industrial field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine vision and image processing, and more specifically to a block analysis method, system and medium based on run-length code binarization. Background Art

[0002] In the field of machine vision, block counting algorithms, as a fundamental and key technology, are widely used in various scenarios. However, current algorithms have certain limitations in the binarization process.

[0003] Specifically, the binarization process often directly generates a new binary image, which not only increases the unnecessary data storage burden but also involves frequent memory allocation and release operations, greatly affecting the overall operating efficiency of the algorithm. Its performance in practical applications still has a lot of room for improvement. The specific shortcomings are as follows: 1. The data storage burden is heavy. The binary image data generated by traditional methods is huge and contains a large amount of redundant data. 2. Frequent memory operations, where frequent memory allocation and release operations reduce the efficiency of the algorithm; 3. Low efficiency. Especially for large-size images (such as 10,000×10,000), the traditional method takes a long time to execute (about 100 milliseconds), which is difficult to meet the needs of efficient processing. Summary of the Invention

[0004] The purpose of the present invention is to provide a block analysis method, system and medium based on run-length code binarization, so as to solve the shortcomings of the prior art described above.

[0005] A first aspect of the present invention provides a block analysis method based on run-length code binarization, comprising the following steps: Obtain the original image to obtain a pixel block sequence; Processing the pixel block sequence based on a preset run length coding structure to obtain a run length code sequence; Dynamically merge connected regions using a union-find method based on the run-length code sequence to obtain a connected region set; The block feature calculation is performed based on the connected domain set to obtain an analysis result, and the analysis result is output visually, wherein the block feature calculation includes calculating geometric features, and the geometric features include at least a minimum circumscribed rectangle, a target diameter, a roundness, and a rectangularity.

[0006] In this solution, obtaining the original image to obtain a pixel block sequence specifically includes: Obtain an original image, wherein the original image includes an H×W matrix, where H is the image height and W is the image length; Divide the original image into pixel blocks, wherein the fixed length of the division is W; The pixel blocks after the block processing are extracted to obtain the pixel block sequence P.

[0007] In this solution, the pixel block sequence is processed based on a preset run length coding structure to obtain a run length code sequence, specifically including: Generating a bit mask based on the pixel block sequence, wherein the generated bit mask specifically includes a binary sequence of length W; Processing is performed based on the bit mask to generate a run length code, and global merging is performed based on the run length codes of all rows to obtain the run length code sequence.

[0008] In this solution, the processing based on the bit mask to generate the run code, and the global merging based on the run codes of all rows to obtain the run code sequence specifically includes: The state machine is maintained based on the bit mask and the position data of the current pixel block in the image, and the state variables include the current stroke start column and the current stroke end column, wherein, Process the mask based on the pixel block type. If the bit mask is entirely background blocks, close the current run; if the bit mask is entirely foreground blocks, open a new run; if the bit mask is a mixed block, scan the mask bit by bit and dynamically adjust the run open or closed according to the current mask state; The unfinished run at the end of the row is forcibly closed and then globally merged to obtain the run code sequence.

[0009] In this solution, the method of dynamically merging connected regions using a union-find method based on the run-length code sequence to obtain a connected region set specifically includes: Initializing each run code in the run code sequence as a union-find independent node, wherein the region attributes of the independent node include boundary coordinates, zero-order moment, first-order moment and a run code endpoint set; Adjacent run codes are detected based on a preset connectivity rule, wherein the root nodes of the adjacent run codes are compared, and if the root nodes are different, they are merged, wherein the merging includes updating boundary coordinates, accumulating moment values, and merging endpoint sets; After all the run codes are detected, they are merged, compressed, and the structure tree is searched to obtain the connected domain set.

[0010] In this solution, the block feature calculation based on the connected domain set is performed to obtain an analysis result, and the analysis result is output visually, specifically including: Calculate the area, center of mass, minimum circumscribed rectangle, target radius, roundness and rectangularity of the block based on the connected domain set; Based on the calculated analysis results as the feature set corresponding to each connected domain; Visual output is performed based on the feature set, including drawing boundaries, centroids and minimum bounding rectangles on the original image, and generating a structured report.

[0011] A second aspect of the present invention further provides a block analysis system based on run-length code binarization, comprising a memory and a processor. The memory includes a block analysis method program based on run-length code binarization. When the block analysis method program based on run-length code binarization is executed by the processor, the following steps are implemented: Obtain the original image to obtain a pixel block sequence; Processing the pixel block sequence based on a preset run length coding structure to obtain a run length code sequence; Dynamically merge connected regions using a union-find method based on the run-length code sequence to obtain a connected region set; The block feature calculation is performed based on the connected domain set to obtain an analysis result, and the analysis result is output visually, wherein the block feature calculation includes calculating geometric features, and the geometric features include at least a minimum circumscribed rectangle, a target diameter, a roundness, and a rectangularity.

[0012] In this solution, obtaining the original image to obtain a pixel block sequence specifically includes: Obtain an original image, wherein the original image includes an H×W matrix, where H is the image height and W is the image length; Divide the original image into pixel blocks, wherein the fixed length of the division is W; The pixel blocks after the block processing are extracted to obtain the pixel block sequence P.

[0013] In this solution, the pixel block sequence is processed based on a preset run length coding structure to obtain a run length code sequence, specifically including: Generating a bit mask based on the pixel block sequence, wherein the generated bit mask specifically includes a binary sequence of length W; Processing is performed based on the bit mask to generate a run length code, and global merging is performed based on the run length codes of all rows to obtain the run length code sequence.

[0014] In this solution, the processing based on the bit mask to generate the run code, and the global merging based on the run codes of all rows to obtain the run code sequence specifically includes: The state machine is maintained based on the bit mask and the position data of the current pixel block in the image, and the state variables include the current stroke start column and the current stroke end column, wherein, Process the mask based on the pixel block type. If the bit mask is entirely background blocks, close the current run; if the bit mask is entirely foreground blocks, open a new run; if the bit mask is a mixed block, scan the mask bit by bit and dynamically adjust the run open or closed according to the current mask state; The unfinished run at the end of the row is forcibly closed and then globally merged to obtain the run code sequence.

[0015] In this solution, the method of dynamically merging connected regions using a union-find method based on the run-length code sequence to obtain a connected region set specifically includes: Initializing each run code in the run code sequence as a union-find independent node, wherein the region attributes of the independent node include boundary coordinates, zero-order moment, first-order moment and a run code endpoint set; Adjacent run codes are detected based on a preset connectivity rule, wherein the root nodes of the adjacent run codes are compared, and if the root nodes are different, they are merged, wherein the merging includes updating boundary coordinates, accumulating moment values, and merging endpoint sets; After all the run codes are detected, they are merged, compressed, and the structure tree is searched to obtain the connected domain set.

[0016] In this solution, the block feature calculation based on the connected domain set is performed to obtain an analysis result, and the analysis result is output visually, specifically including: Calculate the area, center of mass, minimum circumscribed rectangle, target radius, roundness and rectangularity of the block based on the connected domain set; Based on the calculated analysis results as the feature set corresponding to each connected domain; Visual output is performed based on the feature set, including drawing boundaries, centroids and minimum bounding rectangles on the original image, and generating a structured report.

[0017] The third aspect of the present invention provides a computer-readable storage medium, which includes a block analysis method program based on run-length code binarization of a machine. When the block analysis method program based on run-length code binarization is executed by a processor, the steps of a block analysis method based on run-length code binarization as described in any one of the above items are implemented.

[0018] The present invention discloses a block analysis method, system, and medium based on run-length code binarization. By introducing run-length code and parallel computing, the binarization process is optimized, significantly improving the efficiency and practicality of block analysis. It also provides rich block information and is suitable for various application scenarios in the industrial field. Specific beneficial effects are as follows: 1. Efficiency is significantly improved. For a 10,000×10,000 image, the execution time is reduced from 100 milliseconds to approximately 10 milliseconds, a 10-fold increase in efficiency.

[0019] 2. Reduced memory usage: The run-length code structure replaces the traditional binary image, reducing data redundancy and memory operations.

[0020] 3. Rich in functions, it provides a variety of block properties (such as area, bounding rectangle, roundness, etc.) to meet the needs of industrial applications.

[0021] 4. High flexibility, supports ROI and mask ROI functions, and can select or exclude specific areas according to needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A step diagram of a block analysis method based on run-length code binarization according to the present invention is shown; Figure 2 A flow chart of a block analysis method based on run-length code binarization according to the present invention is shown; Figure 3 The original image of a block analysis method based on run-length code binarization of the present invention is shown; Figure 4 The output image of a block analysis method based on run-length code binarization according to the present invention is shown; Figure 5 A block diagram of a block analysis system based on run-length code binarization according to the present invention is shown. DETAILED DESCRIPTION

[0023] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, in the absence of conflict, the embodiments of the present application and the features therein can be combined with each other.

[0024] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the scope of protection of the present invention is not limited to the specific embodiments disclosed below.

[0025] Figure 1 A step diagram of a block analysis method based on run-length code binarization of the present application is shown.

[0026] like Figure 1 As shown, the present application discloses a block analysis method based on run-length code binarization, comprising the following steps: S102, obtaining an original image to obtain a pixel block sequence; S104, processing the pixel block sequence based on a preset run length coding structure to obtain a run length code sequence; S106, dynamically merging connected regions using a union-find based on the run-length code sequence to obtain a connected region set; S108: Calculate block features based on the connected domain set to obtain analysis results, and visualize and output the analysis results.

[0027] It should be noted that, in this embodiment, Figure 2 As shown, it is a flow chart of a block analysis method based on run-length code binarization. Specifically, the original image to be processed is loaded and quickly binarized. The binarization processing includes parallelization and instruction set acceleration processing using a preset run-length coding structure. A fixed-length pixel block is loaded each time, and a run-length code is generated through a bit mask and a state variable to obtain a run-length code sequence. The full background block, the full foreground block and the mixed block are obtained through efficient processing, and boundary processing is performed at the same time, that is, the tail pixel is processed point by point to ensure that the run-length code is closed.

[0028] After obtaining the run code sequence, a connected domain analysis is performed based on a union-find algorithm. This involves storing node and region attributes (e.g., coordinates, moments, and run code endpoints), processing the region nodes corresponding to the run code row by row, and dynamically merging adjacent run codes to update the region attributes to obtain a connected domain set. Finally, block information is calculated based on the connected domain set. Specific calculations include attributes such as area, centroid, minimum bounding rectangle, target radius, roundness, and rectangularity. After the calculated analysis results are obtained, they are visualized. When displaying block information, ROI (Region of Interest) and ROI masking functions are supported to output detection results. The ROI setting is intended to improve algorithm efficiency and accuracy and avoid ineffective calculations. The target radius is the Feret radius, which describes the maximum projection length of a block and is defined as the maximum Euclidean distance between any two points on the block boundary. It also quantifies the maximum size or extension direction of an object (e.g., determining the major axis direction in particle analysis). In this embodiment, the farthest point pair is calculated directly using the run code endpoint set of the connected domain, avoiding scanning all pixels.

[0029] According to an embodiment of the present invention, obtaining the original image to obtain a pixel block sequence specifically includes: Obtain an original image, wherein the original image includes an H×W matrix, where H is the image height and W is the image length; Divide the original image into pixel blocks, wherein the fixed length of the division is W; The pixel blocks after the block processing are extracted to obtain the pixel block sequence P.

[0030] It should be noted that, in this embodiment, Figure 3As shown, the original image is obtained, and efficient conversion of the grayscale original image to the binary run length encoding RLE is achieved. In this embodiment, a data processing strategy of parallel computing and instruction set block division is adopted, and each row of the image is processed by parallelization. For each row of the original image, the instruction set is used for acceleration, and a pixel block of a fixed length W is loaded each time. W is the maximum number of data that the instruction set can process at one time. The instruction set reads the pixel blocks after block processing at one time to obtain the pixel block sequence P, which is specifically expressed as: , is the first pixel block, For the second pixel block, For the pixel blocks.

[0031] According to an embodiment of the present invention, the processing of the pixel block sequence based on a preset run length coding structure to obtain a run length code sequence specifically includes: Generating a bit mask based on the pixel block sequence, wherein the generated bit mask specifically includes a binary sequence of length W; Processing is performed based on the bit mask to generate a run length code, and global merging is performed based on the run length codes of all rows to obtain the run length code sequence.

[0032] It should be noted that, in this embodiment, the pixel block sequence For example, a bit mask is generated based on the comparison between the pixel and the threshold: ,in or Determined according to the binarization requirements, such as The condition defines the image foreground as grayscale less than or equal to a threshold The part of , thereby obtaining a binary sequence of length W corresponds to the bit mask B, and a run length code is generated based on the bit mask B and the block position (r, c), where r is the row number and c is the block start column.

[0033] According to an embodiment of the present invention, the processing based on the bit mask to generate a run code, and performing global merging based on the run codes of all rows to obtain the run code sequence, specifically includes: The state machine is maintained based on the bit mask and the position data of the current pixel block in the image, and the state variables include the current stroke start column and the current stroke end column, wherein, Process the mask based on the pixel block type. If the bit mask is entirely background blocks, close the current run; if the bit mask is entirely foreground blocks, open a new run; if the bit mask is a mixed block, scan the mask bit by bit and dynamically adjust the run open or closed according to the current mask state; The unfinished run at the end of the row is forcibly closed and then globally merged to obtain the run code sequence.

[0034] It should be noted that, in this embodiment, a state variable s is defined to represent the current run start position, and the block information is processed into a run code according to the mask result: ①: Full background block ( ); like , that is, there is a trip in progress, generate the trip segment [s, e] and reset s=-1, where e is the previous position of the block; ②: Full foreground block ( ); like , set s to the block start position and continue processing to the next block; ③:Mixed block( ); For each block index , handle according to different situations: i: when and : Set s to the image x coordinate corresponding to index i; ii: When and : Set e to the image x coordinate corresponding to index i to generate the travel segment and reset ; So far, the mask processing efficiency of data in this embodiment is relatively high, because the Only bit operations need to be performed on B, and ①② do not need to compare pixels point by point as in the general method. At the same time, the tail pixels that are less than the length of W are processed point by point, and the unfinished stroke segment is forcibly closed at the end of the line.

[0035] Accordingly, after the row is determined, the travel code list of the current row is , Finally, the run codes of all rows are combined into a global column to obtain the run code sequence of the entire image of the original image Specifically, the run code is a horizontal line segment and can be represented as follows: ; Among them, r is the row number of the travel code, s and e represent the start and end columns of the travel code, Indicates the first stroke code of the starting column of the current row. Indicates the second stroke code of the starting column of the current row. Indicates the first stroke code of the current row end column. Indicates the second run length code of the current row and the end column. The area covered by several non-overlapping run length codes can correspond one-to-one with the foreground area of the binary image, avoiding the large amount of redundant data generated in the process of generating the binary image and the burden caused by frequent memory allocation and release operations, thereby improving the efficiency of data search and storage.

[0036] According to an embodiment of the present invention, dynamically merging connected regions using a union-find set based on the run-length code sequence to obtain a connected domain set specifically includes: Initializing each run code in the run code sequence as a union-find independent node, wherein the region attributes of the independent node include boundary coordinates, zero-order moment, first-order moment and a run code endpoint set; Adjacent run codes are detected based on a preset connectivity rule, wherein the root nodes of the adjacent run codes are compared, and if the root nodes are different, they are merged, wherein the merging includes updating boundary coordinates, accumulating moment values, and merging endpoint sets; After all the run codes are detected, they are merged, compressed, and the structure tree is searched to obtain the connected domain set.

[0037] It should be noted that, in this embodiment, specifically, each run code {r, s, e} is initialized as an independent node, storing region attributes (boundaries, moments, endpoints, etc.), wherein each node stores the parent node index and region attributes, and uses path compression to optimize search efficiency, wherein the region attributes include: ① minimum / maximum row and column coordinates ② Zero-order moment and first-order moment , ; ③ The left and right endpoint coordinates of all travel codes in the area ;④Record the last merged run length encoding index.

[0038] Furthermore, we traverse the run code line by line, create an independent node for each run code line and initialize the region attributes: For any run code , if it is expressed as , that is, the run code of the rth row, the starting column is s, and the ending column is r, then: ; ; ; ; Among them, r is the row number of the travel code, s and e represent the start and end columns of the travel code, is the minimum row coordinate, is the maximum row coordinate, is the minimum column coordinate, is the maximum column coordinate, is the zero-order moment, and is the first-order moment, and the left and right endpoint coordinates of all run codes in the region and the run code index of the last merge refer to itself.

[0039] Furthermore, we traverse the run codes row by row and initialize the region nodes corresponding to the run codes. We only check whether the run code i is adjacent to a run code j in the previous row (8-connected), that is, whether: ; If they are adjacent, merge the root nodes where the two travel codes are located: the regional node will be the travel code The root node of the node Update to travel code The root node At the same time, update the travel code The regional attributes of the root node: , ; , ; ; ; ; in, For the travel code The root node of the node, For the travel code The root node of the region, the left and right endpoint coordinates of all the trip codes in the region are directly merged; the last merged trip code index is updated according to the newly traversed trip code, and the final connected domain set is ,Each Blob contains: a list of merged trip codes and region attributes (area, boundary, centroid, endpoint set, etc.).

[0040] According to an embodiment of the present invention, calculating block features based on the connected domain set to obtain analysis results and visually outputting the analysis results specifically includes: Calculate the area, center of mass, minimum circumscribed rectangle, target radius, roundness and rectangularity of the block based on the connected domain set; Based on the calculated analysis results as the feature set corresponding to each connected domain; Visual output is performed based on the feature set, including drawing boundaries, centroids and minimum bounding rectangles on the original image, and generating a structured report.

[0041] It should be noted that in this embodiment, during / after the process of connecting the domains, various information of the blocks is calculated, including: area: ; Center of mass: , ; in, are the coordinates of the center of mass, is the pixel block area, is the zero-order moment, and is the first-order moment, is the zero-order moment of the entire block, which is equal to the sum of the zero-order moments of all the run codes it contains. 、 are the first-order moments of the entire block about x and y, respectively, which are equal to the sum of the corresponding first-order moments of all the run codes it contains.

[0042] Minimum enclosing rectangle: Equivalent to the minimum bounding rectangle containing all run-code endpoints: ; in is a connected domain, It is the endpoint set of the travel code corresponding to the connected domain. In actual application, it is calculated by calling, that is, recording the set of travel code endpoints and calling the "cv::minAreaRect" interface of OpenCV to calculate it.

[0043] Target radius (Feret radius): It is defined as the distance between the two farthest points inside the block, which is equal to the distance between the two farthest points at the endpoints of the calculated run code: ; Roundness: The circumscribed circle of a block is defined as the smallest circle containing the block with the center of the block as the center. The radius can be determined by simply calculating the maximum distance from the endpoint of the run code to the center of mass. This embodiment avoids the high time consumption in the process of calculating the fitted circle. The definition is as follows: ; When the block converges to the standard circle, the roundness will converge to "1", which meets the requirement of using roundness as a measure of whether the block is close to a circle in each scene. represents the area of the block, It represents the area of the smallest circle containing the run length code with the center of mass as the center. Its radius is equal to the farthest distance from the end point of the run length code to the center of mass, which is convenient for calculation.

[0044] Rectangularity: ; When the block converges to a standard rectangle, the rectangularity will converge to "1", which meets the requirement of using rectangularity as a measure of whether the block is close to a rectangle in each scene. represents the area of the block, Represents the minimum enclosing rectangle area of a block.

[0045] Furthermore, when visual output is performed based on the feature set, such as Figure 4 As shown, the block information is displayed in the graphical interface, and ROI / shielded ROI is supported. You can select the function of the region of interest and exclude irrelevant areas as needed. The detection results will only include the area inside the ROI and the area outside the shielded ROI. Figure 4 As shown, in this embodiment, due to the existence of ROI and shielding area, only the block in the upper left quarter is output.

[0046] Figure 5 A block diagram of a block analysis system based on run-length code binarization according to the present invention is shown.

[0047] like Figure 5 As shown, the present invention discloses a block analysis system based on run-length code binarization, comprising a memory and a processor. The memory comprises a block analysis method program based on run-length code binarization. When the block analysis method program based on run-length code binarization is executed by the processor, the following steps are implemented: Obtain the original image to obtain a pixel block sequence; Processing the pixel block sequence based on a preset run length coding structure to obtain a run length code sequence; Dynamically merge connected regions using a union-find method based on the run-length code sequence to obtain a connected region set; The block feature calculation is performed based on the connected domain set to obtain an analysis result, and the analysis result is output visually, wherein the block feature calculation includes calculating geometric features, and the geometric features include at least a minimum circumscribed rectangle, a target diameter, a roundness, and a rectangularity.

[0048] It should be noted that, in this embodiment, since the specific implementation of this embodiment corresponds to the aforementioned method embodiment, the same details will not be repeated here. A third aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a block analysis method program based on run-length code binarization, and when the block analysis method program based on run-length code binarization is executed by a processor, the steps of the block analysis method based on run-length code binarization as described in any of the above items are implemented.

[0049] The present invention discloses a block analysis method, system and medium based on run-length encoding binarization, which innovatively introduces the run-length encoding (RLE) structure and combines it with optimization schemes such as instruction set acceleration to deeply optimize the binarization process. By using run-length encoding with smaller data volume and compact structure to replace the traditional original code with large data volume and a lot of redundancy, the system can effectively solve the problem of large data volume and large redundancy. Figure 2 This invention significantly reduces the algorithm's computational complexity and memory usage by using a numerical method. For an image of 10,000 × 10,000 pixels, the computation time is significantly reduced from 100 milliseconds to approximately 10 milliseconds, a tenfold improvement in efficiency. This significantly improves the efficiency and practicality of the block counting algorithm and provides a wealth of block information as output, including area, bounding rectangle, roundness, ellipticity, and more, facilitating industrial applications.

[0050] In the several 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 merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0051] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.

[0052] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0053] Those skilled in the art will appreciate that all or part of the steps of the above-mentioned method embodiments may be implemented by hardware associated with program instructions, and the aforementioned program may be stored in a computer-readable storage medium. When the program is executed, the program executes the steps of the above-mentioned method embodiments. The aforementioned storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.

[0054] Alternatively, if the integrated units described above are implemented as software modules and sold or used as standalone products, they can also be stored on a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product, stored on a storage medium, includes instructions for enabling a computer device (such as a personal computer, server, or network device) to execute all or part of the methods described in various embodiments of the present invention. The aforementioned storage media include various media capable of storing program code, such as removable storage devices, ROM, RAM, magnetic disks, or optical disks.

Claims

1. A block analysis method based on run-length code binarization, characterized in that: The following steps are involved: Obtain the original image to obtain a pixel block sequence; Processing the pixel block sequence based on a preset run length coding structure to obtain a run length code sequence; Dynamically merge connected regions using a union-find method based on the run-length code sequence to obtain a connected region set; The block feature calculation is performed based on the connected domain set to obtain an analysis result, and the analysis result is output visually, wherein the block feature calculation includes calculating geometric features, and the geometric features include at least a minimum circumscribed rectangle, a target diameter, a roundness, and a rectangularity.

2. The block analysis method based on run-length code binarization according to claim 1, characterized in that: The obtaining of the original image to obtain a pixel block sequence specifically includes: Obtain an original image, wherein the original image includes an H×W matrix, where H is the image height and W is the image length; Divide the original image into pixel blocks, wherein the fixed length of the division is W; The pixel blocks after the block processing are extracted to obtain the pixel block sequence P.

3. The block analysis method based on run-length code binarization according to claim 2, characterized in that: The processing of the pixel block sequence based on the preset run length coding structure to obtain a run length code sequence specifically includes: Generating a bit mask based on the pixel block sequence, wherein the generated bit mask specifically includes a binary sequence of length W; Processing is performed based on the bit mask to generate a run length code, and global merging is performed based on the run length codes of all rows to obtain the run length code sequence.

4. The block analysis method based on run-length code binarization according to claim 3, characterized in that: The processing based on the bit mask to generate a run code, and performing global merging based on the run codes of all rows to obtain the run code sequence specifically includes: The state machine is maintained based on the bit mask and the position data of the current pixel block in the image, and the state variables include the current stroke start column and the current stroke end column, wherein, Process the mask based on the pixel block type. If the bit mask is entirely background blocks, close the current run; if the bit mask is entirely foreground blocks, open a new run; if the bit mask is a mixed block, scan the mask bit by bit and dynamically adjust the run open or closed according to the current mask state; The unfinished run at the end of the row is forcibly closed and then globally merged to obtain the run code sequence.

5. The block analysis method based on run-length code binarization according to claim 4, characterized in that: The method of dynamically merging connected regions using a union-find set based on the run-length code sequence to obtain a connected region set specifically includes: Initializing each run code in the run code sequence as a union-find independent node, wherein the region attributes of the independent node include boundary coordinates, zero-order moment, first-order moment and a run code endpoint set; Adjacent run codes are detected based on a preset connectivity rule, wherein the root nodes of the adjacent run codes are compared, and if the root nodes are different, they are merged, wherein the merging includes updating boundary coordinates, accumulating moment values, and merging endpoint sets; After all the run codes are detected, they are merged, compressed, and the structure tree is searched to obtain the connected domain set.

6. The block analysis method based on run-length code binarization according to claim 5, characterized in that: The block feature calculation based on the connected domain set is performed to obtain an analysis result, and the analysis result is output in a visual manner, specifically including: Calculate the area, center of mass, minimum circumscribed rectangle, target radius, roundness and rectangularity of the block based on the connected domain set; Based on the calculated analysis results as the feature set corresponding to each connected domain; Visual output is performed based on the feature set, including drawing boundaries, centroids and minimum bounding rectangles on the original image, and generating a structured report.

7. A block analysis system based on run-length code binarization, characterized in that: The system comprises a memory and a processor, wherein the memory comprises a block analysis method program based on run-length code binarization, and the block analysis method program based on run-length code binarization is executed by the processor to implement the following steps: Obtain the original image to obtain a pixel block sequence; Processing the pixel block sequence based on a preset run length coding structure to obtain a run length code sequence; Dynamically merge connected regions using a union-find method based on the run-length code sequence to obtain a connected region set; The block feature calculation is performed based on the connected domain set to obtain an analysis result, and the analysis result is output visually, wherein the block feature calculation includes calculating geometric features, and the geometric features include at least a minimum circumscribed rectangle, a target diameter, a roundness, and a rectangularity.

8. The block analysis system based on run-length code binarization according to claim 7, characterized in that: The obtaining of the original image to obtain a pixel block sequence specifically includes: Obtain an original image, wherein the original image includes an H×W matrix, where H is the image height and W is the image length; Divide the original image into pixel blocks, wherein the fixed length of the division is W; The pixel blocks after the block processing are extracted to obtain the pixel block sequence P.

9. The block analysis system based on run-length code binarization according to claim 8, characterized in that: The processing of the pixel block sequence based on the preset run length coding structure to obtain a run length code sequence specifically includes: Generating a bit mask based on the pixel block sequence, wherein the generated bit mask specifically includes a binary sequence of length W; Processing is performed based on the bit mask to generate a run length code, and global merging is performed based on the run length codes of all rows to obtain the run length code sequence.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a block analysis method program based on run-length code binarization. When the block analysis method program based on run-length code binarization is executed by a processor, the steps of the block analysis method based on run-length code binarization as described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Multiple-connected-domain rapid merging algorithm and apparatus based on stroke coding

    CN106651862A

  • Algorithm and device for obtaining maximal horizontally inscribed rectangle for any connected domain based on run length encoding

    CN106651944A

  • Connected domain searching method and device based on run length coding

    CN111145191A

  • Method and system for rapidly extracting connected domain based on run-length coding

    CN117152458A

  • Block information determination method and system and storage medium

    CN119205788A