Image corrosion method and device, electronic equipment and storage medium
The Blob analysis process is optimized through the image corrosion method based on run-length encoding, which solves the problem of time-consuming and inefficient Blob analysis calculations and improves processing speed and efficiency.
Patent Information
- Application Number
- CN202511157589.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-19
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-08-19
AI Technical Summary
The existing technology of performing blob analysis on original blob images is time-consuming and inefficient, and lacks an efficient image corrosion solution.
An image erosion method based on run-length encoding is adopted. By traversing the runs of images and structural elements, basic runs are generated. Then, erosion operations are performed under specific conditions, including deleting runs that do not meet the conditions and performing intersection operations, thereby optimizing the image processing process.
The processing speed and efficiency of Blob analysis are significantly improved by eliminating isolated noise points and small interferences, reducing the complexity of Blob contours, and avoiding feature confusion caused by excessive merging.
Smart Images

Figure CN120707393A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to an image corrosion method, device, electronic equipment and storage medium. Background Art
[0002] Blob analysis aims to detect and analyze 2D shapes in images, obtaining information such as target location, shape, orientation, and topological relationships between objects. This information can be used to identify objects. Blob analysis is essentially a characteristic analysis of closed shapes. Before blob analysis can be performed, the image must be segmented into objects and background.
[0003] Blob analysis calculations on original blob images are very time-consuming and inefficient. In order to improve the speed and efficiency of blob analysis, the introduction of image erosion technology can significantly improve processing speed and efficiency. Specifically, the image erosion operation can eliminate isolated noise points and small interferences, reducing the amount of invalid calculations in subsequent connected area analysis; by eroding and stripping off small protrusions on the edge of the target, the complexity of the blob contour is reduced (such as smoothing jagged edges into straight lines); erosion can disconnect weakly connected blobs to avoid feature confusion caused by excessive merging.
[0004] Therefore, in order to improve the speed and efficiency of Blob analysis, providing an efficient image corrosion solution is a technical problem that needs to be solved urgently. Summary of the Invention
[0005] The main purpose of the present invention is to disclose an image corrosion method, device, electronic device and storage medium, so as to at least solve the problems in the related art such as the time-consuming and inefficient blob analysis calculation on the original blob image and the lack of an efficient image corrosion solution.
[0006] According to one aspect of the present invention, an image corrosion method is provided.
[0007] The image erosion method provided by the present invention comprises: traversing the acquired current image and all runs of the structural element to generate basic runs, and marking the numbers of the runs of the structural element corresponding to the basic runs, wherein the basic runs are the result of performing an erosion operation on the runs of the current image and the runs of the structural element; traversing the basic runs row by row, if the number of basic runs of the current row is less than M, or the number of basic runs of the current row is greater than or equal to M and the run index of the structural element is [ 1 , ⋯ , M ] If not complete, delete all basic runs in the current row, where M is an integer greater than 1; otherwise, in the current row, perform an intersection operation on the above basic runs according to the structure element run index, and search for the common area indexed by the structure element run.
[0008] Furthermore, the current run of the current image , the above structural elements are Structural elements, and the structural element runs are , , , the basic run after corrosion is , , ; The current run of the current image above , the above structural elements are Structural elements, and the structural element runs are , , ,if , the basic run after corrosion is , , , otherwise, the basic run is an empty set.
[0009] Furthermore, when the corrosion operation is performed on the run of the above-mentioned current image and the run of the above-mentioned structural element, for the first row of the current input run-length coded image, the method of performing row processing includes: performing a new row operation in the output run-length coded image, creating a new row that is the same as the current input run-length coding, the previous row of the above-mentioned same row, and the next row of the above-mentioned same row, wherein when creating the above-mentioned previous row and the above-mentioned next row, if the output image size range is exceeded, the above-mentioned new row operation is not performed, and when creating the next row, out-of-bounds processing is performed.
[0010] Furthermore, when performing the erosion operation on the run-length of the current image and the run-length of the structuring element, for the second line of the current input run-length coded image and each line after the second line, a method of performing line processing includes one of the following:
[0011] When a current input run-length coding line is adjacent to a previous input run-length coding line, a new line is created in the output run-length coding image next to the current input run-length coding line, and a line addition operation is performed on the current line of the current input run-length coding line and the line before the current input run-length coding line, wherein when creating the new line, an out-of-bounds process is performed;
[0012] When the current input run-length coding line is separated from the previous input run-length coding line by one line, in the output run-length coding image, a current line of the current input run-length coding line and a line next to the current input run-length coding line are newly created, and a line-adding operation is performed on the line previous to the current input run-length coding line, wherein when creating the next line, an out-of-bounds processing is performed;
[0013] When the current input run-length coding line and the previous input run-length coding line are separated by two lines or more, in the output run-length coding image, a new line that is the same as the above-mentioned current input run-length coding line, the previous line of the above-mentioned current input run-length coding line, and the next line of the above-mentioned current input run-length coding line are newly created, and when the next line is newly created, out-of-bounds processing is performed.
[0014] Furthermore, the new row creation operation includes: inserting the current basic run to the end of the current row, adding 1 to the increment mark of the current basic run, and the initial value of the current basic run is 0.
[0015] Furthermore, the current basic run is , the hotspot itinerary is The above row adding operation includes one of the following:
[0016] When satisfied , point the hotspot run to the right neighbor of the hotspot run, and repeat the basic run operation process;
[0017] When satisfied If the hotspot run is the first run of the row, the basic run operation is ended. Otherwise, the hotspot run is pointed to the left adjacent run of the hotspot run and the current basic run operation is ended.
[0018] When satisfied and , modify the above hotspot itinerary to , and add 1 to the increment mark of the hotspot run, point the hotspot run to the right adjacent run of the hotspot run, and repeat the basic run operation process;
[0019] When satisfied and , add 1 to the increment mark of the hotspot run, point the hotspot run to the right adjacent run of the hotspot run, and repeat the basic run operation process;
[0020] When satisfied and , split the above hotspot run into the left half run and right half run , and add 1 to the left half run increment mark, point the above hotspot run to the right half run, and end the current basic run operation;
[0021] When satisfied and , split the above hotspot run into the left half run and right half run , and add 1 to the left half stroke increment mark, point the above hotspot stroke to the right half stroke, and end the current basic stroke operation.
[0022] According to another aspect of the present invention, an image etching device is provided.
[0023] The image erosion device according to the present invention comprises: a generation module for traversing the acquired current image and all runs of the structural element, generating a basic run, and marking the number of the structural element run corresponding to the basic run, wherein the basic run is the result of performing an erosion operation on the run of the current image and the run of the structural element; a traversal module for traversing the basic run row by row; a processing module for processing the basic run when the number of basic runs in the current row is less than M, or the number of basic runs in the current row is greater than or equal to M and the structural element run index is [ 1 , ⋯ , M ] If not complete, delete all the above basic runs. Otherwise, in the current row, perform intersection operation on the above basic runs according to the structure element run index, and search for the common area indexed by the structure element run, where M is an integer greater than 1.
[0024] Furthermore, the generation module includes a row processing unit, wherein the row processing unit is configured to:
[0025] For the first line of the current input run-length coded image, a new line operation is performed in the output run-length coded image to create a new line that is the same as the current input run-length coded image, a line above the same line, and a line below the same line. If the creation of the previous line and the creation of the next line exceeds the output image size range, the new line operation is not performed, and when the next line is created, an out-of-bounds processing is performed;
[0026] For the second row of the current input run-length encoded image, and for each row after the second row, do one of the following:
[0027] When a current input run-length coding line is adjacent to a previous input run-length coding line, a new line is created in the output run-length coding image next to the current input run-length coding line, and a line addition operation is performed on the current line of the current input run-length coding line and the line before the current input run-length coding line, wherein when creating the new line, an out-of-bounds process is performed;
[0028] When the current input run-length coding line is separated from the previous input run-length coding line by one line, in the output run-length coding image, a current line of the current input run-length coding line and a line next to the current input run-length coding line are newly created, and a line-adding operation is performed on the line previous to the current input run-length coding line, wherein when creating the next line, an out-of-bounds processing is performed;
[0029] When the current input run-length coding line and the previous input run-length coding line are separated by two lines or more, in the output run-length coding image, a new line that is the same as the above-mentioned current input run-length coding line, the previous line of the above-mentioned current input run-length coding line, and the next line of the above-mentioned current input run-length coding line are newly created, and when the next line is newly created, out-of-bounds processing is performed.
[0030] According to yet another aspect of the present invention, an electronic device is provided.
[0031] The electronic device according to the present invention includes: a processor and a memory, wherein the memory is used to store executable instructions of the processor, wherein the processor is configured to perform any one of the above-mentioned image corrosion methods by executing the executable instructions.
[0032] According to yet another aspect of the present invention, a computer-readable storage medium is provided.
[0033] The computer-readable storage medium according to the present invention includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned image corrosion methods.
[0034] According to the present invention, an image erosion method, device, electronic device and storage medium are provided. First, the original Blob image is run-length encoded (also known as: RLE), and all subsequent processing steps are implemented based on the run-length encoding of the image. By introducing this Blob image erosion scheme based on run-length encoding, the problem of performing Blob analysis and calculation on the original Blob image in the related art is solved, and the speed and efficiency of Blob analysis processing are significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other implementation drawings based on the provided drawings without inventive effort.
[0036] Figure 1 is a flow chart of an image erosion method according to an embodiment of the present invention;
[0037] Figure 2 is a schematic diagram of run-length encoding according to an example of the present invention;
[0038] Figure 3 1 is a block diagram of a Blob image run-length encoding data structure according to an example of the present invention;
[0039] Figure 4 Schematic diagram of a Blob image run-length encoding data structure according to an example of the present invention;
[0040] Figure 5 is a structural block diagram of an image corrosion device according to an embodiment of the present invention;
[0041] Figure 6 is a structural block diagram of an image corrosion device according to a preferred embodiment of the present invention;
[0042] Figure 7 is a structural block diagram of an electronic device according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0043] The following describes the implementation of the present invention using specific embodiments. Those skilled in the art will readily understand the other advantages and benefits of the present invention from the disclosure herein. Obviously, the embodiments described are only a portion of the present invention, not all of it. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0044] The specific implementation of the present invention is described in detail below with reference to the accompanying drawings.
[0045] According to an embodiment of the present invention, an image corrosion method is provided.
[0046] Figure 1 FIG. 1 is a flow chart of an image corrosion method according to an embodiment of the present invention. Figure 1 As shown, the image corrosion method includes:
[0047] Step S101: traverse the acquired current image and all runs of the structural element to generate basic runs, and mark the numbers of the structural element runs corresponding to the basic runs, wherein the basic runs are the result of performing operations on the runs of the current image and the runs of the structural element;
[0048] Step S102: traverse the basic runs line by line. If the number of basic runs in the current line is less than M, or the number of basic runs in the current line is greater than or equal to M and the structure element run index is [ 1 , ⋯ , M ] If not complete, delete all basic runs of the current row, where M is an integer greater than 1;
[0049] Step S103: Otherwise, in the current row, an intersection operation is performed on the above basic runs according to the structure element run index, and a common area according to the structure element run index is searched.
[0050] In the related art, performing Blob analysis calculation on the original Blob image is very time-consuming and inefficient. Figure 1 The Blob image erosion solution based on run-length encoding solves the problem in related technologies that Blob analysis calculations on original Blob images are very time-consuming and inefficient, and significantly improves the speed and efficiency of Blob analysis processing.
[0051] Run-Length Encoding (RLE) is an image encoding method in which segments (rows or columns) with the same grayscale value are called runs. This invention adopts the row-length encoding method. Figure 2 (a) in the figure shows a binary image. Figure 2 (b) in the figure shows the run-length encoding corresponding to the binary image. The run-length can be fully described by three variables: the row ROW, the column starting point START_COL, and the column ending point END_COL. For example, Figure 2 The first run of the first row in (a) corresponds to Figure 2 The sequence number of (b) is 1, the row ROW is marked as 0, the column starting point START_COL is marked as 0, and the column ending point END_COL is marked as 1. The second run of the first row corresponds to Figure 2 The sequence number of (b) is 2, the row ROW is marked as 0, the column starting point START_COL is marked as 3, the column ending point END_COL is marked as 4, and so on. Figure 2 There are 7 runs in , corresponding to serial numbers 1 to 7. In the run-length encoding implementation, each gray level can be encoded separately for subsequent processing and operation.
[0052] The structural diagram and description of the run-length encoding data structure for Blob images are as follows: Figure 3 and Figure 4 As shown, the run-length coded data is divided into four levels: picture level (such as Figure 4 (a) in), Blob level (such as Figure 4 (b) in), row level (such as Figure 4 (c) in the above), the run unit level (such as Figure 4(d) in the image) and is represented by a linked list. The image-level structure is responsible for managing all Blob objects and their topological relationships, including all Blob data classes, the number of blobs, and all Blob linked lists. The Blob level is one of the core layers. A single Blob data class consists of a Blob label, a linked list of all rows of a single Blob, and the currently accessed row. The row-level structure is the core unit for processing the connectivity of a single row of pixels. A single row data class consists of a row label, a linked list of all run units of a single row, and the currently accessed run unit. At the run unit level, the key fields of a single run unit data class include: starting column, ending column, permanent label, and reserved field.
[0053] The following combines image Z and the structural element The above preferred embodiment is further described with reference to examples.
[0054] image and structural elements The number of pixels is and , the number of runs are and The run-length coding representations of the image and the structural element are 、 ; Corrosion is defined as
[0055] ,
[0056] in, express The origin is translated to Place.
[0057] Depend on
[0058]
[0059] and
[0060]
[0061] Available
[0062]
[0063] consider , which searches all locations ,make Included in If the run Included tour The following three conditions must be met: (1) and itinerary The row number is the same; (2) the run The length must be greater than or equal to Run length; (3) The two endpoints are included in the run Therefore Include , must satisfy
[0064]
[0065] Therefore, the image and structural elements The corrosion operation can be described as
[0066]
[0067] It can be seen that the corrosion operation not only involves the union operation of the basic runs, but also involves the intersection operation of the basic runs.
[0068] In step S101, the current run of the current image , the above structural elements are Structural elements, and the structural element runs are , , , the basic run after corrosion is , , ;
[0069] In step S101, the current run of the current image , the above structural elements are Structural elements, and the structural element runs are , , ,if , the basic run after corrosion is , , , otherwise, the basic run is an empty set.
[0070] Specifically, in the multi-run erosion method based on run-length coding, the input is: the run-length coding data of the acquired image Z; the run-length coding data of the structure element S: Structural elements, and the structural element runs are , , ;right Structural elements, and the structural element runs are , , .
[0071] Output: Run-length encoded data.
[0072] First, traverse all runs of the image row by row. Then generate the basic runs. If the runs Expressed as: ,
[0073] a. Yes Structural element, the basic run after corrosion is , , ;
[0074] b.Yes Structural elements, if , the basic run after corrosion is , , ; Otherwise, the basic run is an empty set .
[0075] In step S101, when the corrosion operation is performed on the run of the above-mentioned current image and the run of the above-mentioned structural element, for the first line of the current input run-length coded image, the method of performing row processing includes: performing a new row operation in the output run-length coded image, creating a new row that is the same as the current input run-length coding, the previous row of the above-mentioned same row, and the next row of the above-mentioned same row, wherein when creating the above-mentioned previous row and the above-mentioned next row, if the output image size range is exceeded, the above-mentioned new row operation is not performed, and when creating the next row, out-of-bounds processing is performed.
[0076] In step S101, when performing the erosion operation on the run-length of the current image and the run-length of the structuring element, for the second line of the current input run-length coded image and each line after the second line, a method of performing line processing includes one of the following:
[0077] When a current input run-length coding line is adjacent to a previous input run-length coding line, a new line is created in the output run-length coding image next to the current input run-length coding line, and a line addition operation is performed on the current line of the current input run-length coding line and the line before the current input run-length coding line, wherein when creating the new line, an out-of-bounds process is performed;
[0078] When the current input run-length coding line is separated from the previous input run-length coding line by one line, in the output run-length coding image, a current line of the current input run-length coding line and a line next to the current input run-length coding line are newly created, and a line-adding operation is performed on the line previous to the current input run-length coding line, wherein when creating the next line, an out-of-bounds processing is performed;
[0079] When the current input run-length coding line and the previous input run-length coding line are separated by two lines or more, in the output run-length coding image, a new line that is the same as the above-mentioned current input run-length coding line, the previous line of the above-mentioned current input run-length coding line, and the next line of the above-mentioned current input run-length coding line are newly created, and when the next line is newly created, out-of-bounds processing is performed.
[0080] Specifically, when performing the erosion operation on the run length of the current image and the run length of the structural element, the row processing strategy is as follows:
[0081] a. For the first line of the input run-length coded image (not necessarily the first line of the input image), create three new lines in the output run-length coded image: the same line as the input run-length coded image, the corresponding line above, and the corresponding line below. If the creation of the previous and next lines exceeds the output image size, the creation is not performed.
[0082] b. For the second and subsequent rows of the input image, there are different processing strategies as follows:
[0083] b.1 The current input run-length coded line is adjacent to the previous input run-length coded line: In the output run-length coded image, a new corresponding next line is created and the current line and the previous line are added.
[0084] b.2 The current input run-length coded line is separated from the previous input run-length coded line by one line: In the output run-length coded image, a new current line is created, corresponding to the next line, and the previous line is appended.
[0085] b.3 If the current input run-length coding line is separated from the previous input run-length coding line by 2 lines or more: In the output run-length coding image, create a new line with the same input run-length coding line, the corresponding line above, and the corresponding line below.
[0086] It should be noted that when creating the next row, out-of-bounds processing must be performed.
[0087] The new row creation operation includes: inserting the current basic stroke to the end of the current row, adding 1 to the increment mark of the current basic stroke, and setting the initial value of the current basic stroke to 0.
[0088] Among them, the current basic journey is , the hotspot itinerary is The above row adding operation includes one of the following:
[0089] When satisfied , point the hotspot run to the right neighbor of the hotspot run, and repeat the basic run operation process;
[0090] When satisfied If the hotspot run is the first run of the row, the basic run operation is ended. Otherwise, the hotspot run is pointed to the left adjacent run of the hotspot run and the current basic run operation is ended.
[0091] When satisfied and , modify the above hotspot itinerary to , and add 1 to the increment mark of the hotspot run, point the hotspot run to the right adjacent run of the hotspot run, and repeat the basic run operation process;
[0092] When satisfied and , add 1 to the increment mark of the hotspot run, point the hotspot run to the right adjacent run of the hotspot run, and repeat the basic run operation process;
[0093] When satisfied and , split the above hotspot run into the left half run and right half run , and add 1 to the left half run increment mark, point the above hotspot run to the right half run, and end the current basic run operation;
[0094] When satisfied and , split the above hotspot run into the left half run and right half run , and add 1 to the left half stroke increment mark, point the above hotspot stroke to the right half stroke, and end the current basic stroke operation.
[0095] In the preferred implementation, the run-length coded image is output. In the current traversal process, the run that was last operated is called the hot run, which is initially the first run of the current row. The current basic run is defined as , the hotspot itinerary is Based on the relationship between the current basic itinerary and the hotspot itinerary, the following operations can be broken down and processed according to the following process:
[0096] a. Left disconnected: . Direct the hotspot run to its right neighbor run and repeat the basic run operation process.
[0097] b. The right is not connected or the left and right are not connected: If the hotspot run is the first run of the row, the basic run operation ends; otherwise, the hotspot run is directed to its left adjacent run and the current basic run operation ends.
[0098] c. Left connected: that is and The hotspot itinerary is modified to , and increase the increment flag by 1. Point the hotspot run to its right neighbor run, and repeat the basic run operation process.
[0099] d. Contains: and The hotspot run increment flag is increased by 1. The hotspot run is directed to its right neighbor run and the basic run operation process is repeated.
[0100] e. Right connected: that is and Split the hotspot run into two runs: the left half and right half run , and add 1 to the left half stroke increment mark. Point the hotspot stroke to the right half stroke and end the current basic stroke operation.
[0101] f. be included: i.e. and Split the hotspot run into two runs: the left half and right half run , and add 1 to the left half stroke increment mark. Point the hotspot stroke to the right half stroke and end the current basic stroke operation.
[0102] In a preferred implementation process, after executing the above steps, the following steps may be further included: output image data pruning: if the incremental mark of a run in the output image data is less than 3, the run is deleted.
[0103] According to an embodiment of the present invention, an image corrosion device is also provided.
[0104] Figure 5 FIG. 1 is a block diagram of an image corrosion device according to an embodiment of the present invention. Figure 5 As shown, the image erosion device includes: a generation module 50, which is used to traverse the acquired current image and all runs of the structural element, generate basic runs, and mark the numbers of the structural element runs corresponding to the basic runs, wherein the basic runs are the results of performing an erosion operation on the runs of the current image and the runs of the structural element; a traversal module 52, which is used to traverse the basic runs row by row; a processing module 54, which is used to process the basic runs when the number of basic runs in the current row is less than M, or when the number of basic runs in the current row is greater than or equal to M and the run index of the structural element is [ 1 , ⋯ , M ] If not complete, delete all the above basic runs. Otherwise, in the current row, perform intersection operation on the above basic runs according to the structure element run index, and search for the common area indexed by the structure element run, where M is an integer greater than 1.
[0105] By introducing Figure 5The Blob image corrosion device based on run-length encoding solves the problem in the related art that Blob analysis calculation on the original Blob image is very time-consuming and inefficient, and significantly improves the speed and efficiency of Blob analysis processing.
[0106] like Figure 6 As shown, the generation module 50 may further include a row processing unit 500, wherein the row processing unit 500 is used to:
[0107] a. For the first line of the current input run-length coded image, perform a new line creation operation in the output run-length coded image. Create a new line identical to the current input run-length coded image, a new line above the previous line, and a new line below the previous line. If the creation of the previous line or the new line exceeds the output image size range, the new line creation operation is not performed. When creating the next line, perform out-of-bounds processing.
[0108] b. For the second row of the current input run-length-encoded image and each row after the second row, do one of the following:
[0109] b.1 When the current input run-length coding line is adjacent to the previous input run-length coding line, a new line is created in the output run-length coding image, and a line addition operation is performed on the current line of the current input run-length coding line and the line before the current input run-length coding line. When creating the new line, cross-border processing is performed;
[0110] b.2 When the current input run-length coding line is separated from the previous input run-length coding line by one line, in the output run-length coding image, a new line is created for the current input run-length coding line and a new line is created next to the current input run-length coding line. A line addition operation is performed on the previous line of the current input run-length coding line. When creating the next line, an out-of-bounds process is performed.
[0111] b.3 When the current input run-length coding line and the previous input run-length coding line are separated by two or more lines, a new line identical to the above-mentioned current input run-length coding line, the previous line of the above-mentioned current input run-length coding line, and the next line of the above-mentioned current input run-length coding line are newly created in the output run-length coding image. When creating the next new line, out-of-bounds processing is performed.
[0112] It should be noted that the above-mentioned image corrosion device can refer to Figures 1 to 4 The corresponding descriptions and effects in the embodiments shown can be understood and will not be repeated here.
[0113] According to an embodiment of the present invention, an electronic device is further provided.
[0114] Figure 71 is a block diagram of an electronic device according to a preferred embodiment of the present invention. Figure 7 As shown, the electronic device according to the present invention includes: a memory 70 and a processor 72, the memory 70 is used to store computer execution instructions of the processor 72; the processor 72 is configured to execute any one of the above-mentioned image corrosion methods by executing the above-mentioned executable instructions.
[0115] The processor 72 may be a central processing unit (CPU). The processor 72 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of these chips.
[0116] Memory 70, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the program instructions / modules corresponding to the image erosion method in the embodiments of the present invention. The processor executes the non-transitory software programs, instructions, and modules stored in the memory to perform various processor functions and data processing.
[0117] The memory 70 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 70 may optionally include a memory remotely located relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0118] The one or more modules are stored in the memory 70 and when executed by the processor 72, the following steps are performed: Figures 1 to 4 The image erosion method in the illustrated embodiment.
[0119] For details of the above electronic equipment, please refer to Figures 1 to 4 The corresponding descriptions and effects in the embodiments shown can be understood and will not be repeated here.
[0120] According to an embodiment of the present invention, a computer-readable storage medium is further provided, on which a computer program is stored, and when the computer program is executed by a processor, the computer program is implemented to perform any of the above-mentioned image erosion methods.
[0121] The computer-readable storage medium may be a memory, for example, a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache memory. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DRRAM).
[0122] To sum up, with the help of the above embodiments provided by the present invention, performing Blob analysis and calculation on the original Blob image is very time-consuming and inefficient. By introducing a Blob image corrosion scheme based on run-length encoding, the problem of performing Blob analysis and calculation on the original Blob image in the related art is solved, and the Blob analysis processing speed and efficiency are significantly improved.
[0123] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of the present invention should be included in the scope of protection of the present invention.
Claims
1. An image corrosion method, characterized in that: include: Traversing the acquired current image and all runs of the structural element to generate basic runs, and marking the numbers of the runs of the structural element corresponding to the basic runs, wherein the basic runs are the results of performing an erosion operation on the runs of the current image and the runs of the structural element; Traverse the basic runs line by line, if the number of basic runs in the current line is less than M, or the number of basic runs in the current line is greater than or equal to M and the structure element run index If not complete, delete all basic runs of the current row, where M is an integer greater than 1; Otherwise, in the current row, an intersection operation is performed on the basic runs by the structure element run index, and a common area by the structure element run index is searched.
2. The method according to claim 1, characterized in that The current run of the current image , the structural element is Structural elements, and the structural element runs are , , , the basic run after corrosion is , , ; The current run of the current image , the structural element is Structural elements, and the structural element runs are , , ,if , the basic run after corrosion is , , , otherwise, the basic run is an empty set.
3. The method according to claim 1, characterized in that When performing the erosion operation on the run length of the current image and the run length of the structure element, for the first line of the current input run length coded image, the method of performing line processing includes: A new row operation is performed in the output run-length coded image to create a new row that is the same as the current input run-length coded row, the previous row of the same row, and the next row of the same row. When creating the previous row and the next row, if the output image size range is exceeded, the new row operation is not performed, and when creating the next row, out-of-bounds processing is performed.
4. The method according to claim 1, wherein When performing the erosion operation on the run-length of the current image and the run-length of the structuring element, for the second line of the current input run-length encoded image and each line after the second line, a method of performing line processing includes one of the following: When a current input run-length coding line is adjacent to a previous input run-length coding line, a new line is created in the output run-length coding image next to the current input run-length coding line, and a line addition operation is performed on the current line of the current input run-length coding line and the line previous to the current input run-length coding line, wherein an out-of-bounds processing is performed when creating the new line; When there is one row between the current input run-length coding line and the previous input run-length coding line, in the output run-length coding image, a current row of the current input run-length coding line and a row next to the current input run-length coding line are newly created, and a row addition operation is performed on the row previous to the current input run-length coding line, wherein when creating the next row, an out-of-bounds processing is performed; When the current input run-length coding line and the previous input run-length coding line are separated by two lines or more, in the output run-length coding image, a new line that is the same as the current input run-length coding line, the previous line of the current input run-length coding line, and the next line of the current input run-length coding line are newly created, wherein when the next line is newly created, out-of-bounds processing is performed.
5. The method according to claim 3 or 4, characterized in that The new row operation includes: Insert the current basic run to the end of the current row, add 1 to the increment mark of the current basic run, and the initial value of the current basic run is 0.
6. The method according to claim 4, characterized in that The current basic itinerary is , the hotspot itinerary is The row adding operation includes one of the following: When satisfied , point the hotspot run to the right adjacent run of the hotspot run, and repeat the basic run operation process; When satisfied If the hotspot run is the first run of the row, the basic run operation is ended; otherwise, the hotspot run is directed to the left adjacent run of the hotspot run, and the current basic run operation is ended; When satisfied and , modify the hotspot run to , and add 1 to the increment mark of the hotspot run, point the hotspot run to the right adjacent run of the hotspot run, and repeat the basic run operation process; When satisfied and , add 1 to the increment mark of the hotspot run, point the hotspot run to the right adjacent run of the hotspot run, and repeat the basic run operation process; When satisfied and , split the hotspot run into the left half run and right half run , and add 1 to the left half run increment mark, point the hotspot run to the right half run, and end the current basic run operation; When satisfied and , split the hotspot run into the left half run and right half run , and add 1 to the left half stroke increment mark, point the hotspot stroke to the right half stroke, and end the current basic stroke operation.
7. An image corrosion device, characterized in that: include: a generation module, configured to traverse the acquired current image and all runs of the structural element, generate basic runs, and mark the numbers of the runs of the structural element corresponding to the basic runs, wherein the basic runs are the results of performing an erosion operation on the runs of the current image and the runs of the structural element; A traversal module, used for traversing the basic run line by line; The processing module is used to process the basic run number of the current row less than M, or the basic run number of the current row is greater than or equal to M and the structure element run index If not, delete all the basic runs. Otherwise, perform an intersection operation on the basic runs according to the structure element run index in the current row, and search for the common area indexed by the structure element run, where M is an integer greater than 1.
8. The device according to claim 7, characterized in that The generation module includes: a row processing unit, wherein the row processing unit is configured to: For the first line of the current input run-length coded image, a new line operation is performed in the output run-length coded image to create a new line that is the same as the current input run-length coded image, a previous line of the same line, and a next line of the same line. If the previous line and the next line are created outside the output image size range, the new line operation is not performed, and when the next line is created, an out-of-bounds process is performed; For the second row of the current input run-length encoded image and each row after it, do one of the following: When a current input run-length coding line is adjacent to a previous input run-length coding line, a new line is created in the output run-length coding image next to the current input run-length coding line, and a line addition operation is performed on the current line of the current input run-length coding line and the line previous to the current input run-length coding line, wherein an out-of-bounds processing is performed when creating the new line; When there is one row between the current input run-length coding line and the previous input run-length coding line, in the output run-length coding image, a current row of the current input run-length coding line and a row next to the current input run-length coding line are newly created, and a row addition operation is performed on the row previous to the current input run-length coding line, wherein when creating the next row, an out-of-bounds processing is performed; When the current input run-length coding line and the previous input run-length coding line are separated by two lines or more, in the output run-length coding image, a new line that is the same as the current input run-length coding line, the previous line of the current input run-length coding line, and the next line of the current input run-length coding line are newly created, wherein when the next line is newly created, out-of-bounds processing is performed.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store executable instructions of the processor, wherein the processor is configured to perform the image corrosion method according to any one of claims 1 to 6 by executing the executable instructions.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the image corrosion method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Multidimensional characteristic extraction method and device based on connected domain analysis
CN106529550A
Rapid area erosion algorithm and device based on random structural element of run-length encoding
CN106600655A
Skew detection in document images
EP1394725A1