CN111091572B - Image processing method and device, electronic equipment and storage medium - Google Patents

Image processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111091572B
CN111091572B CN201911311717.7A CN201911311717A CN111091572B CN 111091572 B CN111091572 B CN 111091572B CN 201911311717 A CN201911311717 A CN 201911311717A CN 111091572 B CN111091572 B CN 111091572B
Authority
CN
China
Prior art keywords
image
adjacent
preset
color block
segmented
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911311717.7A
Other languages
Chinese (zh)
Other versions
CN111091572A (en
Inventor
何梁伟
张发城
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Zhongyuan Network Co ltd
Original Assignee
Shanghai Zhongyuan Network Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Zhongyuan Network Co ltd filed Critical Shanghai Zhongyuan Network Co ltd
Priority to CN201911311717.7A priority Critical patent/CN111091572B/en
Publication of CN111091572A publication Critical patent/CN111091572A/en
Application granted granted Critical
Publication of CN111091572B publication Critical patent/CN111091572B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • G06V10/267Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion by performing operations on regions, e.g. growing, shrinking or watersheds
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/70Arrangements for image or video recognition or understanding using pattern recognition or machine learning
    • G06V10/74Image or video pattern matching; Proximity measures in feature spaces
    • G06V10/75Organisation of the matching processes, e.g. simultaneous or sequential comparisons of image or video features; Coarse-fine approaches, e.g. multi-scale approaches; using context analysis; Selection of dictionaries
    • G06V10/751Comparing pixel values or logical combinations thereof, or feature values having positional relevance, e.g. template matching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

An image processing method, an image processing device, electronic equipment and a storage medium belong to the technical field of image processing. The method comprises the following steps: performing color block segmentation processing on the image to be segmented to obtain a color block image of the image to be segmented; determining a plurality of pixel groups in the color block image according to a pixel group division rule, wherein each pixel group comprises a plurality of pixel points; calculating the similarity of two adjacent pixel groups; determining separation lines corresponding to the positions of two adjacent pixel groups with the similarity smaller than a preset similarity threshold value in a color block image, wherein the color block image comprises at least two separation lines; calculating the distance between two adjacent separation lines; taking two adjacent separation lines with the distance larger than a preset distance threshold value as separation lines of the images to be separated; dividing the image to be divided according to the dividing lines to obtain an image area between two adjacent dividing lines with the distance larger than a preset distance threshold as a target image area. By adopting the technical scheme provided by the application, the UI interface can be segmented.

Description

Image processing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to an image processing method, an image processing device, an electronic device, and a storage medium.
Background
In UI (User Interface) reverse engineering, an electronic device needs to perform image segmentation on a UI Interface to obtain a plurality of image areas, and then, the electronic device may determine a layout code of the UI Interface according to positions of the plurality of image areas in the UI Interface and sizes of the plurality of image areas.
In the related art, the electronic device may divide a general image, such as an image including a person or a landscape, using a conventional image division algorithm, such as an edge-based image division algorithm or a region-based image division algorithm. However, the UI interface includes a plurality of interface elements such as a status bar and a navigation bar, and each interface element is arranged in a different area in the UI interface according to a preset arrangement rule, so that the UI interface is different from an image structure of a common image, and the conventional image segmentation algorithm is not suitable for performing image segmentation on the UI interface. Currently, a technical solution capable of performing image segmentation on a UI interface is needed.
Disclosure of Invention
In order to solve the technical problems described above or at least partially solve the technical problems described above, the application provides an image processing method, an image processing device, an electronic device and a storage medium.
In a first aspect, the present application provides an image processing method, the method including:
performing color block segmentation processing on an image to be segmented to obtain a color block image of the image to be segmented;
determining a plurality of pixel groups in the color block image according to a preset pixel group division rule, wherein each pixel group comprises a plurality of pixel points;
calculating the similarity of two adjacent pixel groups;
determining separation lines corresponding to the positions of two adjacent pixel groups with similarity smaller than a preset similarity threshold value in the color block image, wherein the color block image comprises at least two separation lines;
calculating the distance between two adjacent separation lines;
taking two adjacent separation lines with the distance larger than a preset distance threshold value as the separation lines of the images to be separated;
and dividing the image to be divided according to the dividing lines to obtain an image area between two adjacent dividing lines with the distance larger than a preset distance threshold as a target image area.
Optionally, the calculating the similarity between two adjacent pixel groups includes:
acquiring pixel value distribution of two adjacent pixel groups;
and calculating the similarity of the two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
Optionally, before performing the color block segmentation processing on the image to be segmented to obtain the color block image of the image to be segmented, the method further includes:
the size of the original image is reduced according to a preset reduction ratio, and an image to be segmented is obtained;
the image to be segmented is segmented according to the segmentation lines, and after an image area between two adjacent segmentation lines with a distance larger than a preset distance threshold is obtained as a target image area, the method further comprises the steps of:
and amplifying the size of the target image area according to a preset amplification ratio to obtain the target image area of the original image, wherein the preset amplification ratio is inversely proportional to the preset reduction ratio.
Optionally, after calculating the distance between the two adjacent separation lines, the method further includes:
and determining a dividing line of the image to be divided according to two adjacent dividing lines with the distance smaller than a preset distance threshold.
In a second aspect, the present application provides an image processing apparatus, the apparatus comprising:
the color block segmentation processing module is used for carrying out color block segmentation processing on an image to be segmented to obtain a color block image of the image to be segmented;
the dividing module is used for determining a plurality of pixel groups in the color block image according to a preset pixel group dividing rule, wherein each pixel group comprises a plurality of pixel points;
the first calculation module is used for calculating the similarity of two adjacent pixel groups;
a first determining module, configured to determine separation lines corresponding to positions of two adjacent pixel groups with similarity smaller than a preset similarity threshold in the color block image, where the color block image includes at least two separation lines;
the second calculation module is used for calculating the distance between two adjacent separation lines;
the second determining module is used for taking two adjacent separation lines with the distance larger than a preset distance threshold value as the separation lines of the images to be segmented;
the segmentation module is used for segmenting the image to be segmented according to the segmentation lines to obtain an image area between two adjacent segmentation lines with the distance larger than a preset distance threshold as a target image area.
Optionally, the first computing module includes:
an acquisition sub-module, configured to acquire pixel value distributions of two adjacent pixel groups;
and the calculating sub-module is used for calculating the similarity of the two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
Optionally, the apparatus further includes:
the reduction module is used for reducing the size of the original image according to a preset reduction ratio to obtain an image to be segmented;
and the amplifying module is used for amplifying the size of the target image area according to a preset amplifying proportion to obtain the target image area of the original image, wherein the preset amplifying proportion is inversely proportional to the preset shrinking proportion.
Optionally, the second determining module is further configured to determine a dividing line of the image to be divided according to two adjacent dividing lines with a distance smaller than a preset distance threshold.
In a third aspect, the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of the first aspects when executing a program stored on a memory.
In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored therein, which when executed by a processor implements the method steps of any of the first aspects.
In a fifth aspect, the present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform any of the above described image processing methods.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
according to the method provided by the embodiment of the application, the color block segmentation processing can be carried out on the image to be segmented to obtain the color block image of the image to be segmented; determining a plurality of pixel groups in a color block image according to a preset pixel group division rule, wherein each pixel group comprises a plurality of pixel points; calculating the similarity of two adjacent pixel groups; determining separation lines corresponding to the positions of two adjacent pixel groups with similarity smaller than a preset similarity threshold value in a color block image, wherein the color block image comprises at least two separation lines; calculating the distance between two adjacent separation lines; taking two adjacent separation lines with the distance larger than a preset distance threshold value as separation lines of the images to be separated; dividing the image to be divided according to the dividing lines to obtain an image area between two adjacent dividing lines with the distance larger than a preset distance threshold as a target image area.
When the image to be segmented is a UI interface, the image to be segmented is firstly converted into a color block image, a plurality of pixel groups in the color block image are determined, separation lines are determined based on the similarity of two adjacent pixel groups, then two adjacent separation lines with the distance larger than a preset distance threshold value are used as separation lines, and the image to be segmented is segmented according to the separation lines, so that the pixel groups forming the same interface element can be divided into the same image area, and the UI interface is segmented.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
Fig. 1 is a flowchart of an image processing method according to an embodiment of the present application;
fig. 2a is a schematic diagram of an image to be segmented according to an embodiment of the present application;
fig. 2b is a schematic diagram of a color block image of an image to be segmented according to an embodiment of the present application;
FIG. 2c is a schematic diagram of a color patch image according to an embodiment of the present disclosure;
FIG. 2d is a schematic diagram of a color patch image according to an embodiment of the present disclosure;
fig. 2e is a schematic diagram of an image to be segmented according to an embodiment of the present application;
fig. 3 is a flowchart of an image processing method according to an embodiment of the present application;
fig. 4 is a flowchart of an image processing method according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
The embodiment of the application provides an image processing method which is applied to electronic equipment, wherein the electronic equipment can have an image processing function, and for example, the electronic equipment can be a mobile phone, a tablet personal computer and a notebook personal computer.
The electronic device may perform image segmentation on the UI interface to obtain a plurality of image areas, and then, the electronic device may determine a layout code of the UI interface according to positions of the plurality of image areas in the UI interface and sizes of the plurality of image areas. In this embodiment of the present application, the image to be segmented may be a UI interface, and the image to be segmented may also be a web page interface, a screenshot of an application program interface, and the like, which is not limited herein.
As shown in fig. 1, a flowchart of an image processing method provided in an embodiment of the present application may include:
step 101, performing color block segmentation processing on an image to be segmented to obtain a color block image of the image to be segmented.
In implementation, the electronic device may use the original image to be segmented as the image to be segmented, or may use the original image after the image processing as the image to be segmented. The specific processing procedure of the electronic device for image segmentation of the original image will be described in detail later, wherein the original image after image processing is used as the image to be segmented.
The electronic equipment can adopt a preset color block segmentation algorithm to carry out color block segmentation processing on the image to be segmented, so as to obtain a color block image of the image to be segmented. The color block segmentation algorithm may be any algorithm with a color block segmentation function, for example, the color block segmentation algorithm may be a graph-based image segmentation algorithm.
Fig. 2a is a schematic diagram of an image to be segmented according to an embodiment of the present application; the electronic device may perform a color patch segmentation process on the image to be segmented, to obtain a color patch image of the image to be segmented as shown in fig. 2 b.
Step 102, determining a plurality of pixel groups in the color block image according to a preset pixel group division rule.
Wherein each pixel group comprises a plurality of pixel points.
In implementations, the pixel group division rule may be to divide pixels by rows in the color block image, i.e., the electronics may treat each row of pixels in the color block image as one pixel group. The pixel division rule may also be to divide pixel points by columns in the color block image, i.e., the electronic device may treat each column of pixel points in the color block image as one pixel group. The pixel group dividing rule may further divide the pixel points sequentially according to circles with different values as radii by using the center point of the color block image as a center, and the electronic device may use the pixel point on the circle corresponding to the selected radius in the color block image as a pixel group.
The electronic device may divide the pixel points in the color block image according to a preset pixel group division rule, so as to obtain a plurality of pixel groups in the color block image.
Step 103, calculating the similarity of two adjacent pixel groups.
In an implementation, the electronic device may determine two adjacent pixel groups among the plurality of pixel groups of the color patch image according to a preset traversal order, and then the electronic device may calculate the similarity of the two adjacent pixel groups. The specific process of the electronic device for calculating the similarity between two adjacent pixel groups will be described in detail later.
In this embodiment of the present application, when the pixel group is a row of pixels in the color block image, the traversal order may be in the top-to-bottom order in the color block image, or in the bottom-to-top order. When the pixel group is a column of pixels in a color patch image, the traversal order may be left-to-right in the color patch image, or right-to-left. When the pixel group is composed of circular pixel points in the patch image, the traversal order may be an inside-out order with the patch image center point as an internal reference point, or an outside-in order.
In the embodiment of the present application, the processing procedure of the image processing method is described by taking the pixel group division rule as an example that pixel points are divided by rows in the color block image and the traversal order is the order from top to bottom in the color block image. The specific processing procedures of the image processing method in the other pixel group dividing rules and the traversing sequence are similar, and are not repeated here.
For example, as shown in fig. 2c, a schematic diagram of a color block image is provided in the embodiment of the present application, where pixel group 1, pixel group 2, pixel group 3, and pixel group … … are N rows of pixel groups included in the color block image, and the traversal order is the order of pixel group 1-pixel group 2-pixel group 3- … … -pixel group N. In this traversal order, the electronics can determine that pixel group 1 and pixel group 2 are two adjacent pixel groups, and that pixel group 2 and pixel group 3 are two adjacent pixel groups.
And 104, determining separation lines corresponding to the positions of two adjacent pixel groups with the similarity smaller than a preset similarity threshold in the color block image.
Wherein the color block image comprises at least two separation lines.
In an implementation, the electronic device may compare the similarity between the two adjacent pixel groups with a preset similarity threshold, and if the similarity between the two adjacent pixel groups is greater than the preset similarity threshold, it indicates that the two adjacent pixel groups are similar and should be divided into the same image area, and the electronic device may not perform subsequent processing. If the similarity of two adjacent pixel groups is smaller than the preset similarity threshold, the fact that the similarity of the two adjacent pixel groups is lower is indicated, and the two pixel groups are not divided into the same image area. Thus, the electronic device may determine, for two adjacent pixel groups having a similarity smaller than the preset similarity threshold, a separation line corresponding to the positions of the two adjacent pixel groups in the patch image.
After traversing all adjacent groups of pixels in the color patch image, the electronic device may determine at least two separation lines of the color patch image.
In this embodiment of the present application, for two adjacent pixel groups with a similarity smaller than a preset similarity threshold, the electronic device may determine, in the color block image, a separation line corresponding to the positions of the two adjacent pixel groups in a plurality of ways, and in a feasible implementation manner, the electronic device may use the position of any one of the two adjacent pixel groups as the position of the separation line.
For example, when the traversal order is from top to bottom in the patch image, the electronic device may select a pixel group arranged below from two adjacent pixel groups, and take the position of the pixel group as the position of the dividing line; when the traversal order is an order from bottom to top in the patch image, the electronic device may select a pixel group arranged above from two adjacent pixel groups, and take a position of the pixel group as a position of the dividing line.
In another possible implementation, the electronics can calculate the position of the separation line from the positions of the two adjacent pixel groups. For example, the electronic device may take the intermediate position of the two adjacent pixel groups as the position of the dividing line.
Step 105, calculating the distance between two adjacent separation lines.
In an implementation, the electronic device may determine two adjacent separation lines from at least two separation lines included in the color block image according to a preset traversal sequence, and then the electronic device may calculate a distance between the two adjacent separation lines.
For example, as shown in fig. 2d, the patch image includes four separation lines, separation line 1, separation line 2, separation line 3, and separation line 4, respectively. The electronic device may determine two adjacent separation lines from the 4 separation lines included in the color block image according to a preset traversal sequence, so as to obtain a separation line 1 and a separation line 2, a separation line 2 and a separation line 3, and a separation line 3 and a separation line 4. Then, the electronic device may calculate the distance between the separation line 1 and the separation line 2 to obtain 10mm, and similarly, the electronic device may calculate the distance between the separation line 2 and the separation line 3 to obtain 5mm, and calculate the distance between the separation line 3 and the separation line 4 to obtain 15mm.
And 106, taking two adjacent separation lines with the distance larger than a preset distance threshold as the separation lines of the images to be segmented.
The electronic device may have a preset spacing threshold, for example, 8mm, stored therein.
In an implementation, the electronic device may compare a distance between two adjacent separation lines with a preset distance threshold, and if the distance between two adjacent separation lines is greater than the preset distance threshold, the electronic device may respectively use the two separation lines as the separation lines of the image to be segmented.
If the distance between two adjacent separation lines is smaller than the preset distance threshold, the size of the image area between the two adjacent separation lines is smaller, and the two separation lines can be combined, so that the electronic equipment can determine one separation line of the image to be separated according to the two adjacent separation lines with the distance smaller than the preset distance threshold.
In implementation, when the traversing sequence is from top to bottom in the color block image, the electronic device may select a separation line arranged below from the two separation lines, and use the separation line as a separation line of the image to be segmented; when the traversing order is from bottom to top in the patch image, the electronic device may select a separation line arranged above from the two separation lines, and use the separation line as a separation line of the image to be segmented. The electronic device may also determine either one of the two dividing lines as a dividing line of the image to be divided.
Therefore, the number of the dividing lines of the image to be divided can be reduced by screening the adjacent dividing lines with the distance smaller than the preset distance threshold value, and the accuracy of image division of the image to be divided based on the dividing lines can be improved while the data processing amount of the electronic equipment is reduced.
For example, the separation line 1 and the separation line 2 may be set as a separation line of the image to be divided by the electronic device, with a separation distance of 10mm between the separation line 1 and the separation line 2 being greater than a preset separation distance threshold of 8 mm; the distance 5mm between the separation line 2 and the separation line 3 is smaller than the preset distance threshold value 8mm, the separation line 3 can be removed by the electronic equipment, and the separation line 2 is used as a separation line of the image to be separated; the separation line 2 and the separation line 4 are recalculated to obtain 20mm, and the electronic device can take the separation line 2 and the separation line 4 as the separation line of the image to be segmented because the separation line 2 and the separation line 4 have the separation line 20mm larger than the preset separation threshold value 8mm.
And step 107, dividing the image to be divided according to the dividing lines to obtain an image area between two adjacent dividing lines with the distance larger than a preset distance threshold as a target image area.
In implementation, the electronic device may divide the image to be divided according to the positions of the dividing lines, and use the image area between the dividing lines as the target image area obtained by dividing the image to be divided.
As shown in fig. 2e, a schematic diagram of an image to be segmented according to an embodiment of the present application is provided, where the target image area 1 is obtained by dividing the image to be segmented by an electronic device according to a dividing line 1 and a dividing line 2, and the target image area 2 is obtained by dividing the image to be segmented by the electronic device according to the dividing line 2 and a dividing line 4.
In the embodiment of the application, the electronic device may perform color block segmentation processing on the image to be segmented to obtain a color block image of the image to be segmented; determining a plurality of pixel groups in a color block image according to a preset pixel group division rule, wherein each pixel group comprises a plurality of pixel points; calculating the similarity of two adjacent pixel groups; determining separation lines corresponding to the positions of two adjacent pixel groups with similarity smaller than a preset similarity threshold value in a color block image, wherein the color block image comprises at least two separation lines; calculating the distance between two adjacent separation lines; taking two adjacent separation lines with the distance larger than a preset distance threshold value as separation lines of the images to be separated; dividing the image to be divided according to the dividing lines to obtain an image area between two adjacent dividing lines with the distance larger than a preset distance threshold as a target image area.
When the image to be segmented is a UI interface, the image to be segmented is firstly converted into a color block image, a plurality of pixel groups in the color block image are determined, separation lines are determined based on the similarity of two adjacent pixel groups, then two adjacent separation lines with the distance larger than a preset distance threshold value are used as separation lines, and the image to be segmented is segmented according to the separation lines, so that the pixel groups forming the same interface element can be divided into the same image area, and the UI interface is segmented.
Optionally, the embodiment of the present application provides an implementation manner for calculating the similarity between two adjacent pixel groups, as shown in fig. 3, including the following steps:
in step 301, a distribution of pixel values of two adjacent pixel groups is obtained.
In an implementation, the electronic device may obtain, for each of two adjacent pixel groups, a pixel value of each pixel point included in the pixel group. Then, the electronic device may count the pixel values of each pixel to obtain a plurality of pixel values and the number of the pixel points corresponding to each pixel value, that is, obtain the pixel value distribution of the pixel group.
Step 302, calculating the similarity of two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
In implementations, the electronics can generate, for each of the two adjacent pixel groups, a pixel vector based on a pixel value distribution for that pixel group, resulting in two pixel vectors corresponding to the two adjacent pixel groups. Then, the electronic device may calculate cosine similarity between two pixel vectors, resulting in similarity of two adjacent pixel groups.
Alternatively, the electronic device may determine, for each of the two adjacent pixel groups, a pixel value with the largest number of corresponding pixel points in the pixel group, as a main pixel value of the pixel group, to obtain two main pixel values corresponding to the two adjacent pixel groups. Then, the electronic device may calculate a hamming distance of the two main pixel values, which is 1 if the two main pixel values are different, and which is 0 if the two main pixel values are identical. The electronic device may then calculate a ratio of the hamming distance to the width of the color patch image, taking the ratio as the similarity of the two adjacent pixel groups.
The electronic device may also calculate the similarity between two adjacent pixel groups by using any similarity calculation method in the related art, and the specific processing procedure is not described here again.
In this embodiment of the present application, the electronic device may obtain pixel value distributions of two adjacent pixel groups, and calculate the similarity between the two adjacent pixel groups according to the pixel value distributions of the two adjacent pixel groups. The electronic device calculates the similarity of the two adjacent pixel groups based on the pixel value distribution of the two adjacent pixel groups, so that the calculation accuracy of the similarity can be improved. The method is convenient for determining the separation line based on the comparison result of the similarity and the preset similarity threshold value, determining the separation line of the image to be segmented based on the comparison result of the distance between two adjacent separation lines and the preset distance threshold value, and segmenting the image to be segmented according to the separation line, so that the accuracy of image segmentation can be improved.
Optionally, the electronic device may store a preset reduction ratio and a preset amplification ratio, where the preset reduction ratio and the preset amplification ratio are inversely proportional. For example, the preset reduction ratio may be 0.2, and correspondingly, the preset enlargement ratio may be 5.
In order to accelerate the determination speed of the dividing line, the electronic device may perform reduction processing on the original image according to a preset reduction ratio, take the reduced original image as the image to be divided, and then determine the target image area of the image to be divided by adopting the steps of the image processing method. Then, the electronic device may perform an enlarging process on the target image area according to a preset enlarging ratio, so as to determine a target image area of the original image area, as shown in fig. 4, and the specific processing procedure includes:
step 401, the size of the original image is reduced according to a preset reduction ratio, so as to obtain an image to be segmented.
Step 402, performing color block segmentation processing on the image to be segmented to obtain a color block image of the image to be segmented.
Step 403, determining a plurality of pixel groups in the color block image according to a preset pixel group division rule.
In step 404, the similarity between two adjacent pixel groups is calculated.
In step 405, a separation line corresponding to the position of two adjacent pixel groups with similarity smaller than a preset similarity threshold is determined in the color patch image.
Step 406, calculating the spacing between two adjacent separation lines.
And step 407, taking two adjacent separation lines with the distance larger than a preset distance threshold as the separation lines of the images to be segmented.
Step 408, dividing the image to be divided according to the dividing lines, and obtaining an image area between two adjacent dividing lines with a distance larger than a preset distance threshold as a target image area.
In implementation, the specific processing procedures of steps 402 to 408 may refer to the processing procedures of steps 101 to 107, which are not described herein.
Step 409, enlarging the size of the target image area according to the preset enlargement ratio, to obtain the target image area of the original image.
Alternatively, the electronic device may perform the color block segmentation process on the original image to obtain a color block image of the original image, and then perform the reduction process on the color block image of the original image according to a preset reduction ratio to obtain a color block image of the image to be segmented. Then, the electronic device may determine the dividing line of the image to be divided by adopting the steps of the image processing method, and then determine the position of the dividing line in the original image according to the position of the dividing line in the color block image and the preset amplification ratio. Then, the electronic device can divide the original image according to the position of the dividing line in the original image to obtain a target image area of the original image.
In the embodiment of the application, the electronic device may reduce the size of the original image according to a preset reduction ratio to obtain the image to be segmented. Then, performing color block segmentation processing on the image to be segmented to obtain a color block image of the image to be segmented. Then, according to a preset pixel group division rule, determining a plurality of pixel groups in the color block image, wherein each pixel group comprises a plurality of pixel points; calculating the similarity of two adjacent pixel groups; determining separation lines corresponding to the positions of two adjacent pixel groups with similarity smaller than a preset similarity threshold value in a color block image, wherein the color block image comprises at least two separation lines; calculating the distance between two adjacent separation lines; taking two adjacent separation lines with the distance larger than a preset distance threshold value as separation lines of the images to be separated; dividing the image to be divided according to the dividing lines to obtain an image area between two adjacent dividing lines with the distance larger than a preset distance threshold as a target image area. And finally, amplifying the size of the target image area according to a preset amplification ratio to obtain the target image area of the original image.
Because the reduced original image is used as the image to be segmented, the image to be segmented is processed, so that the data volume required to be processed when the electronic equipment performs the image segmentation processing is small, and the processing speed of the image segmentation can be improved.
The embodiment of the application also provides an image processing device, as shown in fig. 5, the device includes:
the color block segmentation processing module 510 is configured to perform color block segmentation processing on an image to be segmented, so as to obtain a color block image of the image to be segmented;
the dividing module 520 is configured to determine a plurality of pixel groups in the color block image according to a preset pixel group dividing rule, where each pixel group includes a plurality of pixel points;
a first calculating module 530, configured to calculate a similarity between two adjacent pixel groups;
a first determining module 540, configured to determine, in the color patch image, separation lines corresponding to positions of two adjacent pixel groups having a similarity less than a preset similarity threshold, where the color patch image includes at least two separation lines;
a second calculating module 550 for calculating a distance between two adjacent separation lines;
a second determining module 560, configured to take two adjacent separation lines with a distance greater than a preset distance threshold as a separation line of the image to be segmented;
the segmentation module 570 is configured to segment the image to be segmented according to the segmentation line, and obtain an image area between two adjacent segmentation lines with a distance greater than a preset distance threshold as a target image area.
Optionally, the first computing module includes:
an acquisition sub-module, configured to acquire pixel value distributions of two adjacent pixel groups;
and the calculating sub-module is used for calculating the similarity of the two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
Optionally, the apparatus further includes:
the reduction module is used for reducing the size of the original image according to a preset reduction ratio to obtain an image to be segmented;
and the amplifying module is used for amplifying the size of the target image area according to a preset amplifying proportion to obtain the target image area of the original image, wherein the preset amplifying proportion is inversely proportional to the preset shrinking proportion.
Optionally, the second determining module is further configured to determine a dividing line of the image to be divided according to two adjacent dividing lines with a distance smaller than a preset distance threshold.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
the device provided by the embodiment of the application can perform color block segmentation processing on the image to be segmented to obtain a color block image of the image to be segmented; determining a plurality of pixel groups in a color block image according to a preset pixel group division rule, wherein each pixel group comprises a plurality of pixel points; calculating the similarity of two adjacent pixel groups; determining separation lines corresponding to the positions of two adjacent pixel groups with similarity smaller than a preset similarity threshold value in a color block image, wherein the color block image comprises at least two separation lines; calculating the distance between two adjacent separation lines; taking two adjacent separation lines with the distance larger than a preset distance threshold value as separation lines of the images to be separated; dividing the image to be divided according to the dividing lines to obtain an image area between two adjacent dividing lines with the distance larger than a preset distance threshold as a target image area.
When the image to be segmented is a UI interface, the image to be segmented is firstly converted into a color block image, a plurality of pixel groups in the color block image are determined, separation lines are determined based on the similarity of two adjacent pixel groups, then two adjacent separation lines with the distance larger than a preset distance threshold value are used as separation lines, and the image to be segmented is segmented according to the separation lines, so that the pixel groups forming the same interface element can be divided into the same image area, and the UI interface is segmented.
The embodiment of the present application further provides an electronic device, as shown in fig. 6, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604, where the processor 601, the communication interface 602, and the memory 603 perform communication with each other through the communication bus 604,
a memory 603 for storing a computer program;
the processor 601 is configured to execute the program stored in the memory 603, and implement the following steps:
performing color block segmentation processing on an image to be segmented to obtain a color block image of the image to be segmented;
determining a plurality of pixel groups in the color block image according to a preset pixel group division rule, wherein each pixel group comprises a plurality of pixel points;
calculating the similarity of two adjacent pixel groups;
determining separation lines corresponding to the positions of two adjacent pixel groups with similarity smaller than a preset similarity threshold value in the color block image, wherein the color block image comprises at least two separation lines;
calculating the distance between two adjacent separation lines;
taking two adjacent separation lines with the distance larger than a preset distance threshold value as the separation lines of the images to be separated;
and dividing the image to be divided according to the dividing lines to obtain an image area between two adjacent dividing lines with the distance larger than a preset distance threshold as a target image area.
Optionally, the calculating the similarity between two adjacent pixel groups includes:
acquiring pixel value distribution of two adjacent pixel groups;
and calculating the similarity of the two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
Optionally, before performing the color block segmentation processing on the image to be segmented to obtain the color block image of the image to be segmented, the method further includes:
the size of the original image is reduced according to a preset reduction ratio, and an image to be segmented is obtained;
the image to be segmented is segmented according to the segmentation lines, and after an image area between two adjacent segmentation lines with a distance larger than a preset distance threshold is obtained as a target image area, the method further comprises the steps of:
and amplifying the size of the target image area according to a preset amplification ratio to obtain the target image area of the original image, wherein the preset amplification ratio is inversely proportional to the preset reduction ratio.
Optionally, after calculating the distance between the two adjacent separation lines, the method further includes:
and determining a dividing line of the image to be divided according to two adjacent dividing lines with the distance smaller than a preset distance threshold.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment provided herein, there is also provided a computer-readable storage medium having instructions stored therein, which when run on a computer, cause the computer to perform the image processing method of any of the above embodiments.
In a further embodiment provided herein, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the image processing method of any of the above embodiments.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing is only a specific embodiment of the invention to enable those skilled in the art to understand or practice the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (8)

1. An image processing method, the method comprising:
performing color block segmentation processing on an image to be segmented to obtain a color block image of the image to be segmented;
determining a plurality of pixel groups in the color block image according to a preset pixel group division rule, wherein each pixel group comprises a plurality of pixel points;
calculating the similarity of two adjacent pixel groups;
determining separation lines corresponding to the positions of two adjacent pixel groups with similarity smaller than a preset similarity threshold value in the color block image, wherein the color block image comprises at least two separation lines;
calculating the distance between two adjacent separation lines;
taking two adjacent separation lines with the distance larger than a preset distance threshold value as the separation lines of the images to be separated;
dividing the image to be divided according to the dividing lines to obtain an image area between two adjacent dividing lines with the distance larger than a preset distance threshold as a target image area;
the method comprises the steps of performing color block segmentation processing on an image to be segmented, and before obtaining the color block image of the image to be segmented, further comprises the following steps:
the size of the original image is reduced according to a preset reduction ratio, and an image to be segmented is obtained;
the image to be segmented is segmented according to the segmentation lines, and after an image area between two adjacent segmentation lines with a distance larger than a preset distance threshold is obtained as a target image area, the method further comprises the steps of:
and amplifying the size of the target image area according to a preset amplification ratio to obtain the target image area of the original image, wherein the preset amplification ratio is inversely proportional to the preset reduction ratio.
2. The method of claim 1, wherein said calculating the similarity between two adjacent groups of pixels comprises:
acquiring pixel value distribution of two adjacent pixel groups;
and calculating the similarity of the two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
3. The method of claim 1, further comprising, after calculating the spacing between two adjacent separation lines:
and determining a dividing line of the image to be divided according to two adjacent dividing lines with the distance smaller than a preset distance threshold.
4. An image processing apparatus, characterized in that the apparatus comprises:
the color block segmentation processing module is used for carrying out color block segmentation processing on an image to be segmented to obtain a color block image of the image to be segmented;
the dividing module is used for determining a plurality of pixel groups in the color block image according to a preset pixel group dividing rule, wherein each pixel group comprises a plurality of pixel points;
the first calculation module is used for calculating the similarity of two adjacent pixel groups;
a first determining module, configured to determine separation lines corresponding to positions of two adjacent pixel groups with similarity smaller than a preset similarity threshold in the color block image, where the color block image includes at least two separation lines;
the second calculation module is used for calculating the distance between two adjacent separation lines;
the second determining module is used for taking two adjacent separation lines with the distance larger than a preset distance threshold value as the separation lines of the images to be segmented;
the segmentation module is used for segmenting the image to be segmented according to the segmentation lines to obtain an image area between two adjacent segmentation lines with the distance larger than a preset distance threshold as a target image area;
wherein the apparatus further comprises:
the reduction module is used for reducing the size of the original image according to a preset reduction ratio to obtain an image to be segmented;
and the amplifying module is used for amplifying the size of the target image area according to a preset amplifying proportion to obtain the target image area of the original image, wherein the preset amplifying proportion is inversely proportional to the preset shrinking proportion.
5. The apparatus of claim 4, wherein the first computing module comprises:
an acquisition sub-module, configured to acquire pixel value distributions of two adjacent pixel groups;
and the calculating sub-module is used for calculating the similarity of the two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
6. The apparatus according to claim 4, wherein the second determining module is further configured to determine a dividing line of the image to be divided according to two adjacent dividing lines having a distance smaller than a preset distance threshold.
7. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-3 when executing a program stored on a memory.
8. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-3.
CN201911311717.7A 2019-12-18 2019-12-18 Image processing method and device, electronic equipment and storage medium Active CN111091572B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911311717.7A CN111091572B (en) 2019-12-18 2019-12-18 Image processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911311717.7A CN111091572B (en) 2019-12-18 2019-12-18 Image processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111091572A CN111091572A (en) 2020-05-01
CN111091572B true CN111091572B (en) 2023-06-30

Family

ID=70396417

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911311717.7A Active CN111091572B (en) 2019-12-18 2019-12-18 Image processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111091572B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112053360B (en) * 2020-10-10 2023-07-25 腾讯科技(深圳)有限公司 Image segmentation method, device, computer equipment and storage medium
CN112150365B (en) * 2020-10-15 2023-02-21 江西威力固智能设备有限公司 Expansion and shrinkage processing method of jet printing image and jet printing equipment
CN113573153B (en) * 2021-02-02 2022-08-12 腾讯科技(深圳)有限公司 Image processing method, device and equipment
CN113223020B (en) * 2021-05-21 2024-03-26 深圳乐居智能电子有限公司 Partition method and device for cleaning area and cleaning equipment
CN113223019B (en) * 2021-05-21 2024-03-26 深圳乐居智能电子有限公司 Partition method and device for cleaning area and cleaning equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014177756A1 (en) * 2013-05-03 2014-11-06 Nokia Corporation Method, apparatus and computer program product for segmentation of objects in images
JP2015064698A (en) * 2013-09-24 2015-04-09 富士通株式会社 Image processing apparatus, image processing method, and image processing program
CN109214428A (en) * 2018-08-13 2019-01-15 平安科技(深圳)有限公司 Image partition method, device, computer equipment and computer storage medium
WO2019071990A1 (en) * 2017-10-11 2019-04-18 中兴通讯股份有限公司 Image processing method and apparatus

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108681994B (en) * 2018-05-11 2023-01-10 京东方科技集团股份有限公司 Image processing method and device, electronic equipment and readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014177756A1 (en) * 2013-05-03 2014-11-06 Nokia Corporation Method, apparatus and computer program product for segmentation of objects in images
JP2015064698A (en) * 2013-09-24 2015-04-09 富士通株式会社 Image processing apparatus, image processing method, and image processing program
WO2019071990A1 (en) * 2017-10-11 2019-04-18 中兴通讯股份有限公司 Image processing method and apparatus
CN109658427A (en) * 2017-10-11 2019-04-19 中兴通讯股份有限公司 Image processing method and device
CN109214428A (en) * 2018-08-13 2019-01-15 平安科技(深圳)有限公司 Image partition method, device, computer equipment and computer storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
刘汉强 ; 赵静 ; .基于半监督的超像素谱聚类彩色图像分割算法.计算机工程与应用.2017,(14),全文. *
杨洲 ; 陈莉 ; 贾建 ; .基于超像素分割的非局部均值去噪方法.计算机应用研究.2017,(05),全文. *

Also Published As

Publication number Publication date
CN111091572A (en) 2020-05-01

Similar Documents

Publication Publication Date Title
CN111091572B (en) Image processing method and device, electronic equipment and storage medium
CN108334879B (en) Region extraction method, system and terminal equipment
WO2015106700A1 (en) Method and apparatus for implementing image denoising
CN110298858B (en) Image clipping method and device
EP3742394A1 (en) Image target detection method and apparatus, storage medium, and electronic device
CN108960012B (en) Feature point detection method and device and electronic equipment
CN110287361B (en) Figure picture screening method and device
CN113052162B (en) Text recognition method and device, readable storage medium and computing equipment
CN111127480B (en) Image processing method and device, electronic equipment and storage medium
CN110827301A (en) Method and apparatus for processing image
KR102239588B1 (en) Image processing method and apparatus
CN111161289B (en) Method and device for improving contour precision of object in image
CN109872275B (en) Image processing method, device, electronic equipment and computer readable storage medium
WO2022121701A1 (en) Image processing method and apparatus, electronic device, and storage medium
WO2022111070A1 (en) Image processing method and apparatus, and electronic device and storage medium
CN111260739A (en) Picture processing method and device
CN110874814A (en) Image processing method, image processing device and terminal equipment
CN111127310B (en) Image processing method and device, electronic equipment and storage medium
CN111127478A (en) View block segmentation method and device
CN113068043B (en) PNG image compression method and device, electronic equipment and storage medium
JP5988879B2 (en) Feature point detection apparatus and program
CN113627143B (en) Table creation method and device, electronic equipment and storage medium
CN111754487B (en) Black frame region cutting method and device and electronic equipment
CN112580638B (en) Text detection method and device, storage medium and electronic equipment
US20220358279A1 (en) Document element alignment method and apparatus, electronic device, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant