Image processing method, system and electronic device
By determining the color space and pixel ratio of an image, and combining grayscale conversion and pooling operations, accurate classification of white background images and transparent background images is achieved. This solves the problems of coarse and inaccurate classification granularity in existing technologies, and improves the management efficiency and accuracy of the DAM system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 特赞(上海)信息科技有限公司
- Filing Date
- 2022-11-23
- Publication Date
- 2026-05-15
AI Technical Summary
Existing technologies for white background image recognition have coarse granularity and inaccurate classification, requiring users to perform a lot of secondary screening. Furthermore, the generalization ability of machine learning models is limited, resulting in a large number of misclassifications.
By determining whether the color space values of the image to be identified have an alpha channel, the proportion of transparent areas and white pixels is identified. Combined with various preset values and image processing techniques, such as grayscale conversion and pooling operations, accurate classification of white background images and transparent background images is achieved.
It improves the accuracy and efficiency of classifying white background images and transparent background images, ensures that users can retrieve the materials they want, reduces misclassification, and improves the management efficiency of the DAM system.
Smart Images

Figure CN115861202B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and more specifically, relates to an image processing method, system, and electronic device. Background Technology
[0002] White background images are an important type of content in the e-commerce field, bringing significant value to product display, dissemination, and secondary creation. DAM (Digital Asset Management), as the infrastructure of digital content, is playing a crucial role in content management, especially in e-commerce and FMCG sectors. It allows users to easily tag uploaded content, distinguishing between white background images, transparent background images, and non-white background images, greatly facilitating subsequent use by users.
[0003] Simple methods for white background image recognition mostly involve judging the proportion of white pixels around the image border or the proportion of white pixels in the entire image. However, this granularity is too coarse, and users still need to filter a large number of images a second time. Methods trained by machine learning models have limited generalization and are prone to misclassification.
[0004] There is currently no effective solution to the technical problems of coarse granularity and inaccurate classification of white background images in related technologies. Summary of the Invention
[0005] Therefore, the present application provides an image processing method, system, electronic device, and storage medium, aiming to solve at least one problem existing in the prior art.
[0006] To achieve the above objectives, in a first aspect, this application provides an image processing method, comprising:
[0007] Determine whether the color space values of the image to be identified have an alpha channel;
[0008] When an alpha channel is used, the system identifies whether the proportion of transparent areas in the image to be identified is greater than a first preset value. If it is greater, the system determines whether the image features of the image to be identified meet the definition of a transparent background image. If they do, the system marks the image as a transparent background image; otherwise, it marks the image as a non-white background image.
[0009] If the proportion of transparent area in the image to be identified is not greater than the first preset value, or if the color space value does not have an alpha channel, determine whether the proportion of white pixels in the image to be identified is greater than the second preset value. If it is greater, determine whether the image features of the image to be identified meet the definition of a white background image. If it does, mark it with a white background image label. If it does not, mark it with a pending white background image label.
[0010] In one embodiment, before determining whether the color space value of the image to be identified has an alpha channel, the method further includes: parsing the image to be identified, converting the color mode of the image to be identified to RGBA or RGB mode, determining whether the length of the long side of the image to be identified is less than a threshold T1, and if it is less, labeling it as a non-white background image.
[0011] In one embodiment, determining whether the proportion of transparent areas in the image to be identified is greater than a first preset value includes: determining whether the minimum value of the channel pixels of the alpha channel in the image to be identified is less than a threshold T2; if it is less than a threshold T2 and the ratio of the number of minimum value pixels to the number of channel pixels of the alpha channel is greater than a threshold T3, then the proportion of transparent areas in the image to be identified is greater than the first preset value; otherwise, it is not greater than a threshold T2.
[0012] In one embodiment, determining whether the image features of the image to be identified satisfy the definition of a transparent background image includes: converting the image to be identified into a grayscale image, calculating the pixel histogram of the transparent region, and if there are pixel values with a proportion greater than threshold T4, and the proportion of a single pixel value is greater than threshold T5 or the sum of the proportions of multiple pixel values is greater than threshold T6, then the definition of a transparent background image is satisfied; otherwise, it is determined that it is not satisfied.
[0013] In one embodiment, identifying whether the proportion of white pixels in the image to be identified is greater than a second preset value includes: converting the image to be identified into a grayscale image, calculating a pixel histogram, and if the pixel values within a preset ratio D1 from the edge of the image to the center are all greater than a threshold T7, and the proportion of pixel values greater than a threshold T8 within this range is greater than a threshold T9, and the proportion of pixel values greater than a threshold T10 in the entire image is greater than a threshold T11, then the proportion of white pixels in the image to be identified is greater than the second preset value; otherwise, it is not greater than the second preset value.
[0014] In one embodiment, determining whether the image features of the image to be identified satisfy the definition of a white background image includes: if there are pixel values with a proportion greater than threshold T12, and the sum of the proportions of multiple pixel values is greater than threshold T13, then it is determined that the feature is not satisfied; otherwise, based on a preset pooling operation region value V1 and a preset pixel distance V2 between two pooling operations, max pooling sampling is performed on the image to be identified. If the number of pixel values after pooling is less than threshold T30, then it is determined that the feature is not satisfied; if the number of pixel values after pooling is not less than threshold T30, then it is determined that the feature is satisfied.
[0015] In one embodiment, the method further includes: if the proportion of white pixels in the image to be identified is not greater than a second preset value, determining whether the proportion of pixels whose edge distance from the center preset ratio D2 border pixel value is equal to the threshold T40 in the whole image is greater than the threshold T14; if yes, then the first step is executed; if no, determining whether the proportion of pixels whose edge distance from the center preset ratio D3 border pixel value is greater than the threshold T41 in the border value is greater than the threshold T15; if yes, then the first step is executed; the first step includes: performing max pooling sampling on the image to be identified based on the preset pooling operation region value V3 and the preset pixel distance V4 between two pooling operations; if the type of pixel value after pooling is less than the threshold V5, marking the image to be identified with an undetermined white background image label; otherwise... Calculate the pixel histogram of the pooled image. If there are pixel values with a proportion greater than T23, and the sum of the proportions of multiple pixel values is greater than T24, mark the image to be identified with an pending white background image label. Otherwise, calculate the outline of the main body of the object in the image and obtain its bounding moments. Filter out the main bodies of the objects in the image whose bounding moments have areas between thresholds T25 and T26. If the number of remaining main bodies in the image is greater than threshold V6, mark the image to be identified with a non-white background image label. Otherwise, calculate the difference between the length and width of the bounding moments of the remaining main bodies in the image and the corresponding length and width of the image. When the difference is less than threshold T27, mark the image to be identified with an pending white background image label. Otherwise, mark the image to be identified with a white background image label.
[0016] In one embodiment, the method further includes: if the percentage of pixels with a frame pixel value greater than T41 at a preset distance D3 from the center of the image edge is not greater than a threshold T15, then the following steps are performed: calculate the average pixel value in the four corner regions of the image at a preset distance D4 from the center, calculate the difference between the average pixel values of each pair of adjacent corner regions in descending order of the average pixel value, select the three corner regions with smaller differences, and if the maximum difference between the average pixel values of the three corner regions with smaller differences is greater than a threshold T42 or greater than a threshold T16, then the second step is performed; otherwise, calculate the average pixel value in the edge regions at a preset distance D5 from the center of the image edge, select the two edge regions and three corner regions with the smallest average pixel values of the edge regions and the corner regions, and if the difference between the average pixel values of the two edge regions is greater than a threshold T17, or the maximum difference between the average pixel values of the three corner regions and the average pixel values of the two edge regions is greater than a threshold T18, or the maximum difference between the average pixel values of the two edge regions is greater than a threshold T19, then the second step is performed; otherwise, the third step is performed. The second step includes: calculating the average pixel value and pixel difference of the four corners of the image at a preset distance D6 from the center; if the maximum value of the average pixel value is greater than threshold T20 or the maximum value of the pixel difference is greater than threshold T21, then the image to be identified is labeled as a non-white background image; otherwise, the third step is executed. The third step includes: if the pixel value of the selected two edge regions and three corner regions is greater than threshold T43 and the percentage of pixels is greater than threshold T22, then the first step is executed; otherwise, the image to be identified is labeled as a non-white background image.
[0017] Secondly, this application also provides an image processing system, comprising:
[0018] The recognition unit is used to determine whether the color space values of the image to be recognized have an alpha channel;
[0019] The transparent image labeling unit is used to identify whether the proportion of the transparent area of the image to be identified is greater than a first preset value when there is an alpha channel. If it is greater, it determines whether the image features of the image to be identified meet the definition of a transparent background image. If it does, it labels the image with a transparent background image; if it does not, it labels the image with a non-white background image.
[0020] The white background image marking unit is used to identify whether the proportion of white pixels in the image to be identified is greater than a second preset value if the proportion of transparent areas in the image to be identified is not greater than a first preset value or when the color space value does not have an alpha channel. If it is greater, it determines whether the image features of the image to be identified meet the definition of a white background image. If it does, it marks the image with a white background image label. If it does not, it marks the image with a pending white background image label.
[0021] Thirdly, this application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the image processing method.
[0022] This application provides an image processing method, system, and electronic device that determines whether the color space value of the image to be identified has an alpha channel. When it has an alpha channel, it determines whether the proportion of transparent areas in the image to be identified is greater than a first preset value. If it is greater, it determines whether the image features of the image to be identified meet the definition of a transparent background image. If they do, it labels the image as a transparent background image; otherwise, it labels it as a non-white background image. If the proportion of transparent areas in the image to be identified is not greater than the first preset value, or when the color space value does not have an alpha channel, it determines whether the proportion of white pixels in the image to be identified is greater than a second preset value. If it is greater, it determines whether the image features of the image to be identified meet the definition of a white background image. If they do, it labels the image as a white background image; otherwise, it labels it as a pending white background image. This solves the technical problem of coarse granularity and inaccurate classification of white background images in related technologies, and achieves the following beneficial effects: it redefines the functions of white background images and transparent background images, maximizes the recall of the white background images and transparent background images desired by users, and improves the efficiency and accuracy of image classification and labeling. Attached Figure Description
[0023] The accompanying drawings, which form part of this application, are used to provide a further understanding of the application and to make other features, objects, and advantages of the application more apparent. The illustrative embodiments and descriptions of this application are used to explain the application and do not constitute an undue limitation of the application. In the drawings:
[0024] Figure 1 The implementation flow of the image processing method provided in the embodiments of this application;
[0025] Figure 2 The main processing flowchart of the image processing method provided in the embodiments of this application;
[0026] Figure 3-1 This is a flowchart illustrating the main processing steps of the transparent image in the image processing method provided in this application embodiment.
[0027] Figure 3-2 A flowchart illustrating the main processing steps for a white background image in the image processing method provided in this application embodiment;
[0028] Figure 4-1 Examples of non-white background images defined for the white background image in the image processing method provided in the embodiments of this application;
[0029] Figure 4-2 Example of a white background image defined for the image processing method provided in the embodiments of this application;
[0030] Figure 5-1 An example of the original RGB image of the main object in an image provided by the image processing method in this application embodiment;
[0031] Figure 5-2 The image processing method provided in this application provides a binary image obtained by thresholding the grayscale image of the main object in the image;
[0032] Figure 5-3 A visual example of the minimum bounding rectangle of the solved contour of the main body of an object in an image provided in the embodiment of this application;
[0033] Figure 6-1 Example diagram of max pooling sampling for the image processing method provided in the embodiments of this application;
[0034] Figure 6-2 Example diagrams of edge and corner regions of images provided in the image processing method of this application embodiment;
[0035] Figure 7 This is a schematic diagram of the main modules of the image processing system provided in the embodiments of this application;
[0036] Figure 8 An exemplary system architecture diagram provided for application in the embodiments of this application;
[0037] Figure 9 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers in the embodiments of this application. Detailed Implementation
[0038] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0039] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0040] In this application, the terms "upper," "lower," "left," "right," "front," "rear," "top," "bottom," "inner," "outer," "middle," "vertical," "horizontal," "lateral," and "longitudinal" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. These terms are primarily for the purpose of better describing this application and its embodiments, and are not intended to limit the indicated device, element, or component to having a specific orientation, or to be constructed and operated in a specific orientation.
[0041] Furthermore, in addition to indicating location or positional relationship, some of the aforementioned terms may also have other meanings. For example, the term "above" may also be used in some cases to indicate a certain dependency or connection relationship. Those skilled in the art can understand the specific meaning of these terms in this application based on the specific circumstances.
[0042] In addition, the term "multiple" should mean two or more.
[0043] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0044] It should be noted that images are expressed in various color modes in computers, such as RGB, GRAY, Lab, etc. Different image parsing libraries, such as Pillow and OpenCV in Python, support different ranges and formats of color modes when reading images.
[0045] It should be noted that color image files are typically represented in a computer as a three-dimensional matrix with a shape of W*H*3. Here, W represents the width of the image, H represents the height, and 3 represents the R, G, and B color channels. For transparent images, an additional transparency channel, usually denoted as A (alpha channel), is added to the computer's representation, resulting in a W*H*4 image matrix. The value range for each point in the RGBA channels is [0, 255]. For the A channel, a value of 255 indicates opacity (i.e., no RGB corresponding pixel is displayed), and a value of 0 indicates transparency (the RGB corresponding pixel is displayed). The logarithmic relationship between white and black pixels is used to divide the image into several levels, called grayscale. Grayscale has 256 levels, and an image represented in grayscale is called a grayscale image. There are various conversion methods between RGB and grayscale images; a simple example is: Gray = R*0.3 + G*0.59 + B*0.11.
[0046] It should be noted that, in a broad sense, any image with a white background can be considered a white background image for DAM (Digital Asset Management). For example, a photo with text written on a white A4 sheet of paper can be considered a white background image in terms of style. However, DAM users are unlikely to want this image to appear at the top of their search results or recognize it as a white background image. Therefore, in this embodiment of the application, for the DAM system, a white background image is redefined as an image with primary content (i.e., the main image features of the object in the image are patterns of products, images, logos, etc.). Images filtered by this definition are white background image materials with functions such as display, secondary processing, and distribution. They are mainly white background images based on product or marketing elements, and the purpose of marking the image is for subsequent secondary processing and dissemination. For example, a white background image of a pair of Adidas shoes, firstly, has a white background, and the main feature of the object in the image is shoes (a product), which can later be used as an element in creating a poster; for example, such as Figure 4-1 Although the background is white, the main subject of the image is text, not a product, image, logo, or other graphic. It does not serve a display, secondary processing, or distribution purpose, and therefore falls under the definition of a non-white background image in this application. Figure 4-2 In the image, the background is white, and the main object is clothing, which is a commodity and has functions such as display, secondary processing, and distribution. Therefore, it is the white background image defined in this application.
[0047] It should be noted that for some images that meet the above definition of white background images but whose white background ratio is less than a threshold (the specific threshold is related to the actual scene and is a customizable threshold; in this embodiment, the range of white pixels is first defined, for example, those greater than 240 are considered white pixels, and the threshold is set to 0.6), this embodiment defines them as pending options (i.e., pending white background images, not directly used as white background images), which can be used for fast filtering, ensuring both high accuracy and high recall. Specific filtering rules are described in the subsequent embodiment section.
[0048] Meanwhile, for the DAM transparent background image, the same as the functional definition of the white background image in this application, under the premise that the background is transparent, the transparent background image in this embodiment is defined as a transparent background image material image that has the main material content (patterns of products, images, logos, etc.) and has the functions of display, secondary processing, and placement. Its specific description is the same as the definition of the white background image, and will not be repeated here.
[0049] Unless otherwise specified, the white background images and transparent background images mentioned below are all white background images and transparent background images within the scope defined in this invention.
[0050] like Figure 2 This is a flowchart of the main processing method of the image processing method provided in the embodiments of this application. This application redefines the white background image and transparent background image of DAM user material in terms of usage function and proposes an overall framework, which involves image filtering and mode conversion, transparent background image judgment, strong rules for white background image, combination of rules at different levels, and secondary filtering of white background image, used to distinguish white background image, transparent background image and non-white background image in DAM material.
[0051] Based on the proposed framework, this application designs nested methods for recalling transparent background images and nested methods for recalling white background images. Additionally, this application designs filtering methods for certain suspected white background images, such as text images and UI images. The verification environment for this application is Python, and all related libraries mentioned below are Python-based dependencies. The methods proposed in this application are decoupled from specific programming languages, allowing for flexible migration, and all related dependency libraries can be replaced.
[0052] like Figure 2 The image processing method in this application addresses the recognition of transparent and white background images. Overall, after the user inputs an image, a pre-filter module first filters out small images to improve system efficiency, and simultaneously converts the image's color mode to RGBA mode for subsequent processing.
[0053] After color mode conversion, the system first determines whether an image has a transparent background based on the transparent background logic. The specific transparent background determination logic is as follows: First, it checks if the image has an A channel to perform a preliminary transparent background check. If this passes, it checks the definition of a transparent background to see if the image has one. If the image meets the definition of a transparent background and is therefore considered transparent, a transparent background label is output, and the user-input image is labeled with a transparent background label. If the image does not meet the definition or the preliminary transparent background check fails, it performs a strong rule-based preliminary check for a white background to determine if it has a white background. This involves filtering images with a white background and sufficient white background percentage based on whether the proportion of white pixels in the image exceeds a threshold. If the image has a white background, it is then processed as a white background image. Figure 2 The second verification involves using the features of the redefined white background image in this embodiment to determine whether the main image features of the object in the image meet the definition of a white background image. If the verification passes, a white background label is output, and the user-input image is labeled as a white background image. If the verification fails, a pending white background label is output, and the user-input image is labeled as a pending white background image. If it is not a white background image, a weak rule judgment for white background images is performed. This involves filtering images based on whether the proportion of white pixels on the image's border to the entire image or the proportion of white pixels on the border to the border is sufficient. Images where the main image features of the object are relatively large compared to the entire image are then considered separately, and it is determined whether the proportion of all four sides of the image is left blank, which meets the conditions for a white background image. Even after the weak rule judgment for white background images, the image is still considered a white background image. Figure 2 If the verification fails, a "non-white background" label will be output, and the image entered by the user will be labeled as a "non-white background" image; if the verification passes, a "white background" label will be output, and the image entered by the user will be labeled as a "white background" image.
[0054] This system enables overall image filtering and mode conversion, transparent background image detection, strong and weak rule layer combinations for white background images, and secondary filtering of white background images, used to distinguish white background images, transparent background images, and non-white background images in DAM materials.
[0055] like Figure 1 The implementation flow of an image processing method according to a complete embodiment of this application is shown. For ease of explanation, only the parts related to the embodiment of this application are shown, and are described in detail below:
[0056] An image processing method according to an embodiment of this application includes the following steps:
[0057] S101: Determine whether the color space values of the image to be identified have an alpha channel;
[0058] S102: When there is an alpha channel, identify whether the proportion of the transparent area of the image to be identified is greater than a first preset value. If it is greater, determine whether the image features of the image to be identified meet the definition of a transparent background image. If they meet the definition, mark the transparent background image label. If they do not meet the definition, mark the non-white background image label.
[0059] S103: If the proportion of transparent area in the image 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 proportion of white pixels in the image to be identified is greater than the second preset value. If it is greater, determine whether the image features of the image to be identified meet the definition of a white background image. If it does, mark it with a white background image label. If it does not, mark it with a pending white background image label.
[0060] In step S101: It is determined whether the color space value of the image to be identified has an alpha channel. After the user uploads the image, the image to be identified is obtained, and it is determined whether the color space value (RGBA) of the image to be identified has an alpha channel (A channel).
[0061] In one embodiment, before determining whether the color space values of the image to be identified have an alpha channel, the method further includes: parsing the image to be identified and converting the color mode of the image to RGBA or RGB mode. In this embodiment, the color mode of the image is uniformly converted to RGBA or RGB mode when reading the image, which facilitates subsequent processing.
[0062] In one embodiment, when determining whether an image has a transparent or white background, a pre-filter is first applied. This involves checking if the length of the longest side of the image is less than a threshold T1. If it is, the image is directly labeled as a non-white background image. In other words, if the length of the longest side is less than the threshold T1, it is directly classified as a non-white background image, increasing system efficiency. Here, T1 is set to a default value of 30. This rule is based on user experience, meaning that excessively small white background images are unlikely.
[0063] In step S102: Transparent background image definition recognition is performed on the image to be recognized. When the color space value of the image to be recognized has an alpha channel, the percentage of the transparent area of the image to be recognized is checked to see if it is greater than a first preset value. If it is, it is determined whether the image features of the image to be recognized meet the definition of a transparent background image. If it does, a transparent background image label is added; otherwise, a non-white background image label is added. That is, when the RGBA of the image to be recognized has an A channel, the image to be recognized may be a transparent background image. The percentage of the transparent area of the image to be recognized is used to determine whether the image to be recognized is a transparent background image or a non-transparent background image. If the percentage meets the conditions for a transparent background image, it is further determined whether it is a defined transparent background image through the functional definition of a transparent background image (i.e., the definition of a transparent background image mentioned above). If it is a defined transparent background image, the image to be recognized is determined to be a transparent background image, and a transparent background image label is added to the image to be recognized. If it is not a defined transparent background image, it is determined to be a non-white background image, and a non-white background image label is added to the image to be recognized. If the percentage does not meet the conditions for a transparent background image, the image may be a white background image, and white background image recognition logic is then performed subsequently. Meanwhile, when the image does not have an A channel, the subsequent white background image recognition logic is performed. It should be noted that the image features to be recognized are the object features on the image, such as product patterns, image patterns, logo patterns, text patterns, etc. The first preset value can be set based on the actual scenario and requirements. For example, the first preset value can be set to the upper limit of the A channel in the alpha channel and the minimum ratio of the minimum or maximum pixel value of the image to the pixels of the alpha channel. For instance, setting the upper limit to 230 and the minimum ratio to 0.008 can filter images with transparent backgrounds that do not have a transparency effect.
[0064] In one embodiment, determining whether the proportion of transparent areas in the image to be identified is greater than a first preset value includes: determining whether the minimum value of the channel pixels of the alpha channel in the image to be identified is less than a threshold T2. If it is less than T2 and the ratio of the number of pixels with the minimum value to the number of channel pixels of the alpha channel is greater than a threshold T3, then the proportion of transparent areas in the image to be identified is greater than the first preset value; otherwise, it is not greater. Therefore, images that, although containing an A channel (i.e., images that may have a transparent background), have a small proportion of transparent areas that does not meet the requirements of a transparent image can be filtered out. This allows for fast filtering, ensuring both high accuracy and high recall. Here, thresholds T2 and T3 are the aforementioned first preset values, which can be set according to actual needs and scenarios. In this embodiment, T2 defaults to 230, and T3 defaults to 0.008, used to filter images with transparent backgrounds that do not have a transparent effect.
[0065] In one embodiment, determining whether the image features of the image to be identified satisfy the definition of a transparent background image includes: converting the image to be identified into a grayscale image, calculating the pixel histogram of the transparent area, and if there is a pixel value whose percentage of the total number of pixels in the transparent area is greater than threshold T4, and the percentage of a single pixel value in the total number of pixels in the transparent area is greater than threshold T5, or the sum of the percentages of multiple pixel values in the total number of pixels in the transparent area is greater than threshold T6, then the definition of a transparent background image is satisfied; otherwise, it is determined that it is not satisfied. This achieves efficient and accurate recognition of transparent background images, marking the image to be identified as having a transparent or non-transparent background. Here, thresholds T4, T5, and T6 can be set according to actual needs and scenarios. In this embodiment, the default value for T4 is 0.1, the default value for T5 is 0.95, and the default value for T6 is 0.8, used to filter out some text with white backgrounds, UI design images, and logo images, etc.
[0066] Specifically, such as Figure 3-1 This is a flowchart of the main processing steps for transparent images in the image processing method provided in this application embodiment. Step a: Channel determination: If the image has 4 channels, i.e., RGBA mode, proceed to step b; otherwise, proceed to the white background image filtering part. Step b: Proportion determination: If the minimum value of the pixel value in channel A is less than the threshold T2, and the proportion of the minimum value pixel value to the total number of pixels in channel A is greater than the threshold T3, proceed to step c; otherwise, proceed to the white background image filtering part. Here, the default value of T2 is 230, and the default value of T3 is 0.008; this item is used to filter images with no transparency effect on the transparent background. Step c: Functionality determination: Convert the image to be identified into a grayscale image, calculate the pixel histogram of the transparent part, if there is a pixel value whose proportion to the total number of pixels in the transparent area is greater than the threshold T4, and the proportion of a single pixel value to the total number of pixels in the transparent part is greater than the threshold T5, or the sum of the proportions of multiple pixel values to the total number of pixels in the transparent part is greater than the threshold T6, then it is determined to be a transparent background image, and the process ends; otherwise, it is determined to be a non-white background image, and the process ends. Here, the default value for T4 is 0.1, for T5 it is 0.95, and for T6 it is 0.8; this item is used to filter out text images with white backgrounds, UI design images, and logo images, etc. After determining whether an image is a white background image, a transparent background image, or a non-white background image, the image to be identified is labeled with a white background image label, a transparent background image label, or a non-white background image label.
[0067] It should be noted that histograms are a common method in computer image processing. The range of pixel values in an image is [0, 255]. The pixel histogram is obtained by calculating the proportion of each pixel value to the total number of pixels in the image. For example, if the image size is M*N, and there are b pixels with a value of 'a', then the histogram value for coordinate 'a' is b / (M*N).
[0068] In step S103: Strong rule recognition of the white background image and white background are performed on the image to be recognized. Figure 2First filtering, that is, identifying whether the white background of the image to be identified satisfies the preset threshold condition, and whether the identified white-background image meets the definition of a white-background image.
[0069] If the proportion of the transparent area of the image to be identified is not greater than the first preset value or when the color space value does not have an alpha channel, that is, when the image to be identified cannot be a transparent-bottom image and may be a white-bottom image, identify whether the proportion of the number of white pixels in the image to be identified to the total number of pixels in the whole image is greater than the second preset value. If it is greater, judge whether the image features of the image to be identified meet the definition of a white-bottom image. If they meet, mark the white-bottom image label; if they do not meet, mark the pending white-bottom image label. That is, perform a white-bottom image determination on the image to be identified, implementing a strong rule for the white-bottom image judgment rule, where the strong rule is determined by the proportion of the white border, that is, the overall color proportion; at the same time, implement a secondary filtering of the white-bottom image based on the definition of the white-bottom image. Here, the second preset value can be set based on the actual scenario and requirements. The second preset can be a parameter or multiple parameters. For example, the threshold (second preset value) of the proportion of white pixels in the border area or the whole image can be directly set to 0.4, thereby filtering out images with too small white-bottom proportions.
[0070] In one embodiment, identifying whether the proportion of white pixels in the image to be identified is greater than the second preset value includes: converting the image to be identified into a grayscale image, calculating the pixel histogram. If the pixel values within a preset proportion D1 of the center of the image edge are all greater than the threshold T7, and the proportion of the number of pixel values greater than the threshold T8 within this range is greater than the threshold T9, and the proportion of the number of pixel values greater than the threshold T10 in the whole image is greater than the threshold T11, then the proportion of white pixels in the image to be identified is greater than the second preset value; otherwise, it is not greater. Thus, a strong rule for the white-bottom image judgment rule is implemented, where the strong rule is determined by the proportion of the white border, that is, the overall color proportion. Here, T7, T8, T9, T10, and T11 are the second preset values, and the values of D1, T7, T8, T9, T10, and T11 can be set based on the actual scenario and requirements, and are used to filter out images with significantly too small borders by the proportion of the white border, that is, the overall color proportion. In this embodiment, D1 is defaulted to 10%, T7 is defaulted to 200, T8 is defaulted to 240, T9 is defaulted to 0.3, T10 is defaulted to 240, and T11 is defaulted to 0.6.
[0071] It should be noted that the proportion of the number of pixel values greater than the threshold T8 within this range is the proportion of the number of pixels with pixel values greater than T8 to the total number of pixels in the area formed by the range of the proportion D1 of the four sides of the image from the center of the image (such as the area of the 'hui' character, the large 'kou' minus the small 'kou' inside). The total number of pixels in the whole image, that is, the total number of pixels in the whole image. If the height of the image is h and the width is w, then the number of pixels N = h * w; among the N pixels, the number of pixels greater than the threshold T10 is M, and the proportion is M / N.
[0072] In one embodiment, determining whether the image features of the image to be identified satisfy the definition of a white background image includes: calculating a pixel histogram, obtaining the proportion of each pixel value in the range [0, 255] to the total number of pixels from the histogram; if there is a pixel value whose proportion of the total number of pixels in the image is greater than a threshold T12, and the sum of the proportions of multiple pixel values to the total number of pixels in the image is greater than a threshold T13, then it is determined that the image does not satisfy the definition; otherwise, based on a preset pooling operation region value V1 and a preset pixel distance V2 between two pooling operations, max pooling sampling is performed on the image to be identified. If the number of pixel values after pooling is less than a threshold T30, then the image does not satisfy the definition; if the number of pixel values after pooling is not less than a threshold T30, then the image satisfies the definition. Thus, based on the definition of a white background image, a secondary filtering of the obtained white background image is achieved. That is, as a product white background image, the distribution of its image pixels should be relatively scattered, without a concentrated proportion of colors; otherwise, it is likely a text foreground white background image or a UI-type solid color foreground white background image. Here, the values of T12, T13, V1, V2, and T30 can be set based on the actual scenario and requirements. In this embodiment, the default value of T12 is 0.1, the default value of T13 is 0.8, the pooling operation region value kernel = V1 and the preset pixel distance stride = V2 between two pooling operations are set, the default values of V1 and V2 are 10, and the default value of T30 is 30.
[0073] In one embodiment, images that do not meet the white background image criteria after strong rule judgment are subjected to weak rule judgment. This allows for the selection of images where the main image features of the object occupy a relatively large proportion of the overall image, considering only whether the proportion of white space on all four sides of the image meets the white background image criteria. White background images that meet the weak rule judgment are also subjected to secondary white background image filtering. Specifically, this includes: if the proportion of white pixels in the image to be identified is not greater than a second preset value, determining whether the proportion of pixels whose edge distance from the center preset ratio D2 border pixel value is equal to the threshold T40 is greater than the threshold T14. If yes, the first step is executed; if not, determining whether the proportion of pixels whose edge distance from the center preset ratio D3 border pixel value is greater than the threshold T41 border pixel value is greater than the threshold T15. If yes, the first step is executed. The first step includes: performing max pooling sampling on the image to be identified based on a preset pooling operation region value V3 and a preset pixel distance V4 between two pooling operations; if the number of pixel values after pooling is less than a threshold V5, the image to be identified is labeled with a pending white background image label; otherwise, the pixel histogram of the pooled image is calculated; if there are pixel values with a proportion greater than T23 and the sum of the proportions of multiple pixel values is greater than T24, the image to be identified is labeled with a pending white background image label; otherwise, the outline of the main body of the object in the image is calculated and the bounding moments are obtained; the objects whose bounding moments are between thresholds T25 and T26 are filtered out; if the number of remaining objects in the image is greater than threshold V6, the image to be identified is labeled with a non-white background image label; otherwise, the difference between the length and width of the bounding moments of the remaining objects in the image and the corresponding length and width of the image is calculated; when the difference is less than threshold T27, the image to be identified is labeled with a pending white background image label; otherwise, the image to be identified is labeled with a white background image label. This establishes a weak rule for determining a white background image: if a portion of the image's main subject occupies a relatively large proportion of the overall image, then we consider whether the proportion of white space on all four sides of the image meets the criteria for a white background image before further filtering. This filtering of the two weak white background image rules increases the robustness of the weak rule. The primary considerations remain images with white backgrounds and text foregrounds or solid-color foregrounds typical of UI elements. We also add a check for the number of main objects. If more than two main objects are detected, the image is highly likely a promotional or display image, 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, and T41 can be set based on the actual scenario and requirements.In this embodiment, the default value of T40 is 255, the default value of T41 is 250, the default value of D2 is 10%, the default value of T14 is 0.2, the default value of D3 is 5%, the default value of T15 is 0.8, the default value of V3 is 10, the default value of V4 is 10, the default value of V5 is 30, the default value of T23 is 0.1, the default value of T24 is 0.8, the default value of T25 is 0.01, the default value of T26 is 0.99, the default value of V6 is 2, and the default value of T27 is 5.
[0074] In one embodiment, after judging the image using weak rules based on the white background, the judgment standard is further lowered to identify the image again, so as to identify some white background images where the main product is not in the center of the image, but occupies the edge or corner of the image. Specifically, the process includes: If the percentage of pixels with a border value greater than T41 at a preset distance D3 from the center of the image edge does not exceed a threshold T15, then the following steps are executed: Calculate the average pixel value in the four corner regions of the image at a preset distance D4 from the center. Calculate the difference in the average pixel value between any two adjacent corner regions in descending order of the average pixel value. Select the three corner regions with the smallest difference. If the maximum difference in the average pixel value of the three corner regions with the smallest difference exceeds a threshold T42 or exceeds a threshold T16, then proceed to the second step. Otherwise, calculate the average pixel value in the edge regions at a preset distance D5 from the center of the image edge. Select the two edge regions and three corner regions with the smallest average pixel value between the edge regions and the corner regions. If the difference in the average pixel value between the two edge regions exceeds a threshold T17, or the maximum difference between the average pixel value of the three corner regions and the average pixel value of the two edge regions exceeds a threshold T18, or the maximum difference in the average pixel value between the two edge regions exceeds a threshold T19, then proceed to the second step. Otherwise, proceed to the third step. The second step includes: calculating the average pixel value and pixel difference of the four corners of the image from the center at a preset distance D6. If the maximum value of the average pixel value is greater than the threshold T20 or the maximum value of the pixel difference is greater than the threshold T21, then the image to be identified is labeled as a non-white background image; otherwise, the third step is executed. The third step includes: if the proportion of pixels with a value greater than T43 in the selected two edge regions and three corner regions is greater than the threshold T22, then the first step is executed; otherwise, the image to be identified is labeled as a non-white background image. Thus, based on the weak white background image rule, the standard is lowered again. Considering that some white background images may have the main body of the product not in the center of the image, but occupying the edge or corner of the image, the design rules determine whether the three corners and two sides of the image meet the necessary conditions. Furthermore, considering that the main body of some white background images is too large and will occupy the entire image, the system logic at the four corners of the image considers whether the small area meets the white background image condition. For these images, the highest level of the system logic can only classify them as pending white background images for user filtering. Here, the values of D3, T41, T15, D4, T42, T16, D5, T17, T18, T19, D6, T20, T21, T43, and T22 can be set based on the actual scenario and requirements.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.
[0075] Specifically, as shown in the figure Figure 3-2 This is a flowchart illustrating the main white background image processing steps of the image processing method provided in this application embodiment, specifically implementing white background image recognition and marking based on the functional definition of the white background image. Combined with... Figure 3-2 The specific logic is explained in detail below:
[0076] Step a. White pixel percentage filtering: Convert the image to be identified into a grayscale image. If all pixels within the range of the image edge distance D1 are greater than the threshold T7, and the percentage of pixels within this range greater than the threshold T8 is greater than the threshold T9, and the percentage of pixels in the entire image greater than the threshold T10 is greater than the threshold T11, proceed to step b; otherwise, proceed 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.
[0077] Step b. Histogram pixel value proportion filtering: Calculate the pixel histogram. If there are pixel values with a proportion greater than the threshold T12, and the sum of the proportions of multiple pixels is greater than the threshold T13, then the image is classified as a pending white background image, and the process ends; otherwise, proceed to step c. Here, the default value of T12 is 0.1, and the default value of T13 is 0.8.
[0078] Step c. Pooling Pixel Value Ratio Filtering: Set kernel = V1 and stride = V2, perform max pooling sampling. If the number of pixel values after pooling is less than the threshold T30, it is classified as an undetermined white background image, and the process ends; otherwise, it is classified as a white background image, and the process ends. Here, the default value of V1 is 10, the default value of V2 is 10, and the default value of T30 is 30.
[0079] Step d. If the percentage of the entire image with a border pixel value of 255 (D2) is greater than the threshold T14, proceed to step j; otherwise, proceed to step e. Here, the default value for D2 is 10%, and the default value for T14 is 0.2.
[0080] Step e. If the D3 border pixel count is greater than 250 and the border percentage is greater than the threshold T15, proceed to step j; otherwise, proceed to step f. Here, the default value for D3 is 5%, and the default value for T15 is 0.8.
[0081] Step f. Calculate the D4 mean of the four corners of the image. Select the three corners with the smallest differences in order. If the maximum difference of the triangular mean is greater than the threshold 3, or the maximum difference of the pixel values in the corner region is greater than the threshold T16, proceed to step h; otherwise, proceed to step g. (Here, the default value for D4 is 3%, and the default value for T16 is 10%.)
[0082] Step g. Calculate the average pixel value of the four-sided region according to edge D5. Select the two sides with the smallest average edge value and triangular average value. If the difference between the average values of the two sides is greater than threshold T17, or the difference between the triangular average value and the average values of the two sides is greater than threshold T18, or the maximum difference in pixel values of the two sides is greater than threshold T19, proceed to step h; otherwise, proceed to step i. Here, the default value of D5 is 5, the default value of T17 is 3, the default value of T18 is 3, and the default value of T19 is 10.
[0083] Step h. If the mean difference of pixels in the four corner D6 regions is greater than the threshold T20, and the maximum value of the pixel difference is greater than the threshold T21, output a non-white background image and the process ends; otherwise, proceed to step i. Here, the default value of D6 is 10, the default value of T20 is 3, and the default value of T21 is 10.
[0084] Step i. If the selected area has more than 235 pixels and its percentage is greater than the threshold T22, proceed to step j; otherwise, if the background is not white, the process ends. Here, the default value of T22 is 0.8.
[0085] Step j. Set kernel = V3 and stride = V4, and perform max pooling sampling. If the number of pixel values after pooling is less than V5, it is classified as an undetermined white background image, and the process ends; otherwise, proceed to step k. Here, the default value of V3 is 10, the default value of V4 is 10, and the default value of V5 is 30.
[0086] Step k. For the pooled image, calculate the pixel histogram. If there are pixel values with a proportion greater than T23, and the sum of the proportions of multiple pixels is greater than T24, then the image is classified as a pending white background image, and the process ends; otherwise, proceed to step l. Here, the default value of T23 is 0.1, and the default value of T24 is 0.8.
[0087] Step 1. Calculate the outline of the main subject in the image and obtain its bounding moments. If the area of a subject exists between T25 and T26, save the coordinate range and area set of the subject. Filter the saved subjects, removing those that are completely contained within the image. If the number of remaining subjects is greater than V6, they are classified as non-white background images, and the process ends; otherwise, proceed to step m. Here, the default value for T25 is 0.01, the default value for T26 is 0.99, and the default value for V6 is 2.
[0088] Step m. If the difference between the length or width of the subject and the length or width of the image is less than T27, it is classified as a non-white background image, and the process ends; otherwise, it is classified as a white background image, and the process ends. Here, the default value of T27 is 5.
[0089] In this embodiment, steps a, b, and c can be categorized as strong rules for determining white background images. Rule a is determined by the proportion of white borders, i.e., the overall color proportion. Steps b and c perform strong filtering on the obtained white background image. That is, as a product white background image, its pixel distribution should be relatively scattered, without a concentrated color proportion; otherwise, it is likely a text foreground with a white background or a UI-type solid color foreground with a white background image. Steps d and e are weak rules for determining white background images. That is, some image subjects occupy a relatively large proportion of the entire image. Therefore, at this time, we consider whether the proportion of all four sides of the image with white space meets the conditions for a white background image before performing subsequent filtering. Steps f, g, h, and i further lower the standards based on rules d and e. Considering that some white background images may have the main product not in the center but occupying the edges or corners, rules are designed to determine if the three corners and two sides of the image meet the necessary conditions. Furthermore, considering that some white background images have excessively large main parts that occupy the entire image, the system considers whether the small areas at the four corners of the image meet the white background condition. For these images, the highest level of system logic can only classify them as pending white background images for user filtering. Steps j, k, l, and m filter the above two weak white background image rules, increasing the robustness of the weak rules. The main considerations remain images with white backgrounds and text foregrounds or solid-color foregrounds for UI elements, and a judgment on the number of main subjects is added. If more than two main subjects are detected, the image is highly likely a display or promotional image, not a functional white background image.
[0090] This application's design does not directly classify images that pass weak rule and filtering checks as white background images. Instead, it classifies images that pass multiple checks as pending white background images, allowing users to perform secondary filtering. This approach ensures the accuracy of white background image classification while maximizing recall and saving users significant time in distinguishing between them.
[0091] The above process is the general process framework involved in this invention. Based on this, the framework can be further upgraded for specific scenarios. For example, for fixed vertical categories (only a certain type of product will appear), algorithms such as object detection and OCR can be added to filter non-target images and increase the robustness of the framework.
[0092] The default parameters involved in this application process can be used directly, and can be adjusted appropriately for specific scenarios to improve the overall effect.
[0093] Therefore, the image processing method provided in this application embodiment determines whether the color space value of the image to be identified has an alpha channel; when it has an alpha channel, it determines whether the proportion of transparent areas in the image to be identified is greater than a first preset value. If it is greater, it determines whether the image features of the image to be identified meet the definition of a transparent background image. If it does, it marks the image as a transparent background image; if it does not, it marks it as a non-white background image. If the proportion of transparent areas in the image to be identified is not greater than the first preset value, or when the color space value does not have an alpha channel, it determines whether the proportion of white pixels in the image to be identified is greater than a second preset value. If it is greater, it determines whether the image features of the image to be identified meet the definition of a white background image. If it does, it marks the image as a white background image; if it does not, it marks it as a pending white background image. This solves the technical problem of coarse granularity and inaccurate classification of white background images in related technologies, and achieves the following beneficial effects: it redefines the functions of white background images and transparent background images, maximizes the recall of the white background images and transparent background images desired by users, and improves the efficiency and accuracy of image classification and labeling.
[0094] It should be noted that image contour detection is a technique in digital image processing. By setting a threshold, grayscale image pixels can be divided into black and white, allowing the calculation of the subject's contour. Figure 5-1 This is the original RGB image (an image with colors). Figure 5-2 This is the binary image obtained after thresholding the grayscale image. Figure 5-3 To visualize the minimum bounding rectangle of the contour, we can obtain the number and area ratio of objects in a white background image, which allows us to perform relevant filtering.
[0095] like Figure 6-1 An example image of max pooling sampling provided in the embodiments of this application (positions 1, 1, 5, and 6 in the upper left corner are orange; positions 2, 4, 7, and 8 in the upper right corner are green; positions 3, 2, 1, and 2 in the lower left corner are blue; and positions 1, 0, 3, and 4 in the lower right corner are pink). Max pooling is also a technique in digital image processing, a sampling technique for images. Max pooling can maintain the main pixel information of the image while scaling it, such as... Figure 6-1 As shown, this represents max pooling with kernel=2 and stride=2, where kernel represents the length of the sampling region in each iteration, and stride represents the interval between the start position of the next sample and the start position of the current sample. For some UI images, where the main body is a solid color and the background is white, max pooling removes a small number of pixels in the transition between the main body and the background, and the remaining pixels represent the overall pixel distribution of the image.
[0096] like Figure 6-2Example diagrams of the edge and corner regions of an image in the image processing method provided in this application embodiment are provided. The processing flow of the border and four corner regions involved in the above embodiment is further explained. The height of the image is H and the width is W. For example, the border D1 pixel region range (D1 = 50) is selected, as shown in the white area in Figure (a); the border D2 region range (D2 = 10%) is selected, as shown in the white area in Figure (b); the four corner D3 region range (D3 = 10%) is selected, as shown in the black area in Figure (c); the four corner D4 region range (D3 = 5%) is selected, as shown in the black area in Figure (d).
[0097] Figure 7 The diagram shows the main modules of the image processing system provided in the embodiments of this application. For ease of explanation, only the parts related to the embodiments of this application are shown, and are described in detail below:
[0098] An image processing system 200 includes:
[0099] The recognition unit 201 is used to determine whether the color space values of the image to be recognized have an alpha channel;
[0100] The transparent image labeling unit 202 is used to identify whether the proportion of the transparent area of the image to be identified is greater than a first preset value when there is an alpha channel. If it is greater, it determines whether the image features of the image to be identified meet the definition of a transparent background image. If it does, it labels the image with a transparent background image; if it does not, it labels the image with a non-white background image.
[0101] The white background image marking unit 203 is used to identify whether the proportion of white pixels in the image to be identified is greater than a second preset value if the proportion of transparent area in the image to be identified is not greater than a first preset value or when the color space value does not have an alpha channel. If it is greater, it determines whether the image features of the image to be identified meet the definition of a white background image. If it does, it marks the image with a white background image label. If it does not, it marks the image with a pending white background image label.
[0102] The recognition unit 201 is used to determine whether the color space values of the image to be recognized have an alpha channel. After the user uploads the image, the image to be recognized is obtained, and it is determined whether the color space values (RGBA) of the image to be recognized have an alpha channel (A channel).
[0103] In one embodiment, before determining whether the color space values of the image to be identified have an alpha channel, the method further includes: parsing the image to be identified and converting the color mode of the image to RGBA or RGB mode. In this embodiment, the color mode of the image is uniformly converted to RGBA or RGB mode when reading the image, which facilitates subsequent processing.
[0104] In one embodiment, when determining whether an image has a transparent or white background, a pre-filter is first applied. This involves checking if the length of the longest side of the image is less than a threshold T1. If it is, the image is directly labeled as a non-white background image. In other words, if the length of the longest side is less than the threshold T1, it is directly classified as a non-white background image, increasing system efficiency. Here, T1 is set to a default value of 30. This rule is based on user experience, meaning that excessively small white background images are unlikely.
[0105] The transparent image labeling unit 202 is used to identify the transparent background image definition of the image to be identified. When the color space value of the image to be identified has an alpha channel, it identifies whether the percentage of the transparent area of the image to be identified is greater than a first preset value. If it is greater, it determines whether the image features of the image to be identified meet the transparent background image definition. If it does, it is labeled as a transparent background image; otherwise, it is labeled as a non-white background image. That is, when the RGBA of the image to be identified has an alpha channel, the image to be identified may be a transparent background image. The percentage of the transparent area of the image to be identified determines whether the image to be identified is a transparent background image or a non-transparent background image. If the percentage meets the transparent background image condition, it is further determined whether it is a defined transparent background image through the functional definition of transparent background image (i.e., the definition of transparent background image mentioned above). If it is a defined transparent background image, the image to be identified is determined to be a transparent background image, and the image to be identified is labeled as a transparent background image. If it is not a defined transparent background image, it is determined to be a non-white background image, and the image to be identified is labeled as a non-white background image. If the percentage does not meet the transparent background image condition, the image may be a white background image, and the subsequent white background image identification logic is performed. Meanwhile, when the image does not have an A channel, the subsequent white background image recognition logic is performed. It should be noted that the image features to be recognized are the object features on the image, such as product patterns, image patterns, logo patterns, text patterns, etc. The first preset value can be set based on the actual scenario and requirements. For example, the first preset value can be set to the upper limit of the A channel in the alpha channel and the minimum ratio of the minimum or maximum pixel value of the image to the pixels of the alpha channel. For instance, setting the upper limit to 230 and the minimum ratio to 0.008 can filter images with transparent backgrounds that do not have a transparency effect.
[0106] In one embodiment, determining whether the proportion of transparent areas in the image to be identified is greater than a first preset value includes: determining whether the minimum value of the channel pixels of the alpha channel in the image to be identified is less than a threshold T2. If it is less than T2 and the ratio of the number of pixels with the minimum value to the number of channel pixels of the alpha channel is greater than a threshold T3, then the proportion of transparent areas in the image to be identified is greater than the first preset value; otherwise, it is not greater. Therefore, images that, although containing an A channel (i.e., images that may have a transparent background), have a small proportion of transparent areas that does not meet the requirements of a transparent image can be filtered out. This allows for fast filtering, ensuring both high accuracy and high recall. Here, thresholds T2 and T3 are the aforementioned first preset values, which can be set according to actual needs and scenarios. In this embodiment, T2 defaults to 230, and T3 defaults to 0.008, used to filter images with transparent backgrounds that do not have a transparent effect.
[0107] In one embodiment, determining whether the image features of the image to be identified satisfy the definition of a transparent background image includes: converting the image to be identified into a grayscale image, calculating the pixel histogram of the transparent area, and if there is a pixel value whose percentage of the total number of pixels in the transparent area is greater than threshold T4, and the percentage of a single pixel value in the total number of pixels in the transparent area is greater than threshold T5, or the sum of the percentages of multiple pixel values in the total number of pixels in the transparent area is greater than threshold T6, then the definition of a transparent background image is satisfied; otherwise, it is determined that it is not satisfied. This achieves efficient and accurate recognition of transparent background images, marking the image to be identified as having a transparent or non-transparent background. Here, thresholds T4, T5, and T6 can be set according to actual needs and scenarios. In this embodiment, the default value for T4 is 0.1, the default value for T5 is 0.95, and the default value for T6 is 0.8, used to filter out some text with white backgrounds, UI design images, and logo images, etc.
[0108] Specifically, such as Figure 3-1This is a flowchart of the main processing steps for transparent images in the image processing method provided in this application embodiment. Step a: Channel determination: If the image has 4 channels, i.e., RGBA mode, proceed to step b; otherwise, proceed to the white background image filtering part. Step b: Proportion determination: If the minimum value of the pixel value in channel A is less than the threshold T2, and the proportion of the minimum value pixel value to the total number of pixels in channel A is greater than the threshold T3, proceed to step c; otherwise, proceed to the white background image filtering part. Here, the default value of T2 is 230, and the default value of T3 is 0.008; this item is used to filter images with no transparency effect on the transparent background. Step c: Functionality determination: Convert the image to be identified into a grayscale image, calculate the pixel histogram of the transparent part, if there is a pixel value whose proportion to the total number of pixels in the transparent area is greater than the threshold T4, and the proportion of a single pixel value to the total number of pixels in the transparent part is greater than the threshold T5, or the sum of the proportions of multiple pixel values to the total number of pixels in the transparent part is greater than the threshold T6, then it is determined to be a transparent background image, and the process ends; otherwise, it is determined to be a non-white background image, and the process ends. Here, the default value for T4 is 0.1, for T5 it is 0.95, and for T6 it is 0.8; this item is used to filter out text images with white backgrounds, UI design images, and logo images, etc. After determining whether an image is a white background image, a transparent background image, or a non-white background image, the image to be identified is labeled with a white background image label, a transparent background image label, or a non-white background image label.
[0109] It should be noted that histograms are a common method in computer image processing. The range of pixel values in an image is [0, 255]. The pixel histogram is obtained by calculating the proportion of each pixel value to the total number of pixels in the image. For example, if the image size is M*N, and there are b pixels with a value of 'a', then the histogram value for coordinate 'a' is b / (M*N).
[0110] The white background image labeling unit 203 is used for strong rule recognition of the white background image and white background in the image to be recognized. Figure 2Secondary filtering, that is, identifying whether the white background of the image to be recognized meets the preset threshold condition, and whether the recognized white background image meets the definition of a white background image. If the proportion of the transparent area in the image to be recognized is not greater than the first preset value or when the color space value does not have an alpha channel, that is, when the image to be recognized cannot be a transparent background image and may be a white background image, identify whether the proportion of the number of white pixels in the image to be recognized to the total number of pixels in the entire image is greater than the second preset value. If it is greater, determine whether the image features of the image to be recognized meet the definition of a white background image. If they meet, mark the white background image label; if not, mark the pending white background image label. That is, perform a white background image determination on the image to be recognized, implementing the strong rule of the white background image judgment rule, which is determined by the proportion of white in the border, that is, the overall color proportion; at the same time, implement a secondary filtering of the white background image based on the definition of the white background image. Here, the second preset value can be set based on the actual scenario and requirements. The second preset can be a parameter or multiple parameters. For example, the threshold (second preset value) of the proportion of white pixels in the border area or the entire image can be directly set to 0.4, thereby filtering out images with too small white background proportions.
[0111] In one embodiment, identifying whether the proportion of white pixels in the image to be recognized is greater than the second preset value includes: converting the image to be recognized into a grayscale image, calculating the pixel histogram. If the pixel values within the range of a preset ratio D1 from the center of the image edge are all greater than the threshold T7, and the proportion of the number of pixel values greater than the threshold T8 within this range is greater than the threshold T9, and the proportion of the number of pixel values greater than the threshold T10 in the entire image is greater than the threshold T11, then the proportion of white pixels in the image to be recognized is greater than the second preset value; otherwise, it is not greater. Thus, the strong rule of the white background image judgment rule is implemented, which is determined by the proportion of white in the border, that is, the overall color proportion. Here, T7, T8, T9, T10, and T11 are the second preset values, and the values of D1, T7, T8, T9, T10, and T11 can be set based on the actual scenario and requirements, and are used to filter out images with significantly too small borders by the proportion of white in the border, that is, the overall color proportion. In this embodiment, D1 is defaulted to 10%, T7 is defaulted to 200, T8 is defaulted to 240, T9 is defaulted to 0.3, T10 is defaulted to 240, and T11 is defaulted to 0.6.
[0112] It should be noted that the proportion of the number of pixel values greater than the threshold T8 within this range is the proportion of the number of pixels with pixel values greater than T8 to the total number of pixels in the shape (such as the area of the 'hui' character, the large 'kou' minus the internal small 'kou') enclosed by the range of the four sides of the image at a distance of D1 from the center of the image. The total number of pixels in the entire image, that is, the total number of pixels in the entire image. If the height of the image is h and the width is w, then the number of pixels N = h * w; among the N pixels, the number of pixels greater than the threshold T10 is M, and then the proportion is M / N.
[0113] In one embodiment, determining whether the image features of the image to be identified satisfy the definition of a white background image includes: calculating a pixel histogram, obtaining the proportion of each pixel value in the range [0, 255] to the total number of pixels from the histogram; if there is a pixel value whose proportion of the total number of pixels in the image is greater than a threshold T12, and the sum of the proportions of multiple pixel values to the total number of pixels in the image is greater than a threshold T13, then it is determined that the image does not satisfy the definition; otherwise, based on a preset pooling operation region value V1 and a preset pixel distance V2 between two pooling operations, max pooling sampling is performed on the image to be identified. If the number of pixel values after pooling is less than a threshold T30, then the image does not satisfy the definition; if the number of pixel values after pooling is not less than a threshold T30, then the image satisfies the definition. Thus, based on the definition of a white background image, a secondary filtering is performed on the obtained white background image. That is, as a product white background image, the distribution of its image pixels should be relatively scattered, without a concentrated proportion of colors; otherwise, it is likely a text foreground white background image or a UI-type solid color foreground white background image. Here, the values of T12, T13, V1, V2, and T30 can be set based on the actual scenario and requirements. In this embodiment, the default value of T12 is 0.1, the default value of T13 is 0.8, the pooling operation region value kernel = V1 and the preset pixel distance stride = V2 between two pooling operations are set, the default values of V1 and V2 are 10, and the default value of T30 is 30.
[0114] In one embodiment, images that do not meet the white background image criteria after strong rule judgment are subjected to weak rule judgment. This allows for the selection of images where the main image features of the object occupy a relatively large proportion of the overall image, considering only whether the proportion of white space on all four sides of the image meets the white background image criteria. White background images that meet the weak rule judgment are also subjected to secondary white background image filtering. Specifically, this includes: if the proportion of white pixels in the image to be identified is not greater than a second preset value, determining whether the proportion of pixels whose edge distance from the center preset ratio D2 border pixel value is equal to the threshold T40 is greater than the threshold T14. If yes, the first step is executed; if not, determining whether the proportion of pixels whose edge distance from the center preset ratio D3 border pixel value is greater than the threshold T41 border pixel value is greater than the threshold T15. If yes, the first step is executed. The first step includes: performing max pooling sampling on the image to be identified based on a preset pooling operation region value V3 and a preset pixel distance V4 between two pooling operations; if the number of pixel values after pooling is less than a threshold V5, the image to be identified is labeled with a pending white background image label; otherwise, the pixel histogram of the pooled image is calculated; if there are pixel values with a proportion greater than T23 and the sum of the proportions of multiple pixel values is greater than T24, the image to be identified is labeled with a pending white background image label; otherwise, the outline of the main body of the object in the image is calculated and the bounding moments are obtained; the objects whose bounding moments are between thresholds T25 and T26 are filtered out; if the number of remaining objects in the image is greater than threshold V6, the image to be identified is labeled with a non-white background image label; otherwise, the difference between the length and width of the bounding moments of the remaining objects in the image and the corresponding length and width of the image is calculated; when the difference is less than threshold T27, the image to be identified is labeled with a pending white background image label; otherwise, the image to be identified is labeled with a white background image label. This establishes a weak rule for determining a white background image: if a portion of the image's main subject occupies a relatively large proportion of the overall image, then we consider whether the proportion of white space on all four sides of the image meets the criteria for a white background image before further filtering. This filtering of the two weak white background image rules increases the robustness of the weak rule. The primary considerations remain images with white backgrounds and text foregrounds or solid-color foregrounds typical of UI elements. We also add a check for the number of main objects. If more than two main objects are detected, the image is highly likely a promotional or display image, 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, and T41 can be set based on the actual scenario and requirements.In this embodiment, the default value of T40 is 255, the default value of T41 is 250, the default value of D2 is 10%, the default value of T14 is 0.2, the default value of D3 is 5%, the default value of T15 is 0.8, the default value of V3 is 10, the default value of V4 is 10, the default value of V5 is 30, the default value of T23 is 0.1, the default value of T24 is 0.8, the default value of T25 is 0.01, the default value of T26 is 0.99, the default value of V6 is 2, and the default value of T27 is 5.
[0115] In one embodiment, after judging the image using weak rules based on the white background, the judgment standard is further lowered to identify the image again, so as to identify some white background images where the main product is not in the center of the image, but occupies the edge or corner of the image. Specifically, the process includes: If the percentage of pixels with a border value greater than T41 at a preset distance D3 from the center of the image edge does not exceed a threshold T15, then the following steps are executed: Calculate the average pixel value in the four corner regions of the image at a preset distance D4 from the center. Calculate the difference in the average pixel value between any two adjacent corner regions in descending order of the average pixel value. Select the three corner regions with the smallest difference. If the maximum difference in the average pixel value of the three corner regions with the smallest difference exceeds a threshold T42 or exceeds a threshold T16, then proceed to the second step. Otherwise, calculate the average pixel value in the edge regions at a preset distance D5 from the center of the image edge. Select the two edge regions and three corner regions with the smallest average pixel value between the edge regions and the corner regions. If the difference in the average pixel value between the two edge regions exceeds a threshold T17, or the maximum difference between the average pixel value of the three corner regions and the average pixel value of the two edge regions exceeds a threshold T18, or the maximum difference in the average pixel value between the two edge regions exceeds a threshold T19, then proceed to the second step. Otherwise, proceed to the third step. The second step includes: calculating the average pixel value and pixel difference of the four corners of the image from the center at a preset distance D6. If the maximum value of the average pixel value is greater than the threshold T20 or the maximum value of the pixel difference is greater than the threshold T21, then the image to be identified is labeled as a non-white background image; otherwise, the third step is executed. The third step includes: if the proportion of pixels with a value greater than T43 in the selected two edge regions and three corner regions is greater than the threshold T22, then the first step is executed; otherwise, the image to be identified is labeled as a non-white background image. Thus, based on the weak white background image rule, the standard is lowered again. Considering that some white background images may have the main body of the product not in the center of the image, but occupying the edge or corner of the image, the design rules determine whether the three corners and two sides of the image meet the necessary conditions. Furthermore, considering that the main body of some white background images is too large and will occupy the entire image, the system logic at the four corners of the image considers whether the small area meets the white background image condition. For these images, the highest level of the system logic can only classify them as pending white background images for user filtering. Here, the values of D3, T41, T15, D4, T42, T16, D5, T17, T18, T19, D6, T20, T21, T43, and T22 can be set based on the actual scenario and requirements.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.
[0116] Specifically, as shown in the figure Figure 3-2 This is a flowchart illustrating the main white background image processing steps of the image processing method provided in this application embodiment, specifically implementing white background image recognition and marking based on the functional definition of the white background image. Combined with... Figure 3-2 The specific logic is explained in detail below:
[0117] Step a. White pixel percentage filtering: Convert the image to be identified into a grayscale image. If all pixels within the range of the image edge distance D1 are greater than the threshold T7, and the percentage of pixels within this range greater than the threshold T8 is greater than the threshold T9, and the percentage of pixels in the entire image greater than the threshold T10 is greater than the threshold T11, proceed to step b; otherwise, proceed 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.
[0118] Step b. Histogram pixel value proportion filtering: Calculate the pixel histogram. If there are pixel values with a proportion greater than the threshold T12, and the sum of the proportions of multiple pixels is greater than the threshold T13, then the image is classified as a pending white background image, and the process ends; otherwise, proceed to step c. Here, the default value of T12 is 0.1, and the default value of T13 is 0.8.
[0119] Step c. Pooling Pixel Value Ratio Filtering: Set kernel = V1 and stride = V2, perform max pooling sampling. If the number of pixel values after pooling is less than the threshold T30, it is classified as an undetermined white background image, and the process ends; otherwise, it is classified as a white background image, and the process ends. Here, the default value of V1 is 10, the default value of V2 is 10, and the default value of T30 is 30.
[0120] Step d. If the percentage of the entire image with a border pixel value of 255 (D2) is greater than the threshold T14, proceed to step j; otherwise, proceed to step e. Here, the default value for D2 is 10%, and the default value for T14 is 0.2.
[0121] Step e. If the D3 border pixel count is greater than 250 and the border percentage is greater than the threshold T15, proceed to step j; otherwise, proceed to step f. Here, the default value for D3 is 5%, and the default value for T15 is 0.8.
[0122] Step f. Calculate the D4 mean of the four corners of the image. Select the three corners with the smallest differences in order. If the maximum difference of the triangular mean is greater than the threshold 3, or the maximum difference of the pixel values in the corner region is greater than the threshold T16, proceed to step h; otherwise, proceed to step g. (Here, the default value for D4 is 3%, and the default value for T16 is 10%.)
[0123] Step g. Calculate the average pixel value of the four-sided region according to edge D5. Select the two sides with the smallest average edge value and triangular average value. If the difference between the average values of the two sides is greater than threshold T17, or the difference between the triangular average value and the average values of the two sides is greater than threshold T18, or the maximum difference in pixel values of the two sides is greater than threshold T19, proceed to step h; otherwise, proceed to step i. Here, the default value of D5 is 5, the default value of T17 is 3, the default value of T18 is 3, and the default value of T19 is 10.
[0124] Step h. If the mean difference of pixels in the four corner D6 regions is greater than the threshold T20, and the maximum value of the pixel difference is greater than the threshold T21, output a non-white background image and the process ends; otherwise, proceed to step i. Here, the default value of D6 is 10, the default value of T20 is 3, and the default value of T21 is 10.
[0125] Step i. If the selected area has more than 235 pixels and its percentage is greater than the threshold T22, proceed to step j; otherwise, if the background is not white, the process ends. Here, the default value of T22 is 0.8.
[0126] Step j. Set kernel = V3 and stride = V4, and perform max pooling sampling. If the number of pixel values after pooling is less than V5, it is classified as an undetermined white background image, and the process ends; otherwise, proceed to step k. Here, the default value of V3 is 10, the default value of V4 is 10, and the default value of V5 is 30.
[0127] Step k. For the pooled image, calculate the pixel histogram. If there are pixel values with a proportion greater than T23, and the sum of the proportions of multiple pixels is greater than T24, then the image is classified as a pending white background image, and the process ends; otherwise, proceed to step l. Here, the default value of T23 is 0.1, and the default value of T24 is 0.8.
[0128] Step 1. Calculate the outline of the main subject in the image and obtain its bounding moments. If the area of a subject exists between T25 and T26, save the coordinate range and area set of the subject. Filter the saved subjects, removing those that are completely contained within the image. If the number of remaining subjects is greater than V6, they are classified as non-white background images, and the process ends; otherwise, proceed to step m. Here, the default value for T25 is 0.01, the default value for T26 is 0.99, and the default value for V6 is 2.
[0129] Step m. If the difference between the length or width of the subject and the length or width of the image is less than T27, it is classified as a non-white background image, and the process ends; otherwise, it is classified as a white background image, and the process ends. Here, the default value of T27 is 5.
[0130] In this embodiment, steps a, b, and c can be categorized as strong rules for determining white background images. Rule a is determined by the proportion of white borders, i.e., the overall color proportion. Steps b and c perform strong filtering on the obtained white background image. That is, as a product white background image, its pixel distribution should be relatively scattered, without a concentrated color proportion; otherwise, it is likely a text foreground with a white background or a UI-type solid color foreground with a white background image. Steps d and e are weak rules for determining white background images. That is, some image subjects occupy a relatively large proportion of the entire image. Therefore, at this time, we consider whether the proportion of all four sides of the image with white space meets the conditions for a white background image before performing subsequent filtering. Steps f, g, h, and i further lower the standards based on rules d and e. Considering that some white background images may have the main product not in the center but occupying the edges or corners, rules are designed to determine if the three corners and two sides of the image meet the necessary conditions. Furthermore, considering that some white background images have excessively large main parts that occupy the entire image, the system considers whether the small areas at the four corners of the image meet the white background condition. For these images, the highest level of system logic can only classify them as pending white background images for user filtering. Steps j, k, l, and m filter the above two weak white background image rules, increasing the robustness of the weak rules. The main considerations remain images with white backgrounds and text foregrounds or solid-color foregrounds for UI elements, and a judgment on the number of main subjects is added. If more than two main subjects are detected, the image is highly likely a display or promotional image, not a functional white background image.
[0131] Therefore, the image processing system provided in this application embodiment solves the technical problems of coarse granularity and inaccurate classification of white background images in related technologies, and achieves the following beneficial effects: it realizes a redefinition of the functions of white background images and transparent background images, maximizes the recall of the white background images and transparent background images that users want, and improves the efficiency and accuracy of image classification and labeling.
[0132] This application also provides an electronic device, including: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method of this application embodiment.
[0133] This application also provides a computer-readable medium storing a computer program thereon, which, when executed by a processor, implements the image processing method of this application.
[0134] Figure 8An exemplary system architecture 300 is shown that can be applied to the image processing methods or systems of the embodiments of this application.
[0135] like Figure 8 As shown, system architecture 300 may include terminal devices 301, 302, and 303, a network 304, and a server 305. Network 304 serves as the medium for providing communication links between terminal devices 301, 302, and 303 and server 305. Network 304 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0136] Users can use terminal devices 301, 302, and 303 to interact with server 305 via network 304 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 301, 302, and 303, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc.
[0137] Terminal devices 301, 302, and 303 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0138] Server 305 can be a server that provides various services, such as a backend management server that supports messages sent by users using terminal devices 301, 302, and 303. The backend management server can analyze and process requests received from terminal devices and then return the processing results to the terminal devices.
[0139] It should be noted that the image processing method provided in the embodiments of this application is generally executed by terminal devices 301, 302, 303 or server 305, and correspondingly, the image processing system is generally set in terminal devices 301, 302, 303 or server 305.
[0140] It should be understood that Figure 8 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0141] The following is for reference. Figure 9 It shows a schematic diagram of the structure of a computer system 400 suitable for implementing electronic devices according to embodiments of the present application. Figure 9 The computer system shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0142] like Figure 9As shown, the computer system 400 includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 402 or programs loaded from storage section 408 into random access memory (RAM) 403. The RAM 403 also stores various programs and data required for the operation of the system 400. The CPU 401, ROM 402, and RAM 403 are interconnected via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0143] The following components are connected to I / O interface 405: an input section 406 including a keyboard, mouse, etc.; an output section 407 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 408 including a hard disk, etc.; and a communication section 409 including a network interface card such as a LAN card, modem, etc. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to I / O interface 405 as needed. A removable medium 411, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 410 as needed so that computer programs read from it can be installed into storage section 408 as needed.
[0144] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 409, and / or installed from removable medium 411. When the computer program is executed by central processing unit (CPU) 401, it performs the functions defined above in the system of this application.
[0145] It should be noted that the computer-readable medium shown in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0146] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0147] The modules described in the embodiments of this application can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor can be described as including a determining module, an extraction module, a training module, and a filtering module. The names of these modules do not necessarily limit the module itself; for example, the determining module can also be described as a "module for determining a candidate user set".
[0148] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
[0149] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. An image processing method, characterized in that, include: Determine whether the color space values of the image to be identified have an alpha channel; When an alpha channel is used, the system identifies whether the proportion of transparent areas in the image to be identified is greater than a first preset value. If it is greater, the system determines whether the image features of the image to be identified meet the definition of a transparent background image. If they do, the system marks the image as a transparent background image; otherwise, it marks the image as a non-white background image. If the proportion of transparent area in the image 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 proportion of white pixels in the image to be identified is greater than the second preset value. If it is greater, determine whether the image features of the image to be identified meet the definition of a white background image. If it does, mark it with a white background image label. If it does not, mark it with a pending white background image label. The step of determining whether the image features of the image to be identified satisfy the definition of a transparent background image includes: converting the image to be identified into a grayscale image, calculating the pixel histogram of the transparent area, and if there are pixel values with a proportion greater than threshold T4, and the proportion of a single pixel value is greater than threshold T5 or the sum of the proportions of multiple pixel values is greater than threshold T6, then it is determined that the definition of a transparent background image is satisfied; otherwise, it is determined that it is not satisfied. The step of determining whether the image features of the image to be identified meet the definition of a white background image includes: if there are pixel values with a proportion greater than the threshold T12, and the sum of the proportions of multiple pixel values is greater than the threshold T13, then it is determined that the feature does not meet the definition; otherwise, based on the preset pooling operation region value V1 and the preset pixel distance V2 between two pooling operations, the image to be identified is subjected to maximum pooling sampling. If the number of pixel values after pooling is less than the threshold T30, then it is determined that the feature does not meet the definition; if the number of pixel values after pooling is not less than the threshold T30, then it is determined that the feature meets the definition.
2. The image processing method according to claim 1, characterized in that, Before determining whether the color space value of the image to be identified has an alpha channel, the process also includes: parsing the image to be identified, converting the color mode of the image to be identified to RGBA or RGB mode, determining whether the length of the longer side of the image to be identified is less than the threshold T1, and if it is less, labeling it as a non-white background image.
3. The image processing method according to claim 1 or 2, characterized in that, The step of identifying whether the proportion of transparent area in the image to be identified is greater than a first preset value includes: determining whether the minimum value of the channel pixels of the alpha channel in the image to be identified is less than a threshold T2. If it is less than a threshold T2 and the ratio of the number of minimum value pixels to the number of channel pixels of the alpha channel is greater than a threshold T3, then the proportion of transparent area in the image to be identified is greater than the first preset value; otherwise, it is not greater than a threshold T2.
4. The image processing method according to claim 1 or 2, characterized in that, The step of identifying whether the proportion of white pixels in the image to be identified is greater than a second preset value includes: converting the image to be identified into a grayscale image, calculating a pixel histogram, and if the pixel values within a preset ratio D1 from the edge of the image to the center are all greater than a threshold T7, and the proportion of pixel values greater than a threshold T8 within this range is greater than a threshold T9, and the proportion of pixel values greater than a threshold T10 in the entire image is greater than a threshold T11, then the proportion of white pixels in the image to be identified is greater than the second preset value; otherwise, it is not greater than the second preset value.
5. The image processing method according to claim 4, characterized in that, Also includes: If the proportion of white pixels in the image to be identified is not greater than the second preset value, determine whether the proportion of pixels whose edge distance from the center preset ratio D2 is equal to the threshold T40 is greater than the threshold T14. If yes, proceed to the first step; if no, determine whether the proportion of pixels whose edge distance from the center preset ratio D3 is greater than the threshold T41 is greater than the threshold T15. If yes, proceed to the first step. The first step includes: performing max pooling sampling on the image to be identified based on a preset pooling operation region value V3 and a preset pixel distance V4 between two pooling operations; if the number of pixel values after pooling is less than a threshold V5, the image to be identified is labeled with a pending white background image label; otherwise, the pixel histogram of the pooled image is calculated; if there are pixel values with a proportion greater than T23 and the sum of the proportions of multiple pixel values is greater than T24, the image to be identified is labeled with a pending white background image label; otherwise, the outline of the main body of the object in the image is calculated and the bounding moments are obtained; the objects whose bounding moments are between thresholds T25 and T26 are filtered out; if the number of remaining objects in the image is greater than threshold V6, the image to be identified is labeled with a non-white background image label; otherwise, the difference between the length and width of the bounding moments of the remaining objects in the image and the corresponding length and width of the image is calculated; when the difference is less than threshold T27, the image to be identified is labeled with a pending white background image label; otherwise, the image to be identified is labeled with a white background image label.
6. The image processing method according to claim 5, characterized in that, Also includes: If the percentage of pixels with a frame value greater than T41 at the edge of the image from the center at a preset ratio D3 is not greater than the threshold T15, then the following steps are performed: Calculate the average pixel value in each of the four corner regions of the image at a preset ratio D4 from the center. Calculate the difference between the average pixel values of each pair of adjacent corner regions in descending order of the average pixel value. Select the three corner regions with the smallest difference. If the maximum difference in the average pixel values of the three corner regions with the smallest difference is greater than the threshold T42 or the maximum difference in the average pixel values of the three corner regions with the smallest difference is greater than the threshold T16, then the second step is performed. Otherwise, calculate the average pixel value within the edge region at a preset distance D5 from the center of the image. Select the two edge regions and three corner regions with the smallest average pixel values between the edge regions and the corner regions. If the difference between the average pixel values of the two edge regions is greater than threshold T17, or the maximum difference between the average pixel values of the three corner regions and the average pixel values of the two edge regions is greater than threshold T18, or the maximum difference between the pixel values of the two edge regions is greater than threshold T19, then execute the second step; otherwise, execute the third step. The second step includes: calculating the average pixel value and pixel difference of the four corner regions at a preset distance D6 from the center of the image. If the maximum average pixel value is greater than threshold T20 or the maximum pixel difference is greater than threshold T21, then label the image to be identified as a non-white background image; otherwise, execute the third step. The third step includes: if the percentage of pixels with a region pixel value greater than threshold T43 in the selected two edge regions and three corner regions is greater than threshold T22, then execute the first step; otherwise, label the image to be identified as a non-white background image.
7. An image processing system, characterized in that, include: The recognition unit is used to determine whether the color space values of the image to be recognized have an alpha channel; The transparent image labeling unit is used to identify whether the proportion of the transparent area of the image to be identified is greater than a first preset value when there is an alpha channel. If it is greater, it determines whether the image features of the image to be identified meet the definition of a transparent background image. If it does, it labels the image with a transparent background image; if it does not, it labels the image with a non-white background image. The white background image marking unit is used to identify whether the proportion of white pixels in the image to be identified is greater than a second preset value if the proportion of transparent area in the image to be identified is not greater than a first preset value or when the color space value does not have an alpha channel. If it is greater, it determines whether the image features of the image to be identified meet the definition of white background image. If it does, it marks the white background image label. If it does not, it marks the pending white background image label. The step of determining whether the image features of the image to be identified satisfy the definition of a transparent background image includes: converting the image to be identified into a grayscale image, calculating the pixel histogram of the transparent area, and if there are pixel values with a proportion greater than threshold T4, and the proportion of a single pixel value is greater than threshold T5 or the sum of the proportions of multiple pixel values is greater than threshold T6, then it is determined that the definition of a transparent background image is satisfied; otherwise, it is determined that it is not satisfied. The step of determining whether the image features of the image to be identified meet the definition of a white background image includes: if there are pixel values with a proportion greater than the threshold T12, and the sum of the proportions of multiple pixel values is greater than the threshold T13, then it is determined that the feature does not meet the definition; otherwise, based on the preset pooling operation region value V1 and the preset pixel distance V2 between two pooling operations, the image to be identified is subjected to maximum pooling sampling. If the number of pixel values after pooling is less than the threshold T30, then it is determined that the feature does not meet the definition; if the number of pixel values after pooling is not less than the threshold T30, then it is determined that the feature meets the definition.
8. An electronic device, characterized in that, The method includes a memory and a processor, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of the image processing method according to any one of claims 1 to 6.