Image processing method, apparatus, device, and storage medium
By converting facial images into color gradient maps, analyzing and identifying sensitive areas, the problem of low detection efficiency of sensitive areas on the face is solved, and fast and convenient sensitive area identification is achieved.
Patent Information
- Application Number
- CN202011298374.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-18
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2040-11-18
AI Technical Summary
In existing technologies, the detection efficiency of sensitive areas on the face is low, making it difficult for users to quickly and conveniently identify sensitive areas on their face.
By acquiring facial images, converting them into color gradient maps, analyzing target pixels in the color gradient maps, identifying sensitive locations on the skin, and providing identification results to indicate sensitive areas.
This allows users to quickly and intuitively understand the location of sensitive areas on their facial skin, improving detection efficiency, reducing costs, and overcoming site limitations.
Smart Images

Figure CN113762010B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image processing method, apparatus, device, and storage medium. Background Technology
[0002] With the fast pace of modern life, people are more prone to developing sensitive skin due to increased stress in their daily lives. Sensitive skin is a potential skin problem characterized by a thin stratum corneum, severe redness, frequent dryness and dehydration, and a tendency to peel and become allergic. These sensitive areas on the face can be called sensitive zones. When these sensitive areas are damaged by the external environment or when cosmetics or skincare products are applied, allergic reactions can easily occur. In daily life, it is difficult for people to see with the naked eye whether they have potential sensitive skin problems.
[0003] In existing technologies, users mainly determine whether their facial skin has sensitive areas by personally applying cosmetics or skincare products to their face and then checking whether there is any damage to the skin. This detection method can only identify sensitive areas when a sensitive reaction occurs on the face, and the detection efficiency is relatively slow. Summary of the Invention
[0004] This application provides an image processing method, apparatus, device, and storage medium to address the problem of low detection efficiency in existing methods for sensitive areas of facial skin.
[0005] In a first aspect, embodiments of this application provide an image processing method, including:
[0006] Obtain the image to be identified from the face image, wherein the image to be identified includes the facial skin region;
[0007] The image to be labeled is converted into a color gradient map, and the target pixels in the image to be labeled are determined according to the color gradient map. The target pixels are used to characterize the sensitive location points of human facial skin.
[0008] The target pixels are labeled to obtain the labeling results, which are used to indicate the sensitive areas of the facial skin.
[0009] In one possible design of the first aspect, acquiring the image to be identified from the face image includes:
[0010] Obtain the pixel value of each pixel in the face image in the R channel;
[0011] Obtain the pixel value of each pixel in the face image in the G channel;
[0012] Obtain the pixel value of each pixel in the B channel of the face image;
[0013] Based on the pixel values of each pixel in the R channel, the G channel, and the B channel, facial skin pixels are determined from each pixel.
[0014] Based on the facial skin pixels, the face image is subjected to binary processing to obtain a binary image;
[0015] The connected regions in the binary image are filtered to obtain the image to be identified.
[0016] In another possible design of the first aspect, determining facial skin pixels from the individual pixels based on the pixel values in the R channel, the G channel, and the B channel of each pixel includes:
[0017] The first pixel is the pixel whose R channel value is greater than the G channel value and whose R channel value is greater than the B channel value.
[0018] Obtain the minimum difference between the pixel value of the G channel and the pixel value of the B channel in the first pixel.
[0019] When the pixel value of the first pixel in the R channel, the pixel value in the G channel, and the pixel value in the B channel are all greater than the first preset parameter, and the difference between the pixel value of the first pixel in the R channel and the minimum difference is greater than the preset pixel difference, the first pixel is determined to be a facial skin pixel.
[0020] In another possible design of the first aspect, determining facial skin pixels from the individual pixels based on the pixel values in the R channel, the G channel, and the B channel of each pixel includes:
[0021] The second pixel is the pixel whose R channel value is greater than its G channel value and whose R channel value is greater than its G channel value.
[0022] Pixels in the second pixel whose pixel values in the R channel, G channel, and B channel are all greater than the second preset parameter are selected as facial skin pixels.
[0023] In another possible design of the first aspect, the step of filtering the connected regions in the binary image to obtain the image to be identified includes:
[0024] Obtain the area of the connected regions in the binary image;
[0025] Connected regions with an area smaller than a preset area are filtered out to obtain the image to be labeled.
[0026] In another possible design of the first aspect, converting the image to be identified into a color gradient map includes:
[0027] Obtain the pixel value of each pixel in the R channel of the image to be identified;
[0028] Obtain the pixel value of each pixel in the G channel of the image to be identified;
[0029] Obtain the pixel value of each pixel in the B channel of the image to be identified;
[0030] Based on the pixel values of each pixel in the image to be labeled in the R channel, the G channel, and the B channel, the image to be labeled is converted into a color gradient map.
[0031] In another possible design of the first aspect, converting the image to be labeled into a color gradient map based on the pixel values of each pixel in the R channel, the G channel, and the B channel of the image to be labeled includes:
[0032] Obtain the pixel value of each pixel in the image to be identified in the G channel and the average pixel value in the B channel;
[0033] The difference between the pixel value in the R channel of each pixel in the image to be labeled and the mean pixel value is obtained, and the color value of each pixel in the image to be labeled is calculated.
[0034] Based on the color values, the image to be identified is converted into a color gradient map.
[0035] In another possible design of the first aspect, the identification result includes a face identification image, and the identification of the target pixels to obtain the identification result includes:
[0036] The pixel values of the target pixels are updated according to the preset differentiation function to obtain the face identification image.
[0037] In another possible design of the first aspect, updating the pixel values of the target pixels according to a preset differentiation function to obtain a face identification image includes:
[0038] The pixel value of the target pixel in the G channel is updated according to the preset differentiation function;
[0039] The pixel value of the target pixel in the B channel is updated according to the preset differentiation function to obtain the identification image.
[0040] In another possible design of the first aspect, prior to acquiring the image to be identified from the face image, the method further includes:
[0041] A sample image is acquired, and a face detection is performed on the sample image according to a preset face detection algorithm to obtain the face image.
[0042] Secondly, embodiments of this application provide an image processing apparatus, comprising:
[0043] The image acquisition module is used to acquire an image to be identified from a face image, wherein the image to be identified includes the skin region of the face;
[0044] An image conversion module is used to convert the image to be identified into a color gradient map, and to determine the target pixels in the image to be identified based on the color gradient map. The target pixels are used to characterize the sensitive location points of human facial skin.
[0045] The identification module is used to identify the target pixels and obtain identification results, which are used to indicate sensitive areas of facial skin.
[0046] Thirdly, embodiments of this application provide an image processing device, including a memory and at least one processor;
[0047] The memory stores computer-executed instructions;
[0048] The at least one processor executes the computer execution instructions stored in the memory, causing the at least one processor to perform the method described above.
[0049] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, wherein the computer-readable storage medium stores computer instructions, which, when executed by a processor, are used to implement the method described above.
[0050] The image processing method, apparatus, device, and storage medium provided in this application embodiment allow users to input their own facial images. By recognizing the user's facial image, the skin region in the facial image is determined. Then, a color gradient map is used to determine whether there are sensitive points on the skin region, and these sensitive points are marked. Users can then intuitively see which areas of their facial skin are sensitive from the marking results, enabling users to understand the changes in the sensitive areas of their facial skin in real time and improving the efficiency of sensitive area detection on the user's facial skin. Attached Figure Description
[0051] Figure 1 A schematic diagram illustrating a scenario application of the image processing method provided in the embodiments of this application;
[0052] Figure 2 A schematic flowchart of an embodiment of the image processing method provided in this application;
[0053] Figure 3 A schematic diagram of the image to be identified provided in an embodiment of this application;
[0054] Figure 4 A schematic diagram of the color gradient map obtained by converting the image to be identified according to an embodiment of this application;
[0055] Figure 5 A schematic flowchart of Embodiment 2 of the image processing method provided in this application;
[0056] Figure 6 A flowchart illustrating Embodiment 3 of the image processing method provided in this application;
[0057] Figure 7 This is a schematic diagram of a binary image provided in an embodiment of this application;
[0058] Figure 8 A schematic diagram illustrating the process of filtering out connected regions smaller than a preset area from images provided in this application embodiment;
[0059] Figure 9 A schematic flowchart of Embodiment 4 of the image processing method provided in this application;
[0060] Figure 10 This is a flowchart illustrating Embodiment 5 of the image processing method provided in this application.
[0061] Figure 11 A schematic diagram of the differentiation function provided in the embodiments of this application;
[0062] Figure 12 This is a schematic diagram of the structure of the image processing apparatus provided in the embodiments of this application;
[0063] Figure 13 This is a schematic diagram of the structure of the image processing device provided in the embodiments of this application. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0065] The following explanations are provided for some of the terms used in the embodiments of this application, so that those skilled in the art can understand them:
[0066] R channel: Every image has one or more color channels, where the R channel represents a red channel.
[0067] G channel: Every image has one or more color channels, where the G channel represents a green channel.
[0068] B channel: Every image has one or more color channels, where the B channel represents a blue channel.
[0069] Figure 1 This is a schematic diagram illustrating a scenario application of the image processing method provided in the embodiments of this application, such as... Figure 1 As shown, the application scenario of this embodiment is a mobile terminal 10. The mobile terminal 10 can be equipped with a camera, which can capture the user's facial image. The mobile terminal 10 is equipped with an image processing algorithm. When the user wants to know which parts of their face are sensitive skin areas, they only need to take a picture through the mobile terminal 10, and then process the picture through the image processing method provided in this application, and finally output a facial image marked with sensitive areas for the user to view.
[0070] For example, after processing a photo using the image processing method provided in this application, in addition to directly outputting a face image marked with sensitive areas for users to view, it is also possible to output sensitive area information in text or numerical form, such as outputting the location coordinates of the sensitive area in the face, or outputting which organ in the face the sensitive area is located on, so that users can understand which parts of the face are sensitive areas.
[0071] In existing technologies, the most common way for users to find out if there are sensitive areas on their face is by applying cosmetics or skincare products to their face or exposing their face to external environmental damage (such as ultraviolet rays). Only when the facial skin produces a sensitive reaction can users see which areas are sensitive. This method is not convenient for users to quickly and effectively find out if there are sensitive areas on their face.
[0072] There are also some less widely available methods that use specialized equipment to scan the user's face to determine which areas on the face are sensitive. This method is expensive and limited by location, and cannot provide results quickly and in real time.
[0073] In summary, for the identification and detection of sensitive areas in a face, there is currently no suitable detection method that can both quickly obtain detection results and meet the requirements of low cost and ease of use.
[0074] To address the aforementioned issues, this application provides an image processing method, apparatus, device, and storage medium. The main idea is as follows: Although these potentially sensitive areas in a face are difficult to detect with the naked eye, their thin stratum corneum and severe redness cause a color difference between the sensitive skin and the surrounding normal skin. Therefore, an image containing facial skin can be converted into a color gradient map. By analyzing the color gradient map, the pixels with higher pixel values are likely to be sensitive areas. By marking these pixels, the sensitive areas of the facial skin can be identified. Users only need to input their own facial image to understand which areas of their face contain sensitive areas, enabling convenient and rapid detection and improving the efficiency of sensitive facial area detection.
[0075] The technical solution of this application will now be described in detail through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0076] Figure 2 This is a flowchart illustrating an embodiment of the image processing method provided in this application. This image processing method can be applied to mobile terminals or other devices with image processing capabilities. Figure 2 As shown, the image processing method may include the following steps:
[0077] S201. Obtain the image to be identified from the face image.
[0078] The image to be identified includes the skin area of a face. The face image includes facial information and non-facial information. For example, the non-facial information includes background image information, while the facial information includes the skin area of the face, the organ area of the face, and the hair area, etc.
[0079] Understandably, in mobile terminal application scenarios, users can directly capture their own facial images through the mobile terminal, and the captured facial images are directly saved in the mobile terminal.
[0080] Specifically, when a user takes a picture of their face using a mobile device, the resulting image can only be used as a sample image. This sample image contains a lot of interfering information, such as background information. To minimize this interference, a preset face detection algorithm is used to detect faces in the sample image, and the result is then used as the face image. For example, the preset face detection algorithm could be a Single Shot MultiBox Detector (SSD) face detection algorithm.
[0081] For example, users can also use mobile terminal communication technology to communicate with other mobile terminals and obtain facial images of other users.
[0082] Optionally, this application embodiment uses a mobile terminal as the execution subject for illustration. Optionally, after a user takes a picture of their face and saves it in the mobile terminal, the mobile terminal can identify which areas in the face image are facial skin areas, which are facial organ areas (such as ears and eyes), and which are hair areas (such as eyebrows, beards, and hair).
[0083] For example, the pixel values of pixels in the skin region, facial organ region, and hair region of a face are different. The mobile terminal can distinguish the pixel values of each pixel in the face image, thereby identifying the skin region of the face.
[0084] Optionally, the mobile terminal can also pre-set a template image with a template area, then adaptively stack the face image onto the template image, and then determine the facial skin area in the face image based on the drawn template area.
[0085] Optionally, in order to better distinguish facial skin areas, the image to be labeled can be a binary image, that is, the facial skin area is assigned one value and the non-facial skin area is assigned another value. The entire image to be labeled only includes the areas represented by these two values, so that it can be quickly distinguished.
[0086] S202. Convert the image to be labeled into a color gradient map, and determine the target pixel in the image to be labeled based on the color gradient map.
[0087] Among them, the target pixels are used to represent the sensitive locations of the human face skin.
[0088] For example, in this embodiment, a corresponding application software can be installed on a mobile terminal to realize the conversion of the color gradient map. For example, the application software can first read the pixel value of each pixel in the image to be identified, and then convert the pixel value through a preset conversion formula. After the pixel value of each pixel is converted, the color gradient map is obtained.
[0089] For example, pixels with pixel values greater than a preset pixel threshold in the color gradient map can be selected as target pixels.
[0090] Optionally, the color gradient map can be divided into several small regions, and then it can be determined whether the difference between the pixel value of each pixel and the pixel value of its neighboring pixels in each small region is higher than a preset difference. If in a small region, the difference between the pixel value of a pixel and the pixel value of its surrounding neighboring pixels is higher than the preset difference, then that pixel is selected as the target pixel.
[0091] For example, Figure 3 This is a schematic diagram of the image to be identified provided in an embodiment of this application. The white area in the image represents the skin area of a face, while the black area represents non-face areas. Figure 4 This is a schematic diagram of the color gradient map obtained by converting the image to be identified according to an embodiment of this application. The color values of pixels at different positions in the color gradient map are different.
[0092] S203. Mark the target pixels to obtain the marking results.
[0093] The identification result is used to indicate the sensitive areas of the facial skin. For example, the identification result can be a facial image after the target pixels have been marked.
[0094] For example, if the identification result is a face image after the target pixels are marked, the mobile terminal can color-mark these target pixels to highlight them, and then directly output the identification result to the display interface for the user to view.
[0095] Optionally, the identification result can also be a text label. The mobile terminal generates the corresponding text label based on the position of the target pixel on the face, and then outputs the text label to the display interface for the user to view.
[0096] Optionally, the mobile terminal can update the pixel values of these target pixels by using a preset differentiation function to update the pixel values of each target pixel to a new pixel value, thereby achieving the purpose of identification. Afterwards, the mobile terminal outputs the face image containing the target pixels and the updated pixel values to the display interface for the user to view.
[0097] This application embodiment converts an image containing facial skin areas into a color gradient map, uses the color gradient map to determine sensitive areas in the facial skin, and marks these sensitive areas, allowing users to easily and quickly understand the location of their own facial skin's sensitive areas.
[0098] For example, based on the above embodiments, Figure 5 This is a schematic flowchart of Embodiment 2 of the image processing method provided in this application. Figure 5 As shown, step S201 above can be implemented through the following steps:
[0099] S501. Obtain the pixel value of each pixel in the R channel of the face image;
[0100] S502, Obtain the pixel value of each pixel in the face image in the G channel;
[0101] S503. Obtain the pixel value of each pixel in the B channel of the face image;
[0102] S504. Determine the facial skin pixels from each pixel based on the pixel values in the R channel, the G channel, and the B channel.
[0103] S505. Based on the facial skin pixels, perform binary processing on the facial image to obtain a binary image;
[0104] S506. Filter the connected regions in the binary image to obtain the image to be labeled.
[0105] In this embodiment, the face image includes three color channels: R, G, and B. Under different color channels, the pixel values of pixels at the same position may be different. For example, a pixel at the same position may have a first pixel value in the R channel, a second pixel value in the G channel, and a third pixel value in the B channel. The first, second, and third pixel values may be different.
[0106] For example, the first pixel value of pixel A1 at position A is R1, the second pixel value is G1, and the third pixel value is B1. The first pixel value of pixel B at position B is R2, the second pixel value is G2, and the third pixel value is B2. Then, the sizes of R1 and R2 can be different, the sizes of G1 and G2 can be different, and the sizes of B1 and B2 can be different.
[0107] For example, a mobile terminal can determine facial skin pixels based on the relationship between the pixel values in the R channel, the G channel, and the B channel of each pixel. Once all facial skin pixels in the face image have been determined, the facial skin region can be obtained.
[0108] In this embodiment, in order to facilitate the identification of facial skin regions and non-facial skin regions, the facial image is binarized, with facial skin pixels having a value of 1 and non-facial skin pixels having a value of 0, resulting in a binary image. Then, the connected regions in the binary image are filtered to remove noise, and finally the image to be identified is obtained.
[0109] Optionally, in some embodiments, a face image includes a number of pixels, and two criteria can be set to determine whether these pixels are facial skin pixels:
[0110] The first criterion is: determine the pixel point whose R channel pixel value is greater than the G channel pixel value, and the pixel point whose R channel pixel value is greater than the G channel pixel value. The pixel point that satisfies the first condition is called the first pixel point. There can be multiple first pixels point, as follows:
[0111] R(i,j)>G(i,j)and R(i,j)>B(i,j)
[0112] In the above formula, a face image can be represented by I, and the size of the face image is M*N. I is divided into three channels: R, G, and B. For a pixel (i, j) on image I, R(i, j) represents the pixel value of pixel (i, j) in channel R, G(i, j) represents the pixel value of pixel (i, j) in channel G, and B(i, j) represents the pixel value of pixel (i, j) in channel B.
[0113] The second criterion is: in the first pixel point, the pixel values of the R channel, G channel, and B channel are all greater than the first preset parameter, and the difference between the pixel value of the R channel and the minimum difference is greater than the preset pixel difference. Pixel points that satisfy both the first and second criterion are facial skin pixels, as detailed below:
[0114]
[0115] In the above formula, the first preset parameter may include th1, th2, and th3. min(G(i,j)-B(i,j)) represents the minimum difference, that is, among several first pixels, there is a pixel whose pixel value in the G channel and pixel value in the B channel have the minimum difference. th4 represents the preset pixel difference.
[0116] For example, th1 = 95, th2 = 40, th3 = 20, and th4 = 15.
[0117] Optionally, in some embodiments, a face image includes a plurality of pixels. Two determining conditions can be set to determine whether these pixels are facial skin pixels. The first determining condition is the same as the first judgment condition described above. In this case, for ease of distinction, pixels that satisfy the first judgment condition are referred to as second pixels. The number of second pixels can be multiple. The second determining condition is: among the second pixels, pixels whose R-channel pixel values, G-channel pixel values, and B-channel pixel values are greater than a second preset parameter are determined to be facial skin pixels, as detailed below:
[0118]
[0119] In the above formula, the second preset parameters include TH1, TH2, and TH3. For example, TH1 = 220, TH2 = 210, and TH3 = 170.
[0120] This application embodiment obtains the pixel values of each pixel in different color channels of a face image, determines the facial skin pixels based on the size relationship of the pixel values, and performs binary processing after determining the facial skin pixels to filter and obtain the image to be identified. This can effectively eliminate the interference of other non-skin areas in the face image and accurately identify the facial skin area in the face image.
[0121] For example, based on the above embodiments, Figure 6 A flowchart illustrating Embodiment 3 of the image processing method provided in this application is shown below. Figure 6 As shown, step S506 above can be implemented through the following steps:
[0122] S601. Obtain the area of a connected region in a binary image;
[0123] S602. Filter out connected regions whose area is smaller than the preset area to obtain the image to be labeled.
[0124] In this embodiment, a connected region refers to an image region composed of pixels with the same pixel value and adjacent positions. In a binary image, the pixel value has only two values: the value of the facial skin region can be 1, and the value of the non-facial skin region can be 0.
[0125] For example, Figure 7 This is a schematic diagram of a binary image provided in an embodiment of this application, such as... Figure 7 As shown, it includes a large white area (i.e., the facial skin area) and a large black area (the user's hair area). The black area also contains several small, connected white regions. These connected regions have areas smaller than a preset area; removing them yields the image to be labeled. Figure 8 As shown, Figure 8 This is a schematic diagram of an image to be labeled that filters out connected regions smaller than a preset area, as provided in an embodiment of this application. The filtered connected regions become regions with a value of 0, that is, they also become black regions.
[0126] For example, the preset area can be 8.
[0127] This application embodiment reduces noise interference by filtering out smaller areas in the connected region, accurately identifying the facial skin area, thereby improving the accuracy of identifying sensitive areas in the facial skin area.
[0128] Based on the above embodiments, Figure 9 The flowchart of the image processing method provided in Embodiment 4 of this application is shown below. Figure 9 As shown, step S202 above can be implemented through the following steps:
[0129] S901. Obtain the pixel value of each pixel in the R channel of the image to be identified;
[0130] S902. Obtain the pixel value of each pixel in the G channel of the image to be identified;
[0131] S903. Obtain the pixel value of each pixel in the B channel of the image to be identified;
[0132] S904. Based on the pixel values of each pixel in the image to be labeled in the R channel, the G channel, and the B channel, convert the image to be labeled into a color gradient map.
[0133] In this embodiment, the pixel values in the R channel, G channel, and B channel of each pixel can be different. Specifically, the pixel value in the R channel is the fourth pixel value, the pixel value in the G channel is the fifth pixel value, and the pixel value in the B channel is the sixth pixel value. The fourth pixel value, the fifth pixel value, and the sixth pixel value of each pixel can all be different.
[0134] For example, if pixel C has a fourth pixel value of R3, a fifth pixel value of G3, and a sixth pixel value of B3, and pixel D has a fourth pixel value of R4, a fifth pixel value of G4, and a sixth pixel value of B4, then R3 can be different from R4, G3 can be different from G4, and B3 can be different from B4.
[0135] Optionally, the pixel value of each pixel in the G channel and the pixel value in the B channel can be calculated, and then the difference between the pixel value of the pixel in the R channel and the pixel value can be calculated. This difference is used as the color value of the pixel. In this way, the color value of each pixel in the image to be labeled can be obtained. Based on the color value, the image to be labeled is transformed to obtain a color gradient map.
[0136] For example, the image to be labeled can be converted into a color gradient image using a preset calculation formula, the specific calculation formula of which is as follows:
[0137]
[0138] In the above formula, R(i,j) is the pixel value of pixel (i,j) in the R channel, G(i,j) is the pixel value of pixel (i,j) in the G channel, B(i,j) is the pixel value of pixel (i,j) in the B channel, and M2(i,j) represents the value of pixel (i,j) in the image to be labeled. When pixel (i,j) in the image to be labeled is located in a non-face skin area, M2(i,j) is 0, and when pixel (i,j) in the image to be labeled is located in a face skin area, M2(i,j) is greater than 0.
[0139] This application embodiment obtains the pixel values of each pixel in different color channels of the image to be labeled, then converts the pixel values to obtain color values, and converts the image to be labeled into a color gradient map based on the color values, thereby enabling rapid identification of sensitive areas in the color gradient map and improving the detection efficiency of sensitive areas.
[0140] For example, based on the above embodiments, Figure 10 A schematic flowchart of Embodiment 5 of the image processing method provided in this application is shown below. Figure 10 As shown, if the identification result includes a face identification image, the method includes the following steps:
[0141] S1001. Obtain the image to be identified from the face image;
[0142] S1002. Convert the image to be labeled into a color gradient map, and determine the target pixel in the image to be labeled based on the color gradient map.
[0143] S1003. Update the pixel values of the target pixels according to the preset differentiation function to obtain the face identification image.
[0144] The image to be labeled includes the facial skin area; the target pixels are used to represent sensitive locations on the facial skin.
[0145] In this embodiment, steps 1001-S1002 are similar to steps S201-S202, and the details can be found in the description of steps S201-S202, which will not be repeated here. In step S1003, the preset differentiation function can be as follows:
[0146]
[0147] In the above formula, 'a' can be a constant; for example, a = 0.5.
[0148]
[0149] x represents the pixel value of the target pixel, y represents the updated pixel value after the target pixel is updated, M*N represents the size of the face image, and D(i, j) represents the color value of pixel (i, j). For example, Figure 11 A schematic diagram of the differentiation function provided in the embodiments of this application is shown below. Figure 11 As shown, in this differentiation function, the value of a is 0.5, the value of b is 50, and the value of c is 48.
[0150] In this embodiment, after the target pixel is found, the pixel value of the target pixel in the face image can be updated according to the preset differentiation function mentioned above. After the update is completed, the face identification image is output, which allows users to easily and quickly view the sensitive area.
[0151] For example, in some embodiments, after the target pixel is found, the pixel values in each color channel of the target pixel can be updated according to a preset differentiation function. Specifically, the pixel values in the G channel of the target pixel are updated according to the preset differentiation function; the pixel values in the B channel of the target pixel are updated according to the preset differentiation function to obtain the identification image.
[0152] Optionally, when updating the pixel value of the target pixel in the G channel, the updated pixel value G′(i,j) of the G channel can be calculated using the following formula:
[0153]
[0154] Update the pixel value of the target pixel in the G channel based on the updated pixel value G′(i,j).
[0155] Optionally, when updating the pixel value of the target pixel in the B channel, the updated pixel value B′(i,j) of the B channel can be calculated using the following formula:
[0156]
[0157] The image of the target pixel in the B channel is updated based on the updated pixel value B′(i,j).
[0158] This application embodiment uses a differentiation function to differentiate the pixel values of sensitive areas in different channels, making the sensitive areas appear as if they are in an allergic state, thus allowing users to more intuitively see where the allergic area is on the face.
[0159] The following are embodiments of the apparatus of this application, which can be used to execute the embodiments of the method of this application. For details not disclosed in the embodiments of the apparatus of this application, please refer to the embodiments of the method of this application.
[0160] Figure 12This is a schematic diagram of the image processing apparatus provided in the embodiments of this application. The apparatus can be integrated into a mobile terminal, or it can work independently of the mobile terminal while cooperating with it to implement the technical solutions of this application. Figure 12 As shown, the image processing device 120 may include: an image acquisition module 1201, an image conversion module 1202, and an identification module 1203.
[0161] The image acquisition module 1201 is used to acquire the image to be identified in the face image, and the image to be identified includes the skin area of the face;
[0162] The image conversion module 1202 is used to convert the image to be identified into a color gradient map, and to determine the target pixels in the image to be identified based on the color gradient map. The target pixels are used to characterize the sensitive location points of the human face skin.
[0163] The identification module 1203 is used to identify target pixels and obtain identification results, which are used to indicate sensitive areas of facial skin.
[0164] In any of the above embodiments, the image acquisition module 1201 can be specifically used to acquire the pixel values of each pixel in the R channel, the pixel values in the G channel, and the pixel values in the B channel of the face image; and determine the facial skin pixels from each pixel based on the pixel values in the R channel, the pixel values in the G channel, and the pixel values in the B channel of each pixel; and perform binary processing on the face image based on the facial skin pixels to obtain a binary image; and filter the connected regions in the binary image to obtain the image to be identified.
[0165] Optionally, in some embodiments, the image acquisition module 1201 may be specifically used to acquire pixels whose pixel values in the R channel are greater than those in the G channel and whose pixel values in the R channel are greater than those in the B channel as first pixels, and to acquire the minimum difference between the pixel values in the G channel and the pixel values in the B channel among the first pixels, and to acquire pixels whose pixel values in the R channel, the G channel, and the B channel are all greater than a first preset parameter, and whose difference between the pixel value in the R channel and the minimum difference is greater than a preset pixel difference, as facial skin pixels.
[0166] For example, in some embodiments, the image acquisition module 1201 is specifically used to acquire pixels whose pixel values in the R channel are greater than those in the G channel, and pixels whose pixel values in the R channel are greater than those in the G channel as second pixels, and to acquire pixels among the second pixels whose pixel values in the R channel, the G channel, and the B channel are all greater than a second preset parameter as facial skin pixels.
[0167] For example, in any of the above embodiments, the image acquisition module 1201 can be used to acquire the area of connected regions in a binary image; filter out connected regions whose area is smaller than a preset area to obtain the image to be identified.
[0168] Based on the above embodiments, the image conversion module 1202 can specifically be used to obtain the pixel values of each pixel in the R channel, the pixel values in the G channel, and the pixel values in the B channel of the image to be identified, and convert the image to be identified into a color gradient map according to the pixel values of each pixel in the R channel, the pixel values in the G channel, and the pixel values in the B channel of the image to be identified.
[0169] Based on the above embodiments, in some embodiments, the image conversion module 1202 can be specifically used to obtain the pixel value of each pixel in the image to be identified in the G channel and the pixel value in the B channel, and to obtain the difference between the pixel value of each pixel in the image to be identified in the R channel and the pixel value, calculate the color value of each pixel in the image to be identified, and convert the image to be identified into a color gradient map according to the color value.
[0170] For example, in some embodiments, the identification module 1203 may be used to update the pixel value of the target pixel according to a preset differentiation function to obtain a face identification image.
[0171] Optionally, based on the above embodiments, the identification module 1203 can be specifically used to update the pixel value of the target pixel in the G channel according to a preset differentiation function; and to update the pixel value of the target pixel in the B channel according to a preset differentiation function to obtain an identification image.
[0172] In some embodiments, the image processing apparatus further includes a face detection module, wherein the face detection module is used to acquire a sample image, perform face detection on the sample image according to a preset face detection algorithm, and obtain a face image.
[0173] The apparatus provided in this application embodiment can be used to perform the steps in the above method, and its implementation principle and technical effect are similar, so it will not be described again here.
[0174] It should be noted that the division of the various modules in the above device is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. Furthermore, these modules can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some modules can be implemented by processing element calls to software, while others are implemented in hardware. For example, the identification module can be a separate processing element, or it can be integrated into a chip in the above device. Alternatively, it can be stored as program code in the memory of the above device, and its function can be called and executed by a processing element. The implementation of other modules is similar. Moreover, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed through the integrated logic circuits in the hardware of the processor element or through software instructions.
[0175] For example, these modules can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field-programmable gate arrays (FPGAs). As another example, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together to implement a system-on-a-chip (SOC).
[0176] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., a solid-state disk (SSD)).
[0177] Optional, Figure 13 This is a schematic diagram of the structure of an image processing device provided in an embodiment of this application. The image processing device includes a memory 1301 and at least one processor 1302. The memory 1301 stores computer execution instructions. The image processing device also includes a bus 1303, wherein the memory 1301 is connected to the processor 1302 through the bus 1303.
[0178] In the specific implementation process, at least one processor 1302 executes computer execution instructions stored in memory 1301, causing at least one processor 1302 to execute the image processing method described above.
[0179] The specific implementation process of processor 1302 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0180] In the above Figure 13In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0181] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage.
[0182] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0183] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the image processing method described above.
[0184] It is understood that the terms "first," "second," etc., used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of this application, a first color channel may be referred to as a second color channel, and similarly, a second color channel may be referred to as a first color channel. Both the first color channel and the second color channel are color channels, but they are not the same color channel.
[0185] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates an "or" relationship between the preceding and following related objects; in formulas, the character " / " indicates a "division" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0186] It is understood that the various numerical designations used in the embodiments of this application are merely for descriptive convenience and are not intended to limit the scope of the embodiments of this application. In the embodiments of this application, the order of the above-mentioned process numbers does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0187] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. An image processing method, characterized in that, include: Obtain the image to be identified from the face image, wherein the image to be identified includes the facial skin region; The image to be labeled is converted into a color gradient map, and the target pixels in the image to be labeled are determined according to the color gradient map. The target pixels are used to represent sensitive locations of human facial skin. The target pixels are pixels in the color gradient map whose pixel values are greater than a preset pixel threshold. The target pixels are identified to obtain identification results, which are used to indicate sensitive areas of facial skin. The step of converting the image to be identified into a color gradient map includes: Obtain the pixel value of each pixel in the R channel of the image to be identified; Obtain the pixel value of each pixel in the G channel of the image to be identified; Obtain the pixel value of each pixel in the B channel of the image to be identified; Based on the pixel values of each pixel in the image to be labeled in the R channel, the pixel values in the G channel, and the pixel values in the B channel, the image to be labeled is converted into a color gradient map. The identification result includes a face identification image. The process of identifying the target pixels to obtain the identification result includes: According to the preset differentiation function, the pixel value of the target pixel is updated to differentiate the pixel value of the sensitive region in different channels, thereby obtaining a face identification image.
2. The method according to claim 1, characterized in that, The process of acquiring the image to be identified from the face image includes: Obtain the pixel value of each pixel in the face image in the R channel; Obtain the pixel value of each pixel in the face image in the G channel; Obtain the pixel value of each pixel in the B channel of the face image; Based on the pixel values of each pixel in the R channel, the G channel, and the B channel, facial skin pixels are determined from each pixel. Based on the facial skin pixels, the face image is subjected to binary processing to obtain a binary image; The connected regions in the binary image are filtered to obtain the image to be identified.
3. The method according to claim 2, characterized in that, The step of determining facial skin pixels from each pixel based on the pixel values in the R channel, G channel, and B channel includes: The first pixel is the pixel whose R channel value is greater than the G channel value and whose R channel value is greater than the B channel value. Obtain the minimum difference between the pixel value of the G channel and the pixel value of the B channel in the first pixel. Pixels in the first pixel that have pixel values in the R channel, G channel, and B channel all greater than a first preset parameter, and whose pixel value in the R channel differs from the minimum difference value by a preset pixel difference value, are selected as facial skin pixels.
4. The method according to claim 2, characterized in that, The step of determining facial skin pixels from each pixel based on the pixel values in the R channel, G channel, and B channel includes: The second pixel is the pixel whose R channel value is greater than its G channel value and whose R channel value is greater than its G channel value. Pixels in the second pixel whose pixel values in the R channel, G channel, and B channel are all greater than the second preset parameter are selected as facial skin pixels.
5. The method according to claim 2, characterized in that, The step of filtering connected regions in the binary image to obtain the image to be identified includes: Obtain the area of the connected regions in the binary image; Connected regions with an area smaller than a preset area are filtered out to obtain the image to be labeled.
6. The method according to claim 1, characterized in that, The step of converting the image to be labeled into a color gradient map based on the pixel values of each pixel in the R channel, the G channel, and the B channel includes: Obtain the pixel value of each pixel in the image to be identified in the G channel and the average pixel value in the B channel; The difference between the pixel value in the R channel of each pixel in the image to be labeled and the mean pixel value is obtained, and the color value of each pixel in the image to be labeled is calculated. Based on the color values, the image to be identified is converted into a color gradient map.
7. The method according to claim 1, characterized in that, The step of updating the pixel values of the target pixels according to a preset differentiation function to obtain a face identification image includes: The pixel value of the target pixel in the G channel is updated according to the preset differentiation function; The pixel value of the target pixel in the B channel is updated according to the preset differentiation function to obtain the identification image.
8. The method according to any one of claims 1-7, characterized in that, Before acquiring the image to be identified from the face image, the process also includes: A sample image is acquired, and a face detection is performed on the sample image according to a preset face detection algorithm to obtain the face image.
9. An image processing apparatus, characterized in that, include: The image acquisition module is used to acquire an image to be identified from a face image, wherein the image to be identified includes the skin region of the face; An image conversion module is used to convert the image to be identified into a color gradient map, and to determine the target pixels in the image to be identified based on the color gradient map. The target pixels are used to represent sensitive locations of facial skin. The target pixels are pixels in the color gradient map whose pixel values are greater than a preset pixel threshold. The identification module is used to identify the target pixels and obtain identification results, which are used to indicate sensitive areas of facial skin. The image conversion module is specifically used to obtain the pixel value of each pixel in the R channel of the image to be identified; and to obtain the pixel value of each pixel in the G channel of the image to be identified. Obtain the pixel value of each pixel in the B channel of the image to be identified; Based on the pixel values of each pixel in the image to be labeled in the R channel, the pixel values in the G channel, and the pixel values in the B channel, the image to be labeled is converted into a color gradient map. The identification result includes a face identification image. The identification module is specifically used to update the pixel value of the target pixel according to a preset differentiation function to differentiate the pixel value of the sensitive area in different channels, thereby obtaining a face identification image.
10. An image processing device, characterized in that, Includes memory and at least one processor; The memory stores computer-executed instructions; The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the method as described in any one of claims 1-8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, are used to implement the method as described in any one of claims 1-8.
Citation Information
Patent Citations
Cheek sensitive skin recognition method and device
CN108921128A