CN111091572A - 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
CN111091572A
CN111091572A CN201911311717.7A CN201911311717A CN111091572A CN 111091572 A CN111091572 A CN 111091572A CN 201911311717 A CN201911311717 A CN 201911311717A CN 111091572 A CN111091572 A CN 111091572A
Authority
CN
China
Prior art keywords
image
preset
adjacent
segmented
lines
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.)
Granted
Application number
CN201911311717.7A
Other languages
Chinese (zh)
Other versions
CN111091572B (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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Multimedia (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Software Systems (AREA)
  • Image Analysis (AREA)

Abstract

An image processing method, an image processing device, an electronic device and a storage medium belong to the technical field of image processing. The method comprises the following steps: carrying out 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 lump 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 a separation line corresponding to the positions of two adjacent pixel groups with the similarity smaller than a preset similarity threshold value in a color lump image, wherein the color lump 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 division lines of the image to be divided; and 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 value 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 application relates to the field of image processing technologies, and in particular, to an image processing method and apparatus, an electronic device, and a storage medium.
Background
In a UI (User Interface) reverse engineering, an electronic device needs to perform image segmentation on a UI Interface to obtain a plurality of image regions, and then the electronic device may determine a layout code of the UI Interface according to positions of the plurality of image regions in the UI Interface and sizes of the plurality of image regions.
In the related art, the electronic device may segment a normal image by using a conventional image segmentation algorithm, such as an edge-based image segmentation algorithm and a region-based image segmentation algorithm, where the normal image includes a person and a landscape. 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 image structure of the UI interface is different from that of a common image, and a conventional image segmentation algorithm is not suitable for performing image segmentation on the UI interface. At present, a technical scheme capable of performing image segmentation on a UI interface is urgently needed.
Disclosure of Invention
In order to solve the technical problems described above or at least partially solve the technical problems, the present application provides an image processing method, an apparatus, an electronic device, and a storage medium.
In a first aspect, the present application provides an image processing method, comprising:
carrying out 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 images 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 the 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 segmentation lines of the image to be segmented;
and 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 value 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 two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
Optionally, the color block segmentation processing on the image to be segmented further includes, before obtaining the color block image of the image to be segmented:
reducing the size of the original image according to a preset reduction scale to obtain an image to be segmented;
after the image to be segmented is segmented according to the segmentation lines to obtain an image area between two adjacent segmentation lines with the spacing larger than a preset spacing threshold value as a target image area, the method further comprises the following steps:
and amplifying the size of the target image area according to a preset amplification scale to obtain the target image area of the original image, wherein the preset amplification scale is in inverse proportion to the preset reduction scale.
Optionally, after calculating the distance between 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 comprising:
the color block segmentation processing module is used for performing color block segmentation processing on the 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;
the device comprises a first determining module, a second determining module and a third determining module, wherein the first determining module is used for determining a separation line corresponding to the positions of two adjacent pixel groups with the similarity smaller than a preset similarity threshold in the color block image, and the color block image comprises 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 division lines of the image to be divided;
and 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 value as a target image area.
Optionally, the first computing module includes:
the acquisition submodule is used for acquiring the pixel value distribution of two adjacent pixel groups;
and the calculating submodule is used for calculating the similarity of two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
Optionally, the apparatus further comprises:
the reducing module is used for reducing the size of the original image according to a preset reducing scale 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 in inverse proportion to the preset reducing 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 mutual communication through the communication bus;
a memory for storing a computer program;
a processor adapted to perform the method steps of any of the first aspects when executing a program stored in the memory.
In a fourth aspect, the present application provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs 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 image processing methods described above.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages:
the method provided by the embodiment of the application can be used for carrying out color block segmentation processing 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 the color lump images 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 the similarity smaller than a preset similarity threshold value in a color lump image, wherein the color lump 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 division lines of the image to be divided; and 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 value as a target image area.
When the image to be segmented is the UI interface, firstly converting the image to be segmented into a color lump image, determining a plurality of pixel groups in the color lump image, then determining separation lines based on the similarity of two adjacent pixel groups, then taking two adjacent separation lines with the distance larger than a preset distance threshold value as the separation lines, and segmenting the image to be 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 image segmentation of the UI interface is realized.
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 disclosure;
fig. 2b is a schematic diagram of a color block image of an image to be segmented according to the embodiment of the present application;
FIG. 2c is a schematic diagram of a color block image provided in the embodiment of the present application;
FIG. 2d is a schematic diagram of a color block image provided in the embodiment of the present application;
fig. 2e is a schematic diagram of an image to be segmented according to an embodiment of the present disclosure;
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 clearer, the technical solutions in 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 computer and a notebook computer.
The electronic device may perform image segmentation on the UI interface to obtain a plurality of image regions, and then, the electronic device may determine a layout code of the UI interface according to positions of the plurality of image regions in the UI interface and sizes of the plurality of image regions. In this embodiment of the application, the image to be segmented may be a UI interface, and the image to be segmented may also be a screenshot of a web interface or an application interface, 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 is shown, and a specific processing procedure may include:
and 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 image processing as the image to be segmented. The electronic device takes the original image after the image processing as an image to be segmented, and a detailed description will be given later on a specific processing procedure for segmenting the image of the original image.
The electronic device can perform color block segmentation processing on the image to be segmented by adopting a preset color block segmentation algorithm to obtain a color block image of the image to be segmented. The color block segmentation algorithm may be any algorithm having 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 disclosure; the electronic device may perform the patch segmentation processing on the image to be segmented to obtain a patch image of the image to be segmented as shown in fig. 2 b.
And step 102, determining a plurality of pixel groups in the color lump image according to a preset pixel group division rule.
Wherein each pixel group comprises a plurality of pixel points.
In implementation, the pixel group division rule may be to divide the pixel points in the color block image by rows, that is, the electronic device may use each row of the pixel points in the color block image as one pixel group. The pixel division rule may also be to divide the pixel points in the color-block image by columns, that is, the electronic device may use each column of the pixel points in the color-block image as a pixel group. The pixel group division rule may also be that pixel points are sequentially divided according to circles using different numerical values as radii, with the center point of the color block image as the center of a circle, and the electronic device may use the pixel points on the circle corresponding to the selected radius in the color block image as a pixel group.
The electronic device can divide the pixel points in the color block image according to a preset pixel group division rule to obtain a plurality of pixel groups in the color block image.
And 103, calculating the similarity of two adjacent pixel groups.
In implementation, the electronic device may determine two adjacent pixel groups in the plurality of pixel groups of the patch image according to a preset traversal order, and then the electronic device may calculate a similarity between the two adjacent pixel groups. The specific process of calculating the similarity between two adjacent pixel groups by the electronic device will be described in detail later.
In this embodiment of the application, when the pixel group is a row of pixel points in the color block image, the traversal order may be from top to bottom, or from bottom to top, in the color block image. When the pixel group is a column of pixel points in the color-block image, the traversal order may be from left to right in the color-block image, or from right to left. When the pixel group is composed of circular pixels in the patch image, the traversal order may be from inside to outside, or from outside to inside, with the center point of the patch image as an internal reference point.
In the embodiment of the present application, a processing procedure of an image processing method is described by taking an example that a pixel group division rule is to divide pixel points in a color block image according to rows, and a traversal order is from top to bottom in the color block image. The specific processing procedures of the image processing method in the other pixel group division rules and the traversal order are similar to those described above, and are not described herein again.
For example, as shown in fig. 2c, a schematic diagram of a color block image provided in the embodiment of the present application is shown, where pixel group 1, pixel group 2, pixel group 3, and pixel group N … … are pixel groups in N rows included in the color block image, and the traversal order is the order of pixel group 1, pixel group 2, pixel group 3- … …, and pixel group N. In this traversal order, the electronic device may determine that pixel group 1 and pixel group 2 are two adjacent pixel groups, and pixel group 2 and pixel group 3 are two adjacent pixel groups.
And 104, determining a separation line corresponding to the positions of two adjacent pixel groups with the similarity smaller than a preset similarity threshold value in the color lump image.
Wherein, the color block image comprises at least two separation lines.
In implementation, the electronic device may compare the similarity between two adjacent pixel groups with a preset similarity threshold, and if the similarity between 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 similarity of the two adjacent pixel groups is low, and the two pixel groups should not be divided into the same image area. Therefore, the electronic device may determine, for two adjacent pixel groups having a similarity smaller than a preset similarity threshold, a separation line corresponding to the positions of the two adjacent pixel groups in the patch image.
After traversing all adjacent pixel groups in the color-patch image, the electronics can determine at least two separation lines of the color-patch image.
In the embodiment of the present application, for two adjacent pixel groups with 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 in two adjacent pixel groups, and use the position of the pixel group as the position of the separation line; when the traversal order is from bottom to top in the patch image, the electronic device may select a pixel group arranged above from two adjacent pixel groups, and use the position of the pixel group as the position of the separation line.
In another possible implementation, the electronic device may calculate the location of the separation line based on the locations of the two adjacent pixel groups. For example, the electronic device may take the middle position of the two adjacent pixel groups as the position of the separation line.
And 105, calculating the distance between two adjacent separation lines.
In an implementation, the electronic device may determine two adjacent separation lines in at least two separation lines included in the patch image according to a preset traversal order, 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, i.e., a separation line 1, a separation line 2, a separation line 3, and a separation line 4. The electronic device may determine two adjacent separation lines in the 4 separation lines included in the patch images according to a preset traversal order, so as to obtain the separation line 1 and the separation line 2, the separation line 2 and the separation line 3, and the separation line 3 and the separation line 4. The electronic device can then calculate the separation between separation line 1 and separation line 2 to give 10mm, and similarly the electronic device can calculate the separation between separation line 2 and separation line 3 to give 5mm and the separation between separation line 3 and separation line 4 to give 15 mm.
And step 106, taking two adjacent separation lines with the distance larger than a preset distance threshold value as the separation lines of the image to be separated.
The electronic device may be pre-stored with a preset distance threshold, where the preset distance threshold is, for example, 8 mm.
In 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 separated.
If the distance between two adjacent separation lines is smaller than the preset distance threshold, it indicates that the size of the image area between two adjacent separation lines is small, and the two separation lines can be merged, so that the electronic device can determine a separation line of the image to be separated according to two adjacent separation lines with the distance smaller than the preset distance threshold.
In implementation, when the traversal order is from top to bottom in the color block image, the electronic device may select a separation line arranged below the two separation lines, and use the separation line as a segmentation line of the image to be segmented; when the traversal order is from bottom to top in the color patch image, the electronic device may select a separation line arranged above the two separation lines, and use the separation line as a partition line of the image to be partitioned. The electronic device may also determine any one of the two separation lines as a division 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 spacing smaller than the preset spacing threshold, 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 distance 10mm between the separation line 1 and the separation line 2 is greater than the preset distance threshold value 8mm, and the electronic device may use the separation line 1 and the separation line 2 as the dividing line of the image to be divided; the distance 5mm between the separation line 2 and the separation line 3 is smaller than the preset distance threshold value 8mm, the electronic equipment can remove the separation line 3, and the separation line 2 is used as a separation line of the image to be divided; and recalculating the distance between the separation line 2 and the separation line 4 to 20mm, wherein the electronic equipment can take the separation line 2 and the separation line 4 as the separation line of the image to be segmented because the distance between the separation line 2 and the separation line 4 is 20mm larger than the preset distance threshold value of 8 mm.
And 107, 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 value as a target image area.
In an 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 a 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 a target image area 1 is obtained by an electronic device by segmenting the image to be segmented according to a segmentation line 1 and a segmentation line 2, and a target image area 2 is obtained by an electronic device by segmenting the image to be segmented according to a segmentation line 2 and a segmentation line 4.
In the embodiment of the application, the electronic device 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 the color lump images 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 the similarity smaller than a preset similarity threshold value in a color lump image, wherein the color lump 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 division lines of the image to be divided; and 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 value as a target image area.
When the image to be segmented is the UI interface, firstly converting the image to be segmented into a color lump image, determining a plurality of pixel groups in the color lump image, then determining separation lines based on the similarity of two adjacent pixel groups, then taking two adjacent separation lines with the distance larger than a preset distance threshold value as the separation lines, and segmenting the image to be 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 image segmentation of the UI interface is realized.
Optionally, an implementation manner of calculating similarity between two adjacent pixel groups is provided in an embodiment of the present application, and as shown in fig. 3, the implementation manner includes the following steps:
step 301, obtaining the pixel value distribution of two adjacent pixel groups.
In 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 perform statistics on the pixel values of the pixels to obtain a plurality of pixel values and the number of pixels corresponding to each pixel value, that is, to 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 an implementation, the electronic device may generate, for each of two adjacent pixel groups, a pixel vector based on a pixel value distribution of the pixel group, resulting in two pixel vectors corresponding to the two adjacent pixel groups. Then, the electronic device may calculate a cosine similarity between two pixel vectors, resulting in a similarity between two adjacent pixel groups.
Or, the electronic device may determine, for each of two adjacent pixel groups, a pixel value with the largest number of corresponding pixel points in the pixel group, and obtain two main pixel values corresponding to the two adjacent pixel groups as a main pixel value of the pixel group. The electronic device may then calculate a hamming distance of the two main pixel values, which is 1 if the two main pixel values are different and 0 if the two main pixel values are the same. Then, the electronic device can calculate a ratio of the hamming distance to the width of the patch image, and the ratio is used as the similarity of two adjacent pixel groups.
The electronic device may also use any similarity calculation method in the related art to calculate the similarity between two adjacent pixel groups, and the specific processing process is not described herein again.
In the embodiment of the application, the electronic device may obtain the pixel value distribution of two adjacent pixel groups, and calculate the similarity between the two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups. Since the electronic device calculates the similarity of two adjacent pixel groups based on the pixel value distribution of the two adjacent pixel groups, the calculation accuracy of the similarity can be improved. The method is convenient for determining the separation lines based on the comparison result of the similarity and the preset similarity threshold, determining the segmentation lines of the image to be segmented based on the comparison result of the distance between two adjacent separation lines and the preset distance threshold, and segmenting the image to be segmented according to the segmentation lines, so that the image segmentation accuracy can be improved.
Optionally, a preset reduction ratio and a preset enlargement ratio may be stored in the electronic device, and the preset reduction ratio and the preset enlargement 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 increase the speed of determining the segmentation line, the electronic device may perform reduction processing on the original image according to a preset reduction ratio, use the reduced original image as an image to be segmented, and then determine a target image area of the image to be segmented by using the steps of the image processing method. Then, the electronic device may perform an amplification process on the target image area according to a preset amplification ratio, so as to determine the target image area of the original image area, as shown in fig. 4, where the specific processing procedure includes:
step 401, reducing the size of the original image according to a preset reduction scale to obtain an image to be segmented.
And 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.
Step 405, determining a separation line corresponding to the positions of two adjacent pixel groups with the similarity smaller than a preset similarity threshold value in the color block image.
In step 406, the distance between two adjacent separation lines is calculated.
Step 407, taking two adjacent separation lines with the distance larger than the preset distance threshold value as the separation lines of the image to be separated.
And 408, 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 value as a target image area.
In the 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 again.
And step 409, amplifying the size of the target image area according to a preset amplification scale to obtain the target image area of the original image.
Optionally, the electronic device may also perform color block segmentation on the original image to obtain a color block image of the original image, and then perform reduction processing 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 magnification ratio. Then, the electronic device may segment the original image according to the position of the segmentation line in the original image, so as to obtain the target image area of the original image.
In the embodiment of the application, the electronic device can reduce the size of the original image according to a preset reduction scale to obtain the image to be segmented. And then, carrying out color lump segmentation processing on the image to be segmented to obtain a color lump 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 lump 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 the similarity smaller than a preset similarity threshold value in a color lump image, wherein the color lump 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 division lines of the image to be divided; and 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 value as a target image area. And finally, amplifying the size of the target image area according to a preset amplification scale to obtain the target image area of the original image.
Since the reduced original image is used as the image to be divided and the image to be divided is processed, the data amount required to be processed when the electronic device performs the image division processing is small, and the processing speed of the image division can be improved.
An embodiment of the present application further provides an image processing apparatus, as shown in fig. 5, the apparatus includes:
a color block segmentation processing module 510, configured to perform color block segmentation processing on an image to be segmented to obtain a color block image of the image to be segmented;
a dividing module 520, configured to determine, according to a preset pixel group dividing rule, a plurality of pixel groups in the color block image, where each pixel group includes a plurality of pixel points;
a first calculating module 530, configured to calculate similarity between two adjacent pixel groups;
a first determining module 540, configured to determine, in the color-block image, a separation line corresponding to positions of two adjacent pixel groups whose similarity is smaller than a preset similarity threshold, where the color-block image includes at least two separation lines;
a second calculating module 550, configured to calculate a distance between two adjacent separation lines;
a second determining module 560, configured to use two adjacent separation lines with a distance greater than a preset distance threshold as a segmentation line of the image to be segmented;
the segmentation module 570 is configured to segment the image to be segmented according to the segmentation lines, 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:
the acquisition submodule is used for acquiring the pixel value distribution of two adjacent pixel groups;
and the calculating submodule is used for calculating the similarity of two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
Optionally, the apparatus further comprises:
the reducing module is used for reducing the size of the original image according to a preset reducing scale 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 in inverse proportion to the preset reducing 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 be used for carrying out color block segmentation processing 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 the color lump images 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 the similarity smaller than a preset similarity threshold value in a color lump image, wherein the color lump 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 division lines of the image to be divided; and 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 value as a target image area.
When the image to be segmented is the UI interface, firstly converting the image to be segmented into a color lump image, determining a plurality of pixel groups in the color lump image, then determining separation lines based on the similarity of two adjacent pixel groups, then taking two adjacent separation lines with the distance larger than a preset distance threshold value as the separation lines, and segmenting the image to be 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 image segmentation of the UI interface is realized.
The embodiment of the present application further provides an electronic device, as shown in fig. 6, which includes 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 complete mutual communication through the communication bus 604,
a memory 603 for storing a computer program;
the processor 601 is configured to implement the following steps when executing the program stored in the memory 603:
carrying out 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 images 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 the 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 segmentation lines of the image to be segmented;
and 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 value 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 two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
Optionally, the color block segmentation processing on the image to be segmented further includes, before obtaining the color block image of the image to be segmented:
reducing the size of the original image according to a preset reduction scale to obtain an image to be segmented;
after the image to be segmented is segmented according to the segmentation lines to obtain an image area between two adjacent segmentation lines with the spacing larger than a preset spacing threshold value as a target image area, the method further comprises the following steps:
and amplifying the size of the target image area according to a preset amplification scale to obtain the target image area of the original image, wherein the preset amplification scale is in inverse proportion to the preset reduction scale.
Optionally, after calculating the distance between 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 in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the terminal and other equipment.
The Memory may include a Random Access Memory (RAM) or a 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 processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In yet another embodiment provided by the present application, a computer-readable storage medium is further provided, which has instructions stored therein, and when the instructions are executed on a computer, the instructions cause the computer to execute the image processing method described in any of the above embodiments.
In yet another embodiment provided by the present application, 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, the implementation may be wholly or partially realized 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, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the 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)), among others.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be 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. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present 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 (10)

1. An image processing method, characterized in that the method comprises:
carrying out 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 images 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 the 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 segmentation lines of the image to be segmented;
and 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 value as a target image area.
2. The method according to claim 1, wherein said calculating the similarity between two adjacent pixel groups comprises:
acquiring pixel value distribution of two adjacent pixel groups;
and calculating the similarity of two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
3. The method according to claim 1, wherein before the processing of performing color block segmentation on the image to be segmented to obtain the color block image of the image to be segmented, the method further comprises:
reducing the size of the original image according to a preset reduction scale to obtain an image to be segmented;
after the image to be segmented is segmented according to the segmentation lines to obtain an image area between two adjacent segmentation lines with the spacing larger than a preset spacing threshold value as a target image area, the method further comprises the following steps:
and amplifying the size of the target image area according to a preset amplification scale to obtain the target image area of the original image, wherein the preset amplification scale is in inverse proportion to the preset reduction scale.
4. The method according to claim 1, wherein after calculating the distance between two adjacent separation lines, the method further comprises:
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.
5. An image processing apparatus, characterized in that the apparatus comprises:
the color block segmentation processing module is used for performing color block segmentation processing on the 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;
the device comprises a first determining module, a second determining module and a third determining module, wherein the first determining module is used for determining a separation line corresponding to the positions of two adjacent pixel groups with the similarity smaller than a preset similarity threshold in the color block image, and the color block image comprises 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 division lines of the image to be divided;
and 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 value as a target image area.
6. The apparatus of claim 5, wherein the first computing module comprises:
the acquisition submodule is used for acquiring the pixel value distribution of two adjacent pixel groups;
and the calculating submodule is used for calculating the similarity of two adjacent pixel groups according to the pixel value distribution of the two adjacent pixel groups.
7. The apparatus of claim 5, further comprising:
the reducing module is used for reducing the size of the original image according to a preset reducing scale 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 in inverse proportion to the preset reducing proportion.
8. The apparatus according to claim 5, 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.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 4 when executing a program stored in the memory.
10. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1 to 4.
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 true CN111091572A (en) 2020-05-01
CN111091572B 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)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112053360A (en) * 2020-10-10 2020-12-08 腾讯科技(深圳)有限公司 Image segmentation method and device, computer equipment and storage medium
CN112150365A (en) * 2020-10-15 2020-12-29 江西威力固智能设备有限公司 Expansion and shrinkage processing method of jet printing image and jet printing equipment
CN113223019A (en) * 2021-05-21 2021-08-06 深圳乐居智能电子有限公司 Zoning method and device for cleaning area and cleaning equipment
CN113223020A (en) * 2021-05-21 2021-08-06 深圳乐居智能电子有限公司 Zoning method and device for cleaning area and cleaning equipment
CN113573153A (en) * 2021-02-02 2021-10-29 腾讯科技(深圳)有限公司 Image processing method, device and equipment

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
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
US20190347767A1 (en) * 2018-05-11 2019-11-14 Boe Technology Group Co., Ltd. Image processing method and device

Patent Citations (6)

* 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
US20190347767A1 (en) * 2018-05-11 2019-11-14 Boe Technology Group Co., Ltd. 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
刘汉强;赵静;: "基于半监督的超像素谱聚类彩色图像分割算法" *
杨洲;陈莉;贾建;: "基于超像素分割的非局部均值去噪方法" *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112053360A (en) * 2020-10-10 2020-12-08 腾讯科技(深圳)有限公司 Image segmentation method and device, computer equipment and storage medium
CN112053360B (en) * 2020-10-10 2023-07-25 腾讯科技(深圳)有限公司 Image segmentation method, device, computer equipment and storage medium
CN112150365A (en) * 2020-10-15 2020-12-29 江西威力固智能设备有限公司 Expansion and shrinkage processing method of jet printing image and jet printing equipment
CN113573153A (en) * 2021-02-02 2021-10-29 腾讯科技(深圳)有限公司 Image processing method, device and equipment
CN113223019A (en) * 2021-05-21 2021-08-06 深圳乐居智能电子有限公司 Zoning method and device for cleaning area and cleaning equipment
CN113223020A (en) * 2021-05-21 2021-08-06 深圳乐居智能电子有限公司 Zoning method and device for cleaning area and cleaning 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

Also Published As

Publication number Publication date
CN111091572B (en) 2023-06-30

Similar Documents

Publication Publication Date Title
CN111091572B (en) Image processing method and device, electronic equipment and storage medium
CN112102164B (en) Image processing method, device, terminal and storage medium
CN108334879B (en) Region extraction method, system and terminal equipment
CN111444807B (en) Target detection method, device, electronic equipment and computer readable medium
CN111027412B (en) Human body key point identification method and device and electronic equipment
CN110909664A (en) Human body key point identification method and device and electronic equipment
CN112580668A (en) Background fraud detection method and device and electronic equipment
CN111047496A (en) Threshold determination method, watermark detection device and electronic equipment
CN111127480B (en) Image processing method and device, electronic equipment and storage medium
TW201911230A (en) Surveillance method, computing device, and non-transitory storage medium
US9734550B1 (en) Methods and apparatus for efficiently determining run lengths and identifying patterns
CN109872275B (en) Image processing method, device, electronic equipment and computer readable storage medium
CN108764206B (en) Target image identification method and system and computer equipment
CN116152816A (en) Method and device for identifying closed area, electronic equipment and storage medium
CN112816959B (en) Clustering method, device, equipment and storage medium for vehicles
CN110874814A (en) Image processing method, image processing device and terminal equipment
CN113420604B (en) Multi-person posture estimation method and device and electronic equipment
CN111127478A (en) View block segmentation method and device
CN111127310B (en) Image processing method and device, electronic equipment and storage medium
CN114051132A (en) LSC data detection method, device, terminal equipment and medium
CN113343797A (en) Information extraction method and device, terminal equipment and computer readable storage medium
CN113313642A (en) Image denoising method and device, storage medium and electronic equipment
CN113568733A (en) Resource allocation method, device, electronic equipment and storage medium
CN113095211B (en) Image processing method, system and electronic equipment
CN110766644A (en) Image down-sampling method and device

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