Image processing method, device, electronic device and storage medium
By vectorizing and combining the pixel points sets in the raster map, the problem of converting the raster map into a vector map in the prior art is solved, and the file size reduction and image clarity improvement are achieved.
Patent Information
- Application Number
- CN202111443970.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2041-11-30
AI Technical Summary
The prior art is difficult to effectively convert raster images into vector images, resulting in larger file sizes and blurred images when enlarged.
By determining at least one set of pixel points based on the to-process raster map, where the pixel points in the same pixel point set belong to the same color category, vectorization is performed for these sets, local vector maps are obtained, and the local vector maps are combined to generate an overall vector map.
The purpose of converting a raster diagram into a vector diagram is achieved, reducing file size and keeping the image clear when zooming in.
Smart Images

Figure CN114092606B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of information technology, and in particular to an image processing method, device, electronic device and storage medium. Background Art
[0002] Raster images are also commonly called bitmaps, which are made up of millions of small squares of pixels. Raster images usually have larger file sizes.
[0003] Vector graphics are made up of thousands of thin lines (also called paths). Vector graphics require computer software to create complex wireframe images called vector graphics. Each line in the image can be assigned a color value. Because vector graphics are based on digital painting methods, they can be infinitely scaled at any resolution without appearing blurry. Also, vector graphics are usually smaller in file size.
[0004] Given the respective advantages and disadvantages of raster images and vector images, different types of image formats need to be selected based on the application scenarios. Summary of the invention
[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present disclosure provide an image processing method, device, electronic device and storage medium, which achieve the purpose of converting a raster image into a vector image.
[0006] In a first aspect, an embodiment of the present disclosure provides an image processing method, the method comprising:
[0007] Determine at least one pixel point set based on the raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category;
[0008] Vectorizing the at least one pixel point set respectively to obtain local vector graphs corresponding to the at least one pixel point set respectively;
[0009] The overall vector image corresponding to the raster image to be processed is generated based on the local vector image.
[0010] In a second aspect, an embodiment of the present disclosure further provides an image processing device, the device comprising:
[0011] A pixel point set determination module, used to determine at least one pixel point set based on the raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category;
[0012] A vectorization module, used to perform vectorization on the at least one pixel point set respectively to obtain local vector diagrams corresponding to the at least one pixel point set respectively;
[0013] A merging module is used to generate an overall vector image corresponding to the raster image to be processed based on the local vector image.
[0014] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0015] one or more processors;
[0016] A storage device for storing one or more programs;
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method as described above.
[0018] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the image processing method as described above is implemented.
[0019] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has at least the following advantages:
[0020] The image processing method provided by the embodiment of the present disclosure determines at least one pixel point set based on the raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category; vectorizes the at least one pixel point set respectively to obtain local vector diagrams corresponding to the at least one pixel point set respectively; and generates an overall vector diagram corresponding to the raster image to be processed based on the local vector diagram by a technical means, thereby achieving the purpose of converting the raster image into a vector diagram. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0022] Figure 1 is a flowchart of an image processing method in an embodiment of the present disclosure;
[0023] Figure 2 is a flowchart of an image processing method in an embodiment of the present disclosure;
[0024] Figure 3 is a flowchart of an image processing method in an embodiment of the present disclosure;
[0025] Figure 4 A schematic diagram of color classification of each pixel point in a raster image to be processed that falls within a preset window in an embodiment of the present disclosure;
[0026] Figure 5 Schematic diagram of the distribution of position weights of pixels at different positions of a preset window in an embodiment of the present disclosure;
[0027] Figure 6 A schematic diagram of color classification of each pixel point in a raster image to be processed that falls within a preset window in an embodiment of the present disclosure;
[0028] Figure 7 A schematic diagram of the color categories to which each pixel point belongs after noise reduction processing in an embodiment of the present disclosure;
[0029] Figure 8 is a flowchart of an image processing method in an embodiment of the present disclosure;
[0030] Fig. 9 is a structural schematic diagram of an image processing device in an embodiment of the present disclosure;
[0031] Fig.10 It is a structural schematic diagram of an electronic device in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0032] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0033] It should be understood that the various steps described in the method embodiments of the present disclosure can be performed in different orders and in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0034] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0035] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0036] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0037] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0038] Figure 1 The flowchart of an image processing method in an embodiment of the present disclosure is shown in FIG. The method can be executed by an image processing device, which can be implemented in software and / or hardware, and can be configured in an electronic device, such as a display terminal, specifically including but not limited to smart phones, PDAs, tablet computers, portable wearable devices, smart home devices (such as desk lamps) and other electronic devices with display screens.
[0039] like Figure 1 As shown, the method may specifically include the following steps:
[0040] Step 110: determine at least one pixel point set based on the raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category.
[0041] Among them, raster images are also called bitmaps, which are composed of many pixels (pixels can also be called color blocks), and each pixel contains position and color information. The amount of data in raster images is usually large, so raster images need to occupy a large storage space, and the greater the magnification, the blurrier the image. The amount of data in vector images is usually small, that is, vector images occupy a smaller storage space, and can still maintain a clear display effect after magnification, and there will be no problem that the image looks blurrier when the magnification is larger.
[0042] In summary, there is a need to convert raster images into vector images in some application scenarios. For example, cartoon images, whose image content includes more graphics, are more suitable for representation using vector images. If cartoon images are represented using vector images, more storage space can be saved and the image can still be kept clear after enlargement.
[0043] The disclosed embodiment provides an image processing method, which aims to convert a raster image into a vector image. Specifically, firstly, the pixels in the raster image to be processed are classified, and the pixels belonging to the same color are divided into one category. In other words, the pixels in the raster image to be processed are classified, and the pixels belonging to the same color are divided into one category, including: determining at least one pixel set based on the raster image to be processed, wherein the pixels in the same pixel set belong to the same color category. Different colors belong to different color categories, for example, red is one color category and green is another color category.
[0044] It is understandable that each color (such as red, green, dark green, light green, etc.) can be expressed by combining the components of the three color channels of red (R), green (G), and blue (B). For example, the RGB components of red are (255, 0, 0), the RGB components of green are (0, 255, 0), and the RGB components of blue are (0, 0, 255). The RGB components of light green may be (0, 180, 0), etc. The components of the three color channels of the pixels in the same pixel set are relatively close, and usually the components of the three color channels of each pixel in the same pixel set are within the set range. It should be noted that green, light green and dark green may be three different color categories, or they may be the same color category. The division granularity of the color category depends on the set values of the preset parameters in the color classification algorithm adopted, and the details can be referred to the description in the subsequent embodiments.
[0045] Step 120: vectorize the at least one pixel point set respectively to obtain local vector maps corresponding to the at least one pixel point set respectively.
[0046] Specifically, the pixel point sets belonging to each color category are vectorized respectively to obtain the local vector map corresponding to the pixel point sets of each color category. For example, if the raster image to be processed includes two color categories, red and green, the pixel point sets composed of red pixels and the pixel point sets composed of green pixels are vectorized respectively to obtain the local vector map corresponding to the pixel point set composed of red pixels and the local vector map corresponding to the pixel point set composed of green pixels.
[0047] Optionally, the pixel points belonging to each color category can be vectorized separately by Potrace algorithm or AutoTrace algorithm. Potrace algorithm or AutoTrace algorithm are two relatively mature open source algorithms used to convert raster images into vector images, or to vectorize the pixel points belonging to each color category in the raster image.
[0048] Step 130: Generate an overall vector map corresponding to the to-be-processed raster map based on the local vector map.
[0049] Optionally, generating the overall vector diagram corresponding to the raster image to be processed based on the local vector diagram includes: rendering the local vector diagram into a color of a corresponding category, for example, rendering the local vector diagram corresponding to a pixel point set composed of red pixels into red, and rendering the local vector diagram corresponding to a pixel point set composed of green pixels into green.
[0050] Furthermore, the local vector diagram can be rendered into a color of a corresponding category according to specific needs or configuration information. For example, the local vector diagram corresponding to a pixel set composed of red pixels can be rendered as green, and the local vector diagram corresponding to a pixel set composed of green pixels can be rendered as red according to the instructions of the configuration information.
[0051] Then, the local vector maps of the rendered colors are merged into one map to obtain the overall vector map.
[0052] The image processing method provided in this embodiment determines at least one pixel point set based on the raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category; vectorizes the at least one pixel point set respectively to obtain local vector diagrams corresponding to the at least one pixel point set respectively; and uses technical means to generate an overall vector diagram corresponding to the raster image to be processed based on the local vector diagram, thereby achieving the purpose of converting the raster image into a vector diagram.
[0053] Based on the above embodiments, Figure 2 The flowchart of an image processing method in one embodiment is shown in FIG. Based on the above embodiment, this embodiment adds the following step “scaling the raster image to be processed to obtain a raster image of a preset resolution, wherein the preset resolution is less than the original resolution of the raster image to be processed” before the above step 110 “determining at least one pixel point set based on the raster image to be processed”. The advantage of such a setting is that the amount of calculation can be reduced.
[0054] like Figure 2 As shown, the image processing method comprises the following steps:
[0055] Step 210: Scaling the raster image to be processed to obtain a raster image of a preset resolution.
[0056] The preset resolution is smaller than the original resolution of the raster image to be processed. It is understandable that with the continuous development of photography technology and display technology, the current image resolution is usually above 1920×1080, that is, the original resolution of the raster image to be processed is usually above 1920×1080.
[0057] It is understandable that the higher the resolution of an image, the more pixels the image includes. Therefore, if the pixel sets in the raster image to be processed with the original resolution are directly determined, the amount of calculation will be large. In order to reduce the amount of calculation and ensure the image processing effect, in this embodiment, the above-mentioned step 210 "scaling the raster image to be processed to obtain a raster image with a preset resolution, wherein the preset resolution is less than the original resolution of the raster image to be processed" is added before "determining at least one pixel set based on the raster image to be processed".
[0058] The preset resolution is determined according to the number of color categories included in the raster image to be processed. If the number of color categories included in the raster image to be processed is small, the preset resolution is usually set to 256*256 to reduce the amount of calculation while ensuring the image processing effect.
[0059] Step 220: Determine at least one pixel point set based on the grid image of the preset resolution.
[0060] Step 230: vectorize the at least one pixel point set respectively to obtain local vector maps corresponding to the at least one pixel point set respectively.
[0061] Step 240: Generate an overall vector map corresponding to the to-be-processed raster map based on the local vector map.
[0062] The image processing method provided in this embodiment is based on the above embodiment. This embodiment adds the following step "scaling the raster image to be processed to obtain a raster image of a preset resolution, wherein the preset resolution is smaller than the original resolution of the raster image to be processed" before the above step 110 "determining at least one pixel point set based on the raster image to be processed", thereby achieving the purpose of reducing the amount of calculation and ensuring the image processing effect.
[0063] Based on the above embodiments, Figure 3 The flowchart of an image processing method in one embodiment is shown in FIG. Based on the above embodiment, this embodiment adds the following step “performing noise reduction processing on the at least one pixel point set” before the above step 230 “performing vectorization on the at least one pixel point set respectively”. The advantage of such a setting is that a better image processing effect can be obtained.
[0064] like Figure 3 As shown, the image processing method comprises the following steps:
[0065] Step 310: Scaling the raster image to be processed to obtain a raster image of a preset resolution.
[0066] Step 320: Determine at least one pixel point set based on the grid image of the preset resolution.
[0067] Step 330: Perform noise reduction processing on the at least one pixel point set to obtain at least one pixel point set after noise reduction.
[0068] After the pixels are classified, more noise usually appears at the boundary of two pixels of different colors, resulting in inaccurate classification of the pixels at the boundary of the two pixels of different colors. Therefore, in order to obtain a better classification result and thus a better image processing effect, after determining at least one pixel set, a noise reduction process is performed on the at least one pixel set to obtain at least one pixel set after noise reduction.
[0069] Specifically, performing noise reduction processing on the at least one pixel point set to obtain at least one pixel point set after noise reduction includes:
[0070] Based on the at least one pixel point set, the color category of each pixel point in the to-be-processed raster image that falls within a preset window is determined; the number of occurrences of each color category is determined according to the color category of each pixel point that falls within the preset window; and the color category with the largest number of occurrences is determined as the color category of the pixel point of the to-be-processed raster image at the center point of the preset window.
[0071] The method of determining the number of occurrences of each color category according to the color category to which each pixel point falling within the preset window belongs includes: determining the position weight of each pixel point according to the position of each pixel point in the preset window, the closer to the center point of the preset window, the greater the position weight; and obtaining the number of occurrences of each color category by performing weighted summation according to the color category to which each pixel point belongs and the position weight.
[0072] For example, the preset window is a 5*5 window, and the preset window is used to traverse the entire image of the raster image to be processed, and the color category with the largest number of occurrences in the preset window is calculated as the new color category of the center point of the preset window, and the color category of the center point of the preset window is updated using the new color category, that is, the color category of the center point of the preset window is updated to the new color category. Assuming that the pixel point falling at the center point of the preset window is noise, the purpose of removing the noise can be achieved by the above method. At the same time, considering that the pixel point closer to the center point of the preset window should have a higher weight, when calculating the number of occurrences of the color category, the position weight of each pixel point is determined according to the position of each pixel point in the preset window. The closer to the center point of the preset window, the greater the position weight. The number of occurrences of each color category is obtained by weighted summing according to the color category to which each pixel point belongs and the position weight.
[0073] For example, see Figure 4 , Figure 5 , Figure 6 and Figure 7 A schematic diagram of a noise reduction process is shown in FIG. Figure 4 A schematic diagram showing the color classification of each pixel point in the to-be-processed raster image falling within the preset window 410, from Figure 4 It can be seen that the pixel point falling at position 411 of the preset window 410 is a color category, which is recorded as the first color category (such as green); the pixel points falling at positions 412 and 413 of the preset window 410 are a color category, which is recorded as the second color category (such as red); the pixel point falling at position 414 of the preset window 410 is a color category, which is recorded as the third color category (such as cyan). Figure 5 A schematic diagram of the distribution of position weights of pixels at different positions in a preset window is shown in FIG. Figure 4 and Figure 5 Superimposed together, we get Figure 6 The schematic diagram shown in Figure 4 The color category and Figure 5 The position weights of each pixel point at different positions in the preset window shown in FIG. Figure 6 The following conclusions can be drawn from the figure: the number of occurrences of the first color category (such as green) is: 1*7+4*4=23, the number of occurrences of the second color category (such as red) is: 1+6=7, and the number of occurrences of the third color category (such as cyan) is: 1*8+4*4=24. The color category with the most occurrences is the third color category (such as cyan). The color category to which each pixel after noise reduction belongs is as follows: Figure 7As shown, the color category to which the pixel point located at the center point 413 of the preset window 410 belongs changes from the second color category to the third color category.
[0074] Step 340: vectorize the at least one denoised pixel point set to obtain a local vector map corresponding to the at least one pixel point set.
[0075] Step 350: Generate an overall vector map corresponding to the to-be-processed raster map based on the local vector map.
[0076] The image processing method provided in this embodiment is based on the above embodiment. This embodiment adds the following step "performing noise reduction processing on the at least one pixel point set" before the above step 230 "performing vectorization on the at least one pixel point set respectively". Specifically, the color category of each pixel point in the to-be-processed raster image falling within the preset window is determined based on the at least one pixel point set; the number of occurrences of each color category is determined according to the color category of each pixel point falling within the preset window; the color category with the largest number of occurrences is determined as the color category of the pixel point at the center point of the preset window of the to-be-processed raster image. The purpose of improving the image processing effect is achieved.
[0077] Based on the above embodiments, Figure 8 FIG. 1 is a flow chart of an image processing method in an implementation manner. Based on the above embodiment, this embodiment provides an optional implementation manner for the above step 320 “determining at least one pixel point set based on the grid image of the preset resolution”.
[0078] like Figure 8 As shown, the image processing method comprises the following steps:
[0079] Step 810: Scaling the raster image to be processed to obtain a raster image of a preset resolution.
[0080] Step 820: Determine the color category to which each pixel in the raster image of the preset resolution belongs, and classify each pixel according to the color category to which each pixel belongs to obtain at least one pixel set.
[0081] Specifically, each pixel point in a raster image of a preset resolution is input into a preset clustering algorithm to obtain at least one cluster center and at least one pixel point belonging to the at least one cluster center; each of the cluster centers corresponds to a color category, the color category to which the current pixel point belongs is the color category corresponding to the cluster center to which the current pixel point belongs, and the current pixel point is any one of the pixel points.
[0082] The preset clustering algorithm may be, for example, a k-means algorithm. Each pixel in a grid image of a preset resolution is input into the preset clustering algorithm. The output of the preset clustering algorithm is assumed to be two cluster centers (the two cluster centers are marked as c1 and c2, respectively) and pixels marked with labels c1 and / or c2. Each cluster center corresponds to a color category. For example, the color category corresponding to cluster center c1 is red, the color category corresponding to cluster center c2 is green, the color category to which the pixel marked with label c1 belongs is red, and the color category to which the pixel marked with label c2 belongs is green.
[0083] The number of cluster centers (i.e., color categories) output by the preset clustering algorithm is determined by the set value of the preset parameter k. For example, if the set value of the preset parameter k is 3, the number of cluster centers (i.e., color categories) output by the preset clustering algorithm is 3, and the color of the pixel corresponding to each cluster center is the color category corresponding to the cluster center. For example, the color of the pixel corresponding to one of the cluster centers c3 is light green, and the component of the color channel RGB is (0,180,0), then the color category corresponding to the cluster center c3 is light green. When determining other pixels belonging to the color category-light green, the distance between each pixel and the cluster center c3 (0,180,0) is calculated based on the component of the color channel RGB of each pixel, and the color category of the pixel whose distance is less than the set value is classified as light green. In summary, the components of the three color channels of the pixels in the same pixel set (or in the same color category) are relatively close, and usually the components of the three color channels of each pixel in the same pixel set are within the set range.
[0084] Step 830: Perform noise reduction processing on the at least one pixel point set to obtain at least one pixel point set after noise reduction.
[0085] Step 840: vectorize the at least one pixel point set after noise reduction to obtain a local vector map corresponding to the at least one pixel point set.
[0086] Step 850: Generate an overall vector image corresponding to the raster image to be processed based on the local vector image.
[0087] Fig. 9 FIG. 1 is a schematic diagram of the structure of an image processing device in an embodiment of the present disclosure. Fig. 9 As shown, the image processing device specifically includes: a pixel point set determination module 910, a vectorization module 920 and a merging module 930.
[0088] Among them, the pixel point set determination module 910 is used to determine at least one pixel point set based on the raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category; the vectorization module 920 is used to perform vectorization on the at least one pixel point set respectively to obtain local vector diagrams corresponding to the at least one pixel point set respectively; the merging module 930 is used to generate an overall vector diagram corresponding to the raster image to be processed based on the local vector diagram.
[0089] Optionally, it also includes: a processing module, which is used to scale the raster image to be processed before determining at least one pixel point set based on the raster image to be processed, so as to obtain a raster image of a preset resolution, wherein the preset resolution is smaller than the original resolution of the raster image to be processed. Correspondingly, the pixel point set determination module 910 is used to determine at least one pixel point set based on the raster image of the preset resolution.
[0090] Optionally, a noise reduction module is further included, which is used to perform noise reduction processing on the at least one pixel point set to obtain at least one noise-reduced pixel point set before vectorizing the at least one pixel point set to obtain local vector diagrams corresponding to the at least one pixel point set. Correspondingly, the vectorization module 920 is used to perform vectorization on the at least one noise-reduced pixel point set.
[0091] Optionally, the noise reduction module includes: a first determination unit, used to determine the color category to which each pixel point in the raster image to be processed falls within a preset window based on the at least one pixel point set; a second determination unit, used to determine the number of occurrences of each color category according to the color category to which each pixel point falling within the preset window belongs; and a third determination unit, used to determine the color category with the largest number of occurrences as the color category of the pixel point in the raster image to be processed at the center point of the preset window.
[0092] Optionally, the second determination unit specifically includes: a first determination subunit, used to determine the position weight of each pixel point according to the position of each pixel point in the preset window, the closer to the center point of the preset window, the greater the position weight; a second determination subunit, used to obtain the number of occurrences of each color category by performing weighted summation based on the color category to which each pixel point belongs and the position weight.
[0093] Optionally, the pixel point set determination module 910 includes: a fourth determination unit, used to determine the color category to which each pixel point in the raster image to be processed belongs; and a fifth determination unit, used to classify each pixel point according to the color category to which each pixel point belongs, to obtain at least one pixel point set.
[0094] Optionally, the fourth determination unit is specifically used to: input each pixel point in the raster image to be processed into a preset clustering algorithm to obtain at least one cluster center and at least one pixel point belonging to the at least one cluster center; each of the cluster centers corresponds to a color category, the color category to which the current pixel point belongs is the color category corresponding to the cluster center to which the current pixel point belongs, and the current pixel point is any one of the pixel points.
[0095] Optionally, the merging module 930 includes a rendering unit, configured to render the local vector image into a color of a corresponding category; and a merging unit, configured to merge the local vector images of the rendered colors into one image to obtain the overall vector image.
[0096] The image processing device provided in the embodiment of the present disclosure can execute the steps of the image processing method provided in the method embodiment of the present disclosure, and the execution steps and beneficial effects are no longer repeated here.
[0097] Fig.10 Schematic diagram of the structure of an electronic device in the embodiment of the present disclosure. Fig.10 , which shows a schematic diagram of the structure of an electronic device 500 suitable for implementing the embodiment of the present disclosure. The electronic device 500 in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), wearable electronic devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. Fig.10 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0098] like Fig.10 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes to implement the method of the embodiment described in the present disclosure according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage device 508 to the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0099] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Fig.10 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0100] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the method as described above. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0101] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0102] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0103] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0104] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: determines at least one pixel point set based on the raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category; performs vectorization on the at least one pixel point set respectively to obtain local vector diagrams corresponding to the at least one pixel point set respectively; and generates an overall vector diagram corresponding to the raster image to be processed based on the local vector diagram.
[0105] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0106] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0107] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0108] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0109] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0110] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0111] According to one or more embodiments of the present disclosure, the present disclosure provides an image processing method, including: determining at least one pixel point set based on a raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category; performing vectorization on the at least one pixel point set respectively to obtain local vector diagrams corresponding to the at least one pixel point set respectively; and generating an overall vector diagram corresponding to the raster image to be processed based on the local vector diagrams.
[0112] According to one or more embodiments of the present disclosure, in the image processing method provided by the present disclosure, optionally, before determining at least one pixel point set based on the raster image to be processed, it also includes: scaling the raster image to be processed to obtain a raster image of a preset resolution, wherein the preset resolution is smaller than the original resolution of the raster image to be processed; determining at least one pixel point set based on the raster image to be processed includes: determining at least one pixel point set based on the raster image with the preset resolution.
[0113] According to one or more embodiments of the present disclosure, in the image processing method provided by the present disclosure, optionally, before respectively vectorizing the at least one pixel point set to obtain local vector diagrams respectively corresponding to the at least one pixel point set, it also includes: performing noise reduction processing on the at least one pixel point set to obtain at least one noise-reduced pixel point set; the respectively vectorizing the at least one pixel point set includes: vectorizing the at least one noise-reduced pixel point set.
[0114] According to one or more embodiments of the present disclosure, in the image processing method provided by the present disclosure, optionally, the denoising process is performed on the at least one pixel point set to obtain at least one denoised pixel point set, including: determining the color category to which each pixel point in the raster image to be processed that falls within a preset window belongs based on the at least one pixel point set; determining the number of occurrences of each color category according to the color category to which each pixel point that falls within the preset window belongs; and determining the color category with the largest number of occurrences as the color category of the pixel point in the raster image to be processed at the center point of the preset window.
[0115] According to one or more embodiments of the present disclosure, in the image processing method provided by the present disclosure, optionally, the number of occurrences of each color category is determined according to the color category to which each pixel point falling within the preset window belongs, including: determining the position weight of each pixel point according to the position of each pixel point in the preset window, the closer to the center point of the preset window, the greater the position weight; and obtaining the number of occurrences of each color category by performing weighted summation according to the color category to which each pixel point belongs and the position weight.
[0116] According to one or more embodiments of the present disclosure, in the image processing method provided by the present disclosure, optionally, determining at least one pixel point set based on the raster image to be processed includes: determining the color category to which each pixel point in the raster image to be processed belongs; and classifying each pixel point according to the color category to which each pixel point belongs to obtain at least one pixel point set.
[0117] According to one or more embodiments of the present disclosure, in the image processing method provided by the present disclosure, optionally, determining the color category to which each pixel in the raster image to be processed belongs includes: inputting each pixel in the raster image to be processed into a preset clustering algorithm to obtain at least one cluster center and at least one pixel belonging to the at least one cluster center respectively; each of the cluster centers corresponds to a color category, the color category to which the current pixel belongs is the color category corresponding to the cluster center to which the current pixel belongs, and the current pixel is any one of the pixels.
[0118] According to one or more embodiments of the present disclosure, in the image processing method provided by the present disclosure, optionally, generating an overall vector diagram corresponding to the raster image to be processed based on the local vector diagram includes: rendering the local vector diagram into colors of corresponding categories; merging the local vector diagrams of the rendered colors into one image to obtain the overall vector diagram.
[0119] According to one or more embodiments of the present disclosure, the present disclosure provides an image processing device, including: a pixel point set determination module, used to determine at least one pixel point set based on a raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category; a vectorization module, used to perform vectorization on the at least one pixel point set respectively to obtain local vector diagrams corresponding to the at least one pixel point set respectively; and a merging module, used to generate an overall vector diagram corresponding to the raster image to be processed based on the local vector diagrams.
[0120] According to one or more embodiments of the present disclosure, in the image processing device provided by the present disclosure, optionally, it also includes: a processing module, which is used to scale the grid image to be processed before determining at least one pixel point set based on the grid image to be processed to obtain a grid image of a preset resolution, wherein the preset resolution is less than the original resolution of the grid image to be processed. Correspondingly, a pixel point set determination module 910 is used to determine at least one pixel point set based on the grid image of the preset resolution.
[0121] According to one or more embodiments of the present disclosure, in the image processing device provided by the present disclosure, optionally, a noise reduction module is further included, which is used to perform noise reduction processing on the at least one pixel point set to obtain at least one pixel point set after noise reduction before vectorizing the at least one pixel point set to obtain local vector diagrams corresponding to the at least one pixel point set. Correspondingly, the vectorization module 920 is used to perform vectorization on the at least one pixel point set after noise reduction.
[0122] According to one or more embodiments of the present disclosure, in the image processing device provided by the present disclosure, optionally, the denoising module includes: a first determination unit, for determining the color category to which each pixel point in the raster image to be processed that falls within a preset window belongs based on the at least one pixel point set; a second determination unit, for determining the number of occurrences of each color category according to the color category to which each pixel point that falls within the preset window belongs; and a third determination unit, for determining the color category with the largest number of occurrences as the color category of the pixel point in the raster image to be processed at the center point of the preset window.
[0123] According to one or more embodiments of the present disclosure, in the image processing device provided by the present disclosure, optionally, the second determination unit specifically includes: a first determination subunit, used to determine the position weight of each pixel point according to the position of each pixel point in the preset window, the closer to the center point of the preset window, the greater the position weight; a second determination subunit, used to obtain the number of occurrences of each color category by performing weighted summation based on the color category to which each pixel point belongs and the position weight.
[0124] According to one or more embodiments of the present disclosure, in the image processing device provided by the present disclosure, optionally, the pixel point set determination module 910 includes: a fourth determination unit, used to determine the color category to which each pixel point in the raster image to be processed belongs; and a fifth determination unit, used to classify each pixel point according to the color category to which each pixel point belongs, so as to obtain at least one pixel point set.
[0125] According to one or more embodiments of the present disclosure, in the image processing device provided by the present disclosure, optionally, the fourth determination unit is specifically used to: input each pixel point in the raster image to be processed into a preset clustering algorithm to obtain at least one cluster center and at least one pixel point respectively belonging to the at least one cluster center; each of the cluster centers corresponds to a color category, the color category to which the current pixel point belongs is the color category corresponding to the cluster center to which the current pixel point belongs, and the current pixel point is any one of the pixel points.
[0126] According to one or more embodiments of the present disclosure, in the image processing device provided by the present disclosure, optionally, the merging module 930 includes a rendering unit, which is used to render the local vector image into colors of corresponding categories; and a merging unit, which is used to merge the local vector images of the rendered colors into one image to obtain the overall vector image.
[0127] According to one or more embodiments of the present disclosure, the present disclosure provides an electronic device, including:
[0128] one or more processors;
[0129] A memory for storing one or more programs;
[0130] When the one or more programs are executed by the one or more processors, the one or more processors implement any image processing method provided in the present disclosure.
[0131] According to one or more embodiments of the present disclosure, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the image processing method as described in any one of the present disclosure is implemented.
[0132] The embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the image processing method as described above is implemented.
[0133] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0134] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0135] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. An image processing method, characterized in that: The method comprises: Determine at least one pixel point set based on the raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category; Vectorize each pixel point set belonging to the same color category to obtain a local vector map corresponding to each pixel point set; Generate an overall vector diagram corresponding to the raster diagram to be processed based on the local vector diagram; Wherein, before vectorizing each pixel point set belonging to the same color category to obtain the local vector map corresponding to each pixel point set, the method further includes: performing noise reduction processing on the at least one pixel point set to obtain at least one pixel point set after noise reduction; The step of performing noise reduction processing on the at least one pixel point set to obtain at least one pixel point set after noise reduction includes: determining the color category of each pixel point in the to-be-processed raster image that falls within a preset window based on the at least one pixel point set; determining the number of occurrences of each color category according to the color category of each pixel point that falls within the preset window; and determining the color category with the largest number of occurrences as the color category of the pixel point at the center point of the preset window in the to-be-processed raster image; Among them, the number of occurrences of each color category is determined according to the color category to which each pixel point falling within the preset window belongs, including: determining the position weight of each pixel point according to the position of each pixel point in the preset window, the closer to the center point of the preset window, the greater the position weight; and obtaining the number of occurrences of each color category by weighted summation according to the color category to which each pixel point belongs and the position weight.
2. The method according to claim 1, characterized in that Before determining at least one pixel point set based on the grid image to be processed, the method further includes: Scaling the raster image to be processed to obtain a raster image with a preset resolution, wherein the preset resolution is smaller than an original resolution of the raster image to be processed; The step of determining at least one pixel point set based on the grid image to be processed includes: At least one pixel point set is determined based on the grid image of the preset resolution.
3. The method according to claim 1, characterized in that The vectorization of each pixel point set belonging to the same color category includes: Each set of denoised pixels belonging to the same color category is vectorized separately.
4. The method according to any one of claims 1 to 3, characterized in that: The step of determining at least one pixel point set based on the grid image to be processed includes: Determine the color category to which each pixel in the raster image to be processed belongs; The pixels are classified according to the color categories to which the pixels belong, to obtain at least one pixel set.
5. The method according to claim 4, characterized in that Determining the color category to which each pixel in the to-be-processed raster image belongs includes: Inputting each pixel point in the to-be-processed raster image into a preset clustering algorithm to obtain at least one cluster center and at least one pixel point respectively belonging to the at least one cluster center; Each of the cluster centers corresponds to a color category, the color category to which the current pixel point belongs is the color category corresponding to the cluster center to which the current pixel point belongs, and the current pixel point is any one of the pixel points.
6. The method according to any one of claims 1 to 3, characterized in that: The generating of the overall vector diagram corresponding to the to-be-processed raster diagram based on the local vector diagram comprises: Rendering the local vector graph into a color corresponding to a category; The local vector graphs of the rendered colors are merged into one graph to obtain the overall vector graph.
7. An image processing device, characterized in that: include: A pixel point set determination module, used to determine at least one pixel point set based on the raster image to be processed, wherein the pixels in the same pixel point set belong to the same color category; A vectorization module is used to vectorize each pixel point set belonging to the same color category to obtain a local vector map corresponding to each pixel point set; A merging module, used for generating an overall vector diagram corresponding to the raster diagram to be processed based on the local vector diagram; Wherein, before vectorizing each pixel point set belonging to the same color category to obtain the local vector map corresponding to each pixel point set, the method further includes: performing noise reduction processing on the at least one pixel point set to obtain at least one pixel point set after noise reduction; The step of performing noise reduction processing on the at least one pixel point set to obtain at least one pixel point set after noise reduction includes: determining the color category of each pixel point in the to-be-processed raster image that falls within a preset window based on the at least one pixel point set; determining the number of occurrences of each color category according to the color category of each pixel point that falls within the preset window; and determining the color category with the largest number of occurrences as the color category of the pixel point at the center point of the preset window in the to-be-processed raster image; Among them, the number of occurrences of each color category is determined according to the color category to which each pixel point falling within the preset window belongs, including: determining the position weight of each pixel point according to the position of each pixel point in the preset window, the closer to the center point of the preset window, the greater the position weight; and obtaining the number of occurrences of each color category by weighted summation according to the color category to which each pixel point belongs and the position weight.
8. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Fast raster-vector conversion method of remote sensing images
CN108875073A
Picture generation method and device, electronic equipment and storage medium
CN111179370A