Image processing method and device, equipment and storage medium

By acquiring information from each pixel in an image, generating and merging rectangles to determine a graphic, the problem of inaccurate graphics in existing technologies is solved, and the accuracy of image-to-graphic conversion is improved.

CN121661158APending Publication Date: 2026-03-13SUZHOU YUANZHUO OPTOELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

In existing technologies, when determining the image contour by detecting the grayscale value jumps of pixels in an image, the recorded jump point positions do not include the pixel's filling area, resulting in inaccurate graphics.

Method used

The pixel information of each pixel in the image to be processed is obtained, multiple target pixels that meet the preset grayscale value are identified, multiple rectangles are generated according to the pixel size and position information, and these rectangles are merged to obtain the graphic.

Benefits of technology

It improves the accuracy of image-to-graphic conversion, reduces errors, and takes into account the pixel filling area.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121661158A_ABST
    Figure CN121661158A_ABST
Patent Text Reader

Abstract

The invention discloses an image processing method and device, equipment and a storage medium, and relates to the technical field of computers. The method comprises the following steps: acquiring pixel information of each pixel in a to-be-processed image; the pixel information comprises a pixel size, position information and a gray value; determining a plurality of target pixels meeting a preset gray value; determining a plurality of rectangles according to the pixel sizes and the position information of the plurality of target pixels; the size of each rectangle in the plurality of rectangles is determined according to the pixel size correspondingly comprising the target pixels and the number of the target pixels; the position information of each rectangle is determined according to the position information of the target pixel corresponding to each rectangle; and combining the plurality of rectangles to obtain a graph of the to-be-processed image. Therefore, the technical problem that the graph obtained in the prior art is inaccurate can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to an image processing method, apparatus, device, and storage medium, and relates to the field of computer technology. Background Technology

[0002] In the field of computer technology, some computer-aided design software can only edit, analyze, or optimize graphics, and the data size of graphics may be smaller than that of images. Therefore, it is necessary to convert images into graphics.

[0003] In related technologies, the main method is to determine the outline of an image and then obtain the corresponding graphic by detecting abrupt changes in the grayscale values ​​of pixels. However, when a grayscale change is detected, the recorded position of the change point is the pixel's coordinates, excluding the pixel's filled area. This leads to inaccurate results in the obtained graphic. Summary of the Invention

[0004] This invention provides an image processing method, apparatus, device, and storage medium to at least solve the technical problem of inaccurate images obtained in related technologies. The technical solution of this application is as follows:

[0005] According to a first aspect of the embodiments of this application, an image processing method is provided, comprising: acquiring pixel information of each pixel in an image to be processed; the pixel information including pixel size, position information, and grayscale value; determining a plurality of target pixels that satisfy a preset grayscale value; determining a plurality of rectangles based on the pixel size and position information of the plurality of target pixels; the size of each rectangle is determined according to the pixel size and the number of target pixels corresponding to it; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle; and merging the plurality of rectangles to obtain a graphic of the image to be processed.

[0006] In one possible implementation, determining multiple rectangles based on the pixel size and position information of multiple target pixels includes: generating rectangles with the same pixel size and position information as the first target pixel to obtain multiple rectangles; the first target pixel is any one of the multiple target pixels.

[0007] In one possible implementation, determining multiple rectangles based on the pixel size and position information of multiple target pixels includes: determining multiple target pixel sets; each target pixel set includes consecutive target pixels among the multiple target pixels; generating rectangles corresponding to each target pixel set to obtain multiple rectangles; the size of each rectangle is equal to the sum of the pixel sizes of the target pixels corresponding to each rectangle; and the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle.

[0008] In one possible implementation, the method further includes connecting the two points when the difference between the horizontal coordinates of two points in the graph is less than or equal to a preset difference between the horizontal coordinates, and the difference between the vertical coordinates of the two points is less than or equal to a preset difference between the vertical coordinates.

[0009] In one possible implementation, the method further includes: dividing the image to be processed into multiple sub-images to be processed; having an intersection between two adjacent sub-images to be processed; generating multiple sub-tasks that correspond one-to-one with the multiple sub-images to be processed, and calling multiple threads to process the multiple sub-tasks.

[0010] According to a second aspect of the embodiments of this application, an image processing apparatus is provided, the apparatus comprising: an acquisition unit, a determination unit, and a processing unit; the acquisition unit is configured to acquire pixel information of each pixel in an image to be processed; the pixel information includes pixel size, position information, and grayscale value; the determination unit is configured to determine a plurality of target pixels that satisfy a preset grayscale value; the determination unit is further configured to determine a plurality of rectangles based on the pixel size and position information of the plurality of target pixels; the size of each rectangle is determined based on the pixel size and the number of target pixels corresponding to the target pixels; the position information of each rectangle is determined based on the position information of each rectangle corresponding to the target pixels; the processing unit is configured to merge the plurality of rectangles to obtain a graphic of the image to be processed.

[0011] In one possible implementation, in the above image processing apparatus, the determining unit is specifically used to: generate rectangles with the same pixel size and position information as the first target pixel, so as to obtain multiple rectangles; the first target pixel is any one of the multiple target pixels.

[0012] In one possible implementation, in the above image processing apparatus, the determining unit is specifically configured to: determine a plurality of target pixel sets; each target pixel set includes consecutive target pixels among the plurality of target pixels; generate rectangles corresponding to each target pixel set to obtain a plurality of rectangles; the size of each rectangle is equal to the sum of the pixel sizes of the target pixels corresponding to each rectangle; and the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle.

[0013] In one possible implementation, the processing unit in the above-described image processing apparatus is further configured to connect two points when the difference between the horizontal coordinates of two points in the image is less than or equal to a preset difference between the horizontal coordinates, and the difference between the vertical coordinates of the two points is less than or equal to a preset difference between the vertical coordinates.

[0014] In one possible implementation, the image processing apparatus described above further includes a processing unit configured to: divide the image to be processed into multiple sub-images to be processed; ensure that two adjacent sub-images to be processed have an intersection; generate multiple sub-tasks that correspond one-to-one with the multiple sub-images to be processed; and call multiple threads to process the multiple sub-tasks.

[0015] According to a third aspect of the embodiments of this application, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute instructions to implement the method of the first aspect described above and any possible implementation thereof.

[0016] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided, which, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the methods of the first aspect and any possible implementation thereof.

[0017] According to a fifth aspect of the embodiments of this application, a computer program product is provided, the computer program product including computer instructions, which, when executed on an electronic device, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.

[0018] The technical solution of the first aspect provided by the embodiments of this application has at least the following beneficial effects:

[0019] The technical solution provided in this application first obtains pixel information for each pixel in the image to be processed; the pixel information includes pixel size, position information, and grayscale value. Then, multiple target pixels that satisfy a preset grayscale value are determined. Next, multiple rectangles are determined based on the pixel size and position information of the multiple target pixels; the size of each rectangle is determined according to the pixel size and number of target pixels; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle. Further, the multiple rectangles are merged to obtain the graphic of the image to be processed. In this way, since the pixel size and position information in the image to be processed reflect the pixel filling area, the obtained graphic of the image to be processed takes into account the pixel filling area, reducing the error in converting the image to a graphic and improving the accuracy of image-to-graphic conversion.

[0020] It should be noted that the technical effects of any of the implementation methods in aspects two through five can be found in the technical effects of the corresponding implementation methods in aspect one, and will not be repeated here.

[0021] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0022] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application, and do not constitute an undue limitation of this application.

[0023] Figure 1 This is a flowchart illustrating an image processing method according to an exemplary embodiment;

[0024] Figure 2 This is a schematic diagram illustrating an image processing method according to an exemplary embodiment;

[0025] Figure 3 This is a schematic diagram illustrating an image processing method according to an exemplary embodiment;

[0026] Figure 4 This is a schematic diagram illustrating an image processing method according to an exemplary embodiment;

[0027] Figure 5 This is a schematic diagram illustrating yet another image processing method according to an exemplary embodiment;

[0028] Figure 6 This is a schematic diagram illustrating yet another image processing method according to an exemplary embodiment;

[0029] Figure 7 This is a schematic diagram illustrating yet another image processing method according to an exemplary embodiment;

[0030] Figure 8 This is a schematic diagram illustrating yet another image processing method according to an exemplary embodiment;

[0031] Figure 9 This is a block diagram illustrating an image processing apparatus according to an exemplary embodiment;

[0032] Figure 10 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation

[0033] In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, the specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0034] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0035] Before providing a detailed introduction to the image processing method provided in this application, let's briefly introduce the application scenarios involved in this application.

[0036] In the field of computer technology, images visually represent information pixel by pixel, while two-dimensional graphics are geometric shapes on a plane, expressing information through their boundaries and internal regions. Some computer-aided design software can only edit, analyze, or optimize graphics, and the data size of graphics may be smaller than that of images. Therefore, it is necessary to convert images into graphics.

[0037] In related technologies, the main method for determining the image contour is by detecting abrupt changes in the grayscale values ​​of pixels (such as the `findContours` function in OpenCV), thereby obtaining the corresponding graphic. However, when a grayscale change is detected, the recorded position of the change point is the pixel's coordinates, excluding the pixel's filled area. This leads to inaccurate results in the obtained graphic.

[0038] Figure 1 This is a flowchart illustrating an image processing method according to an exemplary embodiment. The method can be applied to an electronic device, or to an image processing apparatus connected to or located within an electronic device. The following description uses an example of the method being applied to an electronic device to illustrate the method. Figure 1 As shown, the image processing method includes the following steps:

[0039] S101, The electronic device acquires pixel information of each pixel in the image to be processed.

[0040] The pixel information includes pixel size, position information, and grayscale value.

[0041] As one possible implementation, the electronic device retrieves the pixel information of each pixel in the image to be processed from the attribute information of the image to be processed.

[0042] As another possible implementation, the electronic device obtains the pixel information of each pixel in the image to be processed by traversing each pixel in the image to be processed.

[0043] It should be noted that the size of a pixel includes the length of the pixel in the horizontal and vertical directions, and the position information of a pixel includes the coordinates of the pixel.

[0044] For example, the pixel at coordinates (3,8) in the image to be processed has a pixel size of 10 micrometers in the horizontal direction and 10 micrometers in the vertical direction, and the gray value of the pixel is 255.

[0045] In practical applications, electronic devices first determine the origin of the coordinate system of the image to be processed, convert the rows of the image to be processed into vertical coordinates, and convert the columns of the image to be processed into horizontal coordinates.

[0046] S102, The electronic device determines multiple target pixels that meet the preset grayscale values.

[0047] As one possible implementation, the electronic device iterates through each pixel in the image to be processed, and when a pixel meets a preset grayscale value, the electronic device identifies that pixel as a target pixel. Furthermore, the electronic device identifies multiple target pixels that meet the preset grayscale values.

[0048] S103. The electronic device determines multiple rectangles based on the pixel size and position information of multiple target pixels.

[0049] The size of each rectangle is determined based on the pixel size and the number of target pixels; the position information of each rectangle is determined based on the position information of the target pixels for each rectangle.

[0050] As one possible implementation, the electronic device generates rectangles with the same pixel size and position information as the first target pixel, to obtain multiple rectangles.

[0051] It should be noted that the first target pixel can be any one of the multiple target pixels.

[0052] As another possible implementation, the electronic device first determines a set of multiple target pixels.

[0053] Furthermore, the electronic device generates a rectangle corresponding to each set of target pixels to obtain multiple rectangles.

[0054] It should be noted that each set of target pixels includes consecutive target pixels from multiple target pixels; the size of each rectangle is equal to the sum of the pixel sizes of the target pixels corresponding to each rectangle; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle.

[0055] S104. The electronic device merges multiple rectangles to obtain the graphic of the image to be processed.

[0056] As one possible implementation, the electronic device inputs multiple rectangles into a Boolean operation on a polygon. Correspondingly, the Boolean operation on the polygon merges the multiple rectangles, outputting the graphic of the image to be processed.

[0057] Understandably, the technical solution provided in this application first obtains pixel information for each pixel in the image to be processed; the pixel information includes pixel size, position information, and grayscale value. Then, multiple target pixels that satisfy a preset grayscale value are determined. Next, multiple rectangles are determined based on the pixel size and position information of the multiple target pixels; the size of each rectangle is determined according to the pixel size and number of target pixels corresponding to it; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle. Further, the multiple rectangles are merged to obtain the graphic of the image to be processed. Thus, since the pixel size and position information in the image to be processed reflect the pixel filling area, the obtained graphic of the image to be processed takes into account the pixel filling area, reducing the error in converting the image to a graphic and improving the accuracy of image-to-graphic conversion.

[0058] In some embodiments, in order to determine multiple rectangles, the image processing method provided in this application embodiment specifically includes the following steps in S103:

[0059] S201. The electronic device generates rectangles with the same pixel size and position information as the first target pixel, so as to obtain multiple rectangles.

[0060] The first target pixel can be any one of the multiple target pixels.

[0061] It should be noted that the size of any one of the multiple rectangles is the same as the pixel size of the first target pixel corresponding to that rectangle.

[0062] For example, when the coordinates of the first target pixel are (3, 5), and the length and height of the pixel are both 10 micrometers, the rectangle obtained after the transformation of the first target pixel will have a length and height of 10 micrometers. Furthermore, in practical applications, the point with coordinates (3, 5) is located on the edge or inside the rectangle.

[0063] As can be understood, the technical solution provided in this application generates multiple rectangles by generating rectangles with the same pixel size and position information as the first target pixel; the first target pixel is any one of the multiple target pixels. In this way, a method for determining multiple rectangles is implemented.

[0064] In some embodiments, in order to determine multiple rectangles, the image processing method provided in this application embodiment specifically includes the following steps in S103:

[0065] S301, The electronic device determines a set of multiple target pixels.

[0066] Each set of target pixels includes consecutive target pixels from multiple target pixels.

[0067] As one possible implementation, the electronic device processes each row of the image to be processed, determining consecutive target pixels in each row as a set of target pixels. Further, the electronic device determines multiple sets of target pixels.

[0068] As another possible implementation, the electronic device processes each column of the image to be processed, determining consecutive target pixels in each column as a target pixel set. Further, the electronic device determines multiple target pixel sets.

[0069] S302, The electronic device generates a rectangle corresponding to each set of target pixels to obtain multiple rectangles.

[0070] The size of each rectangle is equal to the sum of the pixel sizes of the target pixels corresponding to each rectangle; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle.

[0071] For example, when the target pixel set includes 6 target pixels in the same row, and the size of the target pixels is 10 micrometers by 10 micrometers, then the rectangle corresponding to the target pixel set is 60 micrometers by 10 micrometers.

[0072] When the target pixel set includes 7 target pixels in the same column, and the size of the target pixel is 10 micrometers by 10 micrometers, then the rectangle corresponding to the target pixel set is 10 micrometers by 70 micrometers.

[0073] As is understood, the technical solution provided in this application involves determining multiple target pixel sets; each target pixel set includes consecutive target pixels; generating rectangles corresponding to each target pixel set to obtain multiple rectangles; the size of each rectangle is equal to the sum of the pixel sizes of the target pixels corresponding to each rectangle; and the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle. Thus, since the rectangles are generated based on multiple consecutive target pixels, it is not necessary to convert each target pixel into a rectangle, thereby improving the processing efficiency during rectangle conversion.

[0074] In some embodiments, in order to improve the smoothness of graphics, the image processing method provided in this application further includes the following steps:

[0075] S401. The electronic device determines whether there are two points in a graphic whose x-coordinate difference is less than or equal to a preset x-coordinate difference.

[0076] As one possible implementation, the electronic device calculates the difference in the horizontal coordinates of any two points in the graph and determines whether the difference in the horizontal coordinates is less than or equal to a preset difference in the horizontal coordinates.

[0077] For example, the preset difference in the horizontal coordinates is 1.

[0078] S402. The electronic device determines whether there are two points in a graphic whose ordinate difference is less than or equal to a preset ordinate difference.

[0079] As one possible implementation, the electronic device calculates the difference in the vertical coordinates of any two points in the graph and determines whether the difference in the vertical coordinates is less than or equal to a preset difference in the vertical coordinates.

[0080] For example, the preset difference in the vertical coordinates is 1.

[0081] S403. When the difference between the horizontal coordinates of two points in a graph is less than or equal to a preset difference between the horizontal coordinates, and the difference between the vertical coordinates of two points is less than or equal to a preset difference between the vertical coordinates, the electronic device connects the two points.

[0082] Understandably, the technical solution provided in this application determines whether there are two points in the image whose x-coordinate difference is less than or equal to a preset x-coordinate difference, and whether there are two points in the image whose y-coordinate difference is less than or equal to a preset y-coordinate difference. Then, when there are two points in the image whose x-coordinate difference is less than or equal to the preset x-coordinate difference, and whose y-coordinate difference is also less than or equal to the preset y-coordinate difference, the electronic device connects the two points. In this way, without changing the image's outline, the amount of data in the updated image can be reduced, and the smoothness of the image can be improved.

[0083] In some embodiments, in order to improve the smoothness of graphics, the image processing method provided in this application further includes the following steps:

[0084] S501, The electronic device divides the image to be processed into multiple sub-images to be processed.

[0085] Among them, two adjacent sub-images to be processed have an intersection.

[0086] In practical applications, to improve computational efficiency, when using row scanning to accelerate the obtaining of the rectangle corresponding to the target pixel set, width priority can be set. When using column scanning to accelerate the obtaining of the rectangle corresponding to the target pixel set, height priority can be set.

[0087] It is understandable that two adjacent sub-images to be processed have an intersection, which can save the context information of the segmented image regions.

[0088] S502, The electronic device generates multiple sub-tasks that correspond one-to-one with multiple sub-images to be processed, and calls multiple threads to process the multiple sub-tasks.

[0089] As is understood, the technical solution provided in this application divides the image to be processed into multiple sub-images. Furthermore, multiple sub-tasks corresponding one-to-one with the multiple sub-images are generated, and multiple threads are invoked to process these sub-tasks. In this way, by pre-dividing the image to be processed into multiple sub-images, and then processing these multiple sub-images in parallel, the efficiency of image-to-graphics conversion can be improved.

[0090] In some embodiments, such as Figure 2 As shown, Figure 2 This is an image to be processed in a practical application. Figure 3 For the image to be processed in the above Figure 2 A magnified view of the area indicated by the middle arrow.

[0091] The image processing method provided in this application includes the following steps:

[0092] S601. The electronic device acquires pixel information of each pixel in the image to be processed.

[0093] The pixel information includes pixel size, position information, and grayscale value.

[0094] It should be noted that the implementation of S601 above can refer to the implementation of S101 above.

[0095] S602, The electronic device determines multiple target pixels that meet the preset grayscale values.

[0096] For example, the preset grayscale value is 0. Multiple target pixels are black pixels in the image to be processed.

[0097] S603, the electronic device determines multiple rectangles based on the pixel size and position information of multiple target pixels.

[0098] As one possible implementation, the electronic device generates rectangles with the same pixel size and position information as the first target pixel, to obtain multiple rectangles.

[0099] It should be noted that the first target pixel can be any one of the multiple target pixels.

[0100] The resulting multiple rectangles are as follows Figure 4 As shown.

[0101] As another possible implementation, the electronic device determines a set of multiple target pixels.

[0102] Furthermore, the electronic device generates a rectangle corresponding to each set of target pixels to obtain multiple rectangles.

[0103] It should be noted that the size of each rectangle is equal to the sum of the pixel sizes of the target pixels corresponding to each rectangle; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle. Each set of target pixels includes consecutive target pixels from multiple target pixels.

[0104] In practical applications, if a row-scanning acceleration method is used to determine multiple target pixel sets, the rectangle corresponding to each target pixel set generated will be as follows: Figure 5 As shown.

[0105] S604. The electronic device merges multiple rectangles to obtain the graphic of the image to be processed.

[0106] It should be noted that the implementation of S604 above can refer to the implementation of S104 above.

[0107] like Figure 6 As shown, Figure 6 The image to be processed is shown as a graph obtained by merging multiple rectangles.

[0108] S605. When the difference between the horizontal coordinates of two points in a graph is less than or equal to a preset difference between the horizontal coordinates, and the difference between the vertical coordinates of two points is less than or equal to a preset difference between the vertical coordinates, the electronic device connects the two points.

[0109] It should be noted that the implementation of S605 above can refer to the implementation of S401-S403 above.

[0110] like Figure 6 As shown, Figure 6 It includes a jagged graphic.

[0111] like Figure 7 As shown, Figure 7 The arrow in the image points to the smoothed version of the graphic.

[0112] like Figure 8 As shown, Figure 8 For the above Figure 2 The image shown is the result of the image transformation.

[0113] The foregoing mainly describes the solutions provided by the embodiments of this application from a methodological perspective. To achieve the above functions, the image processing apparatus or electronic device includes corresponding hardware structures and / or software modules for performing each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0114] This application embodiment can, according to the above method, exemplarily divide an image processing device or electronic device into functional modules. For example, the image processing device or electronic device may include functional modules corresponding to each functional division, or two or more functions may be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; in actual implementation, there may be other division methods.

[0115] For example, embodiments of this application also provide an image processing apparatus.

[0116] In some embodiments, Figure 9 This is a block diagram illustrating an image processing apparatus 700 according to an exemplary embodiment. (Refer to...) Figure 9 The image processing apparatus 700 includes an acquisition unit 701, a determination unit 702, and a processing unit 703.

[0117] The acquisition unit 701 is used to acquire pixel information of each pixel in the image to be processed; the pixel information includes pixel size, position information and grayscale value.

[0118] The determining unit 702 is used to determine multiple target pixels that satisfy a preset grayscale value.

[0119] The determining unit 702 is further configured to determine multiple rectangles based on the pixel size and position information of multiple target pixels; the size of each rectangle is determined based on the pixel size and number of target pixels corresponding to the target pixels; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle.

[0120] The processing unit 703 is used to merge multiple rectangles to obtain the graphic of the image to be processed.

[0121] Optional, such as Figure 9As shown, the determining unit 702 provided in this embodiment is specifically used for:

[0122] Generate rectangles with the same pixel size and position information as the first target pixel to obtain multiple rectangles; the first target pixel can be any one of the multiple target pixels.

[0123] Optional, such as Figure 9 As shown, the determining unit 702 provided in this embodiment is specifically used for:

[0124] Determine multiple sets of target pixels; each set of target pixels includes consecutive target pixels from multiple target pixels.

[0125] Generate rectangles corresponding to each set of target pixels to obtain multiple rectangles; the size of each rectangle is equal to the sum of the pixel sizes of the target pixels corresponding to each rectangle; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle.

[0126] Optional, such as Figure 9 As shown, the processing unit 703 provided in this application embodiment is further used to connect two points when the difference between the horizontal coordinates of two points in the graph is less than or equal to a preset difference between the horizontal coordinates, and the difference between the vertical coordinates of two points is less than or equal to a preset difference between the vertical coordinates.

[0127] Optional, such as Figure 9 As shown, the processing unit 703 provided in this embodiment is further used for:

[0128] The image to be processed is divided into multiple sub-images; adjacent sub-images have an intersection.

[0129] Generate multiple subtasks that correspond one-to-one with multiple sub-images to be processed, and call multiple threads to process multiple subtasks.

[0130] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0131] Figure 10 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Figure 10 As shown, the electronic device 800 includes, but is not limited to, a processor 801 and a memory 802.

[0132] The memory 802 described above is used to store the executable instructions of the processor 801. It is understood that the processor 801 is configured to execute instructions to implement the image processing method in the above embodiments.

[0133] It should be noted that those skilled in the art will understand that Figure 10 The electronic device structure shown does not constitute a limitation on the electronic device; the electronic device may include, but is not limited to, other electronic devices. Figure 10 This may indicate more or fewer components, or combinations of certain components, or different component arrangements.

[0134] The processor 801 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 802, and by calling data stored in the memory 802, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. The processor 801 may include one or more processing units. Optionally, the processor 801 may integrate an application processor and a modem processor. The application processor mainly handles the operating system, user interface, and applications, while the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 801.

[0135] The memory 802 can be used to store software programs and various data. The memory 802 may primarily include a program storage area and a data storage area. The program storage area may store the operating system, application programs required by at least one functional module (such as a determination unit, processing unit, etc.), etc. Furthermore, the memory 802 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0136] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 802 including instructions, which can be executed by a processor 801 of an electronic device 800 to implement the image processing method in the above embodiments.

[0137] In actual implementation, Figure 9 The functions of the acquisition unit 701, the determination unit 702, and the processing unit 703 can all be provided by... Figure 10 The processor 801 calls the computer program stored in the memory 802 to implement the process. The specific execution process can be found in the description of the image processing method in the previous embodiment, and will not be repeated here.

[0138] Optionally, the computer-readable storage medium may be a non-transitory computer-readable storage medium, such as a read-only memory (ROM), random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device.

[0139] In an exemplary embodiment, this application also provides a computer program product including one or more instructions, which can be executed by a processor 801 of an electronic device to complete the image processing method described above.

[0140] It should be noted that when one or more instructions in the computer-readable storage medium or computer program product are executed by the processor of the electronic device, they implement the various processes of the above-described image processing method embodiments and achieve the same technical effect as the above-described image processing method. To avoid repetition, they will not be described again here.

[0141] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0142] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0143] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the classified units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0144] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0145] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, essentially, or the part that contributes to the prior art, or a complete or partial classification of the technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0146] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. An image processing method, characterized in that, The method includes: Obtain pixel information for each pixel in the image to be processed; the pixel information includes pixel size, position information, and grayscale value; Identify multiple target pixels that meet the preset grayscale values; Multiple rectangles are determined based on the pixel size and position information of the multiple target pixels; the size of each rectangle is determined according to the pixel size and number of the target pixels included; the position information of each rectangle is determined based on the position information of the target pixels included in each rectangle. The multiple rectangles are merged to obtain the graphic of the image to be processed.

2. The method according to claim 1, characterized in that, The step of determining multiple rectangles based on the pixel size and position information of the multiple target pixels includes: A rectangle with the same pixel size and position information as the first target pixel is generated to obtain the plurality of rectangles; the first target pixel is any one of the plurality of target pixels.

3. The method according to claim 1, characterized in that, The step of determining multiple rectangles based on the pixel size and position information of the multiple target pixels includes: Determine multiple sets of target pixels; each set of target pixels includes consecutive target pixels from the multiple sets of target pixels; A rectangle corresponding to each set of target pixels is generated to obtain the plurality of rectangles; the size of each rectangle is equal to the sum of the pixel sizes of the target pixels corresponding to each rectangle; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle.

4. The method according to claim 1, characterized in that, The method further includes: When there are two points in the graph whose x-coordinate difference is less than or equal to a preset x-coordinate difference, and whose y-coordinate difference is less than or equal to a preset y-coordinate difference, connect the two points.

5. The method according to any one of claims 1-4, characterized in that, The method further includes: The image to be processed is divided into multiple sub-images to be processed; adjacent sub-images to be processed have an intersection; Multiple subtasks are generated, each corresponding to one of the multiple sub-images to be processed, and multiple threads are invoked to process the multiple subtasks.

6. An image processing apparatus, characterized in that, The device includes: an acquisition unit, a determination unit, and a processing unit; The acquisition unit is used to acquire pixel information of each pixel in the image to be processed; the pixel information includes pixel size, position information and grayscale value; The determining unit is used to determine multiple target pixels that satisfy a preset grayscale value; The determining unit is further configured to determine a plurality of rectangles based on the pixel size and position information of the plurality of target pixels; the size of each rectangle is determined based on the pixel size and number of target pixels corresponding to the target pixels; the position information of each rectangle is determined based on the position information of the target pixels corresponding to each rectangle. The processing unit is used to merge the multiple rectangles to obtain the graphic of the image to be processed.

7. The apparatus according to claim 6, characterized in that, The determining unit is specifically used for: A rectangle with the same pixel size and position information as the first target pixel is generated to obtain the plurality of rectangles; the first target pixel is any one of the plurality of target pixels.

8. The apparatus according to claim 6, characterized in that, The determining unit is specifically used for: Determine multiple sets of target pixels; each set of target pixels includes consecutive target pixels from the multiple sets of target pixels; A rectangle corresponding to each set of target pixels is generated to obtain the plurality of rectangles; the size of each rectangle is equal to the sum of the pixel sizes of the target pixels corresponding to each rectangle; The position information of each rectangle is determined based on the position information of the target pixel corresponding to each rectangle.

9. The apparatus according to claim 6, characterized in that, The processing unit is further configured to connect the two points when the difference between the horizontal coordinates of two points in the graph is less than or equal to a preset difference between the horizontal coordinates, and the difference between the vertical coordinates of the two points is less than or equal to a preset difference between the vertical coordinates.

10. The apparatus according to any one of claims 6-9, characterized in that, The processing unit is further configured to: The image to be processed is divided into multiple sub-images to be processed; adjacent sub-images to be processed have an intersection; Multiple subtasks are generated, each corresponding to one of the multiple sub-images to be processed, and multiple threads are invoked to process the multiple subtasks.

11. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions, thereby implementing the method as described in any one of claims 1 to 5.

12. A computer-readable storage medium, characterized in that, When the computer-executable instructions stored in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is capable of performing the method as described in any one of claims 1 to 5.