CN117576050A - Image detection method and device - Google Patents

Image detection method and device Download PDF

Info

Publication number
CN117576050A
CN117576050A CN202311586066.9A CN202311586066A CN117576050A CN 117576050 A CN117576050 A CN 117576050A CN 202311586066 A CN202311586066 A CN 202311586066A CN 117576050 A CN117576050 A CN 117576050A
Authority
CN
China
Prior art keywords
neck
area
region
portrait
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311586066.9A
Other languages
Chinese (zh)
Inventor
李由
姜永胜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Changsha Xiongdi Xin'an Technology Co ltd
Original Assignee
Changsha Xiongdi Xin'an Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Changsha Xiongdi Xin'an Technology Co ltd filed Critical Changsha Xiongdi Xin'an Technology Co ltd
Priority to CN202311586066.9A priority Critical patent/CN117576050A/en
Publication of CN117576050A publication Critical patent/CN117576050A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person

Abstract

The embodiment of the invention discloses an image detection method and device, comprising the following steps: after the image of the person to be detected is obtained, dividing the person in the image of the person to be detected through a preset image dividing model to obtain a face skin area and a neck area, then calculating the average brightness of the face skin area and the average brightness of the shadow of the neck area respectively, calculating the ratio of the average brightness of the shadow of the neck area to the average brightness of the face skin area, and if the ratio is smaller than a preset threshold value, determining that the neck shadow of the person in the image of the person to be detected is too deep; the method and the device can improve the accuracy of region selection, and the judgment result is not interfered by skin colors, so that the accuracy of neck shadow detection is greatly improved.

Description

Image detection method and device
Technical Field
The present invention relates to the field of image processing, and in particular, to an image detection method and apparatus.
Background
With the development of social economy, the identification cards such as passports, identity cards, driver licenses and the like used for identification cards are also becoming an integral part of our daily lives. The portrait image (i.e., document photograph) for use in the production of a certificate also has a severe requirement for its image quality because of the special purpose. For example, taking the manufacture of an identity card as an example, if the neck shadow of the original image of the portrait is darker, after the film pressing process, the darker portion will be further deepened, and the neck is over-black, so that details are not obvious, and in order to avoid this situation, before the manufacture, the portrait image with the darker neck shadow needs to be detected, and then returned or corrected.
In the prior art, in detecting neck shadows in a portrait image, a neck region is generally determined by calculating chin key points, ellipsometry or skin color selection, and the like, then, the absolute brightness value of the shadow part in the neck region is determined, and if the absolute brightness value is higher than a preset value, the neck shadows are determined to be too deep.
In the research and practice process of the prior art, the inventor of the application finds that the existing method for determining the neck region easily selects a non-skin region or a missing skin region, so that the subsequent calculation is inaccurate, and skin colors of different people can have larger difference, so that if uniform brightness absolute values are used for judging, inaccurate judging results are easily caused, and the accuracy of neck shadow detection is lower.
Disclosure of Invention
The main purpose of the application is to provide an image detection method and device, which can improve the accuracy of neck shadow detection in a portrait image.
In order to achieve the above object, an embodiment of the present application provides an image detection method, including:
acquiring a portrait image to be detected;
dividing the human images in the human image to be detected through a preset image dividing model to obtain a dividing result;
Determining a facial skin region and a neck region according to the segmentation result;
calculating an average luminance of the facial skin region and an average luminance of the neck region shadow, respectively;
calculating the ratio of the average brightness of the neck region shadow to the average brightness of the facial skin region;
and if the ratio is smaller than a preset threshold value, determining that the neck shadow of the portrait in the portrait image to be detected is too deep.
Optionally, in some embodiments of the present application, the calculating the average brightness of the facial skin area and the average brightness of the neck area shadow respectively includes:
calculating the average value of the brightness channels of the face skin area to obtain the average brightness of the face skin area;
determining a left neck boundary and a right neck boundary of a joint part of the upper edge of the neck of the portrait and the chin according to the skin area and the neck area of the face;
selecting a neck shadow assessment region from the neck regions based on the neck left boundary and neck right boundary;
and calculating the average value of the brightness channels of the neck shadow evaluation area to obtain the average brightness of the neck shadow.
Optionally, in some embodiments of the present application, the calculating the left neck boundary and the right neck boundary of the portion where the upper edge of the neck of the portrait meets the chin according to the facial skin area and the neck area includes:
Expanding the facial skin area according to a preset expansion check to obtain an expanded facial skin area;
overlapping the expanded facial skin area and the neck area to obtain an intersection area of the face and the neck;
acquiring coordinate values of non-zero pixels in an intersection area of the face and the neck, and determining a maximum abscissa value and a minimum abscissa value according to the coordinate values;
and determining the left neck boundary and the right neck boundary of the joint part of the upper edge of the neck of the portrait and the chin according to the maximum abscissa value and the minimum abscissa value.
Optionally, in some embodiments of the present application, the calculating the left neck boundary and the right neck boundary of the portion where the upper edge of the neck meets the chin according to the maximum abscissa value and the minimum abscissa value includes:
taking the minimum abscissa value as the left neck boundary of the joint part of the upper edge of the neck of the portrait and the chin;
and taking the maximum abscissa value as the right boundary of the neck at the joint part of the upper edge of the neck of the portrait and the chin.
Optionally, in some embodiments of the present application, the calculating the left neck boundary and the right neck boundary of the portion where the upper edge of the neck meets the chin according to the maximum abscissa value and the minimum abscissa value includes:
Adding a preset value to the minimum abscissa value to obtain an adjusted minimum abscissa value;
subtracting a preset value from the maximum abscissa value to obtain an adjusted maximum abscissa value;
taking the minimum abscissa value after adjustment as the left neck boundary of the joint part of the upper edge of the neck of the portrait and the chin;
and taking the adjusted maximum abscissa value as the right boundary of the neck at the joint part of the upper edge of the neck of the portrait and the chin.
Optionally, in some embodiments of the present application, the selecting a neck shadow assessment area from the neck area based on the neck left boundary and the neck right boundary includes:
multiplying the difference between the right boundary of the neck and the left boundary of the neck by a preset coefficient to obtain the neck height Y;
traversing each column of pixels in the neck region, and setting the brightness of the pixels with the abscissa smaller than the left boundary of the neck and the brightness of the pixels with the abscissa larger than the right boundary to be 0 to obtain a processed neck region;
and traversing the pixels of each column in the neck region after processing, so that the first Y non-zero pixels are reserved in each column, and the brightness of the rest pixels is set to be 0, thereby obtaining a neck shadow evaluation region.
Optionally, in some embodiments of the present application, the determining the facial skin region and the neck region according to the segmentation result includes:
Determining a face skin area initial mask and a neck area initial mask according to the segmentation result;
converting the color mode of the portrait image to be detected into an LAB color model to obtain a converted portrait image;
determining a facial skin area from the facial skin area initial mask and the converted portrait image;
the neck region is determined from the neck region initial mask and the converted portrait image.
Optionally, in some embodiments of the present application, the determining the facial skin area according to the facial skin area initial mask and the converted portrait image includes: corroding the edge transition area of the initial mask of the face skin area by a preset first corroding core to obtain the mask of the face skin area, and superposing the mask of the face skin area and the converted portrait image to obtain the face skin area;
the determining the neck region according to the neck region initial mask and the converted portrait image includes: and corroding the edge transition area of the initial mask of the neck area by a preset second corrosion check to obtain the mask of the neck area, and overlapping the mask of the neck area and the converted portrait image to obtain the neck area.
Optionally, in some embodiments of the present application, the image detection method may further include:
and if the ratio is greater than 1, adjusting the overall brightness of the portrait image to be detected so that the ratio is equal to 1.
Optionally, in some embodiments of the present application, before the segmenting the person image in the person image to be detected by the preset image segmentation model, the method further includes:
collecting a plurality of training samples, the training samples identifying at least the true values of the facial skin region and the neck region;
dividing the facial skin area and the neck area of the training sample by adopting an initial segmentation model to obtain the predicted values of the facial skin area and the neck area;
and based on the true value and the predicted value, converging the initial segmentation model by using a preset loss function to obtain an image segmentation model.
Correspondingly, the embodiment of the application also provides a portrait image detection device, which comprises:
the acquisition unit is used for acquiring the portrait image to be detected;
the segmentation unit is used for segmenting the human images in the human image to be detected through a preset image segmentation model to obtain segmentation results;
A determination unit configured to determine a facial skin region and a neck region from the segmentation result;
a calculation unit for calculating an average luminance of the face skin region and an average luminance of a neck region shadow, respectively;
and the judging unit is used for calculating the ratio of the average brightness of the neck region shadow to the average brightness of the face skin region, and if the ratio is smaller than a preset threshold value, determining that the neck shadow of the portrait in the portrait image to be detected is too deep.
After the image of the person to be detected is obtained, the person in the image of the person to be detected can be segmented through a preset image segmentation model to obtain a face skin area and a neck area, then average brightness of the face skin area and average brightness of the neck area shadow are calculated respectively, the ratio of the average brightness of the neck area shadow to the average brightness of the face skin area is calculated, and if the ratio is smaller than a preset threshold value, it is determined that the neck shadow of the person in the image of the person to be detected is too deep; because the scheme can determine the facial skin area and the neck area through the image segmentation model, compared with the existing methods of chin key point calculation, ellipsometry or skin color selection and the like, the accuracy of area selection can be improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of an image detection method provided in an embodiment of the present application;
FIG. 2 is an exemplary diagram of a left neck boundary and a right neck boundary in an embodiment of the present application;
FIG. 3 is another flowchart of an image detection method according to an embodiment of the present disclosure;
fig. 4 is a frame diagram of an image detection method according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an image detection device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
The embodiment of the application provides an image detection method and device, and the method and device will be described in detail below.
The present embodiment will be described from the viewpoint of an image detection apparatus, which may be integrated in a network device such as a server or a terminal.
An image detection method, comprising: obtaining a to-be-detected portrait image, segmenting the portrait in the to-be-detected portrait image through a preset segmentation model to obtain a segmentation result, determining a face skin area and a neck area according to the segmentation result, respectively calculating the average brightness of the face skin area and the average brightness of the shadow of the neck area, calculating the ratio of the average brightness of the shadow of the neck area to the average brightness of the face skin area, and if the ratio is smaller than a preset threshold value, determining that the neck shadow of the portrait in the to-be-detected portrait image is too deep.
As shown in fig. 1, the flow of the image detection method may specifically be as follows:
101. and acquiring a portrait image to be detected.
The portrait image to be detected includes a portrait, for example, a portrait certificate photo (for short, certificate photo), or other images including a portrait, etc.
For example, a portrait image input by a user may be received, and the portrait image is used as a portrait image to be detected; alternatively, the portrait image sent by the shooting device may be received, and then the received portrait image is used as a portrait image to be detected; alternatively, the captured portrait image may be read directly from the capturing device, and the read portrait image may be used as a portrait image to be detected, and so on.
The color mode of the portrait image to be detected may be RGB (Red, green, blue), and the so-called RGB color mode, which is also called RGB color model, is a color standard, and it is one of the most widely used color systems to obtain various colors by changing three color channels of Red (R, red), green (G, green) and Blue (B, blue) and overlapping them with each other.
102. And dividing the human images in the human image to be detected through a preset image division model to obtain a division result.
The image segmentation model may be trained by other devices in advance and provided to the image detection device, or may be trained by the image detection device, that is, optionally, before the step of "segmenting the portrait in the portrait image to be detected through the preset image segmentation model to obtain a segmentation result", the image detection method may further include:
And acquiring a plurality of training samples, wherein the training samples at least mark the true values of the facial skin area and the neck area, then adopting an initial segmentation model to segment the facial skin area and the neck area of the training samples to obtain the predicted values of the facial skin area and the neck area, and then converging the initial segmentation model by utilizing a preset loss function based on the true values and the predicted values to obtain the image segmentation model.
The training sample contains a portrait, which can be at least recognized by the face and the neck, for example, the training sample can be a certificate photo, or can be other portrait images meeting the conditions, and the like.
Alternatively, for the training samples, in addition to the true values of the facial skin region and the true values of the neck region, the true values of other parts, which are used to indicate the identity of the true values of the respective segmented parts, also referred to as labels, may be identified. That is, in practice, a plurality of labels to be divided may be defined according to the actual application requirements, such as background, neck, clothing, facial skin, beard, nose, glasses, left eye, right eye, left eyebrow, right eyebrow, left ear, right ear, upper lip, lower lip, middle region of mouth, hair, hat headwear, earrings, necklace, etc. A large number of training samples are input into an initial segmentation model to train and converge the initial segmentation model for a plurality of times, so that a trained model, namely an image segmentation model, can be obtained, and therefore, the region (such as a mask) of the corresponding part of each label can be output only by inputting the portrait image to be segmented into the image segmentation model.
The initial segmentation model and the loss function can be set according to practical application requirements and practical experience. For example, the initial segmentation model may specifically employ an image segmentation network such as SegNet (A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation, depth convolutional encoder-decoder architecture for image segmentation), deep lab (an image segmentation algorithm), mask R-CNN (an object detection or segmentation algorithm), U-Net (a convolutional neural network for two-dimensional image segmentation), or a processed SCNN (an image segmentation network), and the loss function may employ a cross-entropy loss function (cross-entropy loss), which may specifically be set based on the employed image segmentation network, which is not described herein.
103. A facial skin region and a neck region are determined from the segmentation result.
For example, the face skin area initial mask and the neck area initial mask may be determined according to the segmentation result, then, the color mode of the to-be-detected portrait image is converted into an LAB color model to obtain a converted portrait image (for example, if the to-be-detected portrait image is RGB, the to-be-detected portrait image is converted from the RGB color model into the LAB color model, etc.), then, the face skin area under the LAB color model is determined according to the face skin area initial mask and the converted portrait image, and the neck area under the LAB color model is determined according to the neck area initial mask and the converted portrait image.
For convenience of description, in the embodiment of the present invention, the facial skin area under the LAB color model is simply referred to as a facial skin area, and the neck area of the LAB color model is simply referred to as a neck area.
Wherein the LAB color model is also a color pattern, and the LAB color model is composed of three elements, one element is brightness L, and the other two elements a and B, which are referred to as two color channels, a includes colors from dark green to gray to bright pink (positive number of a represents red, negative end represents green), and B includes colors from bright blue to gray to yellow (positive number of B represents yellow, negative end represents blue).
Alternatively, there are various ways of "determining the facial skin area from the facial skin area initial mask and the converted portrait image, and determining the neck area from the neck area initial mask and the converted portrait image", for example, the following may be adopted:
the face skin area initial mask and the converted portrait image are overlapped, so that the face skin area can be obtained; and similarly, the neck region is obtained by superposing the neck region initial mask and the converted portrait image.
Optionally, in order to reduce the influence of the edge transition region, reduce noise, improve the accuracy of segmentation, the edges of the segmentation may be optimized, that is, the step of determining the facial skin region from the facial skin region initial mask and the converted portrait image may specifically be as follows:
And corroding the edge transition area of the initial mask of the face skin area by a preset first corroding core to obtain the mask of the face skin area, and superposing the mask of the face skin area and the converted portrait image to obtain the face skin area.
Similarly, the step of determining the neck region from the neck region initial mask and the converted portrait image may specifically be as follows:
and corroding the edge transition area of the initial mask of the neck area by a preset second corrosion check to obtain the mask of the neck area, and overlapping the mask of the neck area and the converted portrait image to obtain the neck area.
The first corrosion core and the second corrosion core may be set according to the requirements of practical applications, and may be any shape and size, for example, the sizes of the first corrosion core and the second corrosion core may be set to 3, and so on.
104. Calculating an average luminance of the facial skin region and an average luminance of the neck region shadow, respectively; for example, the following may be specifically mentioned:
s1, calculating the average value of the brightness channels (namely L channels) of the face skin area to obtain the average brightness of the face skin area.
S2, determining the left and right boundaries of the neck of the joint part of the upper edge of the neck of the portrait and the chin according to the facial skin area and the neck area, wherein the left boundary of the neck is called a left boundary of the neck and the right boundary of the neck is called a right boundary of the neck for convenience of description.
The manner of determining the left neck boundary and the right neck boundary may be various, for example, the following may be specific:
expanding the facial skin region according to a preset expansion check to obtain an expanded facial skin region, superposing the expanded facial skin region and the neck region to obtain an intersection region (i.e. an intersection part) of the face and the neck, obtaining coordinate values of non-zero pixels in the intersection region of the face and the neck, determining a maximum abscissa value (i.e. a maximum x-axis coordinate value) and a minimum abscissa value (i.e. a minimum x-axis coordinate value) according to the coordinate values, and determining a left neck boundary and a right neck boundary of the intersection part of the upper edge of the neck of the human image and the chin according to the maximum abscissa value and the minimum abscissa value, for example, see fig. 2.
The expansion core may be set according to practical application requirements and practical experience, for example, may be set to 5 or 6, etc., which will not be described herein.
The method for calculating the left neck boundary and the right neck boundary of the connecting part of the upper edge of the neck of the portrait and the chin according to the maximum abscissa value and the minimum abscissa value can be various, for example, the following arbitrary method can be adopted:
mode one:
the minimum abscissa value is directly used as the left boundary of the neck of the portion where the upper edge of the portrait neck meets the chin, and the maximum abscissa value is directly used as the right boundary of the neck of the portion where the upper edge of the portrait neck meets the chin.
Mode two:
adding a preset value to the minimum abscissa value to obtain an adjusted minimum abscissa value, subtracting the preset value from the maximum abscissa value to obtain an adjusted maximum abscissa value, taking the adjusted minimum abscissa value as the left neck boundary of the connecting part of the upper edge of the neck of the portrait and the chin, and taking the adjusted maximum abscissa value as the right neck boundary of the connecting part of the upper edge of the neck of the portrait and the chin.
The preset value may be set according to the requirements and practical experience of the practical application, for example, may be set to 4, or may also be set to the size of the expansion core, such as 5 or 6, and so on.
Taking the preset value as 5 as an example, the minimum abscissa value X 'after adjustment' min And an adjusted maximum abscissa value X' max The following may be possible:
X' min =X min +5;
X' max =X max -5;
wherein X is min X is the minimum abscissa value max Is the maximum abscissa value.
It should be noted that, the second mode can remove the pixels at the edge of the neck, reduce noise, and improve the accuracy of segmentation.
And S3, selecting a neck shadow assessment area from the neck area based on the left neck boundary and the right neck boundary.
For example, specifically, the difference between the right boundary of the neck and the left boundary of the neck may be multiplied by a preset coefficient to obtain the neck height Y, then, each column of pixels in the neck region is traversed, and the brightness of the pixels whose abscissa (i.e., x-axis coordinate) is smaller than the left boundary of the neck and the brightness of the pixels whose abscissa (i.e., x-axis coordinate) is greater than the right boundary are set to 0, so as to obtain the neck region after processing; and traversing the pixels of each column in the neck region after the processing, so that each column keeps the first Y non-zero pixels (i.e. the pixels which are not 0), and the brightness of the rest pixels is set to be 0, thereby obtaining a neck shadow evaluation region.
For example, if the left neck boundary is the minimum abscissa value X min The right boundary of the neck is the maximum abscissa value X max, The neck height Y is:
Y=A(X max -X min );
for another example, if the left neck boundary is the adjusted minimum abscissa value X' min The right boundary of the neck is the maximum abscissa value X 'after adjustment' max, The neck height Y is:
Y=A(X' max -X' min );
wherein a is a preset coefficient, which is a ratio of the neck height to the neck width (i.e. the difference between the right neck boundary and the left neck boundary), and specifically may be set according to the actual application requirement, for example, may generally be set between 0.8 and 1.
After the neck height Y is obtained, each column of pixels in the neck region can be traversed, and then the following processing is performed:
setting the brightness of all pixels to 0 for columns with the abscissa smaller than the left boundary of the neck;
setting the brightness of all pixels to 0 for columns with the abscissa larger than the right boundary of the neck;
columns with the abscissa between the left and right neck boundaries, each column retaining the first Y non-zero pixels, the brightness of the remaining pixels being set to 0.
After the above processing, a neck shadow evaluation region can be obtained.
Since the neck height Y is also taken as a consideration in addition to the neck width in this process, the interference of the portrait clothes neckline to the neck region can be reduced, and the accuracy of the division can be further improved.
S4, calculating the average value of brightness channels (namely L channels) of the neck shadow evaluation area to obtain the average brightness of the neck shadow.
105. Calculating the ratio of the average brightness of the neck region shadow to the average brightness of the facial skin region; for example, the following may be specifically mentioned:
M=L neck /L face
wherein L is face For the average brightness of the facial skin area, L neck The average brightness of the neck region shadow, M is the average brightness L of the neck region shadow neck And average brightness L of facial skin region face Is a ratio of (2).
106. If the ratio obtained in step 105 is smaller than the preset threshold, it is determined that the neck shadow of the portrait in the portrait to be detected is too deep (i.e. too heavy).
The preset threshold may be set according to practical application requirements and practical experience, for example, the preset threshold is set to 0.65, and if the ratio M is less than 0.65, it may be determined that the neck shadow of the portrait in the portrait image to be detected is too deep.
Alternatively, if the ratio is greater than 1, the shadow brightness of the neck region of the portrait in the portrait to be detected may be abnormal, so that the brightness may be adjusted at this time. That is, optionally, after the step of "calculating the ratio of the average brightness of the neck region shadow to the average brightness of the facial skin region", the image detection method may further include:
If the ratio is greater than 1, the overall brightness of the portrait image to be detected is adjusted so that the ratio is equal to 1, i.e. if M >1, then m=1.
As can be seen from the above, in this embodiment, after the image of the person to be detected is obtained, the person in the image of the person to be detected may be segmented by a preset image segmentation model to obtain a face skin area and a neck area, then, the average brightness of the face skin area and the average brightness of the neck area shadow are calculated respectively, and the ratio of the average brightness of the neck area shadow to the average brightness of the face skin area is calculated, and if the ratio is smaller than the preset threshold, it is determined that the neck shadow of the person in the image of the person to be detected is too deep; because the scheme can determine the facial skin area and the neck area through the image segmentation model, compared with the existing methods of chin key point calculation, ellipsometry or skin color selection and the like, the accuracy of area selection can be improved.
Based on the methods described in the above embodiments, examples will be described in further detail below.
In this embodiment, the image detection device is specifically integrated in a network device, and the document to be detected is specifically a document to be detected.
As shown in fig. 3, the specific flow of the image detection method may be as follows:
201. the network device obtains credentials to be detected.
The color mode of the certificate to be detected can be RGB.
202. The network equipment segments the human images in the credentials to be detected through a preset image segmentation model to obtain a segmentation result.
For example, referring to fig. 4, specifically, the document to be detected may be input into an image segmentation model, the image segmentation model performs feature extraction on the document to be detected, then predicts a category to which each pixel in the document to be detected belongs based on the extracted features, and marks a label corresponding to the category, for example, whether the document to be detected is a background, a neck, a facial skin, or a garment, a nose or a beard, and so on, so as to obtain a result marked with various labels. If, during training, the training sample defines 20 labels of the region to be segmented, including background, neck, clothing, facial skin, beard, nose, glasses, left eye, right eye, left eyebrow, right eyebrow, left ear, right ear, upper lip, lower lip, middle region of mouth, hair, hat headwear, earring, and necklace, the image segmentation model outputs the classification result of the 20 labels, i.e. the segmentation result.
It should be noted that, after the image segmentation model is trained by other devices in advance, the image segmentation model may be provided to the network device for use, or the network device may perform training by itself, and the specific training method may refer to the foregoing embodiments, which are not described herein.
203. The network device determines a facial skin area initial mask and a neck area initial mask from the segmentation result.
For example, as shown in fig. 4, after the image segmentation model outputs the segmentation result, the network device may specifically obtain the pixels marked with the "facial skin" label, so as to obtain the facial skin region segmented by the image segmentation model, and similarly obtain the pixels marked with the "neck" label, so as to obtain the neck region segmented by the image segmentation model. For convenience of description, in the embodiment of the present application, the facial skin region segmented by the image segmentation model is referred to as a facial skin region initial mask, and the neck region segmented by the image segmentation model is referred to as a neck region initial mask.
Since the edge transition region may be affected during the segmentation in step 202, a certain noise may exist in the output segmentation result, so in order to remove the influence of the edge transition region, reduce the noise, and improve the segmentation accuracy, the edges of the initial mask for the facial skin region and the initial mask for the neck region may be optimized, that is, step 204 may be performed to obtain a mask for the facial skin region and a mask for the neck region, where the segmentation is more accurate.
204. The network equipment checks the edge transition area of the initial mask of the face skin area with a preset first corrosion to obtain the mask of the face skin area, and checks the edge transition area of the initial mask of the neck area with a preset second corrosion to obtain the mask of the neck area.
The first corrosion core and the second corrosion core may be set according to the requirements of practical applications, and may be any shape and size, for example, the sizes of the first corrosion core and the second corrosion core may be set to 3, and so on.
205. The network equipment converts the human image to be detected from the RGB color model to the LAB color model to obtain a converted human image, superimposes the face skin region mask and the converted human image to obtain a face skin region, and superimposes the neck region mask and the converted human image to obtain a neck region.
206. The network device calculates an average value of the luminance channels (i.e., L channels) of the facial skin region to obtain an average luminance of the facial skin region.
For example, as shown in fig. 4, the network device may specifically obtain the values of the luminance channels of the pixels in the facial skin area, and then calculate the average value of the values of the luminance channels of the pixels, so as to obtain the average luminance of the facial skin area: l (L) face
207. The network device determines a left neck boundary and a right neck boundary of a portion where an upper edge of the neck of the portrait meets the chin according to the facial skin area and the neck area.
In order to improve the accuracy of segmentation, when determining the left neck boundary and the right neck boundary of the joint part of the upper edge of the neck of the portrait and the chin, the facial skin area can be inflated first and then overlapped with the neck area. For example, taking the example of the expansion core as 5, the step of "determining the left and right neck boundaries of the portion where the upper edge of the neck of the portrait meets the chin from the skin area and the neck area of the face" may be specifically as follows:
the network equipment expands the face skin area according to the expansion kernel '5', so as to obtain an expanded face skin area, overlaps the expanded face skin area with the neck area, so as to obtain an intersecting area of the face and the neck, acquires the coordinate value of a non-zero pixel in the intersecting area of the face and the neck, and determines the maximum abscissa value X according to the acquired coordinate value of the non-zero pixel max (i.e., maximum X-axis coordinate value) and minimum X-axis coordinate value min (i.e., a minimum X-axis coordinate value) according to which the maximum X-axis coordinate value is X max And a minimum abscissa value X min The left and right neck boundaries of the portion of the upper edge of the portrait neck meeting the chin are determined. For example, in one aspect, the minimum abscissa value X may be calculated min Adding a preset value to obtain the minimum abscissa value X 'after adjustment' min Then, the adjusted minimum abscissa value X' min A left neck boundary which is the joint part of the upper edge of the neck of the portrait and the chin; alternatively, the maximum abscissa value X may be calculated max Subtracting the preset value to obtain the adjusted maximum abscissa value X' max Then the adjusted maximum abscissa value X' max The right and left boundaries of the neck, namely X ', can be obtained as the right and left boundaries of the neck at the joint part of the upper edge of the neck of the portrait and the chin' min And X' max
The preset value may be set according to the requirements and practical experience of the practical application, for example, may be set to 4, or may also be set to the size of the expansion core, such as 5 or 6, and so on.
208. The network device selects a neck shadow assessment region from the neck region based on the neck right boundary and the neck left boundary.
For example, it is known from practical experience that the ratio of the neck height to the neck width of a portrait in a credential is generally between 0.8 and 1, and therefore, can be determined by the neck width (i.e., the right neck boundary X' max With left boundary X 'of neck' min The difference of (c) to estimate the value of the neck height, namely:
Y=A(X' max -X' min );
wherein Y is the height of the neck, A is a preset coefficient, and the coefficient can be set according to the actual application requirement, for example, the coefficient can be generally set between 0.8 and 1.
After the neck height Y is obtained, each column of pixels in the neck region can be traversed, and then the following processing is performed:
the abscissa (i.e. X-axis coordinate value) is smaller than the left boundary X 'of the neck' min Is set to 0, the brightness of all pixels;
the abscissa (i.e. the X-axis coordinate value) is greater than the right neck boundary X' max Is set to 0, the brightness of all pixels;
the abscissa (i.e. the X-axis coordinate value) is located at the left boundary X 'of the neck' min And neck right boundary X' max Each column holds the first Y non-zero pixels, and the brightness of the remaining pixels is set to 0.
After the above processing, a neck shadow evaluation region can be obtained.
209. The network device calculates the average value of the brightness channels (i.e., L channels) of the neck shadow evaluation region to obtain the average brightness of the neck shadow.
For example, as shown in fig. 4, the network device may specifically obtain the values of the luminance channels of the pixels in the neck shadow evaluation area, and then calculate the average value of the values of the luminance channels of the pixels, so as to obtain the average luminance of the neck shadow: l (L) neck
It should be noted that, the execution sequence of the step 206 and the steps 207 to 209 may be not consecutive, that is, the step of calculating the average brightness of the skin region of the face and the step of calculating the average brightness of the shadow of the neck region may be not consecutive.
210. The network device calculates the ratio of the average brightness of the neck region shadow to the average brightness of the facial skin region, which may be specifically as follows:
M=L neck /L face
wherein L is face For the average brightness of the facial skin area, L neck The average brightness of the neck region shadow, M is the average brightness L of the neck region shadow neck And averaging of facial skin areasBrightness L face Is a ratio of (2).
211. And when the network equipment determines that the ratio is smaller than the preset threshold value, determining that the neck shadow of the portrait in the certificate to be detected is too deep.
The preset threshold may be set according to the requirements and practical experience of practical applications, for example, taking the preset threshold set to 0.65 as an example, if the ratio M is less than 0.65, it may be determined that the neck shadow of the portrait in the certificate to be detected is too deep, see fig. 4; if the ratio is more than or equal to 0.65 and less than or equal to 1, the neck shadow of the portrait in the certificate to be detected can be determined to be normal.
Optionally, if the network device determines that the ratio M >1, it indicates that the shadow brightness of the neck region may be abnormal, and at this time, the overall brightness of the certificate to be detected may be adjusted, so that the ratio m=1.
As can be seen from the above, after obtaining the credentials to be detected, the embodiment may divide the portrait in the credentials to be detected by using a preset image division model to obtain a face skin area and a neck area, then calculate the average brightness of the face skin area and the average brightness of the neck area shadow respectively, calculate the ratio of the average brightness of the neck area shadow to the average brightness of the face skin area, and if the ratio is smaller than a preset threshold, determine that the neck shadow of the portrait in the credentials to be detected is too deep; because the scheme can determine the facial skin area and the neck area through the image segmentation model, compared with the existing methods of chin key point calculation, ellipsometry or skin color selection and the like, the accuracy of area selection can be improved.
In addition, since the embodiment also adopts some special treatments when dividing the face skin area and the neck area and determining the left boundary and the right boundary of the neck, for example, the influence of the edge transition area during division is reduced by corroding the edge transition area, for example, the intersection of the face skin area and the neck area is obtained after the face skin area is inflated, so that the left boundary and the right boundary of the neck are determined, and the like, the treatments can remove the influence of noise, further improve the accuracy of division and lay a foundation for the condition of accurately detecting the neck shadow subsequently.
In order to better implement the above method, the embodiment of the present application further provides an image detection apparatus, as shown in fig. 5, which may include an acquisition unit 301, a segmentation unit 302, a determination unit 303, a calculation unit 304, and a determination unit 305, specifically as follows:
(1) An acquisition unit 301;
an acquiring unit 301 is configured to acquire a portrait image to be detected.
(2) A dividing unit 302;
the segmentation unit 302 is configured to segment the portrait in the portrait image to be detected by using a preset segmentation model, so as to obtain a segmentation result.
(3) A determination unit 303;
A determining unit 303 for determining a facial skin area and a neck area from the segmentation result.
For example, the determining unit 303 may specifically be configured to determine a face skin area initial mask and a neck area initial mask according to the segmentation result, convert a color mode of a portrait image to be detected into a LAB color model, obtain a converted portrait image, determine a face skin area according to the face skin area initial mask and the converted portrait image, and determine a neck area according to the neck area initial mask and the converted portrait image.
For example, the determining unit 303 may be specifically configured to superimpose the face skin area initial mask and the converted portrait image to obtain a face skin area; and superposing the neck region initial mask and the converted portrait image to obtain a neck region.
For another example, the determining unit 303 may be specifically configured to perform erosion on the edge transition area of the initial mask of the facial skin area with a preset first erosion check, obtain a mask of the facial skin area, and determine the facial skin area according to the mask of the facial skin area and the converted portrait image; and corroding the edge transition area of the initial mask of the neck area by a preset second corrosion check to obtain the mask of the neck area, and determining the neck area according to the mask of the neck area and the converted portrait image.
The first corrosion core and the second corrosion core may be set according to the requirements of practical applications, and may be any shape and size, for example, the sizes of the first corrosion core and the second corrosion core may be set to 3, and so on. After the edge transition area is adjusted by adopting the corrosion check, the influence of the edge transition area can be reduced, the noise is reduced, and the segmentation accuracy is improved
(4) A calculation unit 304;
a calculation unit 304 for calculating an average luminance of the facial skin area and an average luminance of the neck area shadow, respectively.
For example, the calculating unit 304 may be specifically configured to calculate an average value of luminance channels (i.e. L channels) of the facial skin area, to obtain an average luminance of the facial skin area; determining a left neck boundary and a right neck boundary of a joint part of the upper edge of the neck of the portrait and the chin according to the skin area and the neck area of the face; selecting a neck shadow assessment region from the neck region at the left neck boundary and the right neck boundary; the average value of the brightness channels (i.e., L channels) of the neck shadow evaluation region is calculated to obtain the average brightness of the neck region shadow.
(5) A determination unit 305;
the determining unit 305 is configured to calculate a ratio of the average brightness of the neck region shadow to the average brightness of the facial skin region, and if the ratio is smaller than a preset threshold, determine that the neck shadow of the portrait in the portrait image to be detected is too deep.
Optionally, the determining unit 305 may be further configured to adjust the overall brightness of the portrait image to be detected when the ratio is greater than 1, so that the ratio is equal to 1.
It should be noted that, the image segmentation model used by the segmentation unit 302 may be provided to the image detection device for use after being trained by other devices in advance, or may be trained by the image detection device, that is, the image detection device may further include a training unit as follows:
the training unit is used for collecting a plurality of training samples, wherein the training samples at least mark the true values of the facial skin area and the neck area, then, an initial segmentation model is adopted to segment the facial skin area and the neck area of the training samples, the predicted values of the facial skin area and the neck area are obtained, and based on the true values and the predicted values, the initial segmentation model is converged by utilizing a preset loss function, so that an image segmentation model can be obtained.
The training sample contains a portrait, which can be at least recognized by the face and the neck, for example, the training sample can be a certificate photo, or can be other portrait images meeting the conditions, and the like. In addition, in the training samples, besides the real values of the facial skin area and the neck area, the real values of other parts can be identified, which are detailed in the previous method embodiments and are not described herein.
Alternatively, the initial segmentation model and the loss function may be set according to actual application requirements and practical experience. For example, the initial segmentation model may be SegNet, deepLab, mask R-CNN, U-Net or Gated SCNN, which are described in detail in the foregoing method embodiments and are not described herein.
The implementation of each unit above may be specifically referred to the foregoing method embodiments, and will not be described herein.
It should be noted that, in the implementation, each unit may be combined arbitrarily, integrated in one or several modules, or may be implemented as a separate entity. In addition, the above units may be implemented in hardware or in software functional modules. The integrated modules may also be stored in a computer readable storage medium if implemented in the form of software functional modules and sold or used as a stand-alone product. The above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, or the like.
The image detection device provided by the embodiment not only can improve the accuracy of region selection, but also can avoid inaccurate judgment caused by different complexion when the brightness absolute value is adopted for judgment, and greatly improves the accuracy of neck shadow detection.
The foregoing has described in detail a method and apparatus for image detection provided by embodiments of the present application, and specific examples have been applied herein to illustrate the principles and embodiments of the present application, where the foregoing examples are provided to assist in understanding the methods and core ideas of the present application; meanwhile, those skilled in the art will have variations in the specific embodiments and application scope in light of the ideas of the present application, and the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. An image detection method, comprising:
acquiring a portrait image to be detected;
dividing the human images in the human image to be detected through a preset image dividing model to obtain a dividing result;
determining a facial skin region and a neck region according to the segmentation result;
calculating an average luminance of the facial skin region and an average luminance of the neck region shadow, respectively;
calculating the ratio of the average brightness of the neck region shadow to the average brightness of the facial skin region;
and if the ratio is smaller than a preset threshold value, determining that the neck shadow of the portrait in the portrait image to be detected is too deep.
2. The method of claim 1, wherein the separately calculating the average luminance of the facial skin region and the average luminance of the neck region shadow comprises:
Calculating the average value of the brightness channels of the face skin area to obtain the average brightness of the face skin area;
determining a left neck boundary and a right neck boundary of a joint part of the upper edge of the neck of the portrait and the chin according to the skin area and the neck area of the face;
selecting a neck shadow assessment region from the neck regions based on the neck left boundary and neck right boundary;
and calculating the average value of the brightness channels of the neck shadow evaluation area to obtain the average brightness of the neck shadow.
3. The method of claim 2, wherein calculating the left and right neck boundaries of the portion of the upper edge of the portrait neck meeting the chin from the facial skin area and the neck area comprises:
expanding the facial skin area according to a preset expansion check to obtain an expanded facial skin area;
overlapping the expanded facial skin area and the neck area to obtain an intersection area of the face and the neck;
acquiring coordinate values of non-zero pixels in an intersection area of the face and the neck, and determining a maximum abscissa value and a minimum abscissa value according to the coordinate values;
and determining the left neck boundary and the right neck boundary of the joint part of the upper edge of the neck of the portrait and the chin according to the maximum abscissa value and the minimum abscissa value.
4. A method according to claim 3, wherein said calculating the left and right neck boundaries of the portion of the upper edge of the neck of the figure meeting the chin from said maximum and minimum abscissa values comprises:
taking the minimum abscissa value as the left neck boundary of the joint part of the upper edge of the neck of the portrait and the chin;
and taking the maximum abscissa value as the right boundary of the neck at the joint part of the upper edge of the neck of the portrait and the chin.
5. A method according to claim 3, wherein said calculating the left and right neck boundaries of the portion of the upper edge of the neck of the figure meeting the chin from said maximum and minimum abscissa values comprises:
adding a preset value to the minimum abscissa value to obtain an adjusted minimum abscissa value;
subtracting a preset value from the maximum abscissa value to obtain an adjusted maximum abscissa value;
taking the minimum abscissa value after adjustment as the left neck boundary of the joint part of the upper edge of the neck of the portrait and the chin;
and taking the adjusted maximum abscissa value as the right boundary of the neck at the joint part of the upper edge of the neck of the portrait and the chin.
6. The method of any one of claims 2 to 5, wherein the selecting a neck shadow assessment region from the neck region based on the neck left boundary and neck right boundary comprises:
Multiplying the difference between the right boundary of the neck and the left boundary of the neck by a preset coefficient to obtain the neck height Y;
traversing each column of pixels in the neck region, and setting the brightness of the pixels with the abscissa smaller than the left boundary of the neck and the brightness of the pixels with the abscissa larger than the right boundary to be 0 to obtain a processed neck region;
and traversing the pixels of each column in the neck region after processing, so that the first Y non-zero pixels are reserved in each column, and the brightness of the rest pixels is set to be 0, thereby obtaining a neck shadow evaluation region.
7. The method according to any one of claims 1 to 5, wherein said determining facial skin and neck regions from the segmentation result comprises:
determining a face skin area initial mask and a neck area initial mask according to the segmentation result;
converting the color mode of the portrait image to be detected into an LAB color model to obtain a converted portrait image;
determining a facial skin area from the facial skin area initial mask and the converted portrait image;
the neck region is determined from the neck region initial mask and the converted portrait image.
8. The method of claim 7, wherein the step of determining the position of the probe is performed,
the determining the facial skin area according to the facial skin area initial mask and the converted portrait image comprises the following steps: corroding the edge transition area of the initial mask of the face skin area by a preset first corroding core to obtain the mask of the face skin area, and superposing the mask of the face skin area and the converted portrait image to obtain the face skin area;
The determining the neck region according to the neck region initial mask and the converted portrait image includes: and corroding the edge transition area of the initial mask of the neck area by a preset second corrosion check to obtain the mask of the neck area, and overlapping the mask of the neck area and the converted portrait image to obtain the neck area.
9. The method according to any one of claims 1 to 5, further comprising:
and if the ratio is greater than 1, adjusting the overall brightness of the portrait image to be detected so that the ratio is equal to 1.
10. A portrait image detection apparatus, comprising:
the acquisition unit is used for acquiring the portrait image to be detected;
the segmentation unit is used for segmenting the human images in the human image to be detected through a preset image segmentation model to obtain segmentation results;
a determination unit configured to determine a facial skin region and a neck region from the segmentation result;
a calculation unit for calculating an average luminance of the face skin region and an average luminance of a neck region shadow, respectively;
and the judging unit is used for calculating the ratio of the average brightness of the neck region shadow to the average brightness of the face skin region, and if the ratio is smaller than a preset threshold value, determining that the neck shadow of the portrait in the portrait image to be detected is too deep.
CN202311586066.9A 2023-11-24 2023-11-24 Image detection method and device Pending CN117576050A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311586066.9A CN117576050A (en) 2023-11-24 2023-11-24 Image detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311586066.9A CN117576050A (en) 2023-11-24 2023-11-24 Image detection method and device

Publications (1)

Publication Number Publication Date
CN117576050A true CN117576050A (en) 2024-02-20

Family

ID=89862190

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311586066.9A Pending CN117576050A (en) 2023-11-24 2023-11-24 Image detection method and device

Country Status (1)

Country Link
CN (1) CN117576050A (en)

Similar Documents

Publication Publication Date Title
CN101609500B (en) Quality estimation method of exit-entry digital portrait photos
Li et al. Multi-angle head pose classification when wearing the mask for face recognition under the COVID-19 coronavirus epidemic
US10304166B2 (en) Eye beautification under inaccurate localization
CN110084135B (en) Face recognition method, device, computer equipment and storage medium
US8983152B2 (en) Image masks for face-related selection and processing in images
CN104834898B (en) A kind of quality classification method of personage's photographs
Ghimire et al. A robust face detection method based on skin color and edges
CN109952594B (en) Image processing method, device, terminal and storage medium
US9111132B2 (en) Image processing device, image processing method, and control program
CN100354875C (en) Red eye moving method based on human face detection
Aiping et al. Face detection technology based on skin color segmentation and template matching
KR20170006355A (en) Method of motion vector and feature vector based fake face detection and apparatus for the same
CN108615239B (en) Tongue image segmentation method based on threshold technology and gray level projection
CN105139404A (en) Identification camera capable of detecting photographing quality and photographing quality detecting method
CN109740572A (en) A kind of human face in-vivo detection method based on partial color textural characteristics
JP3490910B2 (en) Face area detection device
JP2007272435A (en) Face feature extraction device and face feature extraction method
WenJuan et al. A real-time lip localization and tacking for lip reading
CN112528939A (en) Quality evaluation method and device for face image
KR20220078231A (en) Skin condition measuring apparatus, skin condition measring system and method thereof
CN107862298B (en) Winking living body detection method based on infrared camera device
CN112232204A (en) Living body detection method based on infrared image
CN110648336B (en) Method and device for dividing tongue texture and tongue coating
CN108416304A (en) A kind of three classification method for detecting human face using contextual information
CN108629780B (en) Tongue image segmentation method based on color decomposition and threshold technology

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination