A method for generating a face skin sensitivity map and a related device
By adjusting the brightness of a face image and converting it to the LAB color space, extracting the A channel image and performing contrast enhancement and color filling processing, a facial skin sensitivity map is generated. This solves the problem of clearly defining the skin sensitivity area in existing technologies and achieves clear visualization of the skin sensitivity area.
Patent Information
- Application Number
- CN202011018858.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-24
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2040-09-24
AI Technical Summary
Existing technologies struggle to clearly define sensitive areas of facial skin, resulting in the inability to generate accurate skin sensitivity maps and impacting users' ability to visualize and analyze facial skin conditions.
By adjusting the brightness of the face image and converting it to the LAB color space, the A channel image is extracted, and contrast enhancement and color filling are performed to generate a facial skin sensitivity map, distinguishing between sensitive and non-sensitive areas.
It achieves clear visualization of sensitive areas of facial skin, allowing users to clearly understand the condition of their facial skin and improving the accuracy and visualization of skin analysis.
Smart Images

Figure CN112215808B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of image processing, and in particular to a method for generating a face skin sensitivity map and a related device thereof. BACKGROUND
[0002] With the continuous development of software and hardware technology and the improvement of people's living standards, people's skin care and beauty are no longer limited to traditional ways. The concept of combining beauty care with new scientific technology is born, and various terminal products with beauty analysis software and hardware combination have appeared in the market. Among them, many users hope to analyze the skin condition of the face, including the face skin sensitivity and redness.
[0003] At present, a face image is generally obtained by photographing with a mobile device, and the face skin sensitive red area is analyzed in combination with analysis experience, but the sensitive area or the face red area is not obvious, and real skin information cannot be obtained. At the same time, the sensitive area is difficult to clearly define, and is closely related to personal skin, so it is difficult to generate a face skin sensitivity map for visualizing the sensitive area. SUMMARY
[0004] The technical problem solved by the embodiments of the present application is to provide a method for generating a face skin sensitivity map and a related device, which can obtain a face skin sensitivity map to visualize the sensitive area of the face.
[0005] To solve the above technical problem, in a first aspect, a method for generating a face skin sensitivity map is provided in the embodiments of the present application, comprising:
[0006] obtaining a face image;
[0007] adjusting the brightness of the face image to obtain a first face image, wherein the brightness of each pixel point in the first face image is greater than or equal to a preset brightness threshold;
[0008] converting the first face image into a LAB face image, and extracting the A channel component of the LAB face image to obtain an A channel image;
[0009] performing first contrast enhancement processing on the A channel image to obtain a second A channel image, wherein the average gray value of the second A channel image is greater than a first preset gray threshold;
[0010] performing first color filling processing and second color filling processing on the second A channel image to obtain a face skin sensitivity map, wherein the first color filling processing and the second color filling processing are two filling processing modes for making the sensitive area in the face skin and the non-sensitive area in the face skin displayed in different ways in the face skin sensitivity map.
[0011] In some embodiments, the brightness adjustment on the face image to obtain a first face image comprises:
[0012] If the brightness of a target pixel point in the face image is less than the preset brightness threshold, the brightness of the target pixel point is increased to a first brightness to obtain the first face image, wherein the target pixel point is any pixel point in the face image, and the first brightness is greater than or equal to the preset brightness threshold.
[0013] In some embodiments, the increase of the brightness of the target pixel point to the first brightness to obtain the first face image comprises:
[0014] According to the first RGB value of the target pixel point and the brightness of the target pixel point, the HS value of the target pixel point in the HSL color space is obtained.
[0015] According to the first brightness and the HS value, the second RGB value of the target pixel point is determined to obtain the first face image.
[0016] In some embodiments, the first contrast enhancement processing on the A channel image to obtain a second A channel image comprises:
[0017] The histogram normalization is performed on the A channel image to output a normalized image.
[0018] If the average gray value of the normalized image is less than or equal to the first preset gray threshold, the image equalization processing is performed on the normalized image to obtain a second A channel image.
[0019] If the average gray value of the normalized image is greater than the first preset gray threshold, the normalized image is taken as the second A channel image.
[0020] In some embodiments, after the histogram normalization on the A channel image to output a normalized image, it further comprises:
[0021] The second contrast enhancement processing is performed on the normalized image.
[0022] In some embodiments, the first color filling processing and the second color filling processing on the second A channel image to obtain a face skin sensitivity map comprises:
[0023] The gray value of each pixel point in the second A channel image is obtained by traversing each pixel point in the second A channel image.
[0024] The second A channel image is subjected to the first color filling processing and the second color filling processing according to the gray value of each pixel point in the second A channel image, so as to obtain the face skin sensitive map.
[0025] In some embodiments, the first color filling processing and the second color filling processing are performed on the second A channel image according to the gray value of each pixel point in the second A channel image, so as to obtain the face skin sensitive map, including:
[0026] The white degree and the non-white degree of each pixel point in the second A channel image are obtained according to the gray value of each pixel point in the second A channel image, respectively, wherein the white degree is the ratio between the gray value of the pixel point in the second A channel image and the second preset gray threshold, and the non-white degree is 1 minus the white degree.
[0027] The first preset RGB value of the first color is multiplied by the white degree of each pixel point in the second A channel image, respectively, so as to obtain a first color filling map, wherein the first color is the basic filling color of the sensitive area in the face skin.
[0028] The second preset RGB value of the second color is multiplied by the non-white degree of each pixel point in the second A channel image, respectively, so as to obtain a second color filling map, wherein the second color is the basic filling color of the non-sensitive area in the face skin.
[0029] The first color filling map and the second color filling map are subjected to color superposition, so as to obtain the face skin sensitive map.
[0030] In some embodiments, the method further includes:
[0031] The face skin sensitive map is subjected to color enhancement processing, and the face skin sensitive map after color enhancement processing is output.
[0032] To solve the above technical problems, in the second aspect, an electronic device is provided in the embodiments of the present application, which includes:
[0033] at least one processor, and
[0034] a memory connected in communication with the at least one processor, wherein
[0035] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of the first aspect.
[0036] To address the aforementioned technical problems, in a third aspect, embodiments of the present invention provide a non-transitory computer-readable storage medium storing computer-executable instructions for causing an electronic device to perform the method described in the first aspect above.
[0037] The beneficial effects of this invention's embodiments: Unlike existing technologies, the method for generating a facial skin sensitivity map provided by this invention involves enhancing the brightness of a facial image, extracting the A-channel component of each pixel in the LAB color space to obtain an A-channel image, and then enhancing the contrast of the A-channel image to obtain a second A-channel image that meets both brightness and contrast requirements. The grayscale value corresponding to each pixel in the second A-channel image reflects the redness of each pixel in the facial image, i.e., it reflects the sensitivity of the corresponding facial skin area. Therefore, by performing a first color fill process and a second color fill process on the second A-channel image, sensitive and non-sensitive areas of the facial skin are displayed in different ways in the facial skin sensitivity map, thereby obtaining a facial skin sensitivity map that can distinguish between sensitive and non-sensitive areas, allowing users to clearly understand their own facial skin. Attached Figure Description
[0038] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0039] Figure 1 This is a schematic diagram illustrating the application environment of a method for generating a facial skin sensitivity map according to one embodiment of the present invention;
[0040] Figure 2 This is a schematic diagram of the hardware structure of an electronic device provided in one embodiment of the present invention;
[0041] Figure 3 This is a flowchart illustrating a method for generating a facial skin sensitivity map according to one embodiment of the present invention.
[0042] Figure 4 for Figure 3 A schematic diagram of the face image in the method shown;
[0043] Figure 5 for Figure 3 A schematic diagram of the second A-channel image in the method shown;
[0044] Figure 6 For the reason Figure 3 A schematic diagram of the facial skin sensitivity map generated by the method shown;
[0045] Figure 7 For Figure 3 a sub-process schematic diagram of step S22 in the method shown in FIG. 2;
[0046] Figure 8 For Figure 7 a sub-process schematic diagram of step S221 in the method shown in FIG. 2;
[0047] Figure 9 For Figure 3 a sub-process schematic diagram of step S24 in the method shown in FIG. 2;
[0048] Figure 10 For Figure 3 a sub-process schematic diagram of step S25 in the method shown in FIG. 2;
[0049] Figure 11 For Figure 10 a sub-process schematic diagram of step S252 in the method shown in FIG. 2. DETAILED DESCRIPTION
[0050] The application will be described in further detail below with reference to specific embodiments. The following examples are helpful for those skilled in the art to further understand the application, but do not limit the application in any form. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the application. These are all within the scope of protection of the application.
[0051] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are only used to explain the present application and do not limit the present application.
[0052] It should be noted that the features in the embodiments of the present application can be combined with each other without conflict, and are all within the scope of protection of the present application. In addition, although the functional modules are divided in the device schematic diagram, and the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order from the module division in the device or the order in the flowchart. In addition, the "first", "second", "third" and the like used herein do not limit the data and execution order, but only distinguish the same items or similar items with basically the same function and effect.
[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description herein is for describing particular embodiments only and is not intended to be limiting of the application. The use herein of "and / or" means any one or all possible combinations of one or more of the associated listed items.
[0054] Furthermore, the technical features involved in each of the embodiments of the application described below can be combined with each other as long as there is no conflict.
[0055] Figure 1 is a schematic diagram of an operating environment of a method for generating a face skin sensitivity map provided by an embodiment of the application. Please refer to Figure 1 , comprising an electronic device 10 and an image acquisition device 20, the electronic device 10 and the image acquisition device 20 are communicatively connected.
[0056] The communication connection can be a wired connection, such as an optical cable, or a wireless communication connection, such as a WIFI connection, a Bluetooth connection, a 4G wireless communication connection, a 5G wireless communication connection, etc.
[0057] The image acquisition device 20 is used to acquire a face image, and the image acquisition device 20 can be a terminal capable of shooting images, such as a mobile phone, a tablet computer, a video recorder, or a camera with shooting function, etc.
[0058] The electronic device 10 is a device capable of running according to the program, automatically and high-speed processing massive data, which is usually composed of hardware system and software system, such as a computer, a smart phone, etc. The electronic device 10 can be a local device directly connected with the image acquisition device 20, or a cloud device, such as a cloud server, a cloud host, a cloud service platform, a cloud computing platform, etc. The cloud device is connected with the image acquisition device 20 through a network, and the two are communicatively connected through a predetermined communication protocol, which can be TCP / IP, NETBEUI, and IPX / SPX, etc.
[0059] It can be understood that the image acquisition device 20 and the electronic device 10 can also be integrated together as an integrated device, such as a computer or a smart phone with a camera, etc.
[0060] The electronic device 10 receives the face image sent by the image acquisition device 20, processes the face image, and generates a face skin sensitivity map, so that the sensitive parts of the face can be visualized, and the user can clearly understand their own facial skin.
[0061] In the aboveFigure 1 On the basis of the above, other embodiments of the present application provide an electronic device 10, please refer to Figure 2 , the hardware structure diagram of an electronic device 10 provided by the embodiments of the present application, specifically, as shown in Figure 2 , the electronic device 10 includes at least one processor 11 and memory 12 connected in communication (for example, one processor is connected by bus in the middle) Figure 2 ).
[0062] Among them, the processor 11 is used to provide computing and control ability to control the electronic device 10 to perform corresponding tasks, for example, to control the electronic device 10 to perform any one of the methods for generating a face skin sensitivity map provided by the embodiments of the present application.
[0063] It can be understood that the processor 11 can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0064] The memory 12 as a kind of non-transient computer readable storage medium, it can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the method for training wrinkle detection model in the embodiments of the present application, or the program instructions / modules corresponding to the method for generating a face skin sensitivity map in the embodiments of the present application. The processor 11 can realize the method for generating a face skin sensitivity map in any one of the following method embodiments by running the non-transient software programs, instructions and modules stored in the memory 12. Specifically, the memory 12 can include a high-speed random access memory, and can also include a non-transient memory, for example, at least one disk storage device, a flash memory device, or other non-transient solid state storage device. In some embodiments, the memory 12 can also include a memory remotely arranged with respect to the processor, and these remote memories can be connected to the processor through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0065] Next, the method for generating a face skin sensitivity map provided by the embodiments of the present application is described in detail, please refer to Figure 3The method S20 includes but is not limited to the following steps:
[0066] S21: obtaining a face image.
[0067] S22: performing brightness adjustment on the face image to obtain a first face image, wherein the brightness of each pixel in the first face image is greater than or equal to a preset brightness threshold.
[0068] S23: converting the first face image into a LAB face image and extracting an A channel component of the LAB face image to obtain an A channel image.
[0069] S24: performing first contrast enhancement processing on the A channel image to obtain a second A channel image, wherein the average gray value of the second A channel image is greater than a first preset gray threshold.
[0070] S25: performing first color filling processing and second color filling processing on the second A channel image to obtain a face skin sensitivity map, wherein the first color filling processing and the second color filling processing are two kinds of filling processing modes for making the sensitive area in the face skin and the non-sensitive area in the face skin respectively displayed in different ways in the face skin sensitivity map.
[0071] Specifically, in the step S21, the face image is a color digital image including a face, which can be obtained by the above-mentioned image acquisition device. For example, the face image can be an ID photo or a selfie photo collected by the image acquisition device. Here, the source of the face image is not limited as long as it is a color digital image including a face.
[0072] Figure 4 As an example of the face image, it can be known that the face skin reflected by the face image includes normal skin and a sensitive red area, and in the Figure 4 , the pixels corresponding to the normal skin are uniform, and the pixels corresponding to the sensitive red area are deep, for example, the deep pixels circled on the cheeks. It can be understood that Figure 4 the face image in the above-mentioned embodiment is an image after desaturation processing, and in actual application, the face image is generally represented by an RGB color space model. The RGB color space model is a color model generated by the principle of mixing three primary colors. The three primary colors are red, green and blue, represented by R, G and B respectively. Various colors in nature can be mixed by adding three primary colors in different proportions. In addition, skin sensitivity is usually accompanied by the expansion of capillary blood vessels to display red, so that the sensitive red area in the face image displays red, that is, Figure 4 the place circled with deep pixels actually displays red in the RGB color space, and the deeper the pixel, the deeper the red color displayed.
[0073] In the step S22, the brightness of the face image is adjusted so that the brightness of each pixel in the obtained first face image is greater than or equal to a preset brightness threshold, thereby improving the brightness of the original face image and making the obtained first face image clearer and improving the visual effect.
[0074] In some embodiments, the brightness of the face image can be detected and determined by using the ImageStat tool package in the existing pillow library. Specifically, the brightness of each pixel in the face image is obtained by using the stat.rms function. If the brightness of a certain pixel in the face image is less than the preset brightness threshold, the brightness of the pixel is increased so that the brightness of the pixel is greater than or equal to the preset brightness threshold, thereby obtaining the first face image, so that the brightness of each pixel in the first face image is greater than or equal to the preset brightness threshold, so that the first face image is clearer and has a better visual effect.
[0075] It is worth noting that the preset brightness threshold is an empirical value and can be set according to actual conditions. In some embodiments, the preset brightness threshold is 132. Under this preset brightness threshold, the clarity and visualization effect of the first face image are better, and the features in the first face image are not affected by the brightness.
[0076] In the step S23, the first face image is converted into a LAB face image, wherein the LAB face image is an image represented by a LAB color space model.
[0077] A color digital image can be represented by various color space models, such as RGB, HSV, and LAB, etc. The LAB color space model is composed of three elements, i.e., an L channel, an A channel, and a B channel. The L channel is used to represent the brightness of a pixel, and the A channel and the B channel are two color channels. The A channel includes colors from dark green (low brightness value) to gray (medium brightness value) to bright red (high brightness value), and the B channel includes colors from bright blue (low brightness value) to gray (medium brightness value) to yellow (high brightness value).
[0078] Therefore, the A channel image is a single-channel image, and the size of the A channel image is consistent with the first face image. The gray value of each pixel in the A channel image can reflect the redness of each pixel in the first face image. The redness refers to the degree of redness, such as light red and dark red.
[0079] After the A channel image is acquired, there is usually a case that the A channel image is dark as a whole. If the A channel image is dark, it will affect the recognition of the dark part details of the face, for example, the darker red area cannot be displayed, etc.
[0080] In order to improve the display effect of the A channel image, in the step S24, the first contrast enhancement processing is performed on the A channel image, so that the gray mean value of the acquired second A channel image is greater than the first preset gray threshold value. The gray mean value of the second A channel image is the average value of the gray values corresponding to each pixel point in the second A channel image, which can effectively reflect the display effect of the second A channel image. The first preset gray threshold value is an empirical value set by human, which can be set according to the actual situation, or can be the result after a large number of tests, for example, the first preset gray mean value is 119. When the gray mean value in the second A channel image is greater than 119, the second A channel image can have a clear display effect.
[0081] As shown in Figure 5 , in the second A channel image, the area with white gray value reflects the red area in the face skin, including the lips and sensitive area, and the deeper the degree of white gray value, the redder the red area. The area with non-white gray value reflects the normal skin in the face skin, and the deeper the degree of non-white gray value, the more normal the skin, without sensitive redness.
[0082] Finally, in the step S25, after the first color filling processing and the second color filling processing are performed on the second A channel image, the face skin sensitive map is acquired. The face skin sensitive map is a 3 channel image which can visualize the sensitive red area of the face, for example, as shown in Figure 6 , the sensitive red area of the face is displayed. It can be understood that Figure 6 is also an image after desaturation processing, Figure 6 , the deeper the color, the more sensitive the sensitive red area, and the lighter (white) the color, the more normal the normal skin.
[0083] Since the second A channel image is a single channel image, and the gray value corresponding to each pixel point in the second A channel image can reflect the redness of each pixel point in the face image, i.e., can reflect the sensitivity degree of the corresponding face skin. After the first color filling processing and the second color filling processing are performed on the second A channel image, the sensitive area (red area) and the non-sensitive area in the face skin can be displayed in the face skin sensitivity map in different ways. For example, the first color and the second color are filled in each pixel point in the second A channel image according to the gray value thereof, by setting a gray value threshold, the pixel point (sensitive area) with a gray value greater than or equal to the gray value threshold is filled with the first color, and the pixel point (non-sensitive area) with a gray value less than or equal to the gray value threshold is filled with the second color, the first color and the second color are two different colors, so that the sensitive area and the non-sensitive area in the obtained face skin sensitivity map are displayed in different colors, so that the sensitive area and the non-sensitive area in the face skin can be clearly distinguished.
[0084] In the embodiment, the method obtains the second A channel image by performing brightness enhancement on the face image, then extracting the A channel component of each pixel point in the LAB color space, and performing contrast enhancement on the A channel image. The gray value corresponding to each pixel point in the second A channel image can reflect the redness of each pixel point in the face image, i.e., can reflect the sensitivity degree of the corresponding face skin. Therefore, the first color filling processing and the second color filling processing are performed on the second A channel image, so that the sensitive area in the face skin and the non-sensitive area in the face skin are displayed in the face skin sensitivity map in different ways, thereby obtaining the face skin sensitivity map capable of distinguishing the sensitive area and the non-sensitive area, to facilitate the user to clearly understand the face skin of himself.
[0085] In some embodiments, referring to Figure 7 , the step S22 specifically includes:
[0086] S221: If the brightness of the target pixel point in the face image is less than the preset brightness threshold, the brightness of the target pixel point is increased to a first brightness to obtain the first face image, wherein the target pixel point is any pixel point in the face image, and the first brightness is greater than or equal to the preset brightness threshold.
[0087] In this embodiment, any pixel point in the face image, i.e. a target pixel point, is traversed, and the brightness of the target pixel point is compared with the preset brightness threshold value. If the brightness of the target pixel point is less than the preset brightness threshold value, the brightness of the target pixel point is increased to a first brightness, wherein the first brightness is greater than or equal to the preset brightness threshold value. It can be understood that the first brightness is the brightness of the target pixel point after the brightness is increased, and the first brightness corresponding to each target pixel point is not exactly the same. For example, if the preset brightness threshold value is 128, for a target pixel point A, the brightness of which is 100, the first brightness corresponding to the target pixel point A is greater than or equal to 128, which can be 128 or 140, etc. For a target pixel point B, the brightness of which is 90, the first brightness corresponding to the target pixel point B is greater than or equal to 128, which can be 128 or 130, etc.
[0088] In some embodiments, the same increment can be added to the target pixel point whose brightness is less than the preset brightness threshold value, so that the first brightness of each target pixel point is greater than or equal to the preset brightness threshold value.
[0089] In order to reduce the loss of image information caused in the brightness increasing process, in some embodiments, referring to Figure 8 , the brightness of the target pixel point is increased to the first brightness to obtain the first face image, which comprises:
[0090] S2211: According to the first RGB value of the target pixel point and the brightness of the target pixel point, the HS value of the target pixel point in the HSL color space is obtained.
[0091] S2212: According to the first brightness and the HS value, the second RGB value of the target pixel point is determined to obtain the first face image.
[0092] The HSL color space is a color model that conforms to the visual characteristics of the human eye and has the advantage of separating bright colors. In the HSL color space, H represents hue, S represents saturation, and L represents brightness. The brightness L is generally expressed as a percentage, with a value of 1-100%. For brightness enhancement of an image, processing needs to be performed in different color spaces. For example, the RGB value of each pixel point in the face image is converted into the HSL value in the HSL color space, and after adjusting L, the new HSL' value is converted into a new R'G'B' value. In this way, multiple color space conversions of RGB-HSL-HSL'-R'G'B' are required, which is complicated and involves a large number of floating-point operations.
[0093] In order to reduce the conversion of color space, in the embodiment, the brightness enhancement is based on the brightness (L) of the HSV color space, the conversion between the RGB color model and the HSL color space is reduced by adjusting only the L (brightness) part, that is, the color space conversion can be effectively reduced, and the calculation amount is reduced. Specifically, for a target pixel point in the face image, the HS value of the target pixel point in the HSL color space is calculated through the brightness and the first RGB value, respectively, then the brightness L is adjusted to obtain the adjusted first brightness newL, and then the first brightness newL and the HS value can constitute a new HSL color space (i.e. the HSL color space of the first face image), so that the new HSL color space is converted into a new RGB color model, and the second RGB value of the target pixel point is obtained, the second RGB value is the new RGB value of the target pixel point after brightness adjustment, so that the first face image is obtained. Through the above method, only one color space conversion is required to realize brightness adjustment, which reduces the calculation amount and effectively reduces the image information loss caused in the brightening process.
[0094] In some embodiments, the brightness L is not represented by the commonly used percentage, but is valued at 1-255, so as to avoid using floating point numbers for operation, and the operation can be simplified.
[0095] In the embodiment, the conversion between the RGB color model and the HSL color space is reduced by adjusting only the L (brightness) part, on the one hand, the calculation amount can be effectively reduced, and on the other hand, the image information loss caused in the brightening process can be effectively reduced by performing brightness enhancement in different color spaces.
[0096] In some embodiments, referring to Figure 9 , the step S24 specifically comprises:
[0097] S241: histogram normalization is performed on the A channel image to output a normalized image.
[0098] S242: if the average gray value of the normalized image is less than or equal to the first preset gray threshold, image equalization processing is performed on the normalized image to obtain a second A channel image.
[0099] S243: if the average gray value of the normalized image is greater than the first preset gray threshold, the normalized image is taken as the second A channel image.
[0100] The histogram normalization is an automatic selection of the slope a and the intercept b of the image linear variation. For example, the A channel image is denoted as I, which has a width of W and a height of H, I(r, c) represents the gray value of the rth row and the cth column of I, the minimum gray level appearing in I is denoted as I min , and the maximum gray level appearing in I is denoted as I max , that is, I(r, c) ∈ [I min , I max ], in order to make the gray level range of the output image O be [O min , O max ], I(r, c) and O(r, c) have the following mapping relationship:
[0101]
[0102] The above linear transformation process is the histogram normalization, wherein,
[0103]
[0104] In the method, the minMaxLoc tool package of the opencv library is used to obtain I min and I max , O min and O max are 0 and 255 respectively.
[0105] That is, the normalized image = a * the A channel image + b, by performing the histogram normalization on the A channel image, the output normalized image is the image after the gray scale stretching of the A channel image, so as to avoid the concentration of the gray scale in one or several gray scale sections, thereby, the influence of the light and other factors during the image acquisition can be eliminated.
[0106] The average value of all the gray values in the normalized image, that is, the gray mean value of the normalized image, is calculated, and the gray mean value of the normalized image is compared with the first preset gray threshold value, if the gray mean value of the normalized image is less than or equal to the first preset gray threshold value, the normalized image is subjected to the image equalization processing to obtain a second A channel image, if the gray mean value of the normalized image is greater than the first preset gray threshold value, the normalized image is taken as the second A channel image, thereby, the gray mean value of the second A channel image can be ensured to be greater than the first preset gray threshold value, so that the second A channel image has a clear and good image display effect.
[0107] The image equalization processing is an operation of transforming an image with uneven gray level distribution into a uniformly distributed image. For example, the image equalization processing can be performed by using a histogram equalization technique or a createCLAHE toolkit in an OpenCV library to equalize the normalized image. The equalization of the normalized image can make the dark details of the second A-channel image clearer and highlight the contours in the image.
[0108] In this embodiment, the histogram normalization and the image equalization processing are performed on the A-channel image to obtain a second A-channel image with high contrast, so that the second A-channel image is clear and eye-catching and has a good display effect.
[0109] In some embodiments, the step S241 is followed by:
[0110] Step S244: performing a second contrast enhancement processing on the normalized image.
[0111] For example, before comparing the gray mean value of the normalized image with the first preset gray threshold, the ImageEnhance.Contrast function in the pillow library is used to perform a second contrast enhancement processing on the normalized image to increase the contrast of the normalized image. Through a large number of experiments, the enhancement parameter contrast is 1.3, and a good contrast enhancement effect can be obtained.
[0112] In some embodiments, referring to Figure 10 , the step S25 specifically includes:
[0113] S251: traversing each pixel point in the second A-channel image to obtain the gray value of each pixel point in the second A-channel image.
[0114] S252: performing the first color filling processing and the second color filling processing on the second A-channel image according to the gray value of each pixel point in the second A-channel image to obtain a face skin sensitivity map.
[0115] As known from the above, the gray value of each pixel point in the A channel image can reflect the redness of each pixel point in the first face image, so that the second A channel image obtained after the contrast enhancement processing can more clearly reflect the sensitive red region in the face skin, that is, the gray value of each pixel point in the second A channel image can reflect the respective corresponding sensitivity (redness) of each pixel point. Therefore, the first color filling processing and the second color filling processing can be performed on the second A channel image according to the gray value of each pixel point in the second A channel image, so that the sensitive region in the face skin and the non-sensitive region in the face skin are respectively displayed in different ways in the face skin sensitivity map.
[0116] For example, the first color and the second color are filled in each pixel point in the second A channel image according to the gray value thereof, and different gray value pixel points fill different shades of the first color and different shades of the second color, wherein the first color and the second color are two different colors. Since the gray values of the respective pixel points corresponding to the sensitive region and the non-sensitive region in the second A channel image are different, the sensitive region and the non-sensitive region in the face skin sensitivity map obtained after the first color filling processing and the second color filling processing are displayed in different colors, and the sensitivity is different, the corresponding first color depth is different, the non-sensitivity is different, and the corresponding second color depth is different, so that in the obtained face skin sensitivity map, not only the sensitive region and the non-sensitive region in the face skin can be clearly distinguished, but also the sensitivity and the non-sensitivity (normal degree of skin) of the skin can be understood.
[0117] In the present embodiment, by traversing each pixel point in the second A channel image, the gray value of each pixel point in the second A channel image is obtained, the first color filling processing and the second color filling processing are performed on each pixel point in the second A channel image, and the corresponding RGB value of each pixel point is obtained, so that the face skin sensitivity map which can clearly distinguish the sensitive region and the non-sensitive region in the face skin is obtained.
[0118] In some embodiments, referring to Figure 11 , the step S252 specifically includes:
[0119] S2521: According to the gray value of each pixel point in the second A channel image, the white degree and the non-white degree of each pixel point in the second A channel image are respectively obtained, wherein the white degree is the ratio between the gray value of the pixel point in the second A channel image and the second preset gray threshold, and the non-white degree is 1 minus the white degree.
[0120] S2522: multiplying the first preset RGB value of the first color by the white degree of each pixel point in the second A channel image respectively to obtain a first color filling image, wherein the first color is the basic filling color of the sensitive area in the human face skin.
[0121] S2523: multiplying the second preset RGB value of the second color by the non-white degree of each pixel point in the second A channel image respectively to obtain a second color filling image, wherein the second color is the basic filling color of the non-sensitive area in the human face skin.
[0122] S2524: performing color superposition on the first color filling image and the second color filling image to obtain the human face skin sensitive image.
[0123] As Figure 5 described in the above, the second A channel image is a single channel image, wherein the white pixel point in the second A channel image corresponds to the sensitive red area in the human face skin, the deeper the white degree of the pixel point, the redder the sensitive red in the corresponding human face skin, and the deeper the non-white degree of the pixel point, the more normal the corresponding human face skin.
[0124] For example, for any pixel point a i in the second A channel image, the gray value of the pixel point a i is x, the second preset gray threshold is β, the white degree of the pixel point a i is x / β, which reflects the degree of sensitive red in the human face skin corresponding to the pixel point a i . The non-white degree of the pixel point a i is 1-x / β, which reflects the degree of normal skin color in the human face skin corresponding to the pixel point a i . In some embodiments, the second preset gray threshold β can be 255, that is, 100% white is used for comparison to calculate the white degree, and the level is stronger.
[0125] The first preset RGB value of the first color is multiplied by the white degree of each pixel point in the second A channel image respectively, so that the first new RGB value of each pixel point is obtained, which constitutes the first color filling image. Wherein, the first color is the basic filling color of the sensitive area in the human face skin, for example, the first preset RGB value of the first color is [170, 0, 0], and [170, 0, 0] red is used as the basic filling color of the sensitive area. For any pixel point a i in the second A channel image, the white degree x / β of the pixel point a i multiplied by the basic color [170, 0, 0] obtains the first color filling image.
[0126] In this step, as Figure 5The white region in the second A-channel image is filled with the first color according to the white degree of each pixel point, to obtain a first color filling image which can reflect the sensitive region of the face skin.
[0127] The second preset RGB value of the second color is multiplied by the non-white degree of each pixel point in the second A-channel image, to obtain a second new RGB value of each pixel point, which constitutes the second color filling image. The second color is the basic filling color of the non-sensitive region of the face skin. For example, the second preset RGB value of the second color is [255, 255, 255], and the white color [255, 255, 255] is used as the basic filling color of the non-sensitive region. For any pixel point a in the second A-channel image, the non-white degree 1-x / β is multiplied by the basic color [255, 255, 255], to obtain the second color filling image. i
[0128] In this step, the non-white region in the second A-channel image is filled with the second color according to the non-white degree of each pixel point, to obtain a second color filling image which can reflect the non-sensitive region of the face skin. Figure 5
[0129] Finally, the first color filling image and the second color filling image are color superimposed to obtain the face skin sensitive image. That is, the RGB value of each pixel point in the face skin sensitive image = the RGB value of each pixel point in the first color filling image + the RGB value of each pixel point in the second color filling image. It can be understood that the pixel points in the first color filling image, the second color filling image and the face image correspond one by one. It is worth noting that if the sum of the two pixel values is greater than 255 in the process of addition, the pixel value of the corresponding pixel point in the face skin sensitive image is set to 255.
[0130] For example, for a pixel point D(r, c) in the rth row and the cth column of the face skin sensitive map D, a pixel point T1(r, c) in the rth row and the cth column of the first color filling map T1, a pixel point T2(r, c) in the rth row and the cth column of the second color filling map T2, the R value of the pixel point D(r, c) is the sum of the R value of the pixel point T1(r, c) and the R value of the pixel point T2(r, c), if the sum is greater than 255, the R value of the pixel point D(r, c) is 255. Similarly, the G value of the pixel point D(r, c) is the sum of the G value of the pixel point T1(r, c) and the G value of the pixel point T2(r, c), if the sum is greater than 255, the G value of the pixel point D(r, c) is 255. Similarly, the B value of the pixel point D(r, c) is the sum of the B value of the pixel point T1(r, c) and the B value of the pixel point T2(r, c), if the sum is greater than 255, the B value of the pixel point D(r, c) is 255.
[0131] In the embodiment, by obtaining the white degree and the non-white degree of each pixel point according to the gray value of each pixel point in the second channel image, performing the first color filling processing on each pixel point according to the white degree of each pixel point, and performing the second color filling processing on each pixel point according to the non-white degree of each pixel point, the first color filling processing and the second color filling processing of each pixel point are both performed according to the corresponding red degree, which not only can accurately determine the sensitive area in the face skin, reduce the inaccuracy of the boundary between the sensitive area and the normal skin, and display the sensitive area and the non-sensitive area in different colors, but also can reflect the sensitive degree of the sensitive area and the normal degree of the skin in the face skin, the greater the sensitive degree is, the deeper the corresponding first color is, and the more normal the skin is, the deeper the corresponding second color is.
[0132] In order to enhance the visual effect of the face skin sensitive map, in some embodiments, the method further comprises:
[0133] S26: performing color enhancement processing on the face skin sensitive map, and outputting the face skin sensitive map after the color enhancement processing.
[0134] The color enhancement processing can make the face skin sensitivity map as a whole bright, and the color of the sensitive area and the color of the non-sensitive area (the color corresponding to normal skin) more distinct, for example, the sensitive red area is redder, and the non-sensitive white area is whiter. In some embodiments, the color enhancement processing can be implemented by the addWeighted toolkit in the OpenCV library, for example, when the first preset RGB value is [170, 0, 0] and the second preset RGB value is [255, 255, 255], a full black image b1 can be defined, and the face skin sensitivity map is combined with the full black image b1 by the addWeighted toolkit in the OpenCV library, and the output image is the face skin sensitivity map after color enhancement processing.
[0135] One of the embodiments of the present application also provides a non-transitory computer-readable storage medium storing computer executable instructions for causing an electronic device to perform, for example, the method in the above description Figures 3-11 .
[0136] The embodiment of the present application provides a computer program product, including a computer program stored on a non-volatile computer-readable storage medium, the computer program including program instructions, when the program instructions are executed by a computer, causing the computer to perform the method for detecting wrinkles in any method embodiment described above, for example, performing the method steps in the above description Figures 3-11 .
[0137] It should be noted that the apparatus embodiments described above are only schematic, wherein the units as separate components can or can not be physically separate, and the components as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0138] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Those skilled in the art can understand that all or part of the processes in the above-described embodiment methods can be completed by a computer program instructing related hardware, and the program can be stored in a computer readable storage medium. When the program is executed, it can include the processes of the above-described embodiments of each method. The storage medium can be a magnetic disc, an optical disc, a read-only memory (ROM) or a random access memory (RAM), etc.
[0139] Finally, it should be noted that: the above examples are only used to illustrate the technical solutions of the present application, but not limited to them; under the idea of the present application, the technical features of the above examples or different examples can also be combined, the steps can be implemented in any order, and there are many other changes of different aspects of the present application as described above, which are not provided in details for simplicity; although the present application has been described in detail with reference to the foregoing examples, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing examples, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for generating a facial skin sensitivity map, characterized in that, The method comprises the following steps: obtaining a face image; adjusting the brightness of the face image to obtain a first face image, wherein the brightness of each pixel point in the first face image is greater than or equal to a preset brightness threshold; converting the first face image into a LAB face image, and extracting the A channel component of the LAB face image to obtain an A channel image; performing first contrast enhancement processing on the A channel image to obtain a second A channel image, wherein the average gray value of the second A channel image is greater than a first preset gray threshold; traversing each pixel point in the second A channel image to obtain the gray value of each pixel point in the second A channel image; performing the first color filling processing and the second color filling processing on the second A channel image according to the gray value of each pixel point in the second A channel image to obtain a face skin sensitive image, wherein the first color filling processing and the second color filling processing are two kinds of filling processing modes for making the sensitive area in the face skin and the non-sensitive area in the face skin respectively displayed in different ways in the face skin sensitive image; the method of performing the first color filling processing and the second color filling processing on the second A channel image according to the gray value of each pixel point in the second A channel image to obtain a face skin sensitive image comprises the following steps: obtaining the white degree and the non-white degree of each pixel point in the second A channel image according to the gray value of each pixel point in the second A channel image, wherein the white degree is the ratio between the gray value of the pixel point in the second A channel image and the second preset gray threshold, and the non-white degree is 1 minus the white degree; multiplying the first preset RGB value of the first color by the white degree of each pixel point in the second A channel image to obtain a first color filling image, wherein the first color is the basic filling color of the sensitive area in the face skin; multiplying the second preset RGB value of the second color by the non-white degree of each pixel point in the second A channel image to obtain a second color filling image, wherein the second color is the basic filling color of the non-sensitive area in the face skin; color superposition of the first color filling image and the second color filling image to obtain the face skin sensitive image.
2. The method of claim 1, wherein, The method of adjusting the brightness of the face image to obtain a first face image comprises the following steps: if the brightness of a target pixel point in the face image is less than the preset brightness threshold, increasing the brightness of the target pixel point to a first brightness to obtain the first face image, wherein the target pixel point is any pixel point in the face image, and the first brightness is greater than or equal to the preset brightness threshold.
3. The method of claim 2, wherein, The method of increasing the brightness of the target pixel point to a first brightness to obtain the first face image comprises the following steps: obtaining the HS value of the target pixel point in the HSL color space according to the first RGB value of the target pixel point and the brightness of the target pixel point; determining the second RGB value of the target pixel point according to the first brightness and the HS value to obtain the first face image.
4. The method of claim 1, wherein, The first contrast enhancement processing is performed on the A channel image to obtain a second A channel image, including: performing histogram normalization on the A channel image to output a normalized image; if the average gray value of the normalized image is less than or equal to the first preset gray threshold, performing image equalization processing on the normalized image to obtain a second A channel image; if the average gray value of the normalized image is greater than the first preset gray threshold, taking the normalized image as the second A channel image.
5. The method of claim 4, wherein, After the histogram normalization on the A channel image to output a normalized image, the method further includes: performing second contrast enhancement processing on the normalized image.
6. The method of claim 1, wherein, The method further includes: performing color enhancement processing on the face skin sensitive image to output a face skin sensitive image after color enhancement processing.
7. An electronic device, comprising: including: at least one processor, and a memory connected to the at least one processor in communication, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
8. A non-transitory computer-readable storage medium, comprising: The non-transitory computer-readable storage medium stores computer-executable instructions for causing an electronic device to perform the method of any one of claims 1-7.
Citation Information
Patent Citations
Material adding method and apparatus of 3D model, and terminal
CN105574918A
Method for detecting skin colors and pigmentation situation of skin
CN106388781A
Picture brightness adjusting method, device and storage medium thereof
CN109064431A