Skin color recognition method, device and electronic device
By directly matching the interval between the pixel value of the target pixel and the skin color category in the skin color recognition method, the problem of time-consuming and cost-effective skin color recognition is solved in the prior art.
Patent Information
- Application Number
- CN202110773480.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-08
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2041-07-08
AI Technical Summary
The existing skin color recognition methods are time-consuming and costly, and require a lot of manpower and financial costs for data annotation and in-depth model training.
By determining the target area in the image to be identified, the pixel value of the target pixel is obtained, and matching it based on the pixel value interval of the skin color category, the skin color category of the target object is directly determined without data annotation and depth model training.
It realizes a simple and efficient process of skin color recognition, saves manpower and time costs, and alleviates the time-consuming and cost-effective problems of existing methods.
Smart Images

Figure CN113674366B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a skin color recognition method, device and electronic equipment. Background Art
[0002] At present, before people choose skin care products, they often test their own skin through relevant equipment, and then choose the corresponding skin care products according to the test results. Among them, skin color recognition is a part of human skin testing.
[0003] Most of the existing human skin color recognition is based on deep learning image recognition technology, which classifies the input human images to distinguish the degree of skin color (fair, natural, wheat, dark, etc.).
[0004] For example, in order to achieve the purpose of human skin color recognition, it is necessary to train a human skin color recognition model in advance. When training a human skin color recognition model, it is necessary to collect human image data of the corresponding scene and annotate it, and then iterate the training model through supervised training, and then classify and identify human skin color through the trained human skin color model. The above annotation process requires a lot of manpower and financial resources, and data collection and iterative training require a certain amount of time.
[0005] In summary, existing skin color recognition methods have technical problems of being time-consuming and costly. Summary of the invention
[0006] In view of this, an object of the present invention is to provide a skin color recognition method, device and electronic device to alleviate the technical problems of the existing skin color recognition method being time-consuming and costly.
[0007] In a first aspect, an embodiment of the present invention provides a method for identifying skin color, comprising: determining a target area corresponding to a target object in an image to be identified; obtaining pixel values of at least a part of target pixels in the target area; wherein the target pixels belong to a skin area in the target area; and determining a target skin color category to which the target object belongs based on the pixel value and a pixel value interval corresponding to each skin color category.
[0008] In one embodiment, determining the target skin color category to which the target object belongs based on the pixel value and the pixel value intervals corresponding to each skin color category includes: calculating the pixel mean of at least a portion of the target pixels; matching the pixel mean with the pixel value intervals corresponding to each skin color category to determine the target skin color category to which the target object belongs.
[0009] In one embodiment, the pixel mean includes: the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel; the pixel value intervals corresponding to the skin color categories include: the pixel value intervals of the red channel corresponding to the skin color categories, the pixel value intervals of the green channel corresponding to the skin color categories and the pixel value intervals of the blue channel corresponding to the skin color categories; accordingly, the pixel mean of at least a portion of the target pixels is calculated, including: respectively calculating the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel of at least a portion of the target pixels; the pixel mean and the pixel value intervals corresponding to the skin color categories are combined. The target skin color category to which the target object belongs is determined by matching the pixel mean value of the red channel with the pixel value interval of the red channel corresponding to each skin color category to obtain a first matching result, matching the pixel mean value of the green channel with the pixel value interval of the green channel corresponding to each skin color category to obtain a second matching result, and matching the pixel mean value of the blue channel with the pixel value interval of the blue channel corresponding to each skin color category to obtain a third matching result; and determining the target skin color category to which the target object belongs according to the first matching result, the second matching result and the third matching result.
[0010] In one embodiment, determining the target skin color category to which the target object belongs based on the first matching result, the second matching result, and the third matching result includes: if the first matching result, the second matching result, and the third matching result indicate the same skin color category, then determining the skin color category indicated by the first matching result, the second matching result, and the third matching result as the target skin color category; if any two of the first matching result, the second matching result, and the third matching result indicate the same skin color category, and the skin color category indicated by another matching result is adjacent to the skin color category indicated by the any two matching results, then determining the skin color category indicated by the any two matching results as the target skin color category. The skin color category indicated by the result is determined as the target skin color category; wherein, the skin color categories corresponding to adjacent pixel value intervals are adjacent; if any two of the first matching result, the second matching result and the third matching result indicate the same skin color category, and the skin color category indicated by the other matching result is not adjacent to the skin color category indicated by the any two matching results, or the skin color categories indicated by the first matching result, the second matching result and the third matching result are different, then the arithmetic mean of the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel is calculated, and the target skin color category is determined based on the arithmetic mean.
[0011] In one embodiment, the target skin color category is determined based on the arithmetic mean, including: for each skin color category, determining the pixel lower limit mean corresponding to the skin color according to the pixel lower limit value of the pixel value interval of the red channel, the pixel lower limit value of the pixel value interval of the green channel, and the pixel lower limit value of the pixel value interval of the blue channel corresponding to the skin color category, and determining the pixel upper limit mean corresponding to the skin color according to the pixel upper limit value of the pixel value interval of the red channel, the pixel upper limit value of the pixel value interval of the green channel, and the pixel upper limit value of the pixel value interval of the blue channel corresponding to the skin color category; determining the interval formed by the pixel lower limit mean and the pixel upper limit mean as the pixel value mean interval corresponding to the skin color; matching the arithmetic mean with each pixel value mean interval to determine the pixel value mean interval to which the arithmetic mean belongs; and determining the skin color category corresponding to the pixel value mean interval to which the arithmetic mean belongs as the target skin color category.
[0012] In one embodiment, the pixel values include: pixel values of a red channel, pixel values of a green channel, and pixel values of a blue channel, and the pixel value intervals corresponding to each skin color category include: pixel value intervals of a red channel corresponding to each skin color category, pixel value intervals of a green channel corresponding to each skin color category, and pixel value intervals of a blue channel corresponding to each skin color category; accordingly, determining the target skin color category to which the target object belongs based on the pixel values and the pixel value intervals corresponding to each skin color category includes: determining a first pixel ratio of pixels whose red channel pixel values belong to the red channel pixel value interval corresponding to each skin color category in the target pixels, a second pixel ratio of pixels whose green channel pixel values belong to the green channel pixel value interval corresponding to each skin color category in the target pixels, and a third pixel ratio of pixels whose blue channel pixel values belong to the blue channel pixel value interval corresponding to each skin color category in the target pixels; based on the first pixel ratio, the second pixel ratio, and the third pixel ratio, determine the target skin color category.
[0013] In one embodiment, the target skin color category is determined based on the first pixel ratio, the second pixel ratio and the third pixel ratio, including: if the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, then the skin color category indicated by the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio and the maximum pixel ratio in the third pixel ratio is determined as the target skin color category; if any two of the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is adjacent to the skin color category indicated by any two maximum pixel ratios, then any of the maximum pixel ratios is determined as the target skin color category. The skin color category indicated by the two maximum pixel ratios is determined as the target skin color category; wherein, the skin color categories corresponding to adjacent pixel value intervals are adjacent; if any two of the maximum pixel ratios in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is not adjacent to the skin color category indicated by any two maximum pixel ratios, or the skin color categories indicated by the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio are different, then calculate the pixel average of the pixel value of the red channel, the pixel value of the green channel, and the pixel value of the blue channel of each of the target pixels; determine the target skin color category based on the pixel average of each target pixel.
[0014] In one embodiment, the target skin color category is determined based on the pixel average value of each target pixel, including: for each skin color category, according to the pixel lower limit value of the pixel value interval of the red channel, the pixel lower limit value of the pixel value interval of the green channel, and the pixel lower limit value of the pixel value interval of the blue channel corresponding to the skin color category, determine the pixel upper limit mean corresponding to the skin color according to the pixel upper limit value of the pixel value interval of the red channel, the pixel upper limit value of the pixel value interval of the green channel, and the pixel upper limit value of the pixel value interval of the blue channel corresponding to the skin color category; determine the interval formed by the pixel lower limit mean and the pixel upper limit mean as the pixel value average interval corresponding to the skin color; determine the proportion of pixels whose pixel average values belong to each pixel value average interval in the target pixels; and determine the skin color category corresponding to the maximum proportion among the proportions as the target skin color category.
[0015] In one embodiment, the pixel value interval corresponding to each skin color category is determined by the following steps: based on the preset skin color category and the standard skin color color card, the pixel value corresponding to the critical color card is determined; wherein the critical color card is the color card corresponding to when the skin color category changes; based on the pixel value corresponding to the critical color card, the pixel threshold between each skin color category is calculated; based on each of the pixel thresholds, the pixel value interval corresponding to each skin color category is determined.
[0016] In one embodiment, the target object is a human face, and the target area is a human face area; obtaining the pixel values of at least a portion of the target pixels in the target area includes: performing feature extraction on the human face area to obtain facial feature points in the human face area; determining a skin area in the human face area based on the facial feature points; using at least a portion of the pixels in the skin area as the target pixels, and obtaining the pixel values of the target pixels.
[0017] In one embodiment, the skin area includes at least one local skin sub-area; the local skin sub-area includes: chin area, upper left cheek area, middle left cheek area, lower left cheek area, upper right cheek area, middle right cheek area, lower right cheek area, root of nose area and glabellar area.
[0018] In the second aspect, an embodiment of the present invention also provides a skin color recognition device, comprising: a first determination unit, used to determine a target area corresponding to a target object in an image to be identified; an acquisition unit, used to acquire pixel values of at least a part of target pixels in the target area; wherein the target pixels belong to a skin area in the target area; and a second determination unit, used to determine the target skin color category to which the target object belongs based on the pixel value and the pixel value interval corresponding to each skin color category.
[0019] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the methods described in the first aspect when executing the computer program.
[0020] In a fourth aspect, an embodiment of the present invention further provides a computer-readable medium having a non-volatile program code executable by a processor, wherein the program code enables the processor to execute the steps of the method described in any one of the first aspects above.
[0021] In an embodiment of the present invention, first, the target area corresponding to the target object in the image to be identified is determined, then the pixel values of at least a part of the target pixels in the target area are obtained, the target pixels belong to the skin area in the target area, and finally, the target skin color category to which the target object belongs is determined based on the pixel values and the pixel value intervals corresponding to each skin color category. From the above description, it can be seen that the skin color recognition method of the present invention directly matches the pixel values of at least a part of the target pixels in the target area corresponding to the target object with the pixel value intervals corresponding to each skin color category, and then determines the target skin color category to which the target object belongs, without the need for data annotation and deep model training, which is simple, efficient, and cost-saving, alleviating the technical problems of the existing skin color recognition methods being time-consuming and costly. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 A schematic diagram of an electronic device provided by an embodiment of the present invention;
[0024] Figure 2 A flowchart of a skin color recognition method provided by an embodiment of the present invention;
[0025] Figure 3 A flowchart of obtaining pixel values of at least a portion of target pixels in a target area provided by an embodiment of the present invention;
[0026] Figure 4 A schematic diagram of a local skin sub-region of a face image provided by an embodiment of the present invention;
[0027] Figure 5 A flowchart for determining the pixel value interval corresponding to each skin color category provided by an embodiment of the present invention;
[0028] Figure 6 A schematic diagram of an image in a face image dataset provided by an embodiment of the present invention;
[0029] Figure 7 A schematic diagram of a skin color card with preset color numbers provided in an embodiment of the present invention;
[0030] Figure 8A flow chart for determining a target skin color category to which a target object belongs based on a first matching result, a second matching result, and a third matching result provided in an embodiment of the present invention;
[0031] Fig. 9 A flowchart of determining a target skin color category to which a target object belongs based on pixel values and pixel value intervals corresponding to each skin color category provided by an embodiment of the present invention;
[0032] Fig.10 A schematic diagram of a skin color recognition device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0034] Embodiment 1:
[0035] First, refer to Figure 1 An electronic device 100 for implementing an embodiment of the present invention is described. The electronic device can be used to run the skin color recognition method of each embodiment of the present invention.
[0036] like Figure 1 As shown, the electronic device 100 includes one or more processors 102, one or more memories 104, an input device 106, and an output device 108, and these components are interconnected through a bus system 112 and / or other forms of connection mechanisms (not shown). It should be noted that Figure 1 The components and structures of the electronic device 100 shown are merely exemplary and non-limiting. The electronic device may also have other components and structures as required.
[0037] The processor 102 can be implemented in at least one hardware form of a digital signal processor (DSP), a field programmable gate array (FPGA), a programmable logic array (PLA) and an ASIC (Application Specific Integrated Circuit). The processor 102 can be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and can control other components in the electronic device 100 to perform desired functions.
[0038] The memory 104 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 102 may run the program instructions to implement the client functions (implemented by the processor) and / or other desired functions in the embodiments of the present invention described below. Various applications and various data, such as various data used and / or generated by the application, may also be stored in the computer-readable storage medium.
[0039] The input device 106 may be a device used by a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, a touch screen, and the like.
[0040] The output device 108 may output various information (eg, images or sounds) to the outside (eg, a user), and may include one or more of a display, a speaker, and the like.
[0041] After the electronic device 100 obtains the image to be identified, it processes it using the skin color identification method to obtain the target skin color category to which the target object in the image to be identified belongs.
[0042] Exemplarily, the electronic device for implementing the skin color recognition method according to the embodiment of the present invention may be implemented as an intelligent mobile terminal such as a smart phone, a tablet computer, or the like.
[0043] Embodiment 2:
[0044] In recent years, research on computer vision, deep learning, machine learning, image processing, image recognition and other technologies based on artificial intelligence has made important progress. Artificial Intelligence (AI) is an emerging science and technology that studies and develops theories, methods, technologies and application systems for simulating and extending human intelligence. Artificial intelligence is a comprehensive discipline involving many types of technologies such as chips, big data, cloud computing, the Internet of Things, distributed storage, deep learning, machine learning, neural networks, etc. Computer vision, as an important branch of artificial intelligence, specifically allows machines to recognize the world. Computer vision technology usually includes face recognition, liveness detection, fingerprint recognition and anti-counterfeiting verification, biometric recognition, face detection, pedestrian detection, target detection, pedestrian recognition, image processing, image recognition, image semantic understanding, image retrieval, text recognition, video processing, video content recognition, behavior recognition, 3D reconstruction, virtual reality, augmented reality, simultaneous localization and mapping (SLAM), computational photography, robot navigation and positioning and other technologies. With the research and advancement of artificial intelligence technology, this technology has been applied in many fields, such as security, urban management, traffic management, building management, park management, facial access, facial attendance, logistics management, warehouse management, robots, intelligent marketing, computational photography, mobile phone imaging, cloud services, smart homes, wearable devices, unmanned driving, automatic driving, smart medical care, facial payment, facial unlocking, fingerprint unlocking, identity verification, smart screens, smart TVs, cameras, mobile Internet, live streaming, beauty, makeup, medical beauty, and smart temperature measurement.
[0045] An embodiment of the present invention provides an embodiment of a method for identifying skin color. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0046] Figure 2 is a flow chart of a skin color recognition method according to an embodiment of the present invention. Figure 2 As shown, the method comprises the following steps:
[0047] Step S202, determining a target area corresponding to a target object in the image to be identified;
[0048] In the embodiment of the present invention, the image to be identified may be an image of a target object, such as a face image, an arm image, etc.; it may also be a global image including the target object, such as when the target object is a face, the image to be identified is an image of the entire body or a half-body image. The embodiment of the present invention does not impose any specific restrictions on the specific form of the above-mentioned image to be identified. The target object refers to an object for identifying skin color, and may specifically be a part of the human body, such as a face, neck, arm, etc. The embodiment of the present invention does not impose any specific restrictions on the above-mentioned target object. When the target object is a face, the target area is the face area in the image to be identified; when the target object is a neck, the target area is the neck area in the image to be identified.
[0049] Step S204, obtaining pixel values of at least a portion of target pixels in the target area;
[0050] The target pixel belongs to the skin area in the target area, and the pixel value may include: a pixel value of a red channel, a pixel value of a green channel, and a pixel value of a blue channel of each pixel in at least a portion of the target pixels.
[0051] In the embodiment of the present invention, a part of the target pixels in the target area may be acquired, or all the target pixels in the target area may be acquired.
[0052] Step S206: determining the target skin color category to which the target object belongs based on the pixel value and the pixel value intervals corresponding to each skin color category.
[0053] Specifically, the pixel value and the pixel value interval corresponding to each skin color category may be matched to determine the target skin color category to which the target object belongs. This process will be described in detail below and will not be repeated here.
[0054] In an embodiment of the present invention, first, the target area corresponding to the target object in the image to be identified is determined, then the pixel values of at least a part of the target pixels in the target area are obtained, the target pixels belong to the skin area in the target area, and finally, the target skin color category to which the target object belongs is determined based on the pixel values and the pixel value intervals corresponding to each skin color category. From the above description, it can be seen that the skin color recognition method of the present invention directly matches the pixel values of at least a part of the target pixels in the target area corresponding to the target object with the pixel value intervals corresponding to each skin color category, and then determines the target skin color category to which the target object belongs, without the need for data annotation and deep model training, which is simple, efficient, and cost-saving, alleviating the technical problems of the existing skin color recognition methods being time-consuming and costly.
[0055] The above content briefly introduces the skin color recognition method of the present invention, and the specific contents involved therein are described in detail below.
[0056] When the target object is a face and the target area is a face area, refer to Figure 3 The above step S204, obtaining the pixel values of at least a part of the target pixels in the target area, specifically includes the following steps:
[0057] Step S301, extracting features from the face region to obtain face feature points in the face region;
[0058] Specifically, the ERT (ensemble of regression tree) algorithm can be used to extract features from the face region of the image to be recognized, thereby obtaining face feature points in the face region.
[0059] Step S302, determining a skin area in the face area based on the facial feature points, wherein the skin area includes at least one local skin sub-area; the local skin sub-area includes: a chin area, an area on the left cheek, a middle area on the left cheek, an area under the left cheek, an area on the right cheek, a middle area on the right cheek, an area under the right cheek, a root of the nose area, and an area between the eyebrows;
[0060] After obtaining the facial feature points, the facial area can be divided according to the facial feature points. Figure 4 The nine local skin sub-areas shown are the chin area, the upper left cheek area, the middle left cheek area, the lower left cheek area, the upper right cheek area, the middle right cheek area, the lower right cheek area, the root of the nose area and the glabellar area.
[0061] The purpose of dividing the above multiple local skin sub-areas is to avoid the influence of other non-skin parts of the face (such as hair, eyebrows, lips) on skin color recognition, so that the subsequent skin color determined based on the pixel value in the skin area is more accurate.
[0062] Step S303: taking at least a portion of pixels in the skin area as target pixels, and acquiring pixel values of the target pixels.
[0063] Specifically, all pixels in multiple local skin sub-regions (i.e., 9 regions) can be used as at least a part of the target pixels in the above-mentioned target region, or part of the pixels in multiple local skin sub-regions (i.e., 9 regions) can be used as at least a part of the target pixels in the above-mentioned target region, or all pixels in one or more local skin sub-regions among the multiple local skin sub-regions can be used as at least a part of the target pixels in the above-mentioned target region. The embodiment of the present invention does not impose specific restrictions on the determination of the above-mentioned at least a part of the target pixels.
[0064] If all the pixels in multiple local skin sub-areas (i.e., 9 areas) are taken as at least a part of the target pixels in the above-mentioned target area, it covers most of the skin areas of the human face and can accurately reflect the skin color category of the human face skin; if all the pixels in one or more of the multiple local skin sub-areas are taken as at least a part of the target pixels in the above-mentioned target area, the amount of calculation in the subsequent determination of the target skin color category can be reduced, thereby reducing resource consumption.
[0065] When the target area is a neck area, acquiring pixel values of at least a portion of target pixels in the target area may include acquiring pixel values of all or a portion of target pixels in the neck area.
[0066] The present invention is hereinafter described by taking the target area as the face area as an example. When the target area is other areas, the process of specifically determining the target skin color category to which the target object belongs is similar to the following content, and the embodiments of the present invention will not be described one by one.
[0067] The above content introduces in detail the method of obtaining the pixel values of at least a portion of the target pixels in the target area of the present invention. The following introduces the process of determining the target skin color category to which the target object belongs based on the pixel value and the pixel value interval corresponding to each skin color category:
[0068] Determining the target skin color category to which the target object belongs based on the pixel value and the pixel value interval corresponding to each skin color category can be achieved in at least two ways, which are described in detail below:
[0069] Solution 1:
[0070] Calculate the pixel mean of at least a portion of the target pixels; match the pixel mean with the pixel value interval corresponding to each skin color category to determine the target skin color category to which the target object belongs.
[0071] The above-mentioned pixel mean includes: the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel; the pixel value interval corresponding to each skin color category includes: the pixel value interval of the red channel corresponding to each skin color category, the pixel value interval of the green channel corresponding to each skin color category and the pixel value interval of the blue channel corresponding to each skin color category;
[0072] Accordingly, the above-mentioned calculation of the pixel mean of at least a portion of the target pixels includes:
[0073] Calculate the pixel mean of the red channel, the pixel mean of the green channel, and the pixel mean of the blue channel of at least a portion of the target pixels respectively;
[0074] Match the pixel mean and the pixel value interval corresponding to each skin color category to determine the target skin color category to which the target object belongs, including:
[0075] Match the pixel mean of the red channel with the pixel value interval of the red channel corresponding to each skin color category to obtain a first matching result, match the pixel mean of the green channel with the pixel value interval of the green channel corresponding to each skin color category to obtain a second matching result, and match the pixel mean of the blue channel with the pixel value interval of the blue channel corresponding to each skin color category to obtain a third matching result; determine the target skin color category to which the target object belongs based on the first matching result, the second matching result and the third matching result.
[0076] Specifically, assuming that the target pixels to be acquired are N pixels, the pixel value of the i-th pixel can be expressed as p i =[R i ,G i ,B i ], where R i represents the pixel value of the red channel of the i-th pixel, G i represents the pixel value of the green channel of the i-th pixel, B i represents the pixel value of the blue channel of the i-th pixel, then the pixel mean of the target pixel is expressed as: Among them, R mean Represents the pixel mean of the red channel of the target pixel, G mean Represents the pixel mean of the green channel of the target pixel, B mean represents the pixel mean of the blue channel of the target pixel, and N represents the total number of target pixels.
[0077] The following is an introduction to the process of determining the pixel value interval corresponding to each skin color category. Figure 5 , including the following steps:
[0078] Step S501, determining the pixel value corresponding to the critical color card according to the preset skin color category and the standard skin color card; wherein the critical color card is the color card corresponding to the skin color category when it changes;
[0079] Step S502, calculating the pixel thresholds between the skin color categories based on the pixel values corresponding to the critical color card;
[0080] Step S503: determining the pixel value interval corresponding to each skin color category based on each pixel threshold.
[0081] Specifically, first obtain a target object image dataset with skin color categories, for example, first obtain a face image dataset with a fair skin color category, a face image dataset with a natural skin color category, a face image dataset with a wheat skin color category, and a face image dataset with a dark skin color category, and then separate the images in the face image dataset with the above skin color categories (such as Figure 6 As shown, Figure 6 In the figure, the skin color category corresponding to the upper left face image is fair, the skin color category corresponding to the upper right face image is natural, the skin color category corresponding to the lower left face image is wheat, and the skin color category corresponding to the lower right face image is dark) is compared with a standard color card (preferably a Pantone skin color card), the critical color card corresponding to each of the above skin color categories can be determined, and then the pixel value corresponding to the critical color card (including: red channel pixel value, green channel pixel value and blue channel pixel value) can be obtained. Among them, the critical color card in the standard color card corresponding to the fair skin color category is 5y03, the critical color card in the standard color card corresponding to the natural skin color category is 5y06, the critical color card in the standard color card corresponding to the wheat skin color category is 5y09, and the critical color card in the standard color card corresponding to the dark skin color category is 1R13 (such as Figure 7 As shown in FIG. 1 , the pixel values (i.e., RGB values) corresponding to the above critical color cards are (196, 168, 144), (184, 154, 126), (163, 130, 100), and (119, 86, 66). It should be noted that the color numbers and corresponding RGB values of the critical color cards are only exemplarily introduced here, and do not constitute a limitation on the embodiments of the present application.
[0082] The above-mentioned use of skin color scale (that is, skin depth) as a determination indicator of skin color category is more intuitive. The above-mentioned matching of subjective color scale with target area pixel value of face image can conveniently and quickly determine the critical color card in the standard color card corresponding to each skin color category.
[0083] After obtaining the pixel values of the critical color card in the standard color card corresponding to each of the above skin color categories, the pixel thresholds between the skin color categories are further calculated based on the pixel values corresponding to the critical color card. Specifically, if the number of pixel values corresponding to the critical color card is M, the number of pixel thresholds obtained is determined to be M-1. When implemented, the pixel values corresponding to the critical color card are arranged in descending order to obtain a pixel value sequence. The first pixel threshold can adopt the largest pixel value in the above pixel value sequence (i.e., the largest pixel value in the pixel values corresponding to the critical color card), the subsequent intermediate pixel threshold can adopt the average of the subsequent two adjacent pixel values (the two adjacent pixel values in the pixel value sequence), and the final pixel threshold can adopt the smallest pixel value in the above pixel value sequence (i.e., the smallest pixel value in the pixel values corresponding to the critical color card).
[0084] Then, the pixel value intervals corresponding to the skin color categories are determined based on the pixel thresholds. Specifically, the interval greater than the maximum pixel threshold can be determined as the pixel value interval corresponding to the first skin color category, and the interval consisting of the pixel threshold adjacent to the maximum pixel threshold and the maximum pixel threshold can be determined as the pixel value interval corresponding to the second skin color category, and the endpoints of the subsequent pixel value intervals are both two adjacent pixel thresholds, and the last pixel value interval can be determined as the pixel value interval corresponding to the last skin color category by the interval less than the minimum pixel threshold.
[0085] For example, to get the above pixel value:
[0086] C1=(r1,g1,b1)=(196,168,144), C2=(r2,g2,b2)=(184,154,126), C3=(r3,g3,b3)=(163,130,100), C4=(r4,g4,b4)=(119,86,66) Calculate the pixel thresholds between each skin color category. The specific process includes:
[0087] Calculate the pixel threshold between each skin color category: T1 = C1 = (r1, g1, b1) = (196, 168, 144);
[0088]
[0089] T3=C4=(r4,g4,b4)=(119,86,66).
[0090] The pixel value interval corresponding to each skin color category is determined based on each pixel threshold, specifically:
[0091] The pixel value interval of the red channel corresponding to the fair skin color category is: (196, +∞);
[0092] The pixel value interval of the green channel corresponding to the fair skin color category is: (168, +∞);
[0093] The pixel value interval of the blue channel corresponding to the fair skin color category is: (144, +∞);
[0094] The pixel value interval of the red channel corresponding to the natural skin color category is: (173.5, 196);
[0095] The pixel value interval of the green channel corresponding to the natural skin color category is: (142, 168);
[0096] The pixel value interval of the blue channel corresponding to the natural skin color category is: (113, 144);
[0097] The pixel value interval of the red channel corresponding to the wheat skin color category is: (119, 173.5);
[0098] The pixel value interval of the green channel corresponding to the wheat skin color category is: (86, 142);
[0099] The pixel value interval of the blue channel corresponding to the wheat skin color category is: (66, 113);
[0100] The pixel value interval of the red channel corresponding to the dark skin color category is: (-∞, 119);
[0101] The pixel value interval of the green channel corresponding to the dark skin color category is: (-∞, 86);
[0102] The pixel value range of the blue channel corresponding to the dark skin color category is: (-∞, 66).
[0103] In an alternative embodiment of the present invention, reference Figure 8 , according to the first matching result, the second matching result, and the third matching result, determining the target skin color category to which the target object belongs, specifically includes the following steps:
[0104] Step S801, if the first matching result, the second matching result and the third matching result indicate the same skin color category, then the skin color category indicated by the first matching result, the second matching result and the third matching result is determined as the target skin color category;
[0105] Step S802, if any two of the first matching result, the second matching result, and the third matching result indicate the same skin color category, and the skin color category indicated by another matching result is adjacent to the skin color category indicated by any two matching results, then the skin color category indicated by any two matching results is determined as the target skin color category, wherein the skin color categories corresponding to adjacent pixel value intervals are adjacent;
[0106] For example: Continuing with the above example, in the above example, the pixel value interval (196, +∞) of the red channel is adjacent to the pixel value interval (173.5, 196) of the red channel, the pixel value interval (168, +∞) of the green channel is adjacent to the pixel value interval (142, 168) of the green channel, and the pixel value interval (144, +∞) of the blue channel is adjacent to the pixel value interval (113, 144) of the blue channel. Therefore, the white skin color category indicated by the pixel value interval (196, +∞) of the red channel, the pixel value interval (168, +∞) of the green channel, and the pixel value interval (144, +∞) of the blue channel is adjacent to the pixel value interval (113, 144) of the red channel. The natural skin color categories indicated by the pixel value interval (173.5, 196) of the green channel, the pixel value interval (142, 168) of the blue channel, and the pixel value interval (113, 144) of the blue channel are adjacent, that is, the fair skin color category and the natural skin color category are adjacent. Similarly, the natural skin color category is also adjacent to the wheat skin color category, and the wheat skin color category is also adjacent to the dark skin color category. Assuming that the skin color category indicated by the first matching result and the second matching result is the natural skin color category, and the skin color category indicated by the third matching result is the fair skin color category or the wheat skin color category, then the target skin color category is the natural skin color category.
[0107] Step S803, if any two of the first matching result, the second matching result, and the third matching result indicate the same skin color category, and the skin color category indicated by the other matching result is not adjacent to the skin color categories indicated by any two matching results, or the skin color categories indicated by the first matching result, the second matching result, and the third matching result are different, then calculating the arithmetic mean of the pixel mean of the red channel, the pixel mean of the green channel, and the pixel mean of the blue channel;
[0108] Specifically, the arithmetic mean Among them, total mean represents the arithmetic mean, R mean represents the pixel mean of the red channel, G mean represents the pixel mean of the green channel, B mean Represents the pixel mean of the blue channel.
[0109] Step S804, for each skin color category, according to the pixel lower limit value of the pixel value interval of the red channel, the pixel lower limit value of the pixel value interval of the green channel, and the pixel lower limit value of the pixel value interval of the blue channel corresponding to the skin color category, determine the pixel lower limit mean value corresponding to the skin color, and according to the pixel upper limit value of the pixel value interval of the red channel, the pixel upper limit value of the pixel value interval of the green channel, and the pixel upper limit value of the pixel value interval of the blue channel corresponding to the skin color category, determine the pixel upper limit mean value corresponding to the skin color;
[0110] Step S805, determining the interval formed by the lower pixel mean and the upper pixel mean as the pixel value mean interval corresponding to the skin color;
[0111] In an alternative embodiment of the present invention:
[0112] Among them, mean X Indicates the mean interval of pixel values corresponding to the skin color category X, MIN R Indicates the pixel lower limit of the pixel value interval of the red channel corresponding to the X skin color category, MIN G Indicates the pixel lower limit of the green channel pixel value interval corresponding to the X skin color category, MIN B Indicates the pixel lower limit of the pixel value interval of the blue channel corresponding to the X skin color category, Indicates the lower mean of the pixels corresponding to the skin color category X, MAX R Indicates the pixel upper limit of the red channel pixel value interval corresponding to the X skin color category, MAX G Indicates the pixel upper limit of the green channel pixel value interval corresponding to the X skin color category, MAX B Indicates the pixel upper limit of the blue channel pixel value interval corresponding to the X skin color category, Indicates the upper mean value of the pixels corresponding to the skin color category X.
[0113] Specifically, the mean pixel value interval corresponding to the fair skin color category is:
[0114] The mean pixel value interval corresponding to the natural skin color category:
[0115] The mean pixel value interval corresponding to the wheat skin color category:
[0116] The mean pixel value interval corresponding to the dark skin color category:
[0117] Step S806, matching the arithmetic mean with each pixel value mean interval to determine the pixel value mean interval to which the arithmetic mean belongs;
[0118] Step S807: determine the skin color category corresponding to the pixel value mean interval to which the arithmetic mean belongs as the target skin color category.
[0119] The process of determining the target skin color category to which the target object belongs in the first solution of the present invention can simply, quickly and accurately determine the target skin color category to which the target object belongs, with a small amount of calculation, thereby improving the efficiency of determining the target skin color category to which the target object belongs.
[0120] Option 2:
[0121] In an optional embodiment of the present invention, the pixel values include: pixel values of the red channel, pixel values of the green channel and pixel values of the blue channel, and the pixel value intervals corresponding to each skin color category include: the pixel value intervals of the red channel corresponding to each skin color category, the pixel value intervals of the green channel corresponding to each skin color category and the pixel value intervals of the blue channel corresponding to each skin color category (the pixel value intervals corresponding to each skin color category have been introduced above and will not be repeated here).
[0122] refer to Fig. 9 , based on the pixel value and the pixel value interval corresponding to each skin color category, determining the target skin color category to which the target object belongs, specifically includes the following steps:
[0123] Step S901, determining a first pixel ratio of pixels whose red channel pixel values belong to the red channel pixel value interval corresponding to each skin color category in the target pixel, a second pixel ratio of pixels whose green channel pixel values belong to the green channel pixel value interval corresponding to each skin color category in the target pixel, and a third pixel ratio of pixels whose blue channel pixel values belong to the blue channel pixel value interval corresponding to each skin color category in the target pixel;
[0124] Step S902, if the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, then the skin color category indicated by the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio is determined as the target skin color category;
[0125] Step S903, if any two of the maximum pixel ratios in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is adjacent to the skin color categories indicated by any two maximum pixel ratios, then the skin color categories indicated by any two maximum pixel ratios are determined as target skin color categories, wherein the skin color categories corresponding to adjacent pixel value intervals are adjacent;
[0126] For example, in the above example: the fair skin color category is adjacent to the natural skin color category, the natural skin color category is also adjacent to the wheat skin color category, and the wheat skin color category is also adjacent to the dark skin color category. If the skin color category indicated by the maximum pixel ratio in the first pixel ratio and the maximum pixel ratio in the second pixel ratio is the natural skin color category, and the skin color category indicated by the maximum pixel ratio in the third pixel ratio is the fair skin color category or the wheat skin color category, then the target skin color category is the natural skin color category.
[0127] Step S904, if any two of the maximum pixel ratios in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is not adjacent to the skin color categories indicated by any two maximum pixel ratios, or the skin color categories indicated by the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio are different, then calculate the pixel average of the pixel value of the red channel, the pixel value of the green channel, and the pixel value of the blue channel of each target pixel;
[0128] Specifically, the pixel average Among them, i mean represents the pixel average value of pixel i, i R Represents the pixel value of the red channel of pixel i, i G Represents the pixel value of the green channel of pixel i, i B Represents the pixel value of the blue channel of pixel i.
[0129] Step S905, for each skin color category, determine the lower limit mean of pixels corresponding to the skin color according to the lower limit pixel value of the pixel value interval of the red channel, the lower limit pixel value of the pixel value interval of the green channel, and the lower limit pixel value of the pixel value interval of the blue channel corresponding to the skin color category, and determine the upper limit mean of pixels corresponding to the skin color according to the upper limit pixel value of the pixel value interval of the red channel, the upper limit pixel value of the pixel value interval of the green channel, and the upper limit pixel value of the pixel value interval of the blue channel corresponding to the skin color category;
[0130] Step S906, determining the interval formed by the lower pixel mean and the upper pixel mean as the pixel value mean interval corresponding to the skin color;
[0131] In an alternative embodiment of the present invention:
[0132] Among them, mean X Indicates the mean interval of pixel values corresponding to the skin color category X, MIN R Indicates the pixel lower limit of the pixel value interval of the red channel corresponding to the X skin color category, MIN G Indicates the pixel lower limit of the green channel pixel value interval corresponding to the X skin color category, MIN B Indicates the pixel lower limit of the pixel value interval of the blue channel corresponding to the X skin color category, Indicates the lower mean of the pixels corresponding to the skin color category X, MAX R Indicates the pixel upper limit of the red channel pixel value interval corresponding to the X skin color category, MAX G Indicates the pixel upper limit of the green channel pixel value interval corresponding to the X skin color category, MAX B Indicates the pixel upper limit of the blue channel pixel value interval corresponding to the X skin color category, Indicates the upper mean value of the pixels corresponding to the skin color category X.
[0133] Specifically, the mean pixel value interval corresponding to the fair skin color category is:
[0134]
[0135] The mean pixel value interval corresponding to the natural skin color category is:
[0136]
[0137] The mean pixel value interval corresponding to the wheat skin color category is:
[0138]
[0139] The mean pixel value interval corresponding to the dark skin color category is:
[0140]
[0141] Step S907, determining the proportion of pixels whose pixel average values belong to each pixel value average interval in the target pixels;
[0142] Step S908: determine the skin color category corresponding to the maximum proportion among the proportions as the target skin color category.
[0143] The process of determining the target skin color category to which the target object belongs in the second solution of the present invention can more accurately determine the target skin color category to which the target object belongs.
[0144] The skin color recognition method of the present invention can simply and efficiently recognize the skin color category of the target object in the image to be recognized, does not require data annotation and training of a deep model, and saves manpower and time costs.
[0145] Embodiment 3:
[0146] The embodiment of the present invention further provides a skin color recognition device, which is mainly used to execute the skin color recognition method provided in the above content of the embodiment of the present invention. The skin color recognition device provided in the embodiment of the present invention is specifically introduced below.
[0147] Fig.10 is a schematic diagram of a skin color recognition device according to an embodiment of the present invention. Fig.10 As shown, the skin color recognition device mainly includes: a first determination unit 10, an acquisition unit 20 and a second determination unit 30, wherein:
[0148] A first determining unit, used to determine a target area corresponding to a target object in an image to be identified;
[0149] An acquisition unit, used to acquire pixel values of at least a portion of target pixels in the target area; wherein the target pixels belong to a skin area in the target area;
[0150] The second determining unit is used to determine the target skin color category to which the target object belongs based on the pixel value and the pixel value intervals corresponding to each skin color category.
[0151] In an embodiment of the present invention, first, the target area corresponding to the target object in the image to be identified is determined, then the pixel values of at least a part of the target pixels in the target area are obtained, the target pixels belong to the skin area in the target area, and finally, the target skin color category to which the target object belongs is determined based on the pixel values and the pixel value intervals corresponding to each skin color category. From the above description, it can be seen that the skin color recognition method of the present invention directly matches the pixel values of at least a part of the target pixels in the target area corresponding to the target object with the pixel value intervals corresponding to each skin color category, and then determines the target skin color category to which the target object belongs, without the need for data annotation and deep model training, which is simple, efficient, and cost-saving, alleviating the technical problems of the existing skin color recognition methods being time-consuming and costly.
[0152] Optionally, the second determination unit is further used to: calculate a pixel mean of at least a portion of the target pixels; and match the pixel mean with a pixel value interval corresponding to each skin color category to determine the target skin color category to which the target object belongs.
[0153] Optionally, the pixel mean includes: the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel; the pixel value interval corresponding to each skin color category includes: the pixel value interval of the red channel corresponding to each skin color category, the pixel value interval of the green channel corresponding to each skin color category and the pixel value interval of the blue channel corresponding to each skin color category; the second determination unit is also used to: respectively calculate the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel of at least a part of the target pixels; match the pixel mean of the red channel with the pixel value interval of the red channel corresponding to each skin color category to obtain a first matching result, match the pixel mean of the green channel with the pixel value interval of the green channel corresponding to each skin color category to obtain a second matching result, and match the pixel mean of the blue channel with the pixel value interval of the blue channel corresponding to each skin color category to obtain a third matching result; determine the target skin color category to which the target object belongs based on the first matching result, the second matching result and the third matching result.
[0154] Optionally, the second determination unit is also used to: if the first matching result, the second matching result and the third matching result indicate the same skin color category, then the skin color category indicated by the first matching result, the second matching result and the third matching result is determined as the target skin color category; if any two of the first matching result, the second matching result and the third matching result indicate the same skin color category, and the skin color category indicated by the other matching result is adjacent to the skin color category indicated by any two matching results, then the skin color category indicated by any two matching results is determined as the target skin color category; wherein the skin color categories corresponding to adjacent pixel value intervals are adjacent; if any two of the first matching result, the second matching result and the third matching result indicate the same skin color category, and the skin color category indicated by the other matching result is not adjacent to the skin color category indicated by any two matching results, or the skin color categories indicated by the first matching result, the second matching result and the third matching result are different, then the arithmetic mean of the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel is calculated, and the target skin color category is determined based on the arithmetic mean.
[0155] Optionally, the second determination unit is also used to: for each skin color category, determine the pixel lower limit mean corresponding to the skin color according to the pixel lower limit value of the pixel value interval of the red channel, the pixel lower limit value of the pixel value interval of the green channel, and the pixel lower limit value of the pixel value interval of the blue channel corresponding to the skin color category; and determine the pixel upper limit mean corresponding to the skin color according to the pixel upper limit value of the pixel value interval of the red channel, the pixel upper limit value of the pixel value interval of the green channel, and the pixel upper limit value of the pixel value interval of the blue channel corresponding to the skin color category; determine the interval formed by the pixel lower limit mean and the pixel upper limit mean as the pixel value mean interval corresponding to the skin color; match the arithmetic mean with each pixel value mean interval to determine the pixel value mean interval to which the arithmetic mean belongs; and determine the skin color category corresponding to the pixel value mean interval to which the arithmetic mean belongs as the target skin color category.
[0156] Optionally, the pixel values include: pixel values of the red channel, pixel values of the green channel and pixel values of the blue channel, and the pixel value intervals corresponding to each skin color category include: the pixel value intervals of the red channel corresponding to each skin color category, the pixel value intervals of the green channel corresponding to each skin color category and the pixel value intervals of the blue channel corresponding to each skin color category; the second determination unit is also used to: determine a first pixel ratio of pixels whose red channel pixel values belong to the pixel value intervals of the red channel corresponding to each skin color category in the target pixel, a second pixel ratio of pixels whose green channel pixel values belong to the pixel value intervals of the green channel corresponding to each skin color category in the target pixel, and a third pixel ratio of pixels whose blue channel pixel values belong to the pixel value intervals of the blue channel corresponding to each skin color category in the target pixel; determine the target skin color category based on the first pixel ratio, the second pixel ratio and the third pixel ratio.
[0157] Optionally, the second determination unit is also used to: if the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, then the skin color category indicated by the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio is determined as the target skin color category; if any two of the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is adjacent to the skin color categories indicated by any two maximum pixel ratios, then the skin color categories indicated by any two maximum pixel ratios are determined as Target skin color category; wherein, the skin color categories corresponding to adjacent pixel value intervals are adjacent; if any two of the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is not adjacent to the skin color category indicated by any two maximum pixel ratios, or, the skin color categories indicated by the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio are different, then calculate the pixel average of the pixel value of the red channel, the pixel value of the green channel, and the pixel value of the blue channel of each target pixel; determine the target skin color category based on the pixel average of each target pixel.
[0158] Optionally, the second determination unit is also used to: for each skin color category, determine the pixel lower limit mean corresponding to the skin color according to the pixel lower limit value of the pixel value interval of the red channel, the pixel lower limit value of the pixel value interval of the green channel, and the pixel lower limit value of the pixel value interval of the blue channel corresponding to the skin color category; and determine the pixel upper limit mean corresponding to the skin color according to the pixel upper limit value of the pixel value interval of the red channel, the pixel upper limit value of the pixel value interval of the green channel, and the pixel upper limit value of the pixel value interval of the blue channel corresponding to the skin color category; determine the interval formed by the pixel lower limit mean and the pixel upper limit mean as the pixel value mean interval corresponding to the skin color; determine the proportion of pixels whose pixel average values belong to each pixel value mean interval in the target pixels; and determine the skin color category corresponding to the maximum proportion among the proportions as the target skin color category.
[0159] Optionally, the device is also used to: determine the pixel value corresponding to the critical color card according to the preset skin color category and the standard skin color card; wherein the critical color card is the color card corresponding to the skin color category when the skin color category changes; based on the pixel value corresponding to the critical color card, calculate the pixel threshold between each skin color category; based on each pixel threshold, determine the pixel value interval corresponding to each skin color category.
[0160] Optionally, the target object is a human face, the target area is a human face area, and the acquisition unit is further used to: perform feature extraction on the human face area to obtain facial feature points in the human face area; determine the skin area in the human face area based on the facial feature points; take at least a portion of the pixels in the skin area as target pixels, and obtain the pixel value of the target pixel.
[0161] Optionally, the skin area includes at least one local skin sub-area; the local skin sub-area includes: chin area, upper left cheek area, middle left cheek area, lower left cheek area, upper right cheek area, middle right cheek area, lower right cheek area, root of nose area and glabellar area.
[0162] The skin color recognition device of the present invention can simply and efficiently recognize the skin color category of the target object in the image to be recognized, without the need for data annotation and training of deep models, thus saving manpower and time costs.
[0163] The device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0164] In another embodiment of the present invention, a computer storage medium is provided, on which a computer program is stored. When a computer runs the computer program, the steps of the method in the above method embodiment are executed.
[0165] In another embodiment of the present invention, a computer program is also provided, which can be stored in a cloud or local storage medium. When the computer program is run by a computer or a processor, it is used to perform the corresponding steps of the method of the embodiment of the present invention, and is used to implement the corresponding modules in the skin color recognition device according to the embodiment of the present invention.
[0166] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0167] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0168] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0169] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0170] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0171] In addition, each functional unit in each embodiment of the present invention may be integrated into one analysis unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0172] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that can be executed by an analyzer. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.
[0173] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for identifying skin color, characterized in that: include: Determine a target area corresponding to a target object in an image to be identified; Acquire pixel values of at least a portion of target pixels in the target area; wherein the target pixels belong to a skin area in the target area; Determining a target skin color category to which the target object belongs based on the pixel value and the pixel value intervals corresponding to each skin color category; The step of determining the target skin color category to which the target object belongs based on the pixel value and the pixel value intervals corresponding to each skin color category includes: Calculating a pixel mean of the at least a portion of target pixels; Matching the pixel mean with the pixel value intervals corresponding to each skin color category to determine the target skin color category to which the target object belongs; The pixel mean includes: the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel; the pixel value intervals corresponding to each skin color category include: the pixel value interval of the red channel corresponding to each skin color category, the pixel value interval of the green channel corresponding to each skin color category and the pixel value interval of the blue channel corresponding to each skin color category; Accordingly, the calculating the pixel mean of the at least a portion of the target pixels includes: Respectively calculating a pixel mean of a red channel, a pixel mean of a green channel, and a pixel mean of a blue channel of the at least a portion of the target pixels; The matching of the pixel mean with the pixel value intervals corresponding to the skin color categories to determine the target skin color category to which the target object belongs includes: Matching the pixel mean of the red channel with the pixel value interval of the red channel corresponding to each skin color category to obtain a first matching result, matching the pixel mean of the green channel with the pixel value interval of the green channel corresponding to each skin color category to obtain a second matching result, and matching the pixel mean of the blue channel with the pixel value interval of the blue channel corresponding to each skin color category to obtain a third matching result; Determine the target skin color category to which the target object belongs according to the first matching result, the second matching result, and the third matching result; Wherein, determining the target skin color category to which the target object belongs according to the first matching result, the second matching result, and the third matching result includes: If the first matching result, the second matching result and the third matching result indicate the same skin color category, determining the skin color category indicated by the first matching result, the second matching result and the third matching result as the target skin color category; If any two of the first matching result, the second matching result and the third matching result indicate the same skin color category, and the skin color category indicated by another matching result is adjacent to the skin color category indicated by the any two matching results, the skin color category indicated by the any two matching results is determined as the target skin color category; wherein the skin color categories corresponding to adjacent pixel value intervals are adjacent; If any two of the first matching result, the second matching result, and the third matching result indicate the same skin color category, and the skin color category indicated by the other matching result is not adjacent to the skin color category indicated by the any two matching results, or the skin color categories indicated by the first matching result, the second matching result, and the third matching result are different, then calculating the arithmetic mean of the pixel mean of the red channel, the pixel mean of the green channel, and the pixel mean of the blue channel, and determining the target skin color category based on the arithmetic mean; or, The pixel values include: pixel values of a red channel, pixel values of a green channel, and pixel values of a blue channel, and the pixel value intervals corresponding to the skin color categories include: pixel value intervals of a red channel corresponding to the skin color categories, pixel value intervals of a green channel corresponding to the skin color categories, and pixel value intervals of a blue channel corresponding to the skin color categories; Correspondingly, determining the target skin color category to which the target object belongs based on the pixel value and the pixel value intervals corresponding to each skin color category includes: Determine a first pixel ratio of pixels whose red channel pixel values belong to the red channel pixel value interval corresponding to each skin color category in the target pixel, a second pixel ratio of pixels whose green channel pixel values belong to the green channel pixel value interval corresponding to each skin color category in the target pixel, and a third pixel ratio of pixels whose blue channel pixel values belong to the blue channel pixel value interval corresponding to each skin color category in the target pixel; Determining the target skin color category based on the first pixel ratio, the second pixel ratio, and the third pixel ratio; Wherein, determining the target skin color category based on the first pixel ratio, the second pixel ratio, and the third pixel ratio includes: If the maximum pixel ratio among the first pixel ratios, the maximum pixel ratio among the second pixel ratios, and the maximum pixel ratio among the third pixel ratios indicate the same skin color category, the skin color category indicated by the maximum pixel ratio among the first pixel ratios, the maximum pixel ratio among the second pixel ratios, and the maximum pixel ratio among the third pixel ratios is determined as the target skin color category; If any two of the maximum pixel ratios in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is adjacent to the skin color category indicated by the any two maximum pixel ratios, the skin color category indicated by the any two maximum pixel ratios is determined as the target skin color category; wherein the skin color categories corresponding to adjacent pixel value intervals are adjacent; If any two of the maximum pixel ratios in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is not adjacent to the skin color categories indicated by the any two maximum pixel ratios, or the skin color categories indicated by the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio are different, then calculate the pixel average of the pixel value of the red channel, the pixel value of the green channel, and the pixel value of the blue channel of each of the target pixels; The target skin color category is determined based on a pixel average value for each target pixel.
2. The method according to claim 1, characterized in that Determining the target skin color category based on the arithmetic mean includes: For each skin color category, a lower limit mean value of pixels corresponding to the skin color is determined based on a lower limit value of pixels of a pixel value interval of a red channel, a lower limit value of pixels of a pixel value interval of a green channel, and a lower limit value of pixels of a pixel value interval of a blue channel corresponding to the skin color category, and an upper limit mean value of pixels corresponding to the skin color is determined based on an upper limit value of pixels of a pixel value interval of a red channel, a upper limit value of pixels of a pixel value interval of a green channel, and a upper limit value of pixels of a pixel value interval of a blue channel corresponding to the skin color category; Determine the interval formed by the lower pixel mean value and the upper pixel mean value as the pixel value mean interval corresponding to the skin color; Matching the arithmetic mean with each pixel value mean interval to determine the pixel value mean interval to which the arithmetic mean belongs; The skin color category corresponding to the pixel value mean interval to which the arithmetic mean belongs is determined as the target skin color category.
3. The method according to claim 1, characterized in that The step of determining the target skin color category based on the pixel average of each target pixel comprises: For each skin color category, a lower limit mean value of pixels corresponding to the skin color is determined based on a lower limit value of pixels of a pixel value interval of a red channel, a lower limit value of pixels of a pixel value interval of a green channel, and a lower limit value of pixels of a pixel value interval of a blue channel corresponding to the skin color category, and an upper limit mean value of pixels corresponding to the skin color is determined based on an upper limit value of pixels of a pixel value interval of a red channel, a upper limit value of pixels of a pixel value interval of a green channel, and a upper limit value of pixels of a pixel value interval of a blue channel corresponding to the skin color category; Determine the interval formed by the lower pixel mean value and the upper pixel mean value as the pixel value mean interval corresponding to the skin color; Determine the proportion of pixels whose pixel average value belongs to each pixel value average interval in the target pixels; The skin color category corresponding to the maximum proportion among the proportions is determined as the target skin color category.
4. The method according to any one of claims 1 to 3, characterized in that The pixel value interval corresponding to each skin color category is determined by the following steps: Determine the pixel value corresponding to the critical color card according to the preset skin color category and the standard skin color card; wherein the critical color card is the color card corresponding to the skin color category when it changes; Calculating pixel thresholds between skin color categories based on pixel values corresponding to the critical color card; The pixel value intervals corresponding to the skin color categories are determined based on the pixel thresholds.
5. The method according to any one of claims 1, characterized in that The target object is a human face, and the target area is a human face area; The obtaining pixel values of at least a portion of target pixels in the target area includes: Extracting features from the face region to obtain facial feature points in the face region; Determining a skin area in the face area based on the face feature points; At least a portion of pixels in the skin area are used as the target pixels, and pixel values of the target pixels are acquired.
6. The method according to claim 5, characterized in that The skin area includes at least one local skin sub-area; the local skin sub-area includes: chin area, upper left cheek area, middle left cheek area, lower left cheek area, upper right cheek area, middle right cheek area, lower right cheek area, root of nose area and glabellar area.
7. A skin color recognition device, characterized in that: include: A first determining unit, used to determine a target area corresponding to a target object in an image to be identified; An acquisition unit, configured to acquire pixel values of at least a portion of target pixels in the target area; wherein the target pixels belong to a skin area in the target area; A second determining unit, configured to determine a target skin color category to which the target object belongs based on the pixel value and the pixel value intervals corresponding to each skin color category; The second determination unit is further used to: calculate the pixel mean of the at least part of the target pixels; match the pixel mean with the pixel value intervals corresponding to the skin color categories to determine the target skin color category to which the target object belongs; The pixel mean includes: the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel; the pixel value intervals corresponding to each skin color category include: the pixel value interval of the red channel corresponding to each skin color category, the pixel value interval of the green channel corresponding to each skin color category and the pixel value interval of the blue channel corresponding to each skin color category; The second determination unit is further used to: respectively calculate the pixel mean of the red channel, the pixel mean of the green channel, and the pixel mean of the blue channel of the at least part of the target pixels; match the pixel mean of the red channel with the pixel value interval of the red channel corresponding to the skin color categories to obtain a first matching result, match the pixel mean of the green channel with the pixel value interval of the green channel corresponding to the skin color categories to obtain a second matching result, and match the pixel mean of the blue channel with the pixel value interval of the blue channel corresponding to the skin color categories to obtain a third matching result; determine the target skin color category to which the target object belongs based on the first matching result, the second matching result, and the third matching result; Wherein, the second determination unit is further used for: if the first matching result, the second matching result and the third matching result indicate the same skin color category, then the skin color category indicated by the first matching result, the second matching result and the third matching result is determined as the target skin color category; if any two matching results among the first matching result, the second matching result and the third matching result indicate the same skin color category, and the skin color category indicated by the other matching result is adjacent to the skin color category indicated by the any two matching results, then the skin color category indicated by the any two matching results is determined as the target skin color category; wherein the skin color categories corresponding to adjacent pixel value intervals are adjacent; if any two matching results among the first matching result, the second matching result and the third matching result indicate the same skin color category, and the skin color category indicated by the other matching result is not adjacent to the skin color category indicated by the any two matching results, or the skin color categories indicated by the first matching result, the second matching result and the third matching result are different, then the arithmetic average of the pixel mean of the red channel, the pixel mean of the green channel and the pixel mean of the blue channel is calculated, and the target skin color category is determined based on the arithmetic average; or, The pixel values include: pixel values of a red channel, pixel values of a green channel, and pixel values of a blue channel, and the pixel value intervals corresponding to the skin color categories include: pixel value intervals of a red channel corresponding to the skin color categories, pixel value intervals of a green channel corresponding to the skin color categories, and pixel value intervals of a blue channel corresponding to the skin color categories; The second determination unit is further used to: determine a first pixel ratio of pixels whose red channel pixel values belong to the red channel pixel value interval corresponding to each skin color category in the target pixel, a second pixel ratio of pixels whose green channel pixel values belong to the green channel pixel value interval corresponding to each skin color category in the target pixel, and a third pixel ratio of pixels whose blue channel pixel values belong to the blue channel pixel value interval corresponding to each skin color category in the target pixel; determine the target skin color category based on the first pixel ratio, the second pixel ratio and the third pixel ratio; Among them, the second determination unit is also used for: if the maximum pixel ratio among the first pixel ratio, the maximum pixel ratio among the second pixel ratio and the maximum pixel ratio among the third pixel ratio indicate the same skin color category, then the skin color category indicated by the maximum pixel ratio among the first pixel ratio, the maximum pixel ratio among the second pixel ratio and the maximum pixel ratio among the third pixel ratio is determined as the target skin color category; if any two of the maximum pixel ratio among the first pixel ratio, the maximum pixel ratio among the second pixel ratio and the maximum pixel ratio among the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is adjacent to the skin color category indicated by any two maximum pixel ratios, then the skin color category indicated by any two maximum pixel ratios is determined is determined as the target skin color category; wherein, the skin color categories corresponding to adjacent pixel value intervals are adjacent; if any two of the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio indicate the same skin color category, and the skin color category indicated by another maximum pixel ratio is not adjacent to the skin color category indicated by the any two maximum pixel ratios, or the skin color categories indicated by the maximum pixel ratio in the first pixel ratio, the maximum pixel ratio in the second pixel ratio, and the maximum pixel ratio in the third pixel ratio are different, then calculate the pixel average of the pixel value of the red channel, the pixel value of the green channel, and the pixel value of the blue channel of each of the target pixels; determine the target skin color category based on the pixel average of each target pixel.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable medium having a non-volatile program code executable by a processor, characterized in that: The program code enables the processor to execute the steps of the method according to any one of claims 1 to 6.
