Image processing method, electronic equipment and computer readable storage medium

By processing the initial stroke data of binary images line by line and building the stroke pyramid, the problem of low image morphology processing efficiency in the prior art is solved, and more efficient image processing and construction efficiency is achieved.

CN119624788APending Publication Date: 2025-03-14ZHEJIANG HUARAY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411547321.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

The existing image morphology processing method requires multiple repeated access and logical operations on pixels in the image, resulting in low efficiency.

Method used

By morphologically processing the initial stroke data of the binary image line by line, a trip pyramid is constructed, and the pixel rows of the image are traversed, the target stroke data subset is determined from the stroke pyramid, and the morphological processing is performed on the pixel column, and the target image is finally constructed.

Benefits of technology

By building a trip pyramid, repeated access to image pixels is avoided, and the efficiency of image processing and construction efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119624788A_ABST
    Figure CN119624788A_ABST
Patent Text Reader

Abstract

The invention discloses an image processing method, electronic equipment and a computer readable storage medium. The method comprises the following steps: performing morphological processing on obtained initial travel data of a binary image line by line to obtain first travel data; then, a travel pyramid is constructed according to the first travel data, the travel pyramid comprises at least two layers of travel data sets, and each layer of travel data set comprises at least one travel data subset; pixel rows of the binary image are traversed, a target stroke data subset is determined from the stroke pyramid according to the current pixel row, and the target stroke data subset comprises second stroke data obtained after morphological processing on pixel columns is carried out on the current pixel row; and performing image construction according to the second travel data in the target travel data subset corresponding to each pixel row in the binary image to obtain a target image. Therefore, efficiency is improved, and operation resources are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an image processing method, electronic equipment and computer-readable storage medium. Background Art

[0002] Image processing is an important branch of computer vision, and is often used in the fields of medicine, aerospace, and communications engineering. Morphological processing of images can analyze and identify targets in images, thereby solving image problems such as target detection, edge extraction, and feature extraction. It is one of the commonly used image processing methods.

[0003] The current morphological processing method of images is to perform morphological processing on the pixels in the image in the row direction and the column direction respectively. This method requires repeated access to the pixels in the image and repeated logical operations, resulting in low efficiency. Summary of the invention

[0004] The main technical problem solved by the present application is to provide an image processing method, an electronic device and a computer-readable storage medium, which can improve efficiency.

[0005] In order to solve the above technical problems, the present application provides an image processing method.

[0006] In one embodiment, an image processing method includes: performing morphological processing on initial run data of an acquired binary image row by row to obtain first run data; constructing a run pyramid based on the first run data, wherein the run pyramid includes at least two layers of run data sets, and each layer of the run data sets includes at least one run data subset; traversing pixel rows of the binary image, determining a target run data subset from the run pyramid based on a current pixel row, wherein the target run data subset includes second run data after morphological processing on pixel columns of the current pixel row is performed; and constructing an image based on the second run data in the target run data subset corresponding to each pixel row in the binary image to obtain a target image.

[0007] In one embodiment, the step of constructing a trip pyramid according to the first trip data includes: determining the number of layers of the trip pyramid according to size information of an element matrix of the binary image; taking the layer where the first trip data is located as a first layer, determining second trip data of other layers of the trip pyramid layer by layer according to the first trip data in the first layer, wherein the other layers represent layers in the trip pyramid other than the first layer; and determining the trip pyramid based on the first trip data of the first layer and the second trip data of the other layers.

[0008] In one embodiment, the other layers include a second layer and a third layer, and the step of taking the layer where the first trip data is located as the first layer and determining the second trip data of other layers in the trip pyramid layer by layer according to the first trip data includes: performing logical processing on the first trip data in the first layer to obtain the second trip data in the second layer; and performing logical processing on the second trip data in the second layer to obtain the second trip data in the third layer.

[0009] In one embodiment, the run pyramid includes a first layer and other layers, and the step of traversing pixel rows of the binary image and determining a target run data subset from the run pyramid according to a current pixel row includes: determining initial pixel row information corresponding to the current pixel row from the binary image according to the current pixel row, the initial pixel row information including pixel rows to be subjected to morphological processing in a pixel column direction; determining an initial run data subset according to a matching result between the initial pixel row information and target pixel row information, the target pixel row information including pixel rows where second run data in each run data subset of the other layers is located; in response to the existence of a target pixel row between the initial pixel row information and the target pixel row information, determining first run data of the target pixel row from the first layer, the target pixel row representing different pixel rows where the initial pixel row information is equivalent to the target pixel row information; and performing logical processing on the first run data of the target pixel row and the second run data in the initial run data subset to obtain the target run data subset.

[0010] In one embodiment, the step of determining the initial pixel row information corresponding to the current pixel row from the binary image according to the current pixel row includes: obtaining a first target step size in the pixel column direction of the binary image; moving the first target step size in the first direction of the pixel column with the current pixel row as the starting point to obtain the starting point of the moved pixel row; moving the first target step size in the second direction of the pixel column with the current pixel row as the starting point to obtain the end point of the moved pixel row; the first direction is opposite to the second direction; and determining the pixel row between the starting point of the moved pixel row and the end point of the moved pixel row as the initial pixel row information corresponding to the current pixel row.

[0011] In one embodiment, the morphological processing includes dilation processing, the initial stroke data includes stroke data of each pixel row, each stroke data of the pixel row includes an initial stroke start point and an initial stroke end point, and the step of performing morphological processing on the initial stroke data of the acquired binary image row by row to obtain the first stroke data includes: obtaining a second target step length of the binary image in a pixel row direction; moving the second target step length in a third direction of the pixel row with the initial stroke start point as the starting point to obtain the processed first stroke start point; moving the second target step length in a fourth direction of the pixel row with the initial stroke end point as the starting point to obtain the processed first stroke end point; the third direction is opposite to the fourth direction; and determining the first stroke data based on the processed first stroke start point and the processed first stroke end point.

[0012] In one embodiment, the morphological processing includes corrosion processing, the initial stroke data includes stroke data of each pixel row, each stroke data of the pixel row includes an initial stroke start point and an initial stroke end point, and the step of performing morphological processing on the initial stroke data of the acquired binary image row by row to obtain the first stroke data includes: obtaining a second target step length of the binary image in the direction of the pixel row; moving the second target step length in a fourth direction of the pixel row with the initial stroke start point as the starting point to obtain the processed second stroke start point; moving the second target step length in a third direction of the pixel row with the initial stroke end point as the starting point to obtain the processed second stroke end point; and determining the first stroke data based on the processed second stroke start point and the processed second stroke end point.

[0013] In one embodiment, the step of obtaining the second target step size of the binary image in the pixel row direction includes: determining the second target step size of the binary image in the pixel row direction according to size information of the element matrix.

[0014] In order to solve the above technical problems, the present application provides an electronic device, including a memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the above image processing method.

[0015] In order to solve the above technical problems, the present application provides a computer-readable storage medium, including: storing program data, and the program data is used to implement the above image processing method when executed by a processor.

[0016] The present application performs morphological processing on the initial travel data of the acquired binary image row by row to obtain the first travel data; then constructs a travel pyramid based on the first travel data, the travel pyramid includes at least two layers of travel data sets, and each layer of travel data sets includes at least one travel data subset; traverses the pixel rows of the binary image, and determines the target travel data subset from the travel pyramid based on the current pixel row, the target travel data set includes the second travel data after the current pixel row is morphologically processed on the pixel column; then constructs the image based on the second travel data in the target travel data subset corresponding to each pixel row in the binary image to obtain the target image. By constructing the travel pyramid, the target travel data subset used for constructing the target image is determined from the travel pyramid, and repeated access to pixels in the image is avoided, thereby improving the efficiency of constructing the target image. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:

[0018] Figure 1 is a flowchart of an exemplary embodiment of an image processing method shown in the present application;

[0019] Figure 2 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S110 in the image processing method;

[0020] Figure 3 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S120 in the image processing method shown;

[0021] Figure 4 is a schematic diagram of an exemplary embodiment of a trip pyramid shown in the present application;

[0022] Figure 5 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S130 in the image processing method;

[0023] Figure 6 is a schematic diagram of an exemplary embodiment of a binary image shown in the present application;

[0024] Figure 7 is a schematic diagram of an exemplary embodiment of an image after dilation processing of a binary image shown in the present application;

[0025] Figure 8 is a schematic diagram of an exemplary embodiment of an image formed by a target travel data subset of each pixel row of a binary image shown in the present application;

[0026] Fig. 9 is a block diagram of an image processing device shown in an exemplary embodiment of the present application;

[0027] Fig.10 It is a structural schematic diagram of an embodiment of an electronic device provided by the present application;

[0028] Fig.11 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION

[0029] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It will be appreciated that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only some but not all structures related to the present application are shown in the drawings. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the art without making creative work are within the scope of protection of the present application.

[0030] First of all, it should be noted that image processing is an important branch of computer vision, and is usually used in the fields of medicine, aerospace, communication engineering, etc. Morphological processing of images can realize the analysis and recognition of targets in images, thereby solving image problems such as target detection, edge extraction, feature extraction, etc., and is one of the commonly used image processing methods.

[0031] The current morphological processing method of images is to perform morphological processing on the pixels in the image in the row direction and the column direction respectively. This method requires repeated access to the pixels in the image and repeated logical operations, resulting in low efficiency.

[0032] Based on this, the present application provides an image processing method, an electronic device and a computer-readable storage medium. Figure 1 , Figure 1 It is a flowchart of an exemplary embodiment of the image processing method shown in the present application.

[0033] The execution subject of the image processing method may be a terminal device or a server or other processing device, wherein the terminal device may be a computer, a mobile device, a terminal, a computing device, a vehicle-mounted device, etc. The execution subject of the image processing method may also be an image processing device. In some possible implementations, the image processing method may be implemented by a processor calling a computer-readable instruction stored in a memory.

[0034] Specifically, the image processing method of this embodiment includes the following steps:

[0035] Step S110 , performing morphological processing on the acquired initial run length data of the binary image row by row to obtain first run length data.

[0036] A binary image refers to an image composed of pixels with only two values, or an image with only two grayscale states. The values ​​can be 0 and 1, and the colors presented by the grayscale state can be white and black. Exemplarily, the image processing device performs binarization processing on the image to obtain a binary image.

[0037] The initial run data is a pixel sequence formed by continuous pixels with the same pixel value in the binary image. For example, the initial run data may be a pixel sequence formed by continuous non-zero pixels in the binary image, or may be a pixel sequence formed by continuous zero pixels in the binary image.

[0038] In one embodiment, the image processing device includes a CPU (Central Processing Unit), and the image processing device performs block processing on the binary image according to the number of physical cores of the CPU to obtain block images with the same number of physical cores as the CPU, and assigns each block image to a physical core of the CPU to perform run encoding operation to obtain initial run data. For example, the image processing device performs block processing on the binary image I to obtain block images Block 1 、Block 2 、…、Block m , the image height of each block image is ImgH / m; where Block m It represents the mth block image, m is the number of physical cores of the CPU, and ImgH represents the height of the binary image I.

[0039] The image processing device assigns each block image to a physical core of a CPU for run encoding operation to obtain initial run data. Specifically, the image processing device sequentially loads the image data of the block images into the register in the CPU, and uses a preset judgment instruction to judge whether the image data in the register is all non-zero data to obtain a judgment result; in response to the judgment result indicating that the current image data is all non-zero data, the image data of the next block image is loaded into the register and the judgment is continued; in response to the judgment result indicating that the current image data has data with a value of 0, the starting point of the 0 sequence in the current image data is searched, and the starting point and end point of the "non-zero" sequence are used as the initial run data. As an example, the register in the CPU in the image processing device can be a SIMD (Single Instruction Multiple Data) register, and the image processing device uses a SIMD instruction to judge whether the image data in the SIMD register is all non-zero data to obtain a judgment result. As another example, the register in the CPU in the image processing device may also be a ymm register, and the image processing device uses AVX2 (Advanced Vector Extensions 2) instructions to determine whether the image data in the ymm register is all non-zero data to obtain a determination result. It should be noted that the size of the ymm register is 256 bits, and 32 bytes of image data can be loaded and determined at one time.

[0040] In another embodiment, the image processing device scans the image row by row or column by column, identifies a pixel sequence of continuous non-zero pixel values, and uses the pixel row, pixel column starting point, and pixel column end point of the identified pixel sequence as initial run data. For example, the image processing device scans the image row by row or column by column to obtain a continuous "non-zero" pixel sequence, where the row coordinate of the continuous "non-zero" pixel sequence is y, the column coordinate of the pixel column starting point is xs, and the column coordinate of the pixel column end point is xe. The obtained initial run data is represented as run(y,xs,xe). Furthermore, the set of initial run data for a pixel row in a binary image can be represented as (run 12 ,run 2 ,run 3 ,…,run n ), where run n Indicates the nth initial trip data.

[0041] Morphological processing refers to processing an image through a preset morphological operation. For example, the morphological processing may be a dilation process, an erosion process, an opening operation, or a closing operation.

[0042] The first run length data is a sequence of pixels with the same continuous pixel values ​​after morphological processing is performed on the pixel row direction of the binary image.

[0043] The image processing device performs morphological processing on the initial stroke data of the binary image acquired row by row to obtain the first stroke data. As an example, the image processing device performs dilation processing on the initial stroke data of the binary image acquired row by row to obtain the first stroke data. As another example, the image processing device performs erosion processing on the initial stroke data of the binary image acquired row by row to obtain the first stroke data.

[0044] Step S120: construct a trip pyramid according to the first trip data, wherein the trip pyramid includes at least two layers of trip data sets, and each layer of trip data sets includes at least one trip data subset.

[0045] The trip pyramid refers to a pyramid-shaped data set constructed using trip data.

[0046] A trip data set refers to a set of trip data subsets. A trip data subset is a set of trip data. A trip data subset can be a set of first trip data or a set of second trip data.

[0047] The image processing device constructs a trip pyramid based on the first trip data. Specifically, the image processing device performs logic processing on the first trip data to obtain the second trip data; the layer where the first trip data is located is used as the first layer of the pyramid; and the layer where the second trip data is located is used as the other layers of the pyramid. Exemplarily, the image processing device performs a union operation on the first trip data obtained after the dilation process to obtain the second trip data. In another exemplary embodiment, the image processing device performs an intersection operation on the first trip data obtained after the erosion process to obtain the second trip data.

[0048] Step S130 , traverse the pixel rows of the binary image, and determine a target run data subset from the run pyramid according to the current pixel row, wherein the target run data subset includes second run data after the current pixel row is subjected to morphological processing on pixel columns.

[0049] A pixel row is a row of pixels in a binary image.

[0050] The target run length data subset is a set of second run length data after the current pixel row is subjected to morphological processing on pixel columns.

[0051] The second travel data is travel data obtained after logical processing of the first travel data.

[0052] The image processing device traverses the pixel rows of the binary image, and determines the target run data subset from the run pyramid according to the current pixel row. Specifically, the image processing device determines the initial pixel row information corresponding to the current pixel row from the binary image according to the current pixel row, and the initial pixel row information includes the pixel row to be morphologically processed in the pixel column direction; the target run data subset is determined according to the matching result between the initial pixel row information and the target pixel row information, and the target pixel row information includes the pixel row where the second run data in each run data subset of other layers is located.

[0053] Step S140 , constructing an image according to the second run length data in the target run length data subset corresponding to each pixel row in the binary image to obtain a target image.

[0054] Image construction refers to constructing the positions of pixel points according to the second stroke data to obtain an image.

[0055] The image processing device constructs an image according to the second run data in the target run data subset corresponding to each pixel row in the binary image to obtain a target image. Specifically, the second run data includes a pixel row, a pixel column where the second run start point is located, and a pixel column where the second run end point is located. The image processing device traverses each pixel row in the binary image, sets the pixel grid between the second run start point and the second run end point in the second run data corresponding to each pixel row to the first pixel value, and sets the pixel grid outside the second run start point and the second run end point to the second pixel value until an image to be processed is obtained; the image to be processed is constructed to obtain a target image.

[0056] It can be seen that the present application performs morphological processing on the initial travel data of the acquired binary image row by row to obtain the first travel data; then constructs a travel pyramid based on the first travel data, the travel pyramid includes at least two layers of travel data sets, and each layer of travel data sets includes at least one travel data subset; traverses the pixel rows of the binary image, and determines the target travel data subset from the travel pyramid based on the current pixel row, the target travel data set includes the second travel data after the current pixel row is morphologically processed on the pixel column; then constructs the image based on the second travel data in the target travel data subset corresponding to each pixel row in the binary image to obtain the target image. By constructing the travel pyramid, the target travel data subset for constructing the target image is determined from the travel pyramid, and repeated access to pixels in the image is avoided, thereby improving the efficiency of constructing the target image.

[0057] Based on the above examples, please continue to refer to Figure 2 , Figure 2 yes Figure 1The flowchart of an exemplary embodiment of step S110 in the image processing method is shown. Specifically, the morphological processing includes dilation processing, the initial stroke data includes stroke data of each pixel row, each stroke data of the pixel row includes an initial stroke start point and an initial stroke end point, and step S110 performs morphological processing on the initial stroke data of the acquired binary image row by row, and the process of obtaining the first stroke data includes the following steps:

[0058] Step S210: Obtain a second target step length of the binary image in the pixel row direction.

[0059] The image processing device obtains a second target step length of the binary image in the direction of the pixel row. Specifically, the image processing device determines the second target step length of the binary image in the direction of the pixel row according to the size information of the element matrix.

[0060] An element matrix refers to a matrix composed of "1" pixels. Specifically, the image processing device constructs an element matrix according to the input matrix parameters. Exemplarily, the element matrix can be expressed as follows:

[0061]

[0062] Where SE represents the element matrix.

[0063] The size information is information about the width or height. For example, the size information of an element matrix with 5 rows and 3 columns is 3 in width and 5 in height.

[0064] The image processing device performs a rounding operation on the width in the size information of the element matrix to obtain a second target step length of the binary image in the pixel row direction. Exemplarily, the second target step length satisfies the following formula: 2 =floor(L SE / 2); where B 2 represents the second target step length, L SE Indicates the width of the element matrix. For example, if the width of the element matrix is ​​3, the second target stride is 1.

[0065] Step S220: moving the target step length in the third direction of the pixel row from the initial starting point of the stroke as the starting point to obtain a processed first starting point of the stroke.

[0066] The image processing device moves the second target step length toward the third direction of the pixel row from the initial stroke starting point as the starting point to obtain the processed first stroke starting point. Exemplarily, the image processing device moves the second target step length toward the left side of the pixel row from the initial stroke starting point to obtain the processed first stroke starting point.

[0067] Step S230, moving a second target step length in a fourth direction of the pixel row from the initial end point of the stroke as a starting point to obtain a processed first end point of the stroke; the third direction is opposite to the fourth direction.

[0068] The image processing device moves the target step length toward the fourth direction of the pixel row from the initial end point of the stroke as the starting point to obtain the processed first stroke end point. Exemplarily, the image processing device moves the second target step length toward the right of the pixel row from the initial end point of the stroke as the starting point to obtain the processed first stroke end point.

[0069] Step S240: determining first trip data based on the processed first trip starting point and the processed first trip end point.

[0070] The image processing device determines the first stroke data based on the processed first stroke starting point and the processed first stroke end point. Specifically, the image processing device uses the pixel row, the pixel column where the processed first stroke starting point is located, and the pixel column where the processed first stroke end point is located as the first stroke data. The first stroke data can be expressed as the following formula: LD i ={run(y,xs-B2,xe+B2)|y==i, B2 represents the second target step length.

[0071] Furthermore, in response to the existence of overlapping runs in adjacent first run data in a pixel row, the image processing device merges the adjacent first run data with the overlapping runs.

[0072] In one embodiment, the morphological processing includes corrosion processing, and the image processing device performs morphological processing on the initial stroke data of the acquired binary image row by row, and the process of obtaining the first stroke data may also include the following steps: obtaining a second target step length of the binary image in the pixel row direction; moving the second target step length in the fourth direction of the pixel row from the initial stroke starting point as the starting point to obtain a processed second stroke starting point; moving the second target step length in the third direction of the pixel row from the initial stroke end point as the starting point to obtain a processed second stroke end point; and determining the first stroke data based on the processed second stroke starting point and the processed second stroke end point.

[0073] As an example, the image processing device performs corrosion processing on the initial run data of the acquired binary image row by row, and the obtained first run data can be expressed as the following formula:

[0074] LR i ={run(y,xs+B 2 ,xe-B 2 )|y==i&&xe-B 2 ≥xs+B 2}

[0075] Further, the image processing device compares the pixel column where the processed second stroke start point is located with the pixel column where the processed second stroke end point is located to obtain a comparison result; in response to the comparison result indicating that the pixel column where the processed second stroke start point is located is larger than the pixel column where the processed second stroke end point is located, the first stroke data is removed. As an example, if xs+B 2 >xe-B 2 , then the first trip data LR i If it is an empty stroke, the image processing device deletes the empty stroke.

[0076] Based on the above examples, please continue to refer to Figure 3 , Figure 3 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S120 in the image processing method. Specifically, the process of constructing a trip pyramid according to the first trip data in step S120 includes the following steps:

[0077] Step S310: Determine the number of layers of the run pyramid according to the size information of the element matrix of the binary image.

[0078] The image processing device determines the number of layers of the pyramid according to the size information of the element matrix of the binary image. Specifically, the image processing device performs rounding processing on the height of the element matrix of the binary image to obtain the number of layers of the pyramid.

[0079] Exemplarily, the height of the element matrix and the number of layers of the trip pyramid satisfy the following formula:

[0080] C = floor (log 2 H SE )+1

[0081] Among them, C represents the number of layers of the trip pyramid, H SE Represents the height of the element matrix.

[0082] For example, H SE =5, the number of layers of the trip pyramid is C = floor (log 2 H SE )+1=3.

[0083] Step S320: Taking the layer where the first trip data is located as the first layer, second trip data of other layers in the trip pyramid are determined layer by layer according to the first trip data in the first layer, and other layers represent the layers in the trip pyramid except the first layer.

[0084] In one embodiment, the other layers include the second layer and the third layer, and the image processing device takes the layer where the first trip data is located as the first layer, and determines the second trip data of other layers in the trip pyramid layer by layer according to the first trip data. As an example, the image processing device performs logical processing on the first trip data in the first layer to obtain the second trip data in the second layer; and performs logical processing on the second trip data in the second layer to obtain the second trip data in the third layer. As another example, the image processing device performs logical processing on the first trip data in the first layer to obtain the second trip data in the second layer and the second trip data in the third layer.

[0085] Specifically, the first run data of the first layer of the image processing device is expressed as LR j Represents the first run of data of the j-th pixel row, LR j Belongs to the set {LR 1 ,LR 2 …LR n},LR 1 Represents the first run data of the first pixel row in the binary image, LR 2 Represents the first run data of the second pixel row in the binary image, LR n Represents the first run data of the nth pixel row in the binary image, where n represents the number of pixel rows in the binary image. represents the first trip data of the jth first level of the pyramid. The first trip data of the first level can also be expressed as in, Indicates the first trip data of the first level of the pyramid. Indicates the second first trip data of the first level of the pyramid, Indicates the third first trip data of the first level of the pyramid, LR 3 Represents the first run of data for the third pixel row in the binary image. Note that the number of first run of data in the first layer can be expressed as NumPy 1 =n.

[0086] The image processing device performs logical processing on the first-stroke data in the first layer to obtain the second-stroke data in the second layer; and performs logical processing on the second-stroke data in the second layer to obtain the second-stroke data in the third layer. As an example, the image processing device sequentially selects two adjacent first-stroke data in the first layer, performs logical processing on the selected two adjacent first-stroke data, and obtains the second-stroke data in the second layer; sequentially selects two adjacent second-stroke data in the second layer, performs logical processing on the selected two adjacent second-stroke data, and obtains the second-stroke data in the third layer. As another example, the image processing device sequentially selects three adjacent first-stroke data in the first layer, performs logical processing on the selected three adjacent first-stroke data, and obtains the second-stroke data in the second layer; sequentially selects three adjacent second-stroke data in the second layer, performs logical processing on the selected three adjacent second-stroke data, and obtains the second-stroke data in the third layer.

[0087] In one embodiment, the image processing device sequentially selects two adjacent first run data in the first layer, performs intersection operation on the selected two adjacent first run data, and obtains the second run data in the second layer. For example, the intersection of the selected two adjacent first run data is used as the second run data in the second layer, which is expressed by the following formula: in, Indicates the first second trip data of the second layer, Represents the second second run data of the second layer. The number of second run data of the second layer of the pyramid is expressed as NumPy 2 =floor(NumPy 1 ). Further, the image processing device responds to the number NumPyr of the first run data of the first layer. 1 is an even number, then the second trip data of the second layer of the pyramid can be expressed as The number of first trip data corresponding to the first layer NumPyr 1 is an odd number, the first to the NumPyr 2 -1 second trip data is represented as NumPyr of the second layer 2 The second trip data is represented as the last first trip data of the first layer

[0088] In one embodiment, the image processing device sequentially selects two adjacent first run data in the first layer, performs a union operation on the selected two adjacent first run data, and obtains the second run data in the second layer. For example, the second run data in the second layer obtained by performing a union operation on the selected two adjacent first run data can be expressed as the following formula: Further, the image processing device responds to the number NumPyr of the first run data of the first layer. 1 is an even number, then the second trip data of the second layer of the pyramid can be expressed as The number of first trip data corresponding to the first layer NumPyr 1 is an odd number, the first to the NumPyr 2 -1 second trip data is represented as NumPyr of the second layer 2 The second trip data is represented as the last first trip data of the first layer

[0089] Step S330: determine a trip pyramid based on the first trip data of the first layer and the second trip data of other layers.

[0090] The image processing device determines a trip pyramid based on the first trip data of the first layer and the second trip data of other layers. As an example, the image processing device uses the layer where the first trip data is located as the first layer of the trip pyramid, and places the other layers on the first layer in descending order of the second trip data to obtain the trip pyramid.

[0091] As an example, Figure 4 This is a schematic diagram of the trip pyramid. The first layer includes the first trip data run 1 -run 16 ; The second layer includes the second run data obtained by processing the union of two adjacent first run data: run 1 ∪run 2 、run 3 ∪run 4 , ..., run 15 ∪run 16 ; The third layer includes the second run data obtained by combining four adjacent first run data: run 1 ∪run 2 ∪run 3 ∪run 4 , ..., run 13 ∪run 14 ∪run 15 ∪run 16 .

[0092] It can be seen that the number of layers of the trip pyramid is determined according to the size information of the element matrix of the binary image, the layer where the first trip data is located is the first layer, and the second trip data of other layers in the trip pyramid are determined layer by layer according to the first trip data in the first layer, and the other layers represent the layers other than the first layer in the trip pyramid, and the trip pyramid is determined based on the first trip data of the first layer and the second trip data of other layers. In this way, the trip pyramid is constructed according to the first trip data.

[0093] Based on the above examples, please continue to refer to Figure 5 , Figure 5 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S130 in the image processing method. Specifically, step S130 traverses the pixel rows of the binary image, and the process of determining the target trip data subset from the trip pyramid according to the current pixel row includes the following steps:

[0094] Step S510: determining initial pixel row information corresponding to the current pixel row from the binary image according to the current pixel row, where the initial pixel row information includes the pixel row to be morphologically processed in the pixel column direction.

[0095] The pixel column direction refers to the direction of the column where the pixels are located in the binary image.

[0096] The initial pixel row information is the pixel column required for morphological processing of the current pixel row in the pixel column direction. For example, the initial pixel row information can be expressed as dB 1 Go to d+B 1 row, where d represents the row number of the current pixel row, B 1 Indicates the first target step size.

[0097] The image processing device determines the initial pixel row information corresponding to the current pixel row from the binary image according to the current pixel row. Specifically, the image processing device obtains the first target step length of the binary image in the direction of the pixel column; moves the first target step length in the first direction of the pixel column with the current pixel row as the starting point to obtain the starting point of the pixel row after the movement; moves the second target step length in the second direction of the pixel column with the current pixel row as the starting point to obtain the end point of the pixel row after the movement; the first direction is opposite to the second direction; and the pixel row between the starting point of the pixel row after the movement and the end point of the pixel row after the movement is determined as the initial pixel row information corresponding to the current pixel row. Exemplarily, the first direction and the second direction can be up and down, respectively.

[0098] The image processing device obtains the first target step length of the binary image in the direction of pixel columns. As an example, the image processing device uses the column radius of the element matrix as the first target step length of the binary image in the direction of pixel rows. As another example, the image processing device rounds the height in the size information of the element matrix to obtain the first target step length of the binary image in the direction of pixel rows. For example, the first target step length satisfies the following formula B 1 =floor(H SE / 2), B 1 Indicates the first target step size. For example, if the height of the element matrix is ​​5, then the first target step size B of the element matrix 1 =floor(H SE / 2)=2.

[0099] Step S520: determining an initial run length data subset according to a matching result between the initial pixel row information and the target pixel row information, wherein the target pixel row information includes a pixel row where the second run length data in each run length data subset of other layers is located.

[0100] The target pixel row information is the pixel row where the second run length data in each run length data subset of other layers is located.

[0101] The image processing device determines the initial trip data subset according to the matching result between the initial pixel row information and the target pixel row information. Specifically, the image processing device calculates the similarity between the pixel row where the second trip data is located in each trip data subset in the trip pyramid and the initial pixel row information, and obtains the similarity between the pixel row where the second trip data is located in each trip data subset and the initial pixel row information; and uses the pixel row corresponding to each trip data subset with the highest similarity as the target pixel row information.

[0102] Step S530, in response to the existence of a target pixel row between the initial pixel row information and the target pixel row information, determining the first run data of the target pixel row from the first layer, the target pixel row representing a different pixel row where the initial pixel row information is equivalent to the target pixel row information.

[0103] The target pixel row refers to a different pixel row whose initial pixel row information is equivalent to the target pixel row information.

[0104] The image processing device compares the pixel rows in the initial pixel row information with the pixel rows in the target pixel row information to obtain a comparison result; the comparison result indicates that the pixel rows in the initial pixel row information are exactly the same as the pixel rows in the target pixel row information, or the comparison result indicates that there is a target pixel row between the pixel rows in the initial pixel row information and the pixel rows in the target pixel row information; in response to the existence of the target pixel row between the initial pixel row information and the target pixel row information, the first stroke data of the target pixel row is determined from the first layer.

[0105] Step S540: perform logic processing on the first run length data of the target pixel row and the second run length data in the initial run length data subset to obtain a target run length data subset.

[0106] The image processing device performs logic processing on the first stroke data of the target pixel row and the second stroke data in the initial stroke data subset to obtain the target stroke data subset. Specifically, the image processing device performs an intersection operation or a union operation on the first stroke data of the target pixel row and the second stroke data in the initial stroke data subset to obtain the target stroke data subset. It should be noted that the logic processing method used in the process of constructing the stroke pyramid according to the first stroke data in step S120 is consistent with the logic processing method used in obtaining the target stroke data subset in step S540.

[0107] In one embodiment, the process of obtaining the target run data subset by the image processing device includes: the row where the current pixel row is located is the 3rd row, and the initial pixel row information corresponding to the current pixel row is the 1st pixel row to the 5th pixel row. The intersection processing of the first run data from the 1st pixel row to the 5th pixel row can be expressed as According to the matching result between the initial pixel row information and the target pixel row information, the initial travel data subset is determined as follows: Determine the first trip data from the first layer but For details, please refer to Figure 2 , Indicates the data of the first second trip in the third layer of the trip pyramid. is the result of the union operation of the 1st to 4th second trip data in the first layer, that is,

[0108] The row where the current pixel row is located is the 4th row, and the initial pixel row information corresponding to the current pixel row is the 2nd pixel row to the 6th pixel row. The intersection processing of the first run data of the 2nd pixel row to the 6th pixel row can be expressed as According to the matching result between the initial pixel row information and the target pixel row information, the initial travel data subset is determined as follows: Determine the first trip data from the first layer but For details, please refer to Figure 2 , Indicates the second trip data of the second level in the trip pyramid. is the result of the operation of the 3rd to 4th first trip data in the first layer, that is, Indicates the third second trip data of the second layer in the trip pyramid. is the result of the operation of the 5th to 6th first trip data in the first layer, that is,

[0109] The row where the current pixel row is located is the 5th row, and the initial pixel row information corresponding to the current pixel row is the 3rd pixel row to the 7th pixel row. The intersection processing of the first run data of the 3rd pixel row to the 7th pixel row can be expressed as According to the matching result between the initial pixel row information and the target pixel row information, the initial travel data subset is determined as follows: Determine the first trip data from the first layer but

[0110] The row where the current pixel row is located is the 6th row, and the initial pixel row information corresponding to the current pixel row is the 4th pixel row to the 8th pixel row. The intersection processing of the first run data of the 4th pixel row to the 8th pixel row can be expressed as According to the matching result between the initial pixel row information and the target pixel row information, the initial travel data subset is determined as follows: Determine the first trip data from the first layer but Indicates the second trip data of the third level in the trip pyramid. It can be the result of the calculation of the 3rd to 4th second-trip data in the second layer, or it can be the result of the calculation of the 5th to 8th first-trip data in the first layer, that is,

[0111] It should be noted that in the prior art, when performing morphological processing on each pixel row of a binary image in the direction of pixel columns, repeated calculations occur. For example, the morphological processing on the pixel column direction of the i-th pixel row of a binary image can be expressed as: The morphological processing of the pixel column direction in the i+1th pixel row can be expressed as By comparison, we can see that in the morphological processing of the pixel columns of the i-th row and the i+1-th row, LR i-1 ∪…∪LR i ∪…∪LR i+2 Repeat the calculation twice. The time complexity of the above calculation method is O(H SE ). For example, the computational complexity of the 3rd to 6th pixel rows is 4*5=20 units. For binary images with large element matrix height values, repeated computations will lead to explosive growth in computation time. The image processing method provided in this embodiment constructs a trip pyramid, making the computational time complexity O(log 2 H SE ), for example, the calculation for pixel rows 3-6 includes and The calculation amount of the 3rd to 6th pixel rows is 2+3+3+2=10 units. It can be seen that the image processing method provided in this embodiment greatly reduces the amount of repeated calculations by constructing a trip pyramid. For the morphological processing of binary images with large element matrix sizes, the amount of calculations can be greatly reduced, explosive growth can be avoided, and computing resources can be saved.

[0112] In one embodiment, the binary image obtained by the image processing device is as follows: Figure 6 As shown, run encoding is performed on each pixel row in the binary image to obtain the initial run data: run 4 ={(4,4,7),(4,13,13)}, run 5 ={(5,4,7),(5,10,12)}, run 6 ={(6,4,5),(6,12,12)}, run 7 ={(7,5,5),(7,10,12)}, run 8 ={(8,5,5),(8,9,10)}, run 9 ={(9,5,5),(9,9,10)}, run 10 ={(10,4,10)}, run 11 ={(11,4,13)}, run 12 ={(12,4,7),(12,11,11)}、run 13 ={(13,7,11)}, The image processing device performs expansion processing on the initial run data of the acquired binary image line by line to obtain the first run data: LD 4 ={(4,3,8),(4,12,14)},LD 5 ={(5,3,13)}, LD 6 ={(6,3,6),(6,11,13)},LD 7 ={(7,4,6),(7,9,13)},LD 8 ={(8,4,6),(8,8,11)},LD 9 ={(9,4,6),(9,8,11)},LD 10 ={(10,3,11)},LD 11 ={(11,3,14)},LD 12 ={(12,3,8),(12,10,12)},LD 13={(13,6,12)}, The image after the binary image is expanded is as follows Figure 7 The image processing device constructs a trip pyramid based on the first trip data. The number of levels of the trip pyramid is floor(log 2 5)+1=3. The itinerary data of the first level of the itinerary pyramid are:

[0113]

[0114] The trip data of the second level of the trip pyramid is represented as Specifically, they are:

[0115] The trip data of the third level of the trip pyramid is represented as The specific itinerary data of the third level of the itinerary pyramid are: The image processing device traverses the pixel rows of the binary image, determines the target trip data subset from the trip pyramid according to the current pixel row, and obtains the target trip data subsets of each pixel row of the binary image respectively:

[0116] The image formed by the target travel data subset of each pixel row of the binary image is as follows Figure 8 shown.

[0117] It can be seen that the present application performs morphological processing on the binary image in the direction of pixel rows, then determines the second run data after the morphological processing on the pixel columns from the run pyramid, and then performs image construction on the second run data to obtain the target image. By establishing the run pyramid, the amount of repeated calculations of the morphological processing in the direction of pixel columns is reduced, the calculation efficiency is greatly improved, and then the efficiency of constructing the target image is improved.

[0118] Fig. 9 FIG. 1 is a block diagram of an image processing device shown in an exemplary embodiment of the present application. Fig. 9 As shown, the exemplary image processing device 900 includes: a morphological processing module 910, a trip pyramid building module 920, a target trip data subset determination module 930 and a target image acquisition module 940. Specifically:

[0119] The morphological processing module 910 is used to perform morphological processing on the acquired initial run length data of the binary image line by line to obtain first run length data.

[0120] The trip pyramid building module 920 is used to build a trip pyramid according to the first trip data, wherein the trip pyramid includes at least two layers of trip data sets, and each layer of trip data sets includes at least one trip data subset.

[0121] The target run data subset determination module 930 is used to traverse the pixel rows of the binary image and determine the target run data subset from the run pyramid according to the current pixel row, wherein the target run data subset includes the second run data after the current pixel row is subjected to morphological processing on the pixel columns.

[0122] The target image acquisition module 940 is used to construct an image according to the second travel data in the target travel data subset corresponding to each pixel row in the binary image to obtain the target image.

[0123] In the exemplary image processing device, the initial stroke data of the acquired binary image is subjected to morphological processing row by row to obtain the first stroke data; then a stroke pyramid is constructed based on the first stroke data, the stroke pyramid includes at least two layers of stroke data sets, and each layer of the stroke data sets includes at least one stroke data subset; the pixel rows of the binary image are traversed, and a target stroke data subset is determined from the stroke pyramid based on the current pixel row, and the target stroke data set includes the second stroke data after the current pixel row is subjected to morphological processing on the pixel columns; then an image is constructed based on the second stroke data in the target stroke data subset corresponding to each pixel row in the binary image to obtain a target image. By constructing the stroke pyramid, the target stroke data subset used for constructing the target image is determined from the stroke pyramid, and repeated access to pixels in the image is avoided, thereby improving the efficiency of constructing the target image.

[0124] The functions of each module can be found in the embodiment of the image processing method and will not be described in detail here.

[0125] To implement the image processing method of the above embodiment, the present application proposes another electronic device, for details, please refer to Fig.10 , Fig.10 It is a structural schematic diagram of an embodiment of an electronic device provided by the present application.

[0126] The electronic device 1000 includes a memory 1001 and a processor 1002 , wherein the memory 1001 and the processor 1002 are coupled.

[0127] The memory 1001 is used to store program data, and the processor 1002 is used to execute the program data to implement the image processing method of the above embodiment.

[0128] In this embodiment, the processor 1002 may also be referred to as a CPU (Central Processing Unit). The processor 1002 may be an integrated circuit chip having signal processing capabilities. The processor 1002 may also be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. A general-purpose processor may be a microprocessor or the processor 1002 may also be any conventional processor, etc.

[0129] The present application also provides a computer-readable storage medium, such as Fig.11 As shown, the computer-readable storage medium 1100 is used to store program data 1101. When the program data 1101 is executed by the processor, it is used to implement the image processing method in the method embodiment of the present application.

[0130] The method involved in the image processing method embodiment of the present application, when implemented in the form of a software functional unit and sold or used as an independent product, can be stored in a device, such as a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0131] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. An image processing method, characterized in that: The method comprises: Performing morphological processing on the initial stroke data of the acquired binary image row by row to obtain first stroke data; Building a trip pyramid according to the first trip data, wherein the trip pyramid includes at least two layers of trip data sets, and each layer of trip data sets includes at least one trip data subset; traversing pixel rows of the binary image, and determining a target run data subset from the run pyramid according to a current pixel row, wherein the target run data subset includes second run data after morphological processing on pixel columns of the current pixel row is performed; An image is constructed according to the second stroke data in the target stroke data subset corresponding to each pixel row in the binary image to obtain a target image.

2. The image processing method according to claim 1, characterized in that: The step of constructing a trip pyramid according to the first trip data includes: Determining the number of layers of the stroke pyramid according to size information of the element matrix of the binary image; Taking the layer where the first trip data is located as the first layer, determining the second trip data of other layers in the trip pyramid layer by layer according to the first trip data in the first layer, wherein the other layers represent the layers in the trip pyramid other than the first layer; The trip pyramid is determined based on the first trip data of the first layer and the second trip data of the other layers.

3. The image processing method according to claim 2, characterized in that: The other layers include a second layer and a third layer. The step of taking the layer where the first trip data is located as the first layer and determining the second trip data of other layers in the trip pyramid layer by layer according to the first trip data comprises: Performing logical processing on the first trip data in the first layer to obtain second trip data in the second layer; The second trip data in the second layer is logically processed to obtain the second trip data in the third layer.

4. The image processing method according to claim 1, characterized in that: The trip pyramid includes a first layer and other layers, and the step of traversing the pixel rows of the binary image and determining a target trip data subset from the trip pyramid according to the current pixel row includes: Determining initial pixel row information corresponding to the current pixel row from the binary image according to the current pixel row, wherein the initial pixel row information includes a pixel row to be morphologically processed in a pixel column direction; determining an initial run length data subset according to a matching result between the initial pixel row information and the target pixel row information, wherein the target pixel row information includes a pixel row where the second run length data in each run length data subset of the other layer is located; In response to the existence of a target pixel row between the initial pixel row information and the target pixel row information, determining first run length data of the target pixel row from the first layer, the target pixel row representing a different pixel row where the initial pixel row information is equivalent to the target pixel row information; Logically process the first run length data of the target pixel row and the second run length data in the initial run length data subset to obtain the target run length data subset.

5. The image processing method according to claim 4, characterized in that: The step of determining initial pixel row information corresponding to the current pixel row from the binary image according to the current pixel row comprises: Acquire a first target step length of the binary image in a pixel column direction; Taking the current pixel row as the starting point, moving the pixel row in the first direction of the pixel column by the first target step length to obtain a starting point of the pixel row after the movement; Taking the current pixel row as the starting point, move the first target step length in the second direction of the pixel column to obtain an end point of the pixel row after the movement; the first direction is opposite to the second direction; The pixel row between the moved pixel row start point and the moved pixel row end point is determined as initial pixel row information corresponding to the current pixel row.

6. The image processing method according to claim 1, characterized in that: The morphological processing includes dilation processing, the initial stroke data includes stroke data of each pixel row, each stroke data of the pixel row includes an initial stroke start point and an initial stroke end point, and the step of performing morphological processing on the initial stroke data of the acquired binary image row by row to obtain the first stroke data includes: Acquire a second target step length of the binary image in a pixel row direction; Taking the stroke initial starting point as the starting point, moving the second target step length toward the third direction of the pixel row to obtain the processed first stroke starting point; Taking the stroke initial end point as a starting point, moving the second target step length in a fourth direction of the pixel row to obtain the processed first stroke end point; the third direction is opposite to the fourth direction; The first trip data is determined based on the processed first trip start point and the processed first trip end point.

7. The image processing method according to claim 1, characterized in that: The morphological processing includes corrosion processing, the initial stroke data includes stroke data of each pixel row, each stroke data of the pixel row includes an initial stroke start point and an initial stroke end point, and the step of performing morphological processing on the initial stroke data of the acquired binary image row by row to obtain the first stroke data includes: Acquire a second target step length of the binary image in a pixel row direction; Taking the stroke initial starting point as a starting point, moving the second target step length toward a fourth direction of the pixel row to obtain the processed second stroke starting point; Taking the stroke initial end point as a starting point, moving the second target step length toward the third direction of the pixel row to obtain the processed second stroke end point; The first trip data is determined based on the processed second trip starting point and the processed second trip end point.

8. The image processing method according to claim 7, characterized in that: The step of obtaining a second target step length of the binary image in the pixel row direction comprises: A second target step size of the binary image in a pixel row direction is determined according to the size information of the element matrix.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the image processing method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: include: Program data is stored, and when the program data is executed by a processor, it is used to implement the image processing method according to any one of claims 1 to 8.