A facial target area detection method, device and equipment
By performing color value quantification and histogram equalization processing in the Lab color space, the problem of low face detection accuracy in the existing technology is solved, and more accurate red area extraction and skin condition detection are achieved.
Patent Information
- Application Number
- CN202011550837.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-24
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-12-24
AI Technical Summary
In the existing technology, face detection is easily interfered by the image background, resulting in inaccurate face area extraction. The color features extracted from the red area are single and the accuracy is not high.
By quantizing color values in the Lab color space, the color features are enhanced, and combined with binarization processing and histogram equalization, the color types are reduced and the color features are enhanced, thereby accurately extracting the target area in the face.
It effectively reduces the influence of red areas outside the face, improves the accuracy and robustness of red area detection, and enhances the accuracy of skin condition detection.
Smart Images

Figure CN112699760B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of detection equipment, and in particular to a facial target area detection method, device and equipment. Background Art
[0002] With the rapid development of mobile communication technology, various smart terminals are widely used in people's daily lives. People will use APP and other software to initially understand some health problems. Among them, the face is an important indicator of human health, and facial skin problems, such as acne, pigmentation and pores, effectively reflect human health.
[0003] In the prior art, face detection can be performed through an image processing detector. However, it is easily affected by the image background, the facial area is not accurately extracted, and red areas outside the face are easily present. In addition, the extracted red color features are single, and the extractable color feature information is insufficient, resulting in low accuracy of red area detection. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a facial target area detection method, device and equipment, which strengthens the color value through a color enhancement operation, and further enhances the color feature through a color value quantization operation, so as to better extract the target area in the face for detecting the skin condition.
[0005] In a first aspect, an embodiment of the present invention provides a facial target area detection method, the method comprising:
[0006] Obtaining an original image with a human face, performing binarization processing on the original image, and extracting an image to be processed of the human face;
[0007] In the Lab color space, color value quantization is performed on all pixels of the image to be processed to obtain a quantized image;
[0008] According to the pixel value of the target color in the Lab color space, a target area is determined in the quantized image, and the target area is used to detect the skin condition of the face.
[0009] In some embodiments, the step of obtaining an original image with a human face and performing binarization processing on the original image to extract an image to be processed of the human face includes:
[0010] Get the original image with the face;
[0011] According to a facial key point algorithm, a facial contour and at least one key point area are obtained in the original image;
[0012] The area within the facial contour except the key point area is taken as a valid area;
[0013] The grayscale values of the pixels in the effective area are set to a first grayscale value, and the grayscale values of the pixels in the key point area are set to a second grayscale value, so as to obtain a face binary image;
[0014] An image to be processed is obtained according to the binary face image and the original image.
[0015] In some embodiments, after the original image is binarized to extract the image to be processed of the face, the method further includes:
[0016] Convert all pixels in the image to be processed into the HSV color space to obtain an HSV image;
[0017] Draw the original histogram of the HSV image;
[0018] Counting the probability of occurrence of each grayscale pixel in the original histogram;
[0019] The probability of occurrence of each grayscale pixel is adjusted using a cumulative distribution function to update the brightness distribution of each grayscale pixel of the image to be processed.
[0020] In some embodiments, the step of performing color value quantization processing on all pixels of the image to be processed in the Lab color space to obtain a quantized image includes:
[0021] Convert all pixels in the image to be processed into Lab color space to obtain a Lab image, the number of color types corresponding to the Lab image, and the number of pixels of each color;
[0022] Traverse each color and find the two colors with the smallest color difference;
[0023] Classifying the two colors with the smallest color difference into one color to obtain a replacement color;
[0024] Replace the two colors with the smallest color difference with the replacement color to update the number of color types and the number of pixels of each color;
[0025] The replacement color and the number of pixels of the replacement color are combined to obtain a quantized image, wherein the number of color types of the quantized image is less than the number of color types of the Lab image.
[0026] In some embodiments, after obtaining the quantized image, the method further includes:
[0027] The quantized image is filtered using a median filter.
[0028] In some embodiments, determining a target area in the quantized image according to the pixel value of the target color in the Lab color space, wherein the target area is used to detect the skin condition of a human face, includes:
[0029] According to the pixel value of the target color in the Lab color space, obtaining pixel position information of all target colors from the quantized image;
[0030] A target area is constructed according to the pixel position information of the target color.
[0031] In some embodiments, after determining a target area in the quantized image according to the pixel value of the target color in the Lab color space, and the target area is used to detect the skin condition of the face, the method further includes:
[0032] Acquire pixel points of the target area;
[0033] Calculating the proportion of the target area in the quantized image according to the pixel points of the target area and the total pixel points of the quantized image;
[0034] According to the proportion, a status level corresponding to the target area is determined.
[0035] In a second aspect, an embodiment of the present invention provides a facial target area detection device, the device comprising:
[0036] An acquisition module is used to acquire an original image with a human face, and after binarization processing is performed on the original image, an image to be processed of the human face is extracted;
[0037] A quantization module is used to perform color value quantization processing on all pixels of the image to be processed in the Lab color space to obtain a quantized image;
[0038] The target determination module is used to determine a target area in the quantized image according to the pixel value of the target color in the Lab color space, and the target area is used to detect the skin condition of the face.
[0039] In a third aspect, an embodiment of the present invention provides a facial target area detection device, the facial target area detection device comprising:
[0040] at least one processor, and
[0041] A memory, wherein the memory is communicatively connected to the at least one processor, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the above method.
[0042] In a fourth aspect, an embodiment of the present invention provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by a facial target area detection device, the facial target area detection device executes the method described above.
[0043] The facial target area detection method, device and apparatus of the embodiment of the present invention obtains an image to be processed based on an original image with a human face, and then performs color value quantization processing on all pixels of the facial image in the Lab color space to obtain a quantized image, thereby reasonably reducing the types of colors in the image to be processed and further enhancing the color features, and determining a target area in the quantized image based on the pixel value of the target color in the Lab color space, and the target area is used to detect the skin condition of the face. For example, when the target color is red, the target area is determined to be a red area in the quantized image based on the pixel value of red in the Lab color space, thereby accurately detecting the red area of the face. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0045] Figure 1 is a flow chart of an embodiment of a facial target area detection method of the present invention;
[0046] Figure 2 Schematic diagram of key point regions of an embodiment of a facial target region detection method of the present invention;
[0047] Figure 3 is a binary image of a human face effective area in one embodiment of a facial target area detection method of the present invention;
[0048] Figure 4a is a grayscale image of an HSV image of an embodiment of a facial target area detection method of the present invention;
[0049] Figure 4b yes Figure 4a The original histogram of ;
[0050] Figure 5a yes Figure 4a Equalized image;
[0051] Figure 5b yes Figure 5a Histogram of ;
[0052] Figure 6is a structural schematic diagram of an embodiment of a facial target area detection device of the present invention;
[0053] Figure 7 is a structural schematic diagram of an embodiment of a facial target area detection device of the present invention;
[0054] Figure 8 1 is a schematic diagram of the hardware structure of a controller in an embodiment of the facial target area detection device of the present invention. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not 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.
[0056] The facial target area detection method and apparatus provided in the embodiments of the present invention can be applied to a facial target area detection device, wherein the facial target area detection device can be an intelligent terminal device, such as a smart phone, a computer, an iPad, or other terminal devices.
[0057] It can be understood that the facial target area detection device is provided with a controller as a main control center, which strengthens the color value through color enhancement operation, and further enhances the color feature through color value quantization operation, so as to better extract the target area.
[0058] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of a facial target area detection method provided by an embodiment of the present invention. The method may be executed by a controller 13 in a facial target area detection device. Figure 1 As shown, the method is applied to a facial target area detection device, and the method comprises:
[0059] 101: Acquire an original image with a human face, perform binarization processing on the original image, and extract an image to be processed of the human face.
[0060] The original image with the human face can be collected by a camera device of the face target area detection device, or received from other devices.
[0061] In some embodiments, obtaining an original image with a human face, performing binarization processing on the original image, and extracting an image to be processed of the human face may include:
[0062] Get the original image with the face;
[0063] According to a facial key point algorithm, a facial contour and at least one key point area are obtained in the original image;
[0064] The area within the facial contour except the key point area is taken as a valid area;
[0065] The grayscale values of the pixels in the effective area are set to a first grayscale value, and the grayscale values of the pixels in the key point area are set to a second grayscale value, so as to obtain a face binary image;
[0066] An image to be processed is obtained according to the binary face image and the original image.
[0067] After obtaining an original image with a human face, a face key point algorithm is used to obtain at least one key point region in the original image.
[0068] Facial key point detection is also called facial key point detection, positioning or face alignment. It refers to locating the key areas of the face, including eyebrows, eyes, nose, mouth, facial contours, etc., given a face image.
[0069] There are roughly three types of facial key point detection methods: model-based ASM (Active Shape Model) and AAM (Active Appearance Model), cascaded shape regression CPR (Cascaded pose regression) and deep learning-based methods.
[0070] Through the above three methods, several key point areas including eyebrows, eyes, nose, mouth and facial contours are detected, such as Figure 2 As shown in the figure, the area inside the facial contour, except for the key point areas of eyebrows, eyes, nose and mouth, is the valid area.
[0071] After obtaining the effective area, the grayscale value of the pixel point in the effective area is set to the first grayscale value, such as Figure 3 As shown in FIG. 1 , the grayscale values of the pixels in the facial contour area except for the key point areas of eyebrows, eyes, nose, and mouth are set to 1, and the grayscale values of the pixels in the key point areas including eyebrows, eyes, nose, and mouth are set to a second grayscale value, such as 0, so as to obtain the following: Figure 3 The binary image of the effective face area is shown.
[0072] After getting the face binary image I mask Afterwards, the image to be processed is obtained according to the face binary image and the original image. Specifically, the image to be processed I is calculated according to the following formula 1:
[0073] I=src*I mask Formula 1
[0074] Among them, I represents the image to be processed, src represents the face image, and I mask Represents a binary face image.
[0075] By obtaining the effective area of the face, the influence of red pixels outside the face can be effectively reduced. mask After that, the face binary image I mask The image to be processed is obtained by multiplying the original image src, which mainly suppresses the key point areas of eyebrows, eyes, nose and mouth in the original image, thereby enhancing the color value of the effective area.
[0076] In some embodiments, after the original image is binarized to extract the image to be processed of the face, the method may further include:
[0077] Convert all pixels in the image to be processed into the HSV color space to obtain an HSV image;
[0078] Draw the original histogram of the HSV image;
[0079] Counting the probability of occurrence of each grayscale pixel in the original histogram;
[0080] The probability of occurrence of each grayscale pixel is adjusted using a cumulative distribution function to update the brightness distribution of each grayscale pixel of the image to be processed.
[0081] Specifically, after obtaining the image to be processed, the image to be processed will be subjected to histogram equalization. The purpose of histogram equalization is to enhance the visual quality effect of the image to be processed. Moreover, histogram equalization can also overcome the disadvantage of uneven brightness of the color histogram of the image to be processed. After the image to be processed is subjected to histogram equalization, the brightness of the equalized image to be processed can be effectively enhanced.
[0082] The specific histogram equalization process is:
[0083] Convert all pixels in the image to be processed into the HSV color space to obtain an HSV image;
[0084] Draw the original histogram of the HSV image;
[0085] Counting the probability of occurrence of each grayscale pixel in the original histogram;
[0086] The probability of occurrence of each grayscale pixel is adjusted using a cumulative distribution function to update the brightness distribution of each grayscale pixel of the image to be processed.
[0087] HSV color space can express the hue, vividness and brightness of color very intuitively, making it easy to compare colors. H (HUE, hue), S (Saturation, saturation, color purity), V (Value, brightness).
[0088] When the Hue is constant, the saturation decreases, which means adding white to the spectral colors. The proportion of the spectral colors also decreases. When the saturation decreases to 0, it means that the proportion of the spectral colors is zero, causing the entire color to appear white.
[0089] When the brightness V decreases, black is added to the spectral colors, and the proportion of the spectral colors also decreases. When the brightness decreases to 0, it means that the proportion of the spectral colors is zero, causing the entire color to appear black.
[0090] HSV is a relatively intuitive color model for users. It is easy to get a single color, that is, specify the color angle H, let V = S = 1, and then add black and white to get the color we need. Adding black can reduce V while S remains unchanged, and adding white can reduce S while V remains unchanged. For example, to get dark blue, V = 0.4S = 1H = 240 degrees. To get light blue, V = 1S = 0.4H = 240 degrees.
[0091] It should be noted that the image to be processed is an RGB image, which is a two-dimensional image. Therefore, in the HSV color space, the image to be processed is converted into a three-dimensional HSV image, and in the HSV color space, histogram equalization processing is performed on the image to be processed.
[0092] When performing equalization processing, first, all pixels in the image to be processed are converted into the HSV color space to obtain an HSV image, and then the original histogram of the HSV image is drawn. The histogram can be drawn directly in opencv or using MATLAB.
[0093] In the original histogram, the probability of each grayscale pixel appearing is counted and calculated according to Formula 2:
[0094] P(S K )=n K / n,k=0,1,……L-1 Formula 2;
[0095] Among them, P(S K ) represents the probability of occurrence of each grayscale pixel corresponding to the HSV image, n represents the total pixel value in the HSV image, nk Indicates gray level S K The pixel value of L indicates that the color value range is 0-255 and the maximum color value is 255.
[0096] After drawing the original histogram, the histogram needs to be normalized, that is, the grayscale range is changed from 0 to 255 to 0 to 1. The normalized histogram is actually a probability density function, and equalization is to make the probability density 1.
[0097] Therefore, after obtaining the probability of occurrence of each grayscale pixel corresponding to the HSV image, the probability of occurrence of each grayscale pixel is adjusted using the cumulative distribution function. The cumulative distribution function is Formula 3. By using Formula 3, the brightness distribution of each grayscale pixel of the image to be processed is updated.
[0098]
[0099] Among them, S K The conversion function of the Kth gray level of the original histogram is the gray value after the original histogram is equalized. K ) represents the probability of occurrence of each grayscale pixel corresponding to the HSV image, P(S i ) represents the number of pixels at gray level i of the original histogram, where i ranges from 0 to K.
[0100] like Figure 4a , is the grayscale image of the HSV image, Figure 4b is the original histogram, Figure 5a for Figure 4a The equalized image, Figure 5b for Figure 5a It is obvious that after the histogram equalization processing, the brightness values of the pixels in the image to be processed are redistributed so that the brightness values can present the brightness levels of all ranges more evenly, and the grayscale values of each color level are evenly distributed in the entire grayscale range, thereby effectively overcoming the problem of uneven brightness of the image to be processed, effectively enhancing the spatial color pixels, and providing a strong foundation for the subsequent color value quantization processing, making the color value quantization more accurate.
[0101] 102: In the Lab color space, color value quantization is performed on all pixels of the image to be processed to obtain a quantized image.
[0102] After the histogram of the image to be processed is equalized, color value quantization is performed on all pixels of the equalized image to be processed in the Lab color space to obtain a quantized image.
[0103] In some embodiments, performing color value quantization processing on all pixels of the image to be processed in the Lab color space to obtain a quantized image may include:
[0104] 21: Convert all pixels in the image to be processed into Lab color space to obtain a Lab image, the number of color types corresponding to the Lab image, and the number of pixels of each color.
[0105] Specifically, the Lab color space is composed of a brightness channel L and two color channels a and b. In the Lab color space, there are three components, L, a, and b, and the meanings of each component are as follows:
[0106] L represents brightness, ranging from 0 to 100, where 100 is white;
[0107] a represents the component from green to red, ranging from -128 to 127, where 127 is red;
[0108] b represents the component from blue to yellow, ranging from -128 to 127, where 127 is yellow.
[0109] The Lab color space is designed based on people's perception of color, making people perceive it evenly, that is, the visual changes brought about by the same numerical changes are basically the same.
[0110] By converting all pixels in the equalized image to be processed into the Lab color space, we can get the renderings of the three channels, namely, the L channel, the a channel, and the b channel, and thus get the Lab image. After getting the Lab image, we can get the number of color types M corresponding to the Lab image and the number of pixels of each color.
[0111] 22: Traverse each color and find the two colors with the smallest color difference.
[0112] In the Lab color space, traverse each color and find the two colors with the smallest color difference according to Formula 4. Formula 4 is as follows:
[0113]
[0114] Where, ΔL xy Represents the brightness difference between color x and color y in the image to be processed, Δa xy Represents the difference between the green and red components of color x and color y in the image to be processed, Δb xy Indicates the difference between the blue and yellow components of color x and color y in the image to be processed, E xy It represents the comprehensive evaluation index of color difference in the image to be processed. In the image to be processed, the E of the two colors xy When it is the smallest, it means that the color difference between color x and color y is the smallest.
[0115] 23: Classify the two colors with the smallest color difference into one color to obtain a replacement color;
[0116] 24: Replace the two colors with the smallest color difference with the replacement color to update the number of color types and the number of pixels of each color.
[0117] Specifically, the color types can be classified according to the principle of minimum color difference. For example, if the difference between color x and color y is the smallest, then replace color E with C This color replaces the two colors of color x and color y. Specifically, the replacement color E is calculated according to formula 5 C :
[0118] E C =N x E xC +N y E yC
[0119] Among them, N x and N y represents the number of pixels in the image to be processed after color x and color y are equalized, E C Indicates replacement color, correspondingly, E xC and E yC E of Formula 4 xy The calculation formula corresponds to E xC is the color difference between color x and the replacement color C, E yC is the color difference between color y and replacement color C, that is, replacement color E C It is equal to the product of the number of pixels of color x and the color difference between color x and the replacement color C, plus the product of the number of pixels of color y and the color difference between color y and the replacement color C.
[0120] By replacing the two colors with the smallest color difference with the replacement color, the original two types of colors are reduced to one, that is, the number of color types M is updated to M-1, and when M is greater than N (256), continue to return to step 22 to update the number of color types.
[0121] 25: Combining the replacement color and the number of pixels of the replacement color to obtain a quantized image, wherein the number of color types of the quantized image is less than the number of color types of the Lab image.
[0122] Since one replacement color is equivalent to two colors, the number of replacement colors obtained by looping will be significantly less than the number of colors in the Lab image.
[0123] Because there are too many color types in the image to be processed, up to M types, the candidate red zone features are not obvious enough. For example, the red color class itself has light red, red, dark red and other types. The red zone feature extraction covers these types. If these red color types are subdivided, it will be difficult to set the threshold for subsequent color extraction. If the threshold setting is unreasonable, the red zone extraction will not be accurate enough. Therefore, the color value quantization processing is to unify the color values of all different red types, which reduces the difficulty of subsequent processing and further enhances the color features, thereby improving the robustness and accuracy of red zone feature extraction.
[0124] Correspondingly, light green, dark green and other green colors can also be merged into green.
[0125] In some embodiments, after obtaining the quantized image, the method further includes:
[0126] The quantized image is subjected to filtering processing.
[0127] Specifically, after the quantized image is obtained, since there are usually a large number of noise points in the quantized image, the quantized image is filtered to remove the noise points.
[0128] Median filtering can be used for filtering, which not only retains the details of the quantized image, but also reduces the blur of the image.
[0129] For example, after quantization, the 3*3 matrix is removed from the image. In the 3*3 matrix, there are 9 pixels. The 9 pixels are sorted. For example, the corresponding order of the 9 pixels is 1 / 2 / 3...9. At this time, the center point of the 9 pixels is the 5th pixel. Then, the value of the 5th pixel is used to fill the remaining 8 pixels, thereby effectively removing the noise points.
[0130] The present case is not limited to the above-mentioned median filtering method, and the quantized image may also be filtered by means of mean filtering, Gaussian filtering, or bilateral filtering, thereby effectively removing noise points.
[0131] 103: Determine a target area in the quantized image according to the pixel value of the target color in the Lab color space, wherein the target area is used to detect the skin condition of the face.
[0132] The quantized image is essentially the above-mentioned filtered image.
[0133] In some embodiments, determining a target area in the quantized image according to the pixel value of the target color in the Lab color space, wherein the target area is used to detect the skin condition of a face, may include:
[0134] According to the pixel value of the target color in the Lab color space, obtaining pixel position information of all target colors from the quantized image;
[0135] A target area is constructed according to the pixel position information of the target color.
[0136] Specifically, the pixel value of the target color in the Lab color space is in a fixed range. For example, if the target color is red, then the area corresponding to the value range of the target color in the filtered image is determined based on the pixel value range of red in the Lab color space. When it meets the requirements, it can be marked as 1, and when it does not meet the requirements, it is marked as 0. Then, the pixel position information of all target colors is obtained, that is, all areas marked as 1 are obtained, and the pixel position information of all target colors is counted, that is, all pixel position information (pixel coordinates) marked as 1 are counted, and the pixel position information marked as 1 is combined, for example, the points corresponding to the pixel coordinates are connected to construct the target area.
[0137] In some embodiments, after determining a target area in the quantized image according to the pixel value of the target color in the Lab color space, and the target area is used to detect the skin condition of the face, the method further includes:
[0138] Acquire pixel points of the target area;
[0139] Calculating the proportion of the target area in the quantized image according to the pixel points of the target area and the total pixel points of the quantized image;
[0140] According to the proportion, a status level corresponding to the target area is determined.
[0141] Specifically, after detecting the target area, for example, the target area is a red area, after obtaining the red area in the face image, the red area can be graded to determine the severity of the red area. For example, the pixel points of the target area are obtained, that is, the pixel points of the red area are counted, and then, according to the pixel points of the target area and the total pixel points of the quantized image, the proportion of the target area in the quantized image is calculated. Assuming that the pixel points of the target area are n and the total pixel points of the quantized image are N, then the proportion is n / N. According to the ratio of n / N, the severity of the target area can be determined, that is, the state level corresponding to the target area. For example, if the ratio of n / N is greater than 0.8, then the target level can be determined to be the first level, and the degree of facial skin lesions of the face is relatively serious; if the ratio of n / N is 0.5-0.8, then the target level can be determined to be the second level, and the degree of facial lesions of the face is relatively serious. By analogy, the target level is determined according to the ratio of n / N.
[0142] After determining the state level corresponding to the target area, the state level corresponding to the target area can be output so that the user can obtain the state level result corresponding to the target area and perform targeted treatment.
[0143] Correspondingly, such as Figure 6 As shown, the embodiment of the present invention further provides a facial target area detection device, which can be used in a facial target area detection device. The facial target area detection device 700 includes:
[0144] The acquisition module 701 is used to acquire an original image with a human face, and extract an image to be processed of the human face after binarization processing on the original image;
[0145] The quantization module 702 is used to perform color value quantization processing on all pixels of the image to be processed in the Lab color space to obtain a quantized image;
[0146] The target determination module 703 is used to determine a target area in the quantized image according to the pixel value of the target color in the Lab color space, and the target area is used to detect the skin condition of the face.
[0147] In the embodiment of the present invention, an image to be processed is obtained based on an original image with a human face, and then, in the Lab color space, all pixels of the face image are subjected to color value quantization processing to obtain a quantized image, thereby reasonably reducing the types of colors in the image to be processed, further enhancing the color features, and, based on the pixel value of the target color in the Lab color space, determining a target area in the quantized image, the target area is used to detect the skin condition of the face. For example, when the target color is red, based on the pixel value of red in the Lab color space, the target area is determined to be a red area in the quantized image, thereby accurately detecting the red area of the face.
[0148] In other embodiments, the acquisition module 701 is further used for:
[0149] Get the original image with the face;
[0150] According to a facial key point algorithm, a facial contour and at least one key point area are obtained in the original image;
[0151] The area within the facial contour except the key point area is taken as a valid area;
[0152] The grayscale values of the pixels in the effective area are set to a first grayscale value, and the grayscale values of the pixels in the key point area are set to a second grayscale value, so as to obtain a face binary image;
[0153] An image to be processed is obtained according to the binary face image and the original image.
[0154] In other embodiments, after the original image is binarized and the image to be processed of the face is extracted, refer to Figure 7 , the facial target area detection device 700 further includes:
[0155] The histogram equalization module 704 is used to:
[0156] Convert all pixels in the image to be processed into the HSV color space to obtain an HSV image;
[0157] Draw the original histogram of the HSV image;
[0158] Counting the probability of occurrence of each grayscale pixel in the original histogram;
[0159] The probability of occurrence of each grayscale pixel is adjusted using a cumulative distribution function to update the brightness distribution of each grayscale pixel of the image to be processed.
[0160] In other embodiments, the quantization module 702 is further configured to:
[0161] Convert all pixels in the image to be processed into Lab color space to obtain a Lab image, the number of color types corresponding to the Lab image, and the number of pixels of each color;
[0162] Traverse each color and find the two colors with the smallest color difference;
[0163] Classifying the two colors with the smallest color difference into one color to obtain a replacement color;
[0164] Replace the two colors with the smallest color difference with the replacement color to update the number of color types and the number of pixels of each color;
[0165] The replacement color and the number of pixels of the replacement color are combined to obtain a quantized image, wherein the number of color types of the quantized image is less than the number of color types of the Lab image.
[0166] In some embodiments, after obtaining the quantized image, the facial target area detection device 700 further includes:
[0167] The filtering module 705 is used to:
[0168] The quantized image is subjected to filtering processing.
[0169] In some embodiments, the target determination module 703 is further configured to:
[0170] According to the pixel value of the target color in the Lab color space, obtaining pixel position information of all target colors from the quantized image;
[0171] A target area is constructed according to the pixel position information of the target color.
[0172] In some of the embodiments, after determining a target area in the quantized image according to the pixel value of the target color in the Lab color space, and the target area is used to detect the skin condition of the face, please refer to Figure 7 , the facial target area detection device 700 further includes:
[0173] The level determination module 706 is used to:
[0174] Acquire pixel points of the target area;
[0175] Calculating the proportion of the target area in the quantized image according to the pixel points of the target area and the total pixel points of the quantized image;
[0176] According to the proportion, a status level corresponding to the target area is determined.
[0177] It should be noted that the above device can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in the device embodiment, please refer to the method provided in the embodiment of the present application.
[0178] Figure 8 FIG. 1 is a schematic diagram of the hardware structure of a controller in an embodiment of a facial target area detection device. Figure 8 As shown, the controller 13 includes:
[0179] One or more processors 131 and memory 132 . Figure 8 In the figure, a processor 131 and a memory 132 are taken as an example.
[0180] The processor 131 and the memory 132 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0181] The memory 132 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as the program instructions / modules corresponding to the facial target area detection method in the embodiment of the present application (for example, the attached Figure 6-7The processor 131 executes various functional applications and data processing of the controller by running the non-volatile software programs, instructions and modules stored in the memory 132, that is, the facial target area detection method of the above method embodiment is implemented.
[0182] The memory 132 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the facial target area detection device, etc. In addition, the memory 132 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 132 may optionally include a memory remotely arranged relative to the processor 131, and these remote memories may be connected to the facial target area detection device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0183] The one or more modules are stored in the memory 132, and when executed by the one or more processors 131, the face target area detection method in any of the above method embodiments is executed, for example, the face target area detection method described above is executed. Figure 1 Steps 101 to 103 of the method; implementing Figure 6 Modules 701-703 in Figure 7 The functions of modules 701-706.
[0184] The above-mentioned product can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of the present application.
[0185] The embodiment of the present application provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors, such as Figure 8 A processor 131 in the embodiment may enable the one or more processors to execute the face target area detection method in any of the above method embodiments, for example, executing the above described Figure 1 Steps 101 to 103 of the method; implementing Figure 6 Modules 701-703 in Figure 7 The functions of modules 701-706.
[0186] The device embodiments described above are merely illustrative, wherein 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 modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0187] Through the description of the above embodiments, a person of ordinary skill in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, or of course by hardware. A person of ordinary skill in the art can understand that all or part of the processes in the above embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0188] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Under the concept of the present invention, the technical features in the above embodiments or different embodiments may also be combined, the steps may be implemented in any order, and there are many other changes in different aspects of the present invention as described above, which are not provided in detail for the sake of simplicity. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A facial target area detection method, characterized in that: The method comprises: Obtaining an original image with a human face, performing binarization processing on the original image, and extracting an image to be processed of the human face; Convert all pixels in the image to be processed into Lab color space to obtain a Lab image, the number of color types corresponding to the Lab image, and the number of pixels of each color; Traverse each color and find the two colors with the smallest color difference; Classifying the two colors with the smallest color difference into one color to obtain a replacement color; Replace the two colors with the smallest color difference with the replacement color to update the number of color types and the number of pixels of each color; Combining the replacement color and the number of pixels of the replacement color to obtain a quantized image, wherein the number of color types of the quantized image is less than the number of color types of the Lab image; According to the pixel value of the target color in the Lab color space, a target area is determined in the quantized image, and the target area is used to detect the skin condition of the face.
2. The method according to claim 1, characterized in that: The method of obtaining an original image with a human face and performing binarization processing on the original image to extract an image to be processed of the human face includes: Get the original image with the face; According to a facial key point algorithm, a facial contour and at least one key point area are obtained in the original image; The area within the facial contour except the key point area is taken as a valid area; The grayscale values of the pixels in the effective area are set to a first grayscale value, and the grayscale values of the pixels in the key point area are set to a second grayscale value, so as to obtain a face binary image; An image to be processed is obtained according to the binary face image and the original image.
3. The method according to claim 1, characterized in that After the original image is binarized to extract the image to be processed of the face, the method further includes: Convert all pixels in the image to be processed into the HSV color space to obtain an HSV image; Draw the original histogram of the HSV image; Counting the probability of occurrence of each grayscale pixel in the original histogram; The probability of occurrence of each grayscale pixel is adjusted using a cumulative distribution function to update the brightness distribution of each grayscale pixel of the image to be processed.
4. The method according to claim 1, characterized in that: After obtaining the quantized image, the method further includes: The quantized image is subjected to filtering processing.
5. The method according to claim 1, characterized in that The step of determining a target area in the quantized image according to the pixel value of the target color in the Lab color space, wherein the target area is used to detect the skin condition of the face, includes: According to the pixel value of the target color in the Lab color space, obtaining pixel position information of all target colors from the quantized image; A target area is constructed according to the pixel position information of the target color.
6. The method according to any one of claims 1 to 5, characterized in that After determining a target area in the quantized image according to the pixel value of the target color in the Lab color space, and the target area is used to detect the skin condition of the face, the method further includes: Acquire pixel points of the target area; Calculating the proportion of the target area in the quantized image according to the pixel points of the target area and the total pixel points of the quantized image; According to the proportion, a status level corresponding to the target area is determined.
7. A facial target area detection device, characterized in that: The device comprises: An acquisition module is used to acquire an original image with a human face, and after binarization processing is performed on the original image, an image to be processed of the human face is extracted; A quantization module, used for converting all pixels in the image to be processed into a Lab color space, obtaining a Lab image, the number of color types corresponding to the Lab image, and the number of pixels of each color, traversing each color, finding two colors with the smallest color difference, classifying the two colors with the smallest color difference as one color, obtaining a replacement color, replacing the two colors with the smallest color difference with the replacement color to update the number of color types and the number of pixels of each color, combining the replacement color and the number of pixels of the replacement color, and obtaining a quantized image, wherein the number of color types in the quantized image is less than the number of color types in the Lab image; The target determination module is used to determine a target area in the quantized image according to the pixel value of the target color in the Lab color space, and the target area is used to detect the skin condition of the face.
8. A facial target area detection device, characterized in that: The facial target area detection device comprises: at least one processor, and A memory, wherein the memory is communicatively connected to the processor, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in any one of claims 1 to 6.
9. A non-volatile computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by a facial target area detection device, the facial target area detection device is enabled to execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Eye locating method and device
CN103927509A
Image generation method and device
CN110211030A
