CN115861202A - Image processing method and system and electronic equipment - Google Patents

Image processing method and system and electronic equipment Download PDF

Info

Publication number
CN115861202A
CN115861202A CN202211478203.2A CN202211478203A CN115861202A CN 115861202 A CN115861202 A CN 115861202A CN 202211478203 A CN202211478203 A CN 202211478203A CN 115861202 A CN115861202 A CN 115861202A
Authority
CN
China
Prior art keywords
picture
value
pixel
identified
white background
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.)
Pending
Application number
CN202211478203.2A
Other languages
Chinese (zh)
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.)
Tezign Shanghai Information Technology Co Ltd
Original Assignee
Tezign Shanghai Information Technology 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 Tezign Shanghai Information Technology Co Ltd filed Critical Tezign Shanghai Information Technology Co Ltd
Priority to CN202211478203.2A priority Critical patent/CN115861202A/en
Publication of CN115861202A publication Critical patent/CN115861202A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Image Analysis (AREA)

Abstract

The application discloses an image processing method, an image processing system and electronic equipment, wherein the method comprises the steps of judging whether a color space value of a picture to be identified has an alpha channel; when an alpha channel is provided, identifying whether the transparent area proportion of the picture to be identified is greater than a first preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a transparent base map, and if so, marking a transparent base map label; if the transparent area ratio of the picture to be identified is not larger than the first preset value or when the color space value does not have an alpha channel, identifying whether the white pixel ratio of the picture to be identified is larger than a second preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a white background picture, if so, marking a white background picture label, and if not, marking the white background picture label to be identified. The method and the device solve the technical problems of rough identification and classification granularity and inaccurate classification of the white background image in the related art, and improve the efficiency and accuracy of image classification marking.

Description

Image processing method and system and electronic equipment
Technical Field
The application belongs to the technical field of computers, and particularly relates to an image processing method, an image processing system and electronic equipment.
Background
The white background picture is an important material type in the E-commerce field, and important values are brought to the display, the propagation and the secondary creation of products. The DAM (Digital Asset Management system) plays an important role in the Management of materials as the infrastructure of Digital content, especially in the fields of e-commerce and fast-moving away, marks the materials uploaded by users by one key, and distinguishes white background pictures, transparent background pictures and non-white background pictures, thereby being greatly convenient for the subsequent use of the users.
Most of the simple methods for identifying the white background image are to judge the proportion of white pixels around the frame of the image or judge the proportion of white pixels in the whole image, but the granularity is too coarse, and a user still needs to secondarily screen a large number of images; the method of training through the machine learning model has limited generalization and more error classification conditions.
Aiming at the technical problems of rough granularity and inaccurate classification of the identification and classification of the white background map in the related art, no effective solution is provided at present.
Disclosure of Invention
Accordingly, embodiments of the present application are directed to providing an image processing method, an image processing system, an electronic device, and a storage medium, which are used to solve at least one problem in the prior art.
To achieve the above object, in a first aspect, the present application provides an image processing method, including:
judging whether the color space value of the picture to be identified has an alpha channel or not;
when an alpha channel is provided, identifying whether the transparent area proportion of the picture to be identified is greater than a first preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a transparent base map, if so, marking a transparent base map label, and if not, marking a non-white base map label;
if the transparent area ratio of the picture to be identified is not larger than a first preset value or when the color space value does not have an alpha channel, identifying whether the white pixel ratio of the picture to be identified is larger than a second preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a white background picture, if so, marking a white background picture label, and if not, marking the white background picture label to be identified.
In one embodiment, before determining whether the color space value of the picture to be recognized carries an alpha channel, the method further includes: analyzing the picture to be recognized, converting the color mode of the picture to be recognized into an RGBA or RGB mode, judging whether the length value of the long edge of the picture to be recognized is smaller than a threshold value T1, and if so, marking a non-white background icon label.
In one embodiment, the identifying whether the transparent area ratio of the picture to be identified is greater than a first preset value includes: and judging whether the minimum value of the channel pixels of the alpha channel in the picture to be identified is smaller than a threshold value T2, if the minimum value is smaller and the ratio of the number of the minimum value pixels to the channel pixels of the alpha channel is larger than a threshold value T3, the ratio of the transparent area of the picture to be identified is larger than a first preset value, and if not, the ratio of the transparent area of the picture to be identified is not larger than the first preset value.
In one embodiment, the determining whether the picture features of the picture to be recognized satisfy the definition of the transparent base map includes: converting a picture to be identified into a gray-scale image, calculating a pixel histogram of a transparent area, and if a pixel value with a ratio greater than a threshold value T4 exists, and the ratio of a single pixel value is greater than a threshold value T5 or the sum of the ratios of a plurality of pixel values is greater than a threshold value T6, judging that the definition of a transparent base map is met; otherwise, the condition is judged to be not satisfied.
In one embodiment, the identifying whether the white pixel ratio of the picture to be identified is greater than a second preset value includes: converting the picture to be identified into a gray-scale image, calculating a pixel histogram, if the pixel values in the range of the preset proportion D1 of the edge distance to the center of the picture are all larger than a threshold value T7, the number ratio of the pixel values larger than the threshold value T8 in the range is larger than a threshold value T9, the number ratio of the pixel values of the whole picture larger than the threshold value T10 is larger than a threshold value T11, the white pixel ratio of the picture to be identified is larger than a second preset value, and otherwise, the white pixel ratio is not larger than the second preset value.
In one embodiment, the determining whether the picture features of the picture to be recognized satisfy the definition of a white background picture includes: if there is a pixel value whose duty ratio is greater than the threshold value T12 and the sum of the duty ratios of the plurality of pixel values is greater than the threshold value T13, determining that it is not satisfied; otherwise, performing maximum pooling sampling on the picture to be identified based on a preset pooling operation area value V1 and a preset pixel distance V2 between two pooling operations, if the type of the pooled pixel value is less than a threshold T30, determining that the picture is not satisfied, and if the type of the pooled pixel value is not less than the threshold T30, determining that the picture is satisfied.
In one embodiment, further comprising: if the white pixel ratio of the picture to be identified is not greater than the second preset value, judging whether the pixel point ratio of the picture edge to the center preset ratio D2 frame pixel value is equal to the threshold value T40 or not, and if so, executing the first step; if not, judging whether the pixel point proportion frame value of the preset proportion D3 frame pixel value from the edge of the picture to the center is larger than a threshold value T41 is larger than a threshold value T15, if so, executing a first step; the first step comprises: performing maximum pooling sampling on the picture to be identified based on a preset pooling operation area value V3 and a preset pixel distance V4 between two pooling operations, and marking a to-be-fixed white background image label on the picture to be identified if the type of the pooled pixel value is less than a threshold value V5; otherwise, calculating a pixel histogram of the pooled picture, if a pixel value with a ratio larger than T23 exists and the sum of the ratios of a plurality of pixel values is larger than T24, marking a to-be-identified white background picture label on the to-be-identified picture, otherwise, calculating the outline of an object body in the picture and obtaining an external moment, filtering to remove the object body with the area of the external moment of the object body between a threshold value T25 and a threshold value T26 in the picture, if the number of the remaining object bodies in the picture is larger than a threshold value V6, marking a non-white background picture label on the to-be-identified picture, otherwise, calculating the difference value between the length and the width of the external moment of the remaining object bodies in the picture and the length and the width corresponding to the picture, when the difference value is smaller than a threshold value T27, marking the to-be-identified picture label on the to-be-identified picture, otherwise, marking the white background picture label on the to-identified picture.
In one embodiment, further comprising: if the pixel point proportion frame value of the preset proportion D3 frame pixel value to the center of the picture edge is larger than T41 is not larger than the threshold value T15, the following steps are executed: respectively calculating pixel mean values in corner regions with preset proportion D4 from the centers of four corners of the picture, calculating the difference value of the pixel mean values between every two adjacent corner regions in a descending order according to the size of the pixel mean values, selecting three corner regions with smaller difference values, and executing a second step if the maximum difference value of the pixel mean values of the three corner regions with smaller difference values is greater than a threshold value T42 or the maximum difference value of the pixel values of the three corner regions with smaller difference values is greater than a threshold value T16; otherwise, calculating the pixel mean value in the edge area with the preset distance D5 from the edge to the center of the picture, selecting two edge areas and three corner areas with the minimum pixel mean value of the edge areas and the minimum pixel mean value of the corner areas, if the pixel mean value difference value of the two edge areas is larger than a threshold value T17, or the maximum mean value difference value of the three corner areas and the two edge areas is larger than a threshold value T18, or the maximum pixel value difference value of the two edge areas is larger than a threshold value T19, executing the second step, otherwise, executing the third step. Wherein the second step comprises: respectively calculating a pixel mean value and a pixel difference value of a preset distance D6 corner area from four corners to the center of the picture, and if the maximum value of the pixel mean value is greater than a threshold value T20 or the maximum value of the pixel difference value is greater than a threshold value T21, marking a non-white background icon label on the picture to be identified; otherwise, the third step is executed. The third step includes: if the pixel point ratio of the pixel values of the two selected edge areas and the three selected corner areas which are larger than the threshold value T43 pixel is larger than the threshold value T22, executing the first step, otherwise, marking the picture to be identified with a non-white background icon label.
In a second aspect, the present application further provides an image processing system, comprising:
the identification unit is used for judging whether the color space value of the picture to be identified has an alpha channel or not;
the transparent icon marking unit is used for identifying whether the transparent area ratio of the picture to be identified is greater than a first preset value or not when the picture to be identified is provided with an alpha channel, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a transparent base map or not, if so, marking a transparent base map label, and otherwise, marking a non-white base map label;
and the white background icon marking unit is used for identifying whether the white pixel proportion of the picture to be identified is greater than a second preset value or not if the transparent area proportion of the picture to be identified is not greater than the first preset value or if the color space value does not have an alpha channel, judging whether the picture characteristics of the picture to be identified meet the definition of the white background map or not if the white pixel proportion of the picture to be identified is greater than the second preset value, marking a label of the white background map if the picture characteristics of the picture to be identified meet the definition of the white background map, and marking a label of the white background map to be fixed if the picture characteristics of the picture to be identified do not meet the definition of the white background map.
In a third aspect, the present application further provides an electronic device comprising a memory and a processor, the memory having stored therein a computer program, which, when executed by the processor, causes the processor to perform the steps of the image processing method.
According to the image processing method, the image processing system and the electronic equipment, whether the color space value of the picture to be recognized has an alpha channel or not is judged; when an alpha channel is provided, identifying whether the transparent area proportion of the picture to be identified is greater than a first preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a transparent base map, if so, marking a transparent base map label, and if not, marking a non-white base map label; if the transparent area ratio of the picture to be identified is not larger than a first preset value or when the color space value does not have an alpha channel, identifying whether the white pixel ratio of the picture to be identified is larger than a second preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a white background picture, if so, marking a white background picture label, and if not, marking the white background picture label to be identified. The technical problems of rough identification and classification granularity and inaccurate classification of the white background map in the related technology are solved, and the following beneficial effects are realized: the functional definition of the white background image and the transparent background image is realized, the white background image and the transparent background image which are wanted by a user are recalled to the greatest extent, and the efficiency and the accuracy of the image classification marking are improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, serve to provide a further understanding of the application and to enable other features, objects, and advantages of the application to be more apparent. The drawings and their description illustrate the embodiments of the invention and do not limit it. In the drawings:
fig. 1 is a flow chart of an implementation of an image processing method according to an embodiment of the present application;
fig. 2 is a main processing flow chart of an image processing method provided in an embodiment of the present application;
FIG. 3-1 is a transparent diagram main processing flow diagram of an image processing method provided by an embodiment of the present application;
3-2 is a main processing flow chart of a white background image of the image processing method provided by the embodiment of the application;
FIG. 4-1 is a non-white background defined by a white background for an image processing method according to an embodiment of the present application;
fig. 4-2 is an example of a white background diagram defined by a white background diagram of an image processing method provided in an embodiment of the present application;
FIG. 5-1 is an example of an original RGB image of an object subject in a picture according to an embodiment of the present disclosure;
fig. 5-2 is a binary image obtained by thresholding a gray-scale image of an object main body in a picture according to the image processing method provided in the embodiment of the present application;
5-3 are examples of visualization of a minimum bounding rectangle of a solution contour of an object subject in a picture by an image processing method provided in an embodiment of the present application;
FIG. 6-1 is an exemplary diagram of maximum pooled sampling for an image processing method provided by an embodiment of the present application;
fig. 6-2 is an exemplary diagram of an edge region and a corner region of a picture of an image processing method provided by an embodiment of the present application;
FIG. 7 is a schematic diagram of main blocks of an image processing system according to an embodiment of the present application;
FIG. 8 is a diagram of an exemplary system architecture that may be used with embodiments of the present application;
fig. 9 is a schematic structural diagram of a computer system suitable for implementing the terminal device or the server according to the embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, 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, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be used. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In this application, the terms "upper", "lower", "left", "right", "front", "rear", "top", "bottom", "inner", "outer", "middle", "vertical", "horizontal", "lateral", "longitudinal", and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings. These terms are used primarily to better describe the present application and its embodiments, and are not used to limit the indicated devices, elements or components to a particular orientation or to be constructed and operated in a particular orientation.
Moreover, some of the above terms may be used to indicate other meanings besides the orientation or positional relationship, for example, the term "on" may also be used to indicate some kind of attachment or connection relationship in some cases. The specific meaning of these terms in this application will be understood by those of ordinary skill in the art as appropriate.
In addition, the term "plurality" shall mean two as well as more than two.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
It should be noted that there are many color mode expressions such as RGB, GRAY, lab, etc. in the computer, and the range and form of the color mode supported by reading the picture by different picture parsing libraries such as pillow, opencv, etc. involved in python language are also different.
It should be noted that the representation form of reading the color picture file into the computer is usually a three-dimensional matrix, and the shape thereof is: w H3. Where W represents the width of the image, H represents the height of the image, and 3 represents the three color channels R, G, B of the image. For transparent pictures, a transparent channel is added in the computer, generally denoted by A, wherein A is an alpha channel, and the picture matrix shape is W x H x 4; each point of the four channels RGBA in the image matrix has a value range of [0,255], and for the a channel, the position of 255 indicates opaque (i.e. RGB corresponding pixels are not displayed), and the position of 0 indicates transparent (RGB corresponding pixels are displayed). The logarithmic relationship between white and black pixels is divided into several levels, called gray scale. The gray scale is divided into 256 steps, and an image represented by gray scale is called a gray scale map. The conversion between RGB and gray scale maps has many forms, and a simple form can refer to: gray = R0.3 + G0.59 + B0.11.
In the case of a DAM (Digital Asset Management) white background, a picture with a white background can be regarded as a white background in a broad sense. For example, a picture written on white A4 paper may be considered as a white background picture in style, but for the user of DAM, it is highly probable that the picture is not intended to be displayed in front of the picture or is not considered as a white background picture when searching for the white background picture. Therefore, for the DAM system in the embodiment of the present application, on the basis of a picture with a white background, a white background picture is redefined as: the picture with main material content (namely the object main body image features in the picture are patterns of commodities, images, LOGO and the like), the picture screened by the definition is a white background picture material picture with the functions of displaying, secondary processing, putting and the like, and the picture is marked for the purpose of subsequent secondary processing and transmission mainly based on the white background picture of the commodities or marketing elements. For example, a white background picture of a pair of shoes of adidas, where the background is white at first, and the object body feature on the picture is a shoe (which is a commodity), and the background can be used as an element for drawing a poster; for example, as shown in fig. 4-1, although the background is white, the object in the picture is a text, not a pattern of a commodity, an image, a LOGO, and the like, and has no effects of exhibition, secondary processing, putting, and the like, and thus is a non-white background picture in the definition of the present application; as shown in fig. 4-2, the background is white, and the object in the picture is a garment, which is a commodity, and has the functions of displaying, secondary processing, putting, etc., thus being the white background picture defined in the present application.
It should be noted that, for some pictures that meet the above definition of the white background map but have a white background ratio smaller than a threshold (a specific threshold is related to an actual scene and is a customizable threshold, in the embodiment of the present application, a range of white pixels is defined first, for example, white pixels larger than 240 are considered as white pixels, and a threshold is set as 0.6).
Meanwhile, for the DAM transparent base map, on the premise that the background is transparent, the definition of the transparent base map is a transparent base map material picture having main material contents (patterns of goods, images, LOGO, and the like) and having functions of displaying, secondary processing, putting, and the like in this embodiment, and specific descriptions thereof are the same as the definition of the white base map, and are not repeated here.
The white background and the transparent background mentioned below are, if not specifically stated, both white background and transparent background within the scope defined in the present invention.
Fig. 2 is a main processing flow diagram of an image processing method according to an embodiment of the present application, which redefines a white background map and a transparent background map of DAM user material in terms of usage functions, and proposes an overall framework, where the overall framework relates to picture filtering and mode conversion, transparent background map determination, white background map strong rules, if rule hierarchy combination, and secondary filtering of the white background map, and is used to distinguish the white background map, the transparent background map, and the non-white background map in the DAM material.
Based on the proposed framework, the method for nested recall of the transparent base map and the method for nested recall of the white base map are designed, and meanwhile, the filtering method is designed for part of suspected white base maps such as character maps, UI (user interface) maps and the like. The verification environment of the application is python programming language, and the related libraries referred to in the following are all related dependent libraries based on python. The method provided by the application is decoupled from a specific programming language, can be migrated at will, and related dependency libraries can be replaced.
As shown in fig. 2, in the image processing method of the present application, recognition of a transparent background image and a white background image is solved. On the whole, after the user inputs the picture, the small picture is filtered out through the front-end filtering module to improve the system efficiency, and meanwhile, the color mode of the picture is converted into an RGBA mode so as to facilitate subsequent processing.
After the color mode conversion is finished, firstly, judging whether the color mode belongs to the transparent base map according to the logic of the transparent base map, wherein the specific logic for judging the transparent base map is as follows: firstly, carrying out preliminary judgment on a transparent base map according to whether the picture is provided with a channel A or not, and if so, carrying out judgment on definition of the transparent base map to see whether the picture is the transparent base map or not; if the picture meets the definition of the transparent base map, judging the picture to be the transparent base map, outputting a transparent base map label, and printing the transparent base map label on the picture input by the user; if the definition of the transparent base map is not met or the preliminary judgment of the transparent base map is not passed, the strong rule of the white base map is preliminarily judged whether the picture is the white base map or not, namely, the picture which is a white background and has enough white background ratio is screened out according to whether the white pixel ratio of the picture is larger than a threshold value or not. If the image is the white background image, performing secondary verification on the white background image, namely judging whether the image characteristics of the object main body in the image accord with the definition of the white background image or not according to the characteristics of the redefined white background image in the embodiment; and after the verification and filtering are passed, outputting a white background label, printing a white background label on the picture input by the user, if the verification is not passed, outputting a to-be-determined white background label, and printing a to-be-determined white background label on the picture input by the user. If the image is not the white background image, carrying out weak rule judgment on the white background image, namely screening out the image which is larger in the ratio of the object main body image features in part of images to the whole image and whether the ratio of all the white margins of the four sides of the image meets the condition of the white background image or not by judging whether the ratio of the frame white pixels to the whole image of the image is enough or not; performing secondary verification on the white background image after the judgment of the weak rule of the white background image, if the verification fails, outputting a non-white background label, and printing a non-white background icon label on the image input by the user; and outputting a white background label if the verification is passed, and printing the white background label on the picture input by the user.
Therefore, picture filtering and mode conversion, transparent base map judgment, strong rule and weak rule hierarchical combination of the white base map and secondary filtering of the white base map are integrally realized, and the method is used for distinguishing the white base map, the transparent base map and the non-white base map in the DAM material.
As shown in fig. 1, an implementation flow of an image processing method according to a complete embodiment provided in the present application is shown, and for convenience of description, only the portions related to the embodiment are shown, which are detailed as follows:
according to the image processing method provided by the embodiment of the application, the method comprises the following steps:
s101: judging whether the color space value of the picture to be identified has an alpha channel or not;
s102: when an alpha channel is provided, identifying whether the transparent area proportion of the picture to be identified is greater than a first preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a transparent base map, if so, marking a transparent base map label, and if not, marking a non-white base map label;
s103: if the transparent area ratio of the picture to be identified is not larger than a first preset value or when the color space value does not have an alpha channel, identifying whether the white pixel ratio of the picture to be identified is larger than a second preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a white background picture, if so, marking a white background picture label, and if not, marking the white background picture label to be identified.
In step S101: and judging whether the color space value of the picture to be identified has an alpha channel. After a user uploads a picture, the picture to be recognized is obtained, and whether the color space value (RGBA) of the picture to be recognized has an alpha channel (A channel) or not is judged.
In one embodiment, before determining whether the color space value of the picture to be recognized carries an alpha channel, the method further includes: and analyzing the picture to be recognized, and converting the color mode of the picture to be recognized into an RGBA or RGB mode. In this embodiment, the color mode of the image is uniformly converted into the RGBA or RGB mode when the image is read, which is convenient for subsequent processing.
In one embodiment, when the transparent base map and the white base map of the picture to be recognized are determined, pre-filtering is performed on the picture to be recognized, whether the length value of the long edge of the picture to be recognized is smaller than a threshold value T1 is determined, and if the length value of the long edge of the picture to be recognized is smaller than the threshold value T1, a non-white base icon label is directly marked. Namely, if the length of the long edge of the picture is less than the threshold value T1, the picture is directly judged to be a non-white background picture, and the system efficiency is increased. Here, T1 is a default value of 30, and the rule is based on empirical summary of actual usage by the user, i.e., there is substantially no white background.
In step S102: and carrying out transparent base map definition identification on the picture to be identified. When the color space value of the picture to be recognized is provided with an alpha channel, whether the value of the transparent area of the picture to be recognized in the whole picture is larger than a first preset value or not is recognized, if so, whether the picture characteristic of the picture to be recognized meets the definition of a transparent base map or not is judged, if so, a transparent base map label is marked, and if not, a non-white base map label is marked. Namely, when the RGBA of the picture to be recognized has an a channel, the picture to be recognized may be a transparent base map, and it is determined whether the picture to be recognized is the transparent base map or the non-transparent base map by recognizing the transparent area ratio of the picture to be recognized, if the ratio satisfies the condition of the transparent base map, it is further determined whether the picture to be recognized is the defined transparent base map by the function definition of the transparent base map (i.e. the definition of the transparent base map), if so, it is determined that the picture to be recognized is the transparent base map, the picture to be recognized is marked with a transparent base map label, and if not, it is determined that the picture to be recognized is the non-white base map, and the picture to be recognized is marked with a non-white base map label. And if the proportion does not meet the condition of the transparent base map, the picture is possibly a white base map, and then white base map identification logic is carried out subsequently. Meanwhile, when the picture does not have the channel A, white background picture identification logic is carried out subsequently. It should be noted that the picture features of the picture to be recognized are object features on the picture, such as commodity patterns, character patterns, LOGO patterns, character patterns, and the like on the picture. The first preset value may be set based on an actual scene and a requirement, for example, the first preset value may be set as an upper limit value of an a channel in an alpha channel and a minimum value of a ratio of a minimum or maximum pixel value of a picture to pixels of the alpha channel, and the like, for example, the upper limit value is set to 230, and the minimum value of the ratio is set to 0.008, so as to filter the picture without a transparency effect of the transparent base map.
In one embodiment, the identifying whether the transparent area ratio of the picture to be identified is greater than a first preset value includes: and judging whether the minimum value of the channel pixel of the alpha channel in the picture to be identified is smaller than a threshold value T2, if the minimum value is smaller and the ratio of the pixel number of the minimum value pixel value to the channel pixel number of the alpha channel is larger than a threshold value T3, the ratio of the transparent area of the picture to be identified is larger than a first preset value, and if not, the ratio is not larger than the first preset value. Therefore, although the picture with the channel A (namely the picture possibly being the picture of the transparent base map), the picture with the transparent area with the undersize proportion and not meeting the requirement of the transparent map can be filtered, and the method can be used for rapid filtering, thereby ensuring high accuracy and high recall. Here, the threshold values T2 and T3 are the first preset values, and may be set according to actual requirements and scenes, and in this embodiment, the default value of T2 is 230, and the default value of T3 is 0.008, which is used for filtering a picture without a transparency effect of the transparent base map.
In one embodiment, the determining whether the picture features of the picture to be recognized satisfy the definition of the transparent base map includes: converting the picture to be identified into a gray map, calculating a pixel histogram of the transparent area, and if the pixel value with the ratio of the total pixel number of the transparent area to the threshold value T4 exists, and the value with the ratio of a single pixel value to the total pixel number of the transparent area to the threshold value T5 or the sum of the values of the total pixel number of the transparent areas with a plurality of pixel values is greater than the threshold value T6, judging that the definition of the transparent base map is met; otherwise, judging that the condition is not satisfied. Therefore, efficient and accurate identification of the transparent base map is achieved, and marking of the transparent base map and the non-transparent base map is conducted on the picture to be identified. Here, the thresholds T4, T5, and T6 may be set according to actual requirements and scenes, and in this embodiment, the default value of T4 is 0.1, the default value of T5 is 0.95, and the default value of T6 is 0.8, which are used to filter some text white base maps, UI design maps, logo maps, and the like.
Specifically, fig. 3-1 is a main processing flow chart of a transparency chart of the image processing method according to the embodiment of the present application. Step a, channel judgment: b, if the picture is 4 channels, namely an RGBA mode, entering the step b, otherwise, entering a white background picture filtering part; step b, proportion judgment: c, entering a step c if the minimum value of the A channel pixel values is smaller than a threshold value T2 and the value of the number of the minimum value pixel values in the A channel pixel number is larger than a threshold value T3; otherwise, the flow enters the white background filtering part. Here, T2 defaults to 230, T3 defaults to 0.008; the item is used for filtering pictures with transparent base pictures without transparent effect. Step c, functional judgment: converting the picture to be identified into a gray map, calculating a pixel histogram of the transparent part, if a pixel value with the ratio of the total pixel number of the transparent area to the threshold value T4 exists, and the value of the ratio of a single pixel value to the total pixel number of the transparent part is greater than the threshold value T5 or the sum of the values of the pixel values to the total pixel number of the transparent part is greater than the threshold value T6, determining that the picture is a transparent base map, and ending the flow; otherwise, judging the image as a non-white background image, and ending the process. Here, T4 defaults to 0.1, T5 defaults to 0.95, T6 defaults to 0.8; the item is used for filtering some character white base drawings, UI design drawings, logo drawings and the like. After the pictures are judged to be the white background pictures, the transparent background pictures and the non-white background pictures, the white background picture labels, the transparent background picture labels and the non-white background picture labels are marked on the pictures to be recognized.
It should be noted that, the histogram is a common method in computer image processing, the range of image pixel values is [0,255], and the pixel histogram can be obtained by calculating the ratio of the number of each pixel value to the number of all pixels in the image. If the image size M × N is a total of b pixels with a pixel value a, then the histogram value for the coordinate a is b/(M × N).
In step S103: and (3) carrying out strong-rule identification and secondary filtering on the white background image on the picture to be identified, namely identifying whether the white background of the picture to be identified meets the preset threshold condition, and identifying whether the identified white background image meets the definition of the white background image.
If the transparent area ratio of the picture to be identified is not more than a first preset value or when the color space value does not have an alpha channel, namely when the picture to be identified cannot be a transparent base map and is possibly a white base map, identifying whether the value of the number of white pixels of the picture to be identified to the total number of pixels of the whole map is more than a second preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of the white base map, if so, marking a label of the white base map, and if not, marking the label of the white base map to be identified. Namely, white background image judgment is carried out on the picture to be identified, and a strong rule of a white background image judgment rule is realized, wherein the strong rule is determined by a frame white ratio, namely a total color ratio; and simultaneously, secondary filtering of the white background image based on the definition of the white background image is realized. Here, the second preset value may be set based on actual scenes and demands. The second preset may be one parameter or a plurality of parameters, for example, the white pixel ratio of the frame region or the threshold (second preset value) of the white pixel ratio of the whole image may be directly set to 0.4, so as to filter the image with the white background ratio being too small.
In one embodiment, the identifying whether the white pixel ratio of the picture to be identified is greater than a second preset value includes: converting the picture to be identified into a gray-scale image, calculating a pixel histogram, if the pixel values in the range of the preset proportion D1 of the edge distance to the center of the picture are all larger than a threshold value T7, the number ratio of the pixel values larger than the threshold value T8 in the range is larger than a threshold value T9, the number ratio of the pixel values of the whole picture larger than the threshold value T10 is larger than a threshold value T11, the white pixel ratio of the picture to be identified is larger than a second preset value, and otherwise, the white pixel ratio is not larger than the second preset value. Therefore, the strong rule of the white background image judgment rule is realized, and the strong rule is determined by the white proportion of the frame, namely the total color proportion. Here, T7, T8, T9, T10, and T11 are second preset values, and the values of D1, T7, T8, T9, T10, and T11 may be set based on actual scenes and requirements, so as to filter out pictures with significantly smaller borders by the white proportion of the borders, i.e., the overall color proportion. In this embodiment, D1 defaults to 10%, T7 defaults to 200, T8 defaults to 240, T9 defaults to 0.3, T10 defaults to 240, and T11 defaults to 0.6.
It should be noted that, in the shape (for example, the area in which the internal small mouth 'is removed from the' word back 'large mouth') surrounded by the range in which the number of pixel values greater than the threshold T8 is greater than the range is proportional to the ratio of the four sides of the image to the center D1 of the image, the number of pixels having pixel values greater than T8 is greater than the total number of pixels in the area. A whole image pixel, that is, the number of pixels of the whole image, if the image height is h and the width is w, the number of pixels N = h × w; and M is the number of pixels larger than the threshold T10 in the N pixels, so that the occupation ratio is M/N.
In one embodiment, the determining whether the picture features of the picture to be recognized satisfy the definition of a white background picture includes: calculating a pixel histogram, obtaining the proportion of the number of each pixel value in the [0,255] range to the total number from the histogram, and if the value of the number of the pixel values to the total number of the picture is greater than the threshold T12 and the sum of the values of the pixel values to the total number of the picture is greater than the threshold T13, determining that the sum of the values is not satisfied; otherwise, performing maximum pooling sampling on the picture to be identified based on a preset pooling operation area value V1 and a preset pixel distance V2 between two pooling operations, if the type of the pooled pixel value is less than a threshold T30, determining that the picture is not satisfied, and if the type of the pooled pixel value is not less than the threshold T30, determining that the picture is satisfied. Therefore, the obtained white background image is secondarily filtered based on the definition of the white background image, namely, the white background image is used as a commodity white background image, the distribution of image pixels of the white background image is relatively scattered, the proportion of concentrated colors cannot exist, and otherwise, the white background image is a character foreground white background image or a UI pure color foreground white background image with high probability. Here, the values of T12, T13, V1, V2, T30 may be set based on actual scenes and requirements. In this embodiment, the default value of T12 is 0.1, the default value of T13 is 0.8, the pooling operation area value kernel = V1, and the preset pixel distance stride = V2 between two pooling operations, the default value of V1 is 10, the default value of V2 is 10, and the default value of T30 is 30.
In one embodiment, the weak rule judgment of the white background image is carried out on the picture which does not accord with the white background image condition after the strong rule judgment of the white background image, and then the picture which considers whether the proportion of all the white margins of the four sides of the image accords with the condition of the white background image when the feature of the object main body image in part of the pictures is larger than the whole picture is screened out; and (5) carrying out secondary filtering on the white background image according with the judgment of the weak rule. Specifically, the method comprises the following steps: if the white pixel ratio of the picture to be identified is not greater than the second preset value, judging whether the pixel point ratio of the picture edge to the center preset ratio D2 frame pixel value is equal to the threshold value T40 or not, and if so, executing the first step; if not, judging whether the pixel point proportion frame value of the preset proportion D3 frame pixel value from the center of the image edge is larger than the threshold value T41 is larger than the threshold value T15, if so, executing the first step. The first step comprises: performing maximum pooling sampling on the picture to be identified based on a preset pooling operation area value V3 and a preset pixel distance V4 between two pooling operations, and marking a to-be-fixed white background image label on the picture to be identified if the type of the pooled pixel value is less than a threshold value V5; otherwise, calculating a pixel histogram of the pooled picture, if a pixel value with a ratio larger than T23 exists and the sum of the ratios of a plurality of pixel values is larger than T24, marking a to-be-identified white background picture label on the to-be-identified picture, otherwise, calculating the outline of an object body in the picture and obtaining an external moment, filtering to remove the object body with the area of the external moment of the object body between a threshold value T25 and a threshold value T26 in the picture, if the number of the remaining object bodies in the picture is larger than a threshold value V6, marking a non-white background picture label on the to-be-identified picture, otherwise, calculating the difference value between the length and the width of the external moment of the remaining object bodies in the picture and the length and the width corresponding to the picture, when the difference value is smaller than a threshold value T27, marking the to-be-identified picture label on the to-be-identified picture, otherwise, marking the white background picture label on the to-identified picture. Therefore, the weak rule of white background image judgment is realized, namely the proportion of partial image main bodies to the whole image is larger, whether the proportion of all the margins of the four sides of the image meets the condition of the white background image or not is considered independently at the moment, subsequent filtering is carried out, meanwhile, the two weak white background image rules are filtered, the robustness of the weak rule is improved, the image is still considered as a character foreground white background image and a UI type pure color foreground image, the judgment of the number of the object main bodies is improved, and if the number of the main bodies exceeds 2, the image has the maximum probability of being a display image and a propaganda image of the image and is not a functional white background image. Here, the values of D2, T40, T14, D3, T41, T15, V3, V4, V5, T23, T24, T25, T26, V6, T27, T41 may be set based on actual scenarios and requirements. In this embodiment, the default values of T40, T41, D2, V4, V5, T23, T24, T25, T26, V6, and T27 are 255, 250, 10, 0.2, 5, 0.8, 10, 30, 0.1, 0.8, 0.01, 0.99, 2, and 5, respectively.
In one embodiment, after the weak rule determination of the white background image is performed, the determination criterion is further lowered to perform recognition on the picture again, so as to recognize that a part of the white background image may have a picture in which the commodity main body is not in the middle of the picture and occupies the edge or corner of the image. Specifically, the method comprises the following steps: if the pixel point proportion frame value of the preset proportion D3 frame pixel value to the center of the picture is not more than the threshold value T15, executing the following steps: respectively calculating pixel mean values in angular regions with a preset proportion D4 of the distance between four corners of the picture and the center, calculating the difference value of the pixel mean values between every two adjacent angular regions in a descending order according to the size of the pixel mean values, selecting three angular regions with smaller difference values, and executing a second step if the maximum difference value of the pixel mean values of the three angular regions with smaller difference values is greater than a threshold value T42 or the maximum difference value of the pixel values of the three angular regions with smaller difference values is greater than a threshold value T16; otherwise, calculating the pixel mean value in the edge area with the preset distance D5 from the edge to the center of the picture, selecting two edge areas and three corner areas with the minimum pixel mean value of the edge areas and the minimum pixel mean value of the corner areas, if the pixel mean value difference value of the two edge areas is larger than a threshold value T17, or the maximum mean value difference value of the three corner areas and the two edge areas is larger than a threshold value T18, or the maximum pixel value difference value of the two edge areas is larger than a threshold value T19, executing the second step, otherwise, executing the third step. Wherein the second step comprises: respectively calculating a pixel mean value and a pixel difference value of a preset distance D6 corner area from four corners to the center of the picture, and if the maximum value of the pixel mean value is greater than a threshold value T20 or the maximum value of the pixel difference value is greater than a threshold value T21, marking a non-white background icon label on the picture to be identified; otherwise, the third step is executed. The third step includes: if the pixel point ratio of the selected two edge areas and three corner areas is greater than the threshold value T22, executing the first step, and otherwise, marking the picture to be identified with a non-white background icon label. Therefore, on the basis of the weak rule of the white background image, the standard is reduced again, and the fact that part of the white background image possibly has the condition that a commodity main body is not in the middle of the picture and occupies the edge or corner of the image is considered, so that the three corners and two side areas of the image are judged to meet the necessary conditions through the design rule; further considering that the main part of a part of white background pictures is too large and occupies the whole image, considering whether the small area ranges of the four corners of the image meet the white background picture condition, the highest level of the system logic can only classify the picture as the white background picture to be determined for the user to filter. Here, the values of D3, T41, T15, D4, T42, T16, D5, T17, T18, T19, D6, T20, T21, T43, T22 may be set based on actual scenes and needs. In this embodiment, the default value of T42 is 3, the default value of T43 is 235, the default value of D3 is 5%, the default value of T15 is 0.8, the default value of D4 is 3%, the default value of T16 is 10, the default value of D5 is 5, the default value of T17 is 3, the default value of T18 is 3, the default value of T19 is 10, the default value of D6 is 10, the default value of T20 is 3, the default value of T21 is 10, and the default value of T22 is 0.8.
Specifically, fig. 3-2 is a main processing flow diagram of a white background image of the image processing method according to the embodiment of the present application, that is, a white background image identification mark defined for a white background image function is implemented. The specific logic detailed in connection with fig. 3-2 is as follows:
step a, white pixel proportion filtering: converting the picture to be identified into a gray-scale image, and entering the step b if the pixels in the proportional range of the image edge distance D1 are all larger than a threshold value T7, the pixel proportion of the range larger than a threshold value T8 is larger than a threshold value T9, and the proportion of the pixels of the whole image larger than a threshold value T10 is larger than a threshold value T11; otherwise, go to step d. Here, D1 defaults to 10%, T7 defaults to 200, T8 defaults to 240, T9 defaults to 0.3, T10 defaults to 240, and T11 defaults to 0.6.
B, histogram pixel value ratio filtering: calculating a pixel histogram, if a pixel value with the occupation ratio larger than a threshold value T12 exists and the sum of the occupation ratios of a plurality of pixels is larger than a threshold value T13, classifying the picture as a background picture to be fixed, and ending the process; otherwise, entering the step c. Here, T12 is 0.1 by default, and T13 is 0.8 by default.
Step c, filtering the pooled pixel value ratio: setting kernel = V1 and stride = V2, performing maximum pooling sampling, if the type of the pixel values after pooling is less than a threshold T30, classifying the pixel values as a background image to be fixed, and ending the flow; otherwise, the process is classified as a white background picture, and the process is ended. Here V1 defaults to 10, V2 defaults to 10, and T30 defaults to 30.
And D, if the proportion of the D2 frame pixels is equal to 255 and the whole image is larger than a threshold value T14, entering the step j, and otherwise, entering the step e. Here, D2 is 10% by default and T14 is 0.2 by default.
And e, if the D3 frame pixel is larger than the 250-to-frame ratio and the frame is larger than the threshold T15, entering the step j, otherwise, entering the step f. Here, D3 is 5% by default and T15 is 0.8 by default.
And f, calculating the mean value of four corners D4 of the image, sorting and selecting three corners with smaller difference values according to the sequence, entering the step h if the maximum difference value of the triangular mean value is greater than a threshold value 3 or the maximum difference value of pixel values in corner regions is greater than a threshold value T16, and otherwise entering the step g. Here, D4 is 3% by default and T16 is 10% by default)
Step g, calculating the pixel mean value of the 4-side range area according to the side D5, selecting two sides with the minimum side mean value and the minimum triangular mean value, entering the step h if the difference value of the two side mean values is greater than a threshold value T17, or the difference value of the triangular mean value and the two side mean values is greater than a threshold value T18, or the maximum difference value of the two side area pixel values is greater than a threshold value T19, or entering the step i. Here, D5 is 5 by default, T17 is 3 by default, T18 is 3 by default, and T19 is 10 by default.
H, if the pixel mean difference of the four corners D6 area is greater than a threshold value T20, and the maximum value of the pixel difference is greater than a threshold value T21, outputting a non-white background image, and ending the process; otherwise, entering step i. Here, D6 is 10 by default, T20 is 3 by default, and T21 is 10 by default.
And i, if the pixel proportion of the selected area is greater than 235 and greater than a threshold value T22, entering a step j, otherwise, ending the process. Here, T22 defaults to 0.8.
Step j, setting kernel = V3 and stride = V4, performing maximum pooling sampling, and if the type of the pixel values after pooling is less than V5, classifying the pixel values as a background image to be white, and ending the process; otherwise step k is entered. Here, V3 is 10 by default, V4 is 10 by default, and V5 is 30 by default.
Step k, aiming at the image after pooling, calculating a pixel histogram for judgment, if a pixel value with a ratio larger than T23 exists and the sum of the pixel ratios is larger than T24, classifying the image as a white background image to be fixed, and ending the process; otherwise, go to step l. Here, T23 is 0.1 by default, and T24 is 0.8 by default.
And step l, calculating the outline of the image main body and obtaining external moment, and if the area of the main body is between T25 and T26, saving the coordinate range and the area set of the main body. Filtering the stored main bodies, removing the completely contained main bodies, if the number of the remaining main bodies is more than V6, classifying the main bodies as a non-white background chart, and ending the process; otherwise, go to step m. Here, T25 is 0.01 by default, T26 is 0.99 by default, and V6 is 2 by default.
If the difference value between the length or width of the main body and the length or width of the image is less than T27, the main body is classified as a non-white background image, and the process is ended; otherwise, the process is classified as a white background picture and the process is ended. Here, T27 defaults to 5.
In this embodiment of the present application, the steps a, b, and c may be classified as a strong rule of the white background image determination rule, where the rule a is determined by a frame white ratio, that is, an overall color ratio, and the steps b and c perform strong filtering on the obtained white background image, that is, the white background image is used as a commodity white background image, the distribution of image pixels of the commodity white background image should be relatively scattered, there is no concentrated color ratio, otherwise, the image pixels are mostly a text foreground white background image or a UI-type solid-color foreground white background image. And d and e are weak rules for judging the white background image, namely the proportion of the partial image main body to the whole image is larger, so whether the proportion of all the white margins on the four sides of the image meets the condition of the white background image is considered separately at the moment, and subsequent filtering is carried out. F, g, h and i, reducing the standard again on the basis of the rules of the steps d and e, considering that part of white background images possibly have the condition that the commodity main body is not in the middle of the image and occupies the edge or corner of the image, judging that three corners and two side areas of the image meet the necessary conditions through the design rules; further, considering that the main part of a part of white background pictures is too large and occupies the whole image, considering whether the small region ranges of the four corners of the image meet the white background picture condition, the highest level of the system logic can only classify the part of the pictures as the to-be-determined white background pictures for user screening. And j, k, l and m are used for filtering the two weak white background image rules to increase the robustness of the weak rules, the main consideration is still that the image is a character foreground white background and a UI pure color foreground, the judgment of the number of main bodies is increased, and if the judgment exceeds 2 main bodies, the image has the maximum probability of being a display image and a propaganda image of the image and not a functional white background image.
The method and the device have the advantages that the pictures passing the weak rules and the filtering verification cannot be directly classified into the white background pictures, the pictures passing the judgment for many times are classified into the white background pictures to be determined, secondary filtering is carried out by the user, the recall is guaranteed to the maximum extent on the premise of guaranteeing the classification precision of the white background pictures, and the great distinguishing time is also considered to be saved for the user.
The above flow is a general flow framework related to the present invention, and on this basis, the framework can be upgraded more for specific scenes, for example, for a fixed vertical type (only some commodity appears), algorithms such as target detection, OCR and the like can be added to filter non-target images, so as to increase the robustness of the framework.
The default parameters related in the process can be directly used, and can be properly adjusted according to a specific scene, so that the overall effect is improved.
Therefore, the image processing method provided by the embodiment of the application judges whether the color space value of the picture to be identified has an alpha channel; when an alpha channel is provided, identifying whether the transparent area proportion of the picture to be identified is greater than a first preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a transparent base map, if so, marking a transparent base map label, and if not, marking a non-white base map label; if the transparent area ratio of the picture to be identified is not larger than a first preset value or when the color space value does not have an alpha channel, identifying whether the white pixel ratio of the picture to be identified is larger than a second preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a white background picture, if so, marking a white background picture label, and if not, marking the white background picture label to be identified. The technical problems of rough identification and classification granularity and inaccurate classification of the white background map in the related technology are solved, and the following beneficial effects are realized: the functional definition of the white background image and the transparent background image is realized, the white background image and the transparent background image which are wanted by a user are recalled to the greatest extent, and the efficiency and the accuracy of the image classification marking are improved.
It should be noted that, the image contour detection is a technique in digital image processing, and a method of setting a threshold value can be used to divide gray-scale image pixels into black and white, so as to calculate the contour of a subject, for example, fig. 5-1 is an original RGB image (a picture with color), fig. 5-2 is a binary image obtained by thresholding the gray-scale image, fig. 5-3 is a visualization of a minimum bounding rectangle for solving the contour, so that we can obtain the ratio of the number and the area of objects in a white background image, and can perform related filtering.
Fig. 6-1 is an exemplary diagram of maximum pooled sampling of the image processing method provided in the embodiment of the present application (in the diagram, positions of upper left corners 1, 5, and 6 are orange, positions of upper right corners 2, 4, 7, and 8 are green, positions of lower left corners 3, 2, 1, and 2 are blue, and positions of lower right corners 1, 0, 3, and 4 are pink). Image max-pooling, which is also a technique in digital images, is a sampling technique for images, and the max-pooling can be performed while scaling the image, and the information of the main pixels of the image is maintained, as shown in fig. 6-1, which represents max-pooling of kernel =2 and stride =2, where kernel represents the length of each sampling region and stride represents the interval between the next sampling and the start position of the current sampling. For some UI images, etc., the main part is solid color, the background is white, a small amount of pixels between the main part and the background are removed in a transition mode of maximum pooling, and the remaining part of pixels can represent the whole pixel distribution of the image.
As shown in fig. 6-2, which is an exemplary diagram of an edge region and a corner region of a picture of an image processing method provided in an embodiment of the present application, a supplementary description is provided for a processing flow of a frame and a four corner region in the foregoing embodiment, where a height of an image is H and a width of the image is W, for example, a frame D1 pixel region range (D1 = 50) is selected, such as a white region in a diagram (a) in the diagram; for example, a frame D2 region range (D2 = 10%) is selected, such as a white region in the drawing (b); for example, a four-corner D3 area range (D3 = 10) is selected, such as a black area in the (c) diagram; for example, a four-corner D4 area range (D3 = 5%) is selected, such as a black area in the graph (D).
Fig. 7 shows a schematic diagram of main blocks of an image processing system provided in an embodiment of the present application, and for convenience of explanation, only the parts related to the embodiment of the present application are shown, which are detailed as follows:
an image processing system 200 comprising:
the identification unit 201 is configured to determine whether a color space value of the picture to be identified has an alpha channel;
the transparent icon marking unit 202 is used for identifying whether the transparent area ratio of the picture to be identified is greater than a first preset value or not when the picture to be identified is provided with an alpha channel, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a transparent base map or not, if so, marking a transparent base map label, and otherwise, marking a non-white base map label;
and the white background icon marking unit 203 is configured to identify whether the white pixel proportion of the picture to be identified is greater than a second preset value if the transparent area proportion of the picture to be identified is not greater than the first preset value or when the color space value does not have an alpha channel, determine whether the picture characteristics of the picture to be identified meet the definition of the white background icon if the white pixel proportion of the picture to be identified is greater than the second preset value, mark a label of the white background icon if the picture characteristics of the picture to be identified meet the definition of the white background icon, and mark a label of the white background icon to be fixed if the picture characteristics of the picture to be identified do not meet the definition of the white background icon.
The recognition unit 201 is configured to determine whether the color space value of the picture to be recognized carries an alpha channel. After a user uploads a picture, the picture to be recognized is obtained, and whether the color space value (RGBA) of the picture to be recognized has an alpha channel (A channel) or not is judged.
In one embodiment, before determining whether the color space value of the picture to be recognized carries an alpha channel, the method further includes: analyzing the picture to be recognized, and converting the color mode of the picture to be recognized into an RGBA or RGB mode. In this embodiment, the color mode of the picture is uniformly converted into the RGBA mode or the RGB mode when the picture is read, which is convenient for subsequent processing.
In one embodiment, when the transparent base map and the white base map of the picture to be recognized are determined, pre-filtering is performed on the picture to be recognized, whether the length value of the long edge of the picture to be recognized is smaller than a threshold value T1 is determined, and if the length value of the long edge of the picture to be recognized is smaller than the threshold value T1, a non-white base icon label is directly marked. Namely, if the length of the long edge of the picture is less than the threshold value T1, the picture is directly judged to be a non-white background picture, and the system efficiency is increased. Here, T1 is a default value of 30, and the rule is based on empirical summary of actual usage by the user, i.e., there is substantially no white background.
And the transparent image marking unit 202 is used for performing transparent base image definition identification on the image to be identified. When the color space value of the picture to be recognized is provided with an alpha channel, whether the value of the transparent area of the picture to be recognized in the whole picture is larger than a first preset value or not is recognized, if so, whether the picture characteristic of the picture to be recognized meets the definition of a transparent base map or not is judged, if so, a transparent base map label is marked, and if not, a non-white base map label is marked. Namely, when the RGBA of the picture to be recognized has an a channel, the picture to be recognized may be a transparent base map, and it is determined whether the picture to be recognized is a transparent base map or a non-transparent base map by recognizing the transparent area proportion of the picture to be recognized, if the proportion satisfies the condition of the transparent base map, it is further determined whether the picture to be recognized is the defined transparent base map by the function definition of the transparent base map (i.e. the definition of the transparent base map), if the picture to be recognized is the defined transparent base map, it is determined that the picture to be recognized is the transparent base map, the picture to be recognized is marked with a transparent base map label, and if the picture to be recognized is not the defined transparent base map, it is determined that the picture to be recognized is a non-white base map, and the picture to be recognized is marked with a non-white base map label. And if the proportion does not meet the condition of the transparent base map, the picture is possibly a white base map, and then white base map identification logic is carried out subsequently. Meanwhile, when the picture does not have the channel A, white background picture identification logic is carried out subsequently. It should be noted that the picture features of the picture to be recognized are object features on the picture, such as commodity patterns, image patterns, LOGO patterns, text patterns, and the like on the picture. The first preset value may be set based on an actual scene and a requirement, for example, the first preset value may be set as an upper limit value of an a channel in an alpha channel and a minimum value of a ratio of a minimum or maximum pixel value of a picture to pixels of the alpha channel, and the like, for example, the upper limit value is set to 230, and the minimum value of the ratio is set to 0.008, so as to filter the picture without a transparency effect of the transparent base map.
In one embodiment, the identifying whether the transparent area ratio of the picture to be identified is greater than a first preset value includes: and judging whether the minimum value of the channel pixel of the alpha channel in the picture to be identified is smaller than a threshold value T2, if the minimum value is smaller and the ratio of the pixel number of the minimum value pixel value to the channel pixel number of the alpha channel is larger than a threshold value T3, the ratio of the transparent area of the picture to be identified is larger than a first preset value, and if not, the ratio is not larger than the first preset value. Therefore, although the picture with the channel A (namely the picture possibly being the picture of the transparent base map), the picture with the transparent area with the undersize proportion and not meeting the requirement of the transparent map can be filtered, and the method can be used for rapid filtering, thereby ensuring high accuracy and high recall. Here, the threshold values T2 and T3 are the first preset values, and may be set according to actual requirements and scenes, and in this embodiment, the default value of T2 is 230, and the default value of T3 is 0.008, which is used for filtering a picture without a transparency effect of the transparent base map.
In one embodiment, the determining whether the picture features of the picture to be recognized satisfy the definition of the transparent base map includes: converting a picture to be identified into a gray map, calculating a pixel histogram of a transparent area, and if a pixel value with the ratio of the total pixel number of the transparent area to the threshold value T4 exists, and the value with the ratio of a single pixel value to the total pixel number of the transparent area to the threshold value T5 or the sum of the values of the total pixel number of the transparent areas with a plurality of pixel values is greater than the threshold value T6, judging that the definition of a transparent base map is met; otherwise, judging that the condition is not satisfied. Therefore, efficient and accurate identification of the transparent base map is achieved, and marking of the transparent base map and the non-transparent base map is conducted on the picture to be identified. Here, the thresholds T4, T5, and T6 may be set according to actual requirements and scenes, and in this embodiment, the default value of T4 is 0.1, the default value of T5 is 0.95, and the default value of T6 is 0.8, which are used to filter some text white base drawings, UI design drawings, logo drawings, and the like.
Specifically, as shown in fig. 3-1, a main processing flow chart of a transparency chart of the image processing method provided in the embodiment of the present application is shown. Step a, channel judgment: b, if the picture is 4 channels, namely an RGBA mode, entering the step b, otherwise, entering a white background picture filtering part; step b, proportion judgment: c, entering a step c if the minimum value of the A channel pixel values is smaller than a threshold value T2 and the value of the number of the minimum value pixel values in the A channel pixel number is larger than a threshold value T3; otherwise, the flow enters the white background filtering part. Here, T2 defaults to 230, T3 defaults to 0.008; the item is used for filtering pictures with transparent base pictures without transparent effect. Step c, functional judgment: converting the picture to be identified into a gray map, calculating a pixel histogram of the transparent part, if a pixel value with the ratio of the total pixel number of the transparent area to the threshold value T4 exists, and the value of the ratio of a single pixel value to the total pixel number of the transparent part is greater than the threshold value T5 or the sum of the values of the pixel values to the total pixel number of the transparent part is greater than the threshold value T6, determining that the picture is a transparent base map, and ending the flow; otherwise, judging the image as a non-white background image, and ending the process. Here, T4 defaults to 0.1, T5 defaults to 0.95, T6 defaults to 0.8; the item is used for filtering some character white base drawings, UI design drawings, logo drawings and the like. After the picture is judged to be the white background picture, the transparent background picture and the non-white background picture, the white background picture label, the transparent background picture label and the non-white background picture label are marked on the picture to be identified.
It should be noted that, the histogram is a common method in computer image processing, the range of image pixel values is [0,255], and the pixel histogram can be obtained by calculating the ratio of the number of each pixel value to the number of all pixels in the image. If the image size M × N is a total of b pixels with a pixel value a, then the histogram value for the coordinate a is b/(M × N).
The white background icon marking unit 203 is configured to perform strong-rule identification and secondary filtering on the white background map on the picture to be identified, that is, identify whether the white background of the picture to be identified satisfies a preset threshold condition, and whether the identified white background map satisfies the definition of the white background map. . If the transparent area ratio of the picture to be identified is not more than a first preset value or when the color space value does not have an alpha channel, namely when the picture to be identified cannot be a transparent base map and is possibly a white base map, identifying whether the value of the number of white pixels of the picture to be identified to the total number of pixels of the whole map is more than a second preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of the white base map, if so, marking a label of the white base map, and if not, marking the label of the white base map to be identified. Namely, white background image judgment is carried out on the picture to be identified, and a strong rule of a white background image judgment rule is realized, wherein the strong rule is determined by a frame white ratio, namely a total color ratio; and simultaneously, secondary filtering of the white background image based on the definition of the white background image is realized. Here, the second preset value may be set based on actual scenes and demands. The second preset may be one parameter or a plurality of parameters, for example, the white pixel ratio of the frame region or the threshold (second preset value) of the white pixel ratio of the whole image may be directly set to 0.4, so as to filter the image with the white background ratio being too small.
In one embodiment, the identifying whether the white pixel ratio of the picture to be identified is greater than a second preset value includes: converting the picture to be identified into a gray-scale image, calculating a pixel histogram, if the pixel values in the range of the preset proportion D1 of the edge distance to the center of the picture are all larger than a threshold value T7, the number ratio of the pixel values larger than the threshold value T8 in the range is larger than a threshold value T9, the number ratio of the pixel values of the whole picture larger than the threshold value T10 is larger than a threshold value T11, the white pixel ratio of the picture to be identified is larger than a second preset value, and otherwise, the white pixel ratio is not larger than the second preset value. Therefore, the strong rule of the white background image judgment rule is realized, and the strong rule is determined by the white proportion of the frame, namely the total color proportion. Here, T7, T8, T9, T10, and T11 are second preset values, and the values of D1, T7, T8, T9, T10, and T11 may be set based on actual scenes and requirements, so as to filter out pictures with significantly smaller borders by the white proportion of the borders, i.e., the overall color proportion. In this embodiment, D1 defaults to 10%, T7 defaults to 200, T8 defaults to 240, T9 defaults to 0.3, T10 defaults to 240, and T11 defaults to 0.6.
It should be noted that, in the shape (for example, the area where the ' large mouth in a ' shape ' is removed from the small mouth inside) surrounded by the range whose four sides of the image are proportional to the image center D1, the number of pixel values greater than the threshold value T8 in the range is greater than the total number of pixels in the area. A whole image pixel, that is, the number of pixels of the whole image, if the image height is h and the width is w, the number of pixels N = h × w; and M is the number of pixels larger than the threshold T10 in the N pixels, so that the occupation ratio is M/N.
In one embodiment, the determining whether the picture features of the picture to be recognized satisfy the definition of a white background picture includes: calculating a pixel histogram, obtaining the proportion of the number of each pixel value in the [0,255] range to the total number from the histogram, and if the value of the number of the pixel values to the total number of the picture is greater than the threshold T12 and the sum of the values of the pixel values to the total number of the picture is greater than the threshold T13, determining that the sum of the values is not satisfied; otherwise, performing maximum pooling sampling on the picture to be identified based on a preset pooling operation area value V1 and a preset pixel distance V2 between two pooling operations, if the type of the pooled pixel value is less than a threshold T30, determining that the picture is not satisfied, and if the type of the pooled pixel value is not less than the threshold T30, determining that the picture is satisfied. Therefore, the obtained white background image is secondarily filtered based on the definition of the white background image, namely the white background image is used as a commodity white background image, the distribution of image pixels of the white background image is relatively scattered, the proportion of concentrated colors cannot exist, and otherwise, the white background image is a character foreground white background image or a UI pure color foreground white background image with high probability. Here, the values of T12, T13, V1, V2, T30 may be set based on actual scenes and requirements. In this embodiment, the default value of T12 is 0.1, the default value of T13 is 0.8, the pooling operation area value kernel = V1, and the preset pixel distance stride = V2 between two pooling operations, the default value of V1 is 10, the default value of V2 is 10, and the default value of T30 is 30.
In one embodiment, the weak rule judgment of the white background image is carried out on the picture which does not accord with the white background image condition after the strong rule judgment of the white background image, and then the picture which considers whether the proportion of all the white margins of the four sides of the image accords with the condition of the white background image when the feature of the object main body image in part of the pictures is larger than the whole picture is screened out; and (5) carrying out secondary filtering on the white background image according with the judgment of the weak rule. Specifically, the method comprises the following steps: if the white pixel ratio of the picture to be identified is not greater than the second preset value, judging whether the pixel point ratio of the picture edge to the center preset ratio D2 frame pixel value is equal to the threshold value T40 or not, and if so, executing the first step; if not, judging whether the pixel point proportion frame value of the preset proportion D3 frame pixel value from the center of the image edge is larger than the threshold value T41 is larger than the threshold value T15, if so, executing the first step. The first step comprises: performing maximum pooling sampling on the picture to be identified based on a preset pooling operation area value V3 and a preset pixel distance V4 between two pooling operations, and marking a to-be-fixed white background image label on the picture to be identified if the type of the pooled pixel value is less than a threshold value V5; otherwise, calculating a pixel histogram of the pooled picture, if a pixel value with a ratio larger than T23 exists and the sum of the ratios of a plurality of pixel values is larger than T24, marking a to-be-identified white background picture label on the to-be-identified picture, otherwise, calculating the outline of an object body in the picture and obtaining an external moment, filtering to remove the object body with the area of the external moment of the object body between a threshold value T25 and a threshold value T26 in the picture, if the number of the remaining object bodies in the picture is larger than a threshold value V6, marking a non-white background picture label on the to-be-identified picture, otherwise, calculating the difference value between the length and the width of the external moment of the remaining object bodies in the picture and the length and the width corresponding to the picture, when the difference value is smaller than a threshold value T27, marking the to-be-identified picture label on the to-be-identified picture, otherwise, marking the white background picture label on the to-identified picture. Therefore, the weak rule of white background image judgment is realized, namely the proportion of partial image main bodies to the whole image is larger, whether the proportion of all the margins of the four sides of the image meets the condition of the white background image or not is considered independently at the moment, subsequent filtering is carried out, meanwhile, the two weak white background image rules are filtered, the robustness of the weak rule is improved, the image is still considered as a character foreground white background image and a UI type pure color foreground image, the judgment of the number of the object main bodies is improved, and if the number of the main bodies exceeds 2, the image has the maximum probability of being a display image and a propaganda image of the image and is not a functional white background image. Here, the values of D2, T40, T14, D3, T41, T15, V3, V4, V5, T23, T24, T25, T26, V6, T27, T41 may be set based on actual scenarios and requirements. In this embodiment, the default values of T40, T41, D2, V4, V5, T23, T24, T25, T26, V6, and T27 are 255, 250, 10, 0.2, 5, 0.8, 10, 30, 0.1, 0.8, 0.01, 0.99, 2, and 5, respectively.
In one embodiment, after the weak rule determination of the white background image is performed, the determination criterion is further lowered to perform recognition on the picture again, so as to recognize that a part of the white background image may have a picture in which the commodity main body is not in the middle of the picture and occupies the edge or corner of the image. Specifically, the method comprises the following steps: if the pixel point proportion frame value of the preset proportion D3 frame pixel value to the center of the picture is not more than the threshold value T15, executing the following steps: respectively calculating pixel mean values in corner regions with preset proportion D4 from the centers of four corners of the picture, calculating the difference value of the pixel mean values between every two adjacent corner regions in a descending order according to the size of the pixel mean values, selecting three corner regions with smaller difference values, and executing a second step if the maximum difference value of the pixel mean values of the three corner regions with smaller difference values is greater than a threshold value T42 or the maximum difference value of the pixel values of the three corner regions with smaller difference values is greater than a threshold value T16; otherwise, calculating the pixel mean value in the edge area with the preset distance D5 from the edge to the center of the picture, selecting two edge areas and three corner areas with the minimum pixel mean value of the edge areas and the minimum pixel mean value of the corner areas, if the pixel mean value difference value of the two edge areas is larger than a threshold value T17, or the maximum value of the mean value difference value of the three corner areas and the two edge areas is larger than a threshold value T18, or the maximum value of the pixel value difference value of the two edge areas is larger than a threshold value T19, executing the second step, and otherwise, executing the third step. Wherein the second step comprises: respectively calculating a pixel mean value and a pixel difference value of a preset distance D6 corner area from four corners to the center of the picture, and if the maximum value of the pixel mean value is greater than a threshold value T20 or the maximum value of the pixel difference value is greater than a threshold value T21, marking a non-white background icon label on the picture to be identified; otherwise, the third step is executed. The third step includes: if the pixel point ratio of the selected two edge areas and three corner areas is greater than the threshold value T22, executing the first step, otherwise, marking a non-white background icon label on the picture to be identified. Therefore, on the basis of the weak rule of the white background image, the standard is reduced again, and the fact that part of the white background image possibly has the condition that a commodity main body is not in the middle of the picture and occupies the edge or corner of the image is considered, so that the three corners and two side areas of the image are judged to meet the necessary conditions through the design rule; further, considering that the main part of a part of white background pictures is too large and occupies the whole image, considering whether the small region ranges of the four corners of the image meet the white background picture condition, the highest level of the system logic can only classify the part of the pictures as the to-be-determined white background pictures for user screening. Here, the values of D3, T41, T15, D4, T42, T16, D5, T17, T18, T19, D6, T20, T21, T43, T22 may be set based on actual scenes and needs. In this embodiment, the default value of T42 is 3, the default value of T43 is 235, the default value of D3 is 5%, the default value of T15 is 0.8, the default value of D4 is 3%, the default value of T16 is 10, the default value of D5 is 5, the default value of T17 is 3, the default value of T18 is 3, the default value of T19 is 10, the default value of D6 is 10, the default value of T20 is 3, the default value of T21 is 10, and the default value of T22 is 0.8.
Specifically, fig. 3-2 is a main processing flow diagram of a white background image of the image processing method according to the embodiment of the present application, that is, a white background image identification mark defined for a white background image function is implemented. The specific logic detailed in connection with fig. 3-2 is as follows:
step a, white pixel proportion filtering: converting the picture to be identified into a gray scale image, and entering the step b if all pixels in the proportional range of the image edge distance D1 are greater than a threshold value T7, the pixel proportion of the range greater than a threshold value T8 is greater than a threshold value T9, and the proportion of the pixels of the whole image greater than a threshold value T10 is greater than a threshold value T11; otherwise, go to step d. Here, D1 defaults to 10%, T7 defaults to 200, T8 defaults to 240, T9 defaults to 0.3, T10 defaults to 240, and T11 defaults to 0.6.
B, histogram pixel value ratio filtering: calculating a pixel histogram, if a pixel value with the occupation ratio larger than a threshold value T12 exists and the sum of the occupation ratios of a plurality of pixels is larger than a threshold value T13, classifying the picture as a background picture to be fixed, and ending the process; otherwise, entering the step c. Here, T12 is 0.1 by default, and T13 is 0.8 by default.
Step c, filtering the pooled pixel value ratio: setting kernel = V1 and stride = V2, performing maximum pooling sampling, if the type of the pixel values after pooling is less than a threshold T30, classifying the pixel values as a background image to be fixed, and ending the flow; otherwise, the process is classified as a white background picture, and the process is ended. Here, V1 is 10 by default, V2 is 10 by default, and T30 is 30 by default.
And D, if the proportion of the D2 frame pixels is equal to 255 and the whole image is larger than a threshold value T14, entering the step j, and otherwise, entering the step e. Here, D2 is 10% by default and T14 is 0.2 by default.
And e, if the D3 frame pixel is larger than the 250-to-frame ratio and the frame is larger than the threshold T15, entering the step j, otherwise, entering the step f. Here, D3 is 5% by default and T15 is 0.8 by default.
And f, calculating the mean value of four corners D4 of the image, sorting and selecting three corners with smaller difference values according to the sequence, entering the step h if the maximum difference value of the triangular mean value is greater than a threshold value 3 or the maximum difference value of pixel values in corner regions is greater than a threshold value T16, and otherwise entering the step g. Here, D4 is 3% by default and T16 is 10% by default)
Step g, calculating the pixel mean value of the 4-side range area according to the side D5, selecting two sides with the minimum side mean value and the minimum triangular mean value, entering the step h if the difference value of the two side mean values is greater than a threshold value T17, or the difference value of the triangular mean value and the two side mean values is greater than a threshold value T18, or the maximum difference value of the two side area pixel values is greater than a threshold value T19, or entering the step i. Here, D5 is 5 by default, T17 is 3 by default, T18 is 3 by default, and T19 is 10 by default.
H, if the pixel mean difference of the four corners D6 area is greater than a threshold value T20, and the maximum value of the pixel difference is greater than a threshold value T21, outputting a non-white background image, and ending the process; otherwise, entering step i. Here, D6 is 10 by default, T20 is 3 by default, and T21 is 10 by default.
And i, if the pixel proportion of the selected area is greater than 235 and greater than a threshold value T22, entering a step j, otherwise, ending the process. Here, T22 defaults to 0.8.
Step j, setting kernel = V3 and stride = V4, performing maximum pooling sampling, and if the type of the pixel values after pooling is less than V5, classifying the pixel values as a background image to be white, and ending the process; otherwise step k is entered. Here, V3 is 10 by default, V4 is 10 by default, and V5 is 30 by default.
Step k, aiming at the image after pooling, calculating a pixel histogram for judgment, if a pixel value with a ratio larger than T23 exists and the sum of the pixel ratios is larger than T24, classifying the image as a white background image to be fixed, and ending the process; otherwise, go to step l. Here, T23 is 0.1 by default, and T24 is 0.8 by default.
And step l, calculating the outline of the image main body and obtaining external moment, and if the area of the main body is between T25 and T26, saving the coordinate range and the area set of the main body. Filtering the stored main bodies, removing the completely contained main bodies, if the number of the remaining main bodies is more than V6, classifying the main bodies as a non-white background chart, and ending the process; otherwise, go to step m. Here, T25 is 0.01 by default, T26 is 0.99 by default, and V6 is 2 by default.
If the difference value between the length or width of the main body and the length or width of the image is less than T27, the main body is classified as a non-white background image, and the process is ended; otherwise, the process is classified as a white background picture and the process is ended. Here, T27 defaults to 5.
In this embodiment of the present application, the steps a, b, and c may be classified as a strong rule of the white background image determination rule, where the rule a is determined by a frame white ratio, that is, an overall color ratio, and the steps b and c perform strong filtering on the obtained white background image, that is, the white background image is used as a commodity white background image, the distribution of image pixels of the commodity white background image should be relatively scattered, there is no concentrated color ratio, otherwise, the image pixels are mostly a text foreground white background image or a UI-type solid-color foreground white background image. And d and e are weak rules for judging the white background image, namely the proportion of the partial image main body to the whole image is larger, so whether the proportion of all the white margins on the four sides of the image meets the condition of the white background image is considered separately at the moment, and subsequent filtering is carried out. F, g, h and i, reducing the standard again on the basis of the rules of the steps d and e, considering that part of white background images possibly have the condition that the commodity main body is not in the middle of the image and occupies the edge or corner of the image, judging that three corners and two side areas of the image meet the necessary conditions through the design rules; further, considering that the main part of a part of white background pictures is too large and occupies the whole image, considering whether the small region ranges of the four corners of the image meet the white background picture condition, the highest level of the system logic can only classify the part of the pictures as the to-be-determined white background pictures for user screening. And j, k, l and m are used for filtering the two weak white background image rules to increase the robustness of the weak rules, the main consideration is still that the image is a character foreground white background and a UI pure color foreground, the judgment of the number of main bodies is increased, and if the judgment exceeds 2 main bodies, the image has the maximum probability of being a display image and a propaganda image of the image and not a functional white background image.
Therefore, the image processing system provided by the embodiment of the application solves the technical problems of rough identification and classification granularity and inaccurate classification of the white background image in the related technology, and achieves the following beneficial effects: the method and the device realize the functional definition of the white background picture and the transparent background picture again, recall the white background picture and the transparent background picture which are wanted by the user to the maximum extent, and improve the efficiency and the accuracy of the picture classification marking.
An embodiment of the present application further provides an electronic device, including: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by one or more processors, the one or more processors realize the image processing method of the embodiment of the application.
Embodiments of the present application also provide a computer readable medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program implements an image processing method according to an embodiment of the present application.
Fig. 8 illustrates an exemplary system architecture 300 to which the image processing method or system of the present application may be applied.
As shown in fig. 8, the system architecture 300 may include terminal devices 301, 302, 303, a network 304, and a server 305. The network 304 serves as a medium for providing communication links between the terminal devices 301, 302, 303 and the server 305. Network 304 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal device 301, 302, 303 to interact with the server 305 via the network 304 to receive or send messages or the like. The terminal devices 301, 302, 303 may have various communication client applications installed thereon, such as a shopping application, a web browser application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 301, 302, 303 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 305 may be a server providing various services, such as a background management server providing support for the user to utilize the incoming and outgoing messages sent by the terminal devices 301, 302, 303. The background management server can perform analysis and other processing after receiving the terminal device request, and feed back the processing result to the terminal device.
It should be noted that the image processing method provided in the embodiment of the present application is generally executed by the terminal device 301, 302, 303 or the server 305, and accordingly, the image processing system is generally disposed in the terminal device 301, 302, 303 or the server 305.
It should be understood that the number of terminal devices, networks, and servers in fig. 8 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 9, shown is a block diagram of a computer system 400 suitable for use in implementing the electronic device of an embodiment of the present application. The computer system shown in fig. 9 is only an example, and should not bring any limitation to the function and the scope of use of the embodiments of the present application.
As shown in fig. 9, the computer system 400 includes a Central Processing Unit (CPU) 401 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM) 402 or a program loaded from a storage section 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the system 400 are also stored. The CPU 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
The following components are connected to the I/O interface 405: an input portion 406 including a keyboard, a mouse, and the like; an output section 407 including a display device such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 408 including a hard disk and the like; and a communication section 409 including a network interface card such as a LAN card, a modem, or the like. The communication section 409 performs communication processing via a network such as the internet. A driver 410 is also connected to the I/O interface 405 as needed. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 410 as necessary, so that a computer program read out therefrom is mounted into the storage section 408 as necessary.
In particular, according to embodiments disclosed herein, the processes described above with reference to the flow diagrams may be implemented as computer software programs. For example, embodiments disclosed herein include a computer program product comprising a computer program embodied on a computer-readable medium, the computer program comprising program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 409, and/or installed from the removable medium 411. The above-described functions defined in the system of the present application are executed when the computer program is executed by a Central Processing Unit (CPU) 401.
It should be noted that the computer readable medium shown in the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present application may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a determination module, an extraction module, a training module, and a screening module. Where the names of these modules do not in some cases constitute a limitation of the module itself, for example, a determination module may also be described as a "module that determines a set of candidate users".
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (10)

1. An image processing method, comprising:
judging whether the color space value of the picture to be identified has an alpha channel or not;
when an alpha channel is provided, identifying whether the transparent area proportion of the picture to be identified is greater than a first preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a transparent base map, if so, marking a transparent base map label, and if not, marking a non-white base map label;
if the transparent area ratio of the picture to be identified is not larger than a first preset value or when the color space value does not have an alpha channel, identifying whether the white pixel ratio of the picture to be identified is larger than a second preset value, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a white background picture, if so, marking a white background picture label, and if not, marking the white background picture label to be identified.
2. The image processing method according to claim 1, wherein before determining whether the color space value of the picture to be recognized carries an alpha channel, the method further comprises: analyzing the picture to be recognized, converting the color mode of the picture to be recognized into an RGBA or RGB mode, judging whether the length value of the long edge of the picture to be recognized is smaller than a threshold value T1, and if so, marking a non-white background icon label.
3. The image processing method according to claim 1 or 2, wherein the identifying whether the transparent area ratio of the picture to be identified is greater than a first preset value comprises: and judging whether the minimum value of the channel pixels of the alpha channel in the picture to be recognized is smaller than a threshold value T2, if the minimum value is smaller and the ratio of the number of the minimum value pixels to the number of the channel pixels of the alpha channel is larger than a threshold value T3, determining that the ratio of the transparent area of the picture to be recognized is larger than a first preset value, and if not, determining that the ratio of the transparent area of the picture to be recognized is not larger than the first preset value.
4. The image processing method according to claim 3, wherein the determining whether the picture features of the picture to be recognized satisfy the definition of the transparent base map comprises: converting a picture to be identified into a gray-scale image, calculating a pixel histogram of a transparent area, and if a pixel value with a ratio greater than a threshold value T4 exists, and the ratio of a single pixel value is greater than a threshold value T5 or the sum of the ratios of a plurality of pixel values is greater than a threshold value T6, judging that the definition of a transparent base map is met; otherwise, judging that the condition is not satisfied.
5. The image processing method according to claim 1 or 2, wherein the identifying whether the white pixel ratio of the picture to be identified is greater than a second preset value comprises: converting the picture to be identified into a gray-scale image, calculating a pixel histogram, if the pixel values in the range of the preset proportion D1 of the edge distance to the center of the picture are all larger than a threshold value T7, the number ratio of the pixel values larger than the threshold value T8 in the range is larger than a threshold value T9, the number ratio of the pixel values of the whole picture larger than the threshold value T10 is larger than a threshold value T11, the white pixel ratio of the picture to be identified is larger than a second preset value, and otherwise, the white pixel ratio is not larger than the second preset value.
6. The image processing method according to claim 5, wherein the determining whether the picture features of the picture to be recognized satisfy a white background definition comprises: if there is a pixel value whose duty ratio is greater than the threshold value T12 and the sum of the duty ratios of the plurality of pixel values is greater than the threshold value T13, determining that it is not satisfied; otherwise, performing maximum pooling sampling on the picture to be identified based on a preset pooling operation area value V1 and a preset pixel distance V2 between two pooling operations, if the type of the pooled pixel value is less than a threshold T30, determining that the picture is not satisfied, and if the type of the pooled pixel value is not less than the threshold T30, determining that the picture is satisfied.
7. The image processing method according to claim 5, further comprising: if the white pixel ratio of the picture to be identified is not greater than the second preset value, judging whether the pixel point ratio of the picture edge to the center preset ratio D2 frame pixel value is equal to the threshold value T40 or not, and if so, executing the first step; if not, judging whether the pixel point proportion frame value of the preset proportion D3 frame pixel value from the center of the image is larger than the threshold value T41 is larger than the threshold value T15 or not, if so, executing the first step; the first step comprises: performing maximum pooling sampling on the picture to be identified based on a preset pooling operation area value V3 and a preset pixel distance V4 between two pooling operations, and marking a to-be-fixed white background image label on the picture to be identified if the type of the pooled pixel value is less than a threshold value V5; otherwise, calculating a pixel histogram of the pooled picture, if a pixel value with a ratio larger than T23 exists and the sum of the ratios of a plurality of pixel values is larger than T24, marking a to-be-identified white background picture label on the to-be-identified picture, otherwise, calculating the outline of an object body in the picture and obtaining an external moment, filtering to remove the object body with the area of the external moment of the object body between a threshold value T25 and a threshold value T26 in the picture, if the number of the remaining object bodies in the picture is larger than a threshold value V6, marking a non-white background picture label on the to-be-identified picture, otherwise, calculating the difference value between the length and the width of the external moment of the remaining object bodies in the picture and the length and the width corresponding to the picture, when the difference value is smaller than a threshold value T27, marking the to-be-identified picture label on the to-be-identified picture, otherwise, marking the white background picture label on the to-identified picture.
8. The image processing method according to claim 7, further comprising: if the pixel point proportion frame value of the preset proportion D3 frame pixel value to the center of the picture edge is larger than T41 is not larger than the threshold value T15, the following steps are executed: respectively calculating pixel mean values in corner regions with preset proportion D4 from the centers of four corners of the picture, calculating the difference value of the pixel mean values between every two adjacent corner regions in a descending order according to the size of the pixel mean values, selecting three corner regions with smaller difference values, and executing a second step if the maximum difference value of the pixel mean values of the three corner regions with smaller difference values is greater than a threshold value T42 or the maximum difference value of the pixel values of the three corner regions with smaller difference values is greater than a threshold value T16; otherwise, calculating the pixel mean value in the edge area with the preset distance D5 from the edge to the center of the picture, selecting two edge areas and three corner areas with the minimum pixel mean value of the edge areas and the minimum pixel mean value of the corner areas, if the pixel mean value difference value of the two edge areas is larger than a threshold value T17, or the maximum mean value difference value of the three corner areas and the two edge areas is larger than a threshold value T18, or the maximum pixel value difference value of the two edge areas is larger than a threshold value T19, executing the second step, otherwise, executing the third step. Wherein the second step comprises: respectively calculating a pixel mean value and a pixel difference value of a preset distance D6 corner area from four corners to the center of the picture, and if the maximum value of the pixel mean value is greater than a threshold value T20 or the maximum value of the pixel difference value is greater than a threshold value T21, marking a non-white background icon label on the picture to be identified; otherwise, the third step is executed. The third step includes: if the pixel point ratio of the pixel values of the two selected edge areas and the three selected corner areas which are larger than the threshold value T43 pixel is larger than the threshold value T22, executing the first step, otherwise, marking the picture to be identified with a non-white background icon label.
9. An image processing system, comprising:
the identification unit is used for judging whether the color space value of the picture to be identified has an alpha channel or not;
the transparent icon marking unit is used for identifying whether the transparent area ratio of the picture to be identified is greater than a first preset value or not when the picture to be identified is provided with an alpha channel, if so, judging whether the picture characteristics of the picture to be identified meet the definition of a transparent base map or not, if so, marking a transparent base map label, and otherwise, marking a non-white base map label;
and the white background icon marking unit is used for identifying whether the white pixel proportion of the picture to be identified is greater than a second preset value or not if the transparent area proportion of the picture to be identified is not greater than the first preset value or if the color space value does not have an alpha channel, judging whether the picture characteristics of the picture to be identified meet the definition of the white background map or not if the white pixel proportion of the picture to be identified is greater than the second preset value, marking a label of the white background map if the picture characteristics of the picture to be identified meet the definition of the white background map, and marking a label of the white background map to be fixed if the picture characteristics of the picture to be identified do not meet the definition of the white background map.
10. An electronic device, comprising a memory and a processor, the memory having stored therein a computer program which, when executed by the processor, causes the processor to carry out the steps of the image processing method of any one of claims 1 to 8.
CN202211478203.2A 2022-11-23 2022-11-23 Image processing method and system and electronic equipment Pending CN115861202A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211478203.2A CN115861202A (en) 2022-11-23 2022-11-23 Image processing method and system and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211478203.2A CN115861202A (en) 2022-11-23 2022-11-23 Image processing method and system and electronic equipment

Publications (1)

Publication Number Publication Date
CN115861202A true CN115861202A (en) 2023-03-28

Family

ID=85665575

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211478203.2A Pending CN115861202A (en) 2022-11-23 2022-11-23 Image processing method and system and electronic equipment

Country Status (1)

Country Link
CN (1) CN115861202A (en)

Similar Documents

Publication Publication Date Title
US10984295B2 (en) Font recognition using text localization
US10699166B2 (en) Font attributes for font recognition and similarity
US9824304B2 (en) Determination of font similarity
CN110503097A (en) Training method, device and the storage medium of image processing model
CN113313111B (en) Text recognition method, device, equipment and medium
EP3879450A1 (en) Text recognition method and terminal device
CN111243061B (en) Commodity picture generation method, device and system
CN113064964A (en) Text classification method, model training method, device, equipment and storage medium
CN108268510B (en) Image annotation method and device
CN111738252B (en) Text line detection method, device and computer system in image
CN113255501B (en) Method, apparatus, medium and program product for generating form recognition model
CN112925905B (en) Method, device, electronic equipment and storage medium for extracting video subtitles
CN117058271A (en) Method and computing device for generating commodity main graph background
CN112883926A (en) Identification method and device for table medical images
CN115496820A (en) Method and device for generating image and file and computer storage medium
CN110969641A (en) Image processing method and device
CN114581928A (en) Form identification method and system
CN116486153A (en) Image classification method, device, equipment and storage medium
CN115861202A (en) Image processing method and system and electronic equipment
CN111753836A (en) Character recognition method and device, computer readable medium and electronic equipment
CN114818627A (en) Form information extraction method, device, equipment and medium
CN113902001A (en) Model training method and device, electronic equipment and storage medium
CN114399497A (en) Text image quality detection method and device, computer equipment and storage medium
CN114511862A (en) Form identification method and device and electronic equipment
CN114387600A (en) Text feature recognition method and device, computer equipment 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