Skin area detection method, system, image processing terminal and storage medium

Through Lab color space and Sobel edge detection technology, combining clustering and face feature points, the misidentification problem in the existing technology is solved, and the method of accurately obtaining skin areas is achieved, ensuring the accuracy of the skin tone effect of the characters in the photo.

CN113095147BActive Publication Date: 2024-11-26BEIJING XIONGDI ANPU TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110280360.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-16
Publication Date
2024-11-26
Estimated Expiration
2041-03-16

AI Technical Summary

Technical Problem

Existing skin tone detection technology can easily misidentify clothes or backgrounds as skin areas, causing the skin tone effect of the characters in the photos to deviate from the standard requirements.

Method used

By converting the original face image to the Lab color space, Sobel edge detection is performed, gradient face image is obtained, and multiple clustering centers are obtained based on the gradient face image to generate color clustering images, and select seed clustering based on the face feature points. blocks, merge similar cluster blocks to obtain skin areas.

Benefits of technology

It effectively avoids the problem of mistakenly identifying clothes as skin. The method is stable and reliable and can accurately obtain the skin area.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113095147B_ABST
    Figure CN113095147B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a skin area detection method, including: obtaining an original face image, converting the original face image to a Lab color space, obtaining a color space face image, performing sobel edge detection on the original face image, and obtaining a gradient face image; obtaining multiple cluster centers of the color space face image according to the gradient face image, and generating a color cluster image including multiple cluster blocks according to the multiple cluster centers; performing face recognition on the original face image, obtaining face feature points, and selecting seed cluster blocks from multiple cluster blocks according to the face feature points; merging multiple cluster blocks according to the boundary pixels of the multiple seed cluster blocks, and obtaining the skin area according to the merged result. The present invention also discloses a skin area detection system, a camera device, and a storage medium. The present invention can improve the stability and reliability of skin area detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a skin area detection method, system, image processing terminal and storage medium. Background Art

[0002] With the booming economy and the continuous innovation of technology in all walks of life, people's living standards have been continuously improved. The innovative application of self-service photo equipment has also brought a very convenient experience to people applying for ID photos. However, relevant national departments have certain requirements for the effects of the photos taken, among which the requirements for the skin color of the people in the photos are one aspect. There are many factors that affect the skin color difference, for example, camera parameters, photo lighting atmosphere, and the skin condition of the person (race, color, makeup, skin brightness, etc.) will cause the skin color effect of the person in the photo to deviate from the standard requirements. Some current skin color detection technologies are to establish a skin color model and analyze whether each pixel meets the model requirements through the skin color model to determine whether the pixel point belongs to the skin area, but it is easy to mistakenly identify some clothes or backgrounds as skin areas. Summary of the invention

[0003] Based on this, it is necessary to propose a skin area detection method, system, image processing terminal and storage medium to address the above problems.

[0004] A skin area detection method comprises: obtaining an original face image, converting the original face image into a Lab color space, obtaining a color space face image, performing Sobel edge detection on the original face image, and obtaining a gradient face image; obtaining multiple cluster centers of the color space face image according to the gradient face image, and generating a color cluster image including multiple cluster blocks according to the multiple cluster centers; performing face recognition on the original face image, obtaining face feature points, and selecting seed cluster blocks from the multiple cluster blocks according to the face feature points; merging the multiple cluster blocks according to the boundary pixels of the multiple seed cluster blocks, and obtaining a skin area according to the merging result.

[0005] A skin area detection system includes: an acquisition module, which acquires an original face image, converts the original face image into a Lab color space, acquires a color space face image, performs Sobel edge detection on the original face image, and acquires a gradient face image; a clustering module, which is used to acquire multiple cluster centers of the color space face image according to the gradient face image, and generate a color cluster image including multiple cluster blocks according to the multiple cluster centers; a seed module, which is used to perform face recognition on the original face image, acquire face feature points, and select seed cluster blocks from the multiple cluster blocks according to the face feature points; and a merging module, which is used to merge the multiple cluster blocks according to the boundary pixels of the multiple seed cluster blocks, and acquire a skin area according to the merged result.

[0006] A photographing device comprises: a processor, a memory and a communication circuit, wherein the processor is coupled to the memory and the communication circuit, a computer program is stored in the memory, and the processor executes the computer program to implement the method described above.

[0007] A storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the steps of the method described above.

[0008] The embodiments of the present invention have the following beneficial effects:

[0009] The color space face image and the gradient face image of the original face image are obtained, and multiple cluster centers of the color space face image are obtained according to the gradient face image. A color cluster image including multiple cluster blocks is generated according to the multiple cluster centers. A seed cluster block is selected from the multiple cluster blocks according to the facial feature points; the multiple cluster blocks are merged according to the boundary pixels of the multiple seed cluster blocks, and the skin area is obtained according to the merged result. Image clustering combined with facial feature points will not cause the problem of misidentifying clothes as skin, and the method is stable and reliable. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0011] in:

[0012] Figure 1 is a flow chart of a first embodiment of a skin area detection method provided by the present invention;

[0013] Figure 2 is a schematic diagram of facial feature points provided by the present invention;

[0014] Figure 3 is a flow chart of a second embodiment of the method for obtaining cluster blocks provided by the present invention;

[0015] Figure 4 is a flow chart of a second embodiment of the skin area detection method provided by the present invention;

[0016] Figure 5 is a structural schematic diagram of an embodiment of a skin area detection system provided by the present invention;

[0017] Figure 6 It is a structural schematic diagram of an embodiment of a photographing device provided by the present invention;

[0018] Figure 7 It is a structural schematic diagram of an embodiment of the storage medium provided by the present invention. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only 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.

[0020] See also Figure 1 , Figure 1 1 is a flow chart of a first embodiment of a skin region detection method provided by the present invention. The skin region detection method provided by the present invention comprises the following steps:

[0021] S101: Obtain an original face image, convert the original face image into Lab color space, obtain a color space face image, perform Sobel edge detection on the original face image, and obtain a gradient face image.

[0022] In a specific implementation scenario, an original face image is obtained. The original face image can be a photo of an ID card taken by a user when using a self-service photo taking device, or a photo of an ID card to be processed provided by a user, or a face image obtained from the original image by face recognition technology. The original image is an RGB image, and the original image is converted from RGB format to Lab color space to obtain a color space face image. Lab is an uncommon color space. It is a device-independent color system and a color system based on physiological characteristics. This means that it uses a digital method to describe human visual perception. The L component in the Lab color space is used to represent the brightness of the pixel, and the value range is [0,100], representing from pure black to pure white; a represents the range from red to green, and the value range is [127, -128]; b represents the range from yellow to blue, and the value range is [127, -128]. The RGB color space cannot be directly converted to the Lab color space. It is necessary to use the XYZ color space to convert the RGB color space to the XYZ color space, and then convert the XYZ color space to the Lab color space.

[0023] Specifically, the conversion is performed according to the following formula.

[0024]

[0025] L * =116·f(Y / Y n )-16

[0026] a * =500·[f(X / X n )-f(Y / Y n )]

[0027] b * =200·[f(Y / Y n )-f(Z / Z n )]

[0028]

[0029] Among them, R, G, B are the R value, G value and B value of the pixel respectively, and L*, a*, b* are the L value, a value and b value of the pixel respectively.

[0030] The Sobel operator is mainly used for edge detection. Technically, it is a discrete difference operator used to calculate the approximate grayscale value of the image brightness function. The operator contains two sets of 3x3 matrices, one for horizontal and one for vertical. By performing a planar convolution with the original image, the approximate horizontal and vertical brightness difference values ​​can be obtained respectively. If A represents the original image, G x and Gy Respectively represent the grayscale values ​​of the image after horizontal and vertical edge detection, and the formulas are as follows:

[0031]

[0032]

[0033] The horizontal and vertical grayscale values ​​of each pixel of the gradient face image are combined through the following formula to calculate the grayscale of the pixel:

[0034] |G|=|G x |+|G y |

[0035] If the gradient value G corresponding to a pixel point (x, y) is greater than a preset threshold, the pixel point (x, y) is considered to be an edge point.

[0036] S102: Acquire multiple cluster centers of the color space face image according to the gradient face image, and generate a color cluster image including multiple cluster blocks according to the multiple cluster centers.

[0037] In a specific implementation scenario, clustering is a kind of data aggregation, which is to group similar data into one category. Clustering is an unsupervised classification method, and its advantage is that it does not require a pre-training process. Currently, the more commonly used clustering methods include K-means, Gaussian Mixture Models (GMM), Mean shift, etc.

[0038] According to the gradient face image, multiple cluster centers of the color space face image are obtained. For example, the color space face image is divided into multiple regions, and the point with the largest gradient in each region is obtained as the cluster center. The image in the Lab color space has two color channels, a and b, so the color value (V a ,V b ), calculate the distance from each pixel to each cluster center, which includes the spatial distance and the color distance, and classify each pixel in the spatial face image into its corresponding cluster center according to the obtained distance, so as to generate cluster blocks corresponding to multiple cluster centers one by one, and obtain the multiple cluster blocks to generate a color cluster image.

[0039] S103: performing face recognition on the original face image to obtain face feature points, and selecting a seed cluster block from multiple cluster blocks according to the face feature points.

[0040] In a specific implementation scenario, please refer to Figure 2 , Figure 2is a schematic diagram of facial feature points provided by the present invention. Figure 2 The facial feature points shown in the figure are located at the specific positions on the original facial image to obtain the facial contour. A seed clustering block is selected from multiple clustering blocks according to the facial contour. In actual application scenarios, the original facial image includes not only the face, but also other objects such as shooting background, clothing, and jewelry. Therefore, some clustering blocks correspond to non-face areas. These clustering blocks cannot correspond to skin areas. Therefore, the facial feature points can be used for screening, and the clustering blocks within the facial contour are used as seed clustering blocks. This avoids treating the non-face area as the skin area in subsequent clustering.

[0041] S104: merging the multiple cluster blocks according to the boundary pixels of the multiple seed cluster blocks, and obtaining the skin area in combination with the facial feature points.

[0042] In a specific implementation scenario, the boundary pixels of each seed cluster block are obtained, the adjacent block information of each seed cluster block is confirmed, the color similarity of each adjacent seed cluster block is calculated, the adjacent seed cluster blocks with color similarity higher than a preset similarity threshold are merged, and a merged cluster block is obtained, and the above steps are repeated to obtain a new merged cluster block until the color similarity of all adjacent cluster blocks obtained is lower than the preset similarity threshold. The skin area is obtained according to the last cluster block.

[0043] It can be seen from the above description that in this embodiment, a color space face image and a gradient face image of the original face image are obtained, multiple cluster centers of the color space face image are obtained according to the gradient face image, a color cluster image including multiple cluster blocks is generated according to the multiple cluster centers, a seed cluster block is selected from the multiple cluster blocks according to the facial feature points; the multiple cluster blocks are merged according to the boundary pixels of the multiple seed cluster blocks, and the skin area is obtained according to the merged result. Image clustering is performed in combination with facial feature points, and the problem of misidentifying clothes as skin will not occur, and the method is stable and reliable.

[0044] See also Figure 3 , Figure 3 1 is a flow chart of a second embodiment of the method for obtaining cluster blocks provided by the present invention. The method for obtaining cluster blocks provided by the present invention comprises the following steps:

[0045] S201: Obtain an original face image, convert the original face image into Lab color space, obtain a color space face image, perform Sobel edge detection on the original face image, and obtain a gradient face image.

[0046] In a specific implementation scenario, step S201 is substantially consistent with step S101 of the first embodiment of the skin area detection method provided by the present invention, and will not be described in detail herein.

[0047] S202: Divide the color space face image into m*n grids, obtain the target pixel point corresponding to the position with the minimum gradient in each grid according to the gradient face image, and use the target pixel point as the cluster center of the grid; wherein m and n are any positive integers.

[0048] In a specific implementation scenario, the color space face image is divided into m*n grids, where m and n are any positive integers. The center of each grid is taken as the initial center of the grid, and the initial centers of all grids are traversed in a loop to determine whether the initial center is the pixel point with the smallest gradient of the grid in which it is located. If so, the initial center is taken as the cluster center of the grid in which it is located. If not, the pixel point with the smallest gradient of the grid in which it is located is obtained as the distance center of the grid. Specifically, the pixels are traversed within the range of 5×5 of the original center to determine whether the initial center is the pixel point with the smallest gradient of the grid in which it is located.

[0049] S203: Obtain the cluster distance from the pixel point in the color space face image to each cluster center, and use the cluster center corresponding to the shortest cluster distance as the belonging cluster center corresponding to the pixel point.

[0050] In a specific implementation scenario, the color distance D from each pixel in the color space face image to each cluster center is obtained. c , add the center mark of the cluster center corresponding to the shortest color distance of each pixel to the pixel. c According to the following formula:

[0051]

[0052] Among them, a j is the color value of the a channel of pixel j, b j is the b channel color value of pixel j, a i is the color value of the a channel of pixel i, b i is the b channel color value of pixel i, and one point between pixel i and pixel j is the cluster center.

[0053] Get the spatial distance D from each pixel in the color space face image to each cluster center s . Spatial distance D s According to the following formula:

[0054]

[0055] Among them, x j is the x coordinate value of pixel j, y j is the y coordinate value of pixel j, xi is the x coordinate value of pixel i, y i is the y coordinate value of pixel i.

[0056] According to the color distance D c and spatial distance D s Calculate the cluster distance D′:

[0057]

[0058]

[0059] Among them, represents the maximum color distance, N c It is generally taken as a fixed constant. In this implementation scenario, N c The value range of is [1,40], for example, it can be 10. Therefore, it can be concluded that:

[0060]

[0061] Get the cluster distance from each pixel to each cluster center, and use the cluster center corresponding to the shortest cluster distance as the cluster center corresponding to the pixel. In this implementation scenario, for each pixel, search for the cluster center closest to its cluster distance D′ within its 2S×2S range. For example, a pixel is in the range of 2S×2S to three cluster centers L, M, and N, and the corresponding cluster distances are l, m, and n, respectively, and l>m>n, then the cluster center corresponding to the pixel is N. Take a cluster center and its corresponding pixel as a cluster block.

[0062] S204: Generate multiple cluster blocks according to the cluster center corresponding to each pixel point.

[0063] In a specific implementation scenario, a cluster center and the pixel points to which the cluster center belongs are taken as a cluster block, so that K cluster blocks are generated for K cluster centers.

[0064] In other implementation scenarios, after generating cluster blocks, the cluster centers need to be iteratively updated until the position difference between the updated cluster centers and the previous cluster centers is less than a preset distance, and then cluster blocks are obtained based on the cluster centers obtained by the last iterative update.

[0065] Specifically, after the step of generating multiple cluster blocks, the average vector value of each cluster block is obtained, and the update center of each cluster block is obtained according to the average vector value. It is determined whether the difference between the position distance of the update center and the cluster center is less than the preset difference threshold. If it is less than, it proves that the change of the update center is small enough. If it is greater than or equal to, it proves that the change of the update center is large and the position of the update center is not stable. Then the update center is used as the new cluster center, and the content of step S204 is repeated. Until the difference between the position of the update center obtained most recently and the cluster center is less than the preset difference threshold. If the difference between the position distance of the update center and the cluster center is less than the preset difference threshold, it proves that the position of the update center is relatively stable, then the update center is used as the new cluster center, and the cluster block corresponding to the new cluster center is obtained according to the above method steps.

[0066] From the above description, it can be seen that in this embodiment, the color space face image is divided into m*n grids, and the target pixel point corresponding to the position with the smallest gradient in each grid is obtained according to the gradient face image. The target pixel point is used as the cluster center of the grid, and the cluster distance from the pixel point in the color space face image to each cluster center is obtained. The cluster center corresponding to the shortest cluster distance is used as the cluster center corresponding to the pixel point. Multiple cluster blocks are generated according to the cluster center corresponding to each pixel point, which can effectively improve the accuracy of clustering.

[0067] See also Figure 4 , Figure 4 1 is a flow chart of a second embodiment of the skin region detection method provided by the present invention. The skin region detection method provided by the present invention comprises the following steps:

[0068] S301: Obtain an original face image, convert the original face image into Lab color space, obtain a color space face image, perform Sobel edge detection on the original face image, and obtain a gradient face image.

[0069] S302: Acquire multiple cluster centers of the color space face image according to the gradient face image, and generate a color cluster image including multiple cluster blocks according to the multiple cluster centers.

[0070] In a specific implementation scenario, steps S301-S302 are substantially consistent with steps S101-S102 in the first embodiment of the skin area detection method provided by the present invention, and will not be described in detail herein.

[0071] S303: Performing connected domain analysis on the color clustering image to obtain a connected domain image, where the connected domain image includes multiple connected domains.

[0072] In a specific implementation scenario, the color cluster image includes multiple connected domains. A 4-connectivity method is used to perform connected domain analysis on the color cluster image to obtain a connected domain image, and attribute information such as labels, width, height, area, and center coordinates of each connected domain in the connected domain image is calculated.

[0073] S304: Select target feature points from the facial feature points, divide a target reserved area on the connected domain image according to the target feature points, and use the cluster blocks in the target reserved area as seed cluster blocks.

[0074] In a specific implementation scenario, please refer to Figure 2 , select target feature points 1, 17, 11, 9, 7 from the facial feature points, serialize the selected target feature points into an array in the order of {1, 17, 11, 9, 7, 1} in the clockwise direction, traverse each target feature point in the array, connect the coordinates of two adjacent target feature points in the array into a line, and draw it out until the traversal is completed, and a polygonal irregular area can be obtained. The irregular area is the target reserved area, and the target reserved area is divided on the connected domain image. The image within the irregular area is retained by the floodfill marking method, and the pixel values ​​of the pixels outside the irregular area are set to 255. The cluster blocks in the target reserved area are used as seed cluster blocks.

[0075] S305: Obtain the neighboring cluster blocks of each seed cluster block, calculate the color similarity between each seed cluster block and the neighboring cluster blocks, and if the color similarity meets the preset conditions, merge the seed cluster block with the neighboring cluster blocks, and obtain the skin area according to the merged result.

[0076] In a specific implementation scenario, the neighboring cluster blocks of each seed cluster block are obtained, and the color similarity between each seed cluster block and the neighboring cluster blocks is calculated. If the color similarity meets the preset conditions, the seed cluster block and the neighboring cluster block are merged. If the color similarity does not meet the preset conditions, the seed cluster block and the neighboring cluster block are not merged. Therefore, seed cluster blocks with the same or similar colors can be merged to obtain the skin area of ​​the face.

[0077] In an implementation scenario, each pixel in the target reserved area is traversed to obtain the seed cluster block to which each pixel belongs, and the cluster block label to which each pixel belongs is obtained according to the seed cluster block to which it belongs, and the cluster block label to which each pixel belongs is pushed into the stack S 0 In the example above, we get the seed block stack S 0 .

[0078] For each seed cluster block, set the linked list L with an initial size of 0. If the seed cluster block b x and b yIf the blocks are adjacent, the seed cluster block b y The clustering block label index is put into the seed clustering block b x The corresponding linked list L x Similarly, cluster the seed blocks b x The clustering block label index is pressed into the seed clustering block b y The corresponding linked list L y In order to avoid repeated placement of cluster block label indexes, each time a label index is placed, it will be confirmed whether the label index of the seed cluster block has been placed in the linked list. If not, it will be placed in the linked list, otherwise the placement operation will be skipped. All seed cluster blocks are traversed until the adjacent information record of the seed cluster block is completed.

[0079] Set the flag array Mark, each seed cluster block corresponds to a flag, and set the flag of each seed cluster block to 0. Assuming that the current seed cluster block is i, the seed block stack S 0 Pop operation, the seed cluster block currently popped is denoted as b i , calculate the seed cluster block b i The color information of the a and b channels in the Lab color space. i Mark i Set to 1. Retrieve seed cluster block b i The linked list L of adjacent seed clustering block information i , compare the distance between the color information of the two, if it is lower than the threshold T, push the block into the stack S 0 In the corresponding flag Mark i Set to 1, otherwise the flag is Mark i Set to 0.

[0080] Determine sub-cluster block b i Are there other adjacent seed cluster blocks? If so, update the flag Mark based on the color distance to the next adjacent block. i , iterate again, and repeat until the seed block stack S 0 All seed clustering blocks in the stack are popped off.

[0081] The skin area is obtained according to the value of each flag bit in the flag bit array Mark.

[0082]

[0083] That is to say, the pixel values ​​of the parts with equal and similar color distances in the seed cluster block are set to 255, and the rest are set to 0, so that A can be obtained. f The black area corresponding to (x,y) is the skin area.

[0084] From the above description, it can be seen that in this embodiment, by selecting target feature points from facial feature points, a target retention area is divided on the connected domain image according to the target feature points, and the cluster blocks in the target retention area are used as seed cluster blocks. The adjacent cluster blocks of each seed cluster block are obtained, and the color similarity between each seed cluster block and the adjacent cluster blocks is calculated. If the color similarity meets the preset conditions, the seed cluster block is merged with the adjacent cluster block to obtain the skin area, and the image is clustered in combination with the facial feature points. The problem of misidentifying clothes as skin will not occur, and the method is stable and reliable.

[0085] See also Figure 5 , Figure 5 The skin region detection system 10 includes: an acquisition module 11 , a clustering module 12 , a seed module 13 , and a merging module 14 .

[0086] The acquisition module 11 acquires the original face image, converts the original face image into the Lab color space, acquires the color space face image, performs sobel edge detection on the original face image, and acquires the gradient face image; the clustering module 12 is used to acquire multiple cluster centers of the color space face image according to the gradient face image, and generate a color cluster image including multiple cluster blocks according to the multiple cluster centers; the seed module 13 is used to perform face recognition on the original face image, acquire face feature points, and select seed cluster blocks from the multiple cluster blocks according to the face feature points; the merging module 14 is used to merge the multiple cluster blocks according to the boundary pixels of the multiple seed cluster blocks, and acquire the skin area according to the merged result.

[0087] The clustering module 12 is also used to divide the color space face image into m*n grids, obtain the target pixel point corresponding to the position with the smallest gradient in each grid according to the gradient face image, and use the target pixel point as the clustering center of the grid; wherein m and n are any positive integers.

[0088] The clustering module 12 is also used to obtain the spatial distance from the pixel point to each cluster center in the color space face image, and use the cluster center corresponding to the shortest spatial distance as the belonging cluster center corresponding to the pixel point; and generate multiple cluster blocks according to the belonging cluster center corresponding to each pixel point.

[0089] The clustering module 12 is also used to obtain the average vector value of each cluster block, obtain the update center of each cluster block according to the average vector value, and determine whether the gap between the update center and the cluster center is less than a preset gap threshold; if the gap between the update center and the cluster center is greater than or equal to the preset gap threshold, the update center is used as the new cluster center, and the color distance from the pixel point in the color space face image to each cluster center and subsequent steps are repeatedly executed until the gap is less than the preset gap threshold.

[0090] The seed module 13 is used to perform connected domain analysis on the color cluster image to obtain a connected domain image, which includes multiple connected domains; select target feature points from the facial feature points, divide the target retention area on the connected domain image according to the target feature points, and use the cluster blocks in the target retention area as seed cluster blocks.

[0091] The merging module 14 is further used to obtain the neighboring cluster blocks of each seed cluster block, calculate the color similarity between each seed cluster block and the neighboring cluster blocks, and if the color similarity meets a preset condition, the seed cluster block is merged with the neighboring cluster block.

[0092] The merging module 14 is also used to obtain the color information of each cluster block, calculate the color distance between the target cluster block and its adjacent cluster blocks according to the color information, and if the color distance is less than a preset color threshold, determine that the color similarity between the target cluster block and the adjacent cluster block meets the preset condition.

[0093] It can be seen from the above description that in this embodiment, the skin area detection system obtains the color space face image and the gradient face image of the original face image, obtains multiple cluster centers of the color space face image according to the gradient face image, generates a color cluster image including multiple cluster blocks according to the multiple cluster centers, selects a seed cluster block from the multiple cluster blocks according to the face feature points; merges the multiple cluster blocks according to the boundary pixels of the multiple seed cluster blocks, and obtains the skin area according to the merged result. Image clustering is performed in combination with face feature points, and the problem of misidentifying clothes as skin will not occur, and the method is stable and reliable.

[0094] See also Figure 6 , Figure 6 2 is a schematic diagram of a photographing device according to an embodiment of the present invention. The photographing device 20 includes a processor 21 and a memory 22. The processor 21 is coupled to the memory 22. The memory 22 stores a computer program, and the processor 21 executes the computer program when working to achieve the following. Figure 1 , Figure 3-Figure 4 The detailed method can be found in the above, which will not be described here.

[0095] It can be seen from the above description that the camera device in this embodiment can obtain the color space face image and the gradient face image of the original face image, obtain multiple cluster centers of the color space face image according to the gradient face image, generate a color cluster image including multiple cluster blocks according to the multiple cluster centers, select a seed cluster block from the multiple cluster blocks according to the face feature points; merge the multiple cluster blocks according to the boundary pixels of the multiple seed cluster blocks, and obtain the skin area according to the merged result. Image clustering is performed in combination with face feature points, and the problem of misidentifying clothes as skin will not occur, and the method is stable and reliable.

[0096] See also Figure 7 , Figure 7 The storage medium 30 stores at least one computer program 31, which is used to be executed by the processor to implement the following. Figure 1 , Figure 3-Figure 4 The method shown. The detailed method can be found above and will not be repeated here. In one embodiment, the storage medium 30 can be a storage chip, a hard disk, a mobile hard disk, a USB flash drive, an optical disk, or other readable and writable storage tools in the terminal, or a server, etc.

[0097] It can be seen from the above description that the computer program in the storage medium in this embodiment can be used to obtain the color space face image and the gradient face image of the original face image, obtain multiple cluster centers of the color space face image according to the gradient face image, generate a color cluster image including multiple cluster blocks according to the multiple cluster centers, select a seed cluster block from the multiple cluster blocks according to the face feature points; merge the multiple cluster blocks according to the boundary pixels of the multiple seed cluster blocks, and obtain the skin area according to the merged result. Image clustering is performed in combination with face feature points, and the problem of misidentifying clothes as skin will not occur, and the method is stable and reliable.

[0098] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0099] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0100] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A skin area detection method, characterized in that: include: Acquire an original face image, convert the original face image into Lab color space, acquire a color space face image, perform Sobel edge detection on the original face image, and acquire a gradient face image; Acquire a plurality of cluster centers of the color space face image according to the gradient face image, and generate a color cluster image including a plurality of cluster blocks according to the plurality of cluster centers; Performing face recognition on the original face image to obtain face feature points, and selecting a seed cluster block from the multiple cluster blocks according to the face feature points; Merging the plurality of cluster blocks according to boundary pixels of the plurality of seed cluster blocks, and acquiring a skin area according to a result of the merging; The step of obtaining a plurality of cluster centers of the color space face image according to the gradient face image comprises: Divide the color space face image into m*n grids, obtain the target pixel point corresponding to the position with the minimum gradient in each grid according to the gradient face image, and use the target pixel point as the cluster center of the grid; Wherein, m and n are any positive integers; Take the center of each grid as the initial center of the grid, loop through the initial centers of all grids, and determine whether the initial center is the pixel with the smallest gradient of the grid in which it is located. If so, take the initial center as the cluster center of the grid in which it is located. If not, obtain the pixel with the smallest gradient of the grid in which it is located as the distance center of the grid. The step of generating a regional color cluster image including a plurality of cluster blocks according to the plurality of cluster centers comprises: Obtaining the spatial distance from the pixel point in the color space face image to each of the cluster centers, and taking the cluster center corresponding to the shortest spatial distance as the belonging cluster center corresponding to the pixel point; including: Get the color distance D from each pixel in the color space face image to each cluster center c , add the center mark of the cluster center corresponding to the shortest color distance of each pixel to the pixel; where the color distance D c According to the following formula: Among them, a j is the color value of the a channel of pixel j, b j is the b channel color value of pixel j, a i is the color value of the a channel of pixel i, b i is the b channel color value of pixel i, and one point between pixel i and pixel j is the cluster center; Get the spatial distance D from each pixel in the color space face image to each cluster center s ; According to the color distance D c and spatial distance D s Calculate the cluster distance D'; Get the cluster distance D' from each pixel to each cluster center, and take the cluster center corresponding to the shortest cluster distance as the cluster center corresponding to the pixel; A plurality of cluster blocks are generated according to the belonging cluster center corresponding to each pixel point.

2. The skin area detection method according to claim 1, characterized in that: After the step of generating a plurality of cluster blocks according to the belonging cluster center corresponding to each pixel point, the method further comprises: Obtaining an average vector value of each cluster block, obtaining an update center of each cluster block according to the average vector value, and determining whether a gap between the update center and the cluster center is less than a preset gap threshold; If the gap between the update center and the cluster center is greater than or equal to the preset gap threshold, the update center is used as the new cluster center, and the step of obtaining the color distance from the pixel point in the color space face image to each cluster center and subsequent steps are repeated until the gap is less than the preset gap threshold.

3. The skin area detection method according to claim 2, characterized in that: The step of merging the plurality of cluster blocks according to boundary pixels of the plurality of seed cluster blocks comprises: The adjacent cluster blocks of each of the seed cluster blocks are obtained, and the color similarity between each of the seed cluster blocks and the adjacent cluster blocks is calculated. If the color similarity meets a preset condition, the seed cluster block is merged with the adjacent cluster block.

4. The skin area detection method according to claim 3, wherein the step of calculating the color similarity between each of the seed cluster blocks and the adjacent cluster blocks comprises: The color information of each cluster block is obtained, and the color distance between the target cluster block and its adjacent cluster blocks is calculated according to the color information. If the color distance is less than a preset color threshold, it is determined that the color similarity between the target cluster block and the adjacent cluster block meets a preset condition.

5. A skin area detection system, characterized in that: include: An acquisition module is used to acquire an original face image, convert the original face image into a Lab color space, acquire a color space face image, and perform a Sobel edge detection on the original face image to acquire a gradient face image; A clustering module, used to obtain multiple cluster centers of the color space face image according to the gradient face image, and generate a color cluster image including multiple cluster blocks according to the multiple cluster centers; specifically used to divide the color space face image into m*n grids, obtain the target pixel point corresponding to the position with the smallest gradient in each grid according to the gradient face image, and use the target pixel point as the cluster center of the grid; wherein m and n are any positive integers; and also used to use the center in each grid as the initial center of the grid, loop through the initial centers of all grids, and determine whether the initial center is the pixel point with the smallest gradient of the grid in which it is located. If so, use the initial center as the cluster center of the grid in which it is located; if not, obtain the pixel point with the smallest gradient of the grid in which it is located as the distance center of the grid; It is also used to obtain the spatial distance from the pixel point in the color space face image to each of the cluster centers, take the cluster center corresponding to the shortest spatial distance as the belonging cluster center corresponding to the pixel point, and generate multiple cluster blocks according to the belonging cluster center corresponding to each of the pixel points; It is also specifically used to obtain the color distance D from each pixel in the color space face image to each cluster center. c , add the center mark of the cluster center corresponding to the shortest color distance of each pixel to the pixel; where the color distance D c According to the following formula: Among them, a j is the color value of the a channel of pixel j, b j is the b channel color value of pixel j, a i is the color value of the a channel of pixel i, b i is the b channel color value of pixel i, and one of pixel i and pixel j is the cluster center; obtain the spatial distance D from each pixel in the color space face image to each cluster center s ; According to the color distance D c and spatial distance D s Calculate the cluster distance D'; obtain the cluster distance D' from each pixel to each cluster center, and use the cluster center corresponding to the shortest cluster distance as the cluster center corresponding to the pixel; A seed module, configured to perform face recognition on the original face image, obtain face feature points, and select a seed cluster block from the plurality of cluster blocks according to the face feature points; The merging module is used to merge the multiple cluster blocks according to the boundary pixels of the multiple seed cluster blocks, and obtain the skin area according to the merging result.

6. A photographing device, characterized in that: include: A processor, a memory and a communication circuit, wherein the processor is coupled to the memory and the communication circuit, a computer program is stored in the memory, and the processor executes the computer program to implement the method according to any one of claims 1 to 4.

7. A storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a processor, the processor executes the steps of the method as described in any one of claims 1 to 4.