Image processing methods, apparatus, storage media and devices
By generating and overlaying a face mask corresponding to a reference face image, the problem of obtaining face sample images under complex lighting conditions is solved, improving the pass rate of face recognition devices and reducing acquisition costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-21
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies struggle to efficiently and cost-effectively acquire sample images of faces with varying shades of light in complex lighting conditions, resulting in low pass rates for face recognition devices under such conditions.
Generate a face mask corresponding to the reference face image, including a shadow face mask region and a sun face mask region, and overlay it with the reference face image to generate a face mask sample image to simulate the face mask effect under various lighting scenarios.
By generating sample images of faces with varying shades of light and shadow, the pass rate of faces with varying shades of light and shadow in complex lighting scenarios is improved, while reducing collection time and labor costs.
Smart Images

Figure CN115439914B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of image processing technology, and in particular to an image processing method, apparatus, storage medium and device. Background Technology
[0002] With the development of machine learning technology, the application of facial recognition technology is becoming more and more widespread. For example, facial recognition technology can be applied to security checks, access control, and payment.
[0003] Currently, many facial recognition devices are used in scenarios with complex lighting, such as outdoor environments. When facial recognition devices are placed in complex lighting conditions, uneven lighting on the face can easily occur. Uneven lighting on the face refers to the situation where the light on the face is uneven due to external lighting. Uneven lighting on the face reduces the pass rate of facial recognition devices. Therefore, it is necessary to obtain sample images of uneven lighting on the face in complex lighting scenarios.
[0004] Therefore, how to efficiently and cost-effectively acquire sample images of faces with varying lighting conditions under different lighting scenarios has become a pressing technical challenge. Summary of the Invention
[0005] This specification provides an image processing method, apparatus, storage medium, and device that can efficiently and cost-effectively acquire sample images of faces with varying lighting conditions under different lighting scenarios, thereby improving the pass rate of faces with varying lighting conditions under complex lighting conditions.
[0006] Firstly, embodiments of this specification provide an image processing method, including:
[0007] Obtain a reference face image;
[0008] Generate a face mask corresponding to the reference face image, wherein the face mask includes a face mask region and a face mask region;
[0009] The yin-yang face mask is superimposed on the reference face image to generate a yin-yang face sample image. The yin-yang face region of the yin-yang face sample image corresponds to the yin-yang face mask region, and the yang-yang face region of the yin-yang face sample image corresponds to the yang-yang face mask region.
[0010] Secondly, embodiments of this specification provide an image processing apparatus, comprising:
[0011] The reference image acquisition module is used to acquire reference face images;
[0012] A face mask generation module is used to generate a face mask corresponding to the reference face image, wherein the face mask includes a face mask region and a face mask region;
[0013] An image overlay module is used to overlay the yin-yang face mask with the reference face image to generate a yin-yang face sample image, wherein the yin face region of the yin-yang face sample image corresponds to the yin face mask region, and the yang face region of the yin-yang face sample image corresponds to the yang face mask region.
[0014] Thirdly, embodiments of this specification provide a computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the steps of the method described above.
[0015] Fourthly, embodiments of this specification provide a computer program product containing instructions that, when run on a computer or processor, cause the computer or processor to perform the steps of the method described above.
[0016] Fifthly, embodiments of this specification provide an electronic device, including: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to execute the steps of the method described above.
[0017] According to the technical solution of the embodiments of this specification, on the one hand, a face mask corresponding to a reference face image is generated. The face mask includes a shadow face mask region and a light face mask region, which can generate face masks that simulate various lighting scenarios. On the other hand, the face mask is superimposed on the reference face image to generate a face sample image. This can efficiently and cost-effectively obtain face sample images under complex lighting scenarios, thereby improving the pass rate of face masks under complex lighting scenarios. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A schematic diagram of the system architecture for an application scenario of an image processing method and apparatus provided in the embodiments of this specification;
[0020] Figure 2 This is a schematic flowchart of an image processing method provided in an embodiment of this specification;
[0021] Figure 3 A schematic diagram of a face mask with two shades of white provided in the embodiments of this specification;
[0022] Figure 4A schematic flowchart illustrating another image processing method provided in the embodiments of this specification;
[0023] Figure 5 A schematic flowchart illustrating another image processing method provided in the embodiments of this specification;
[0024] Figure 6 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of this specification;
[0025] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. Detailed Implementation
[0026] To make the features and advantages of this specification more apparent and understandable, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this specification without creative effort are within the scope of protection of this specification.
[0027] First, the terms and concepts used in one or more embodiments of this specification will be explained.
[0028] Uneven lighting on the face: This refers to a situation where the lighting on a person's face is uneven due to external light. For example, if there is a light source in a certain direction on the face, the uneven lighting on the face will create an uneven lighting effect.
[0029] Masking: This refers to using a selected image to occlude all or part of an image to be processed, thereby controlling the processing area or process of the image. For example, a mask can be a binary image composed of 0s and 1s. When a mask is applied, regions with 1 values are processed, while regions with 0 values that are masked are not included in the calculation.
[0030] Two-tone face mask: A two-tone face mask is a mask that includes a shadow face mask area and a sun face mask area. For example, the pixel value of the shadow face mask area is 0, and the pixel value of the sun face mask area is a predetermined value, such as 1.
[0031] Boundary processing: The boundaries of the shadow mask region and the sun mask region of the shadow mask are filtered or eroded. Boundary processing makes the pixels in the boundary region no longer have only 0 or 1, but a floating-point value between 0 and 1.
[0032] Erosion processing: Used to eliminate the boundary points of an object, causing the boundary to shrink inward. For example, by scanning the image to be processed through a structuring element of a certain shape, a bitwise AND operation is performed between the structuring element and the pixels of the image to be processed that it covers. If both are 1, then the value of that pixel in the image to be processed is 1; otherwise, it is 0.
[0033] Many facial recognition devices are used in complex lighting environments, such as outdoor settings. When placed in such environments, facial recognition devices are prone to producing unevenly lit faces (some faces appearing in different shades). These unevenly lit faces reduce the recognition rate of the facial recognition model, often becoming a bottleneck in its operation. If the pass rate of the facial recognition model is low under certain lighting conditions, it is common practice to collect facial sample images under those conditions. However, because the types and directions of lighting vary, the time and labor costs of collecting facial sample images are high.
[0034] Based on the above, embodiments of this specification provide an image processing method and an image processing apparatus. On the one hand, a face mask corresponding to a reference face image is generated, which can generate face mask images simulating various lighting scenarios. On the other hand, the face mask is superimposed on the reference face image to generate a face sample image, which can efficiently and cost-effectively obtain face sample images under complex lighting scenarios, thereby solving the problem of low pass rate of face images under complex lighting scenarios.
[0035] The technical solutions of the embodiments of this specification will now be described in detail with reference to the accompanying drawings.
[0036] Figure 1 This is a schematic diagram of the system architecture for an application scenario of an image processing method and apparatus provided in the embodiments of this specification.
[0037] like Figure 1 As shown, the system architecture of this application scenario may include one or more of face recognition devices 110, 120, and 130, a network 140, and a server 150. Network 140 serves as the medium for providing communication links between face recognition devices 110, 120, 130, and server 150. Network 140 may include various connection types, such as wired or wireless communication links or fiber optic cables; for example, network 140 may be a Public Switched Telephone Network (PSTN) or the Internet. Face recognition devices 110, 120, and 130 may be various electronic devices with cameras, including but not limited to desktop computers, laptops, smartphones, and tablets.
[0038] It should be understood that, Figure 1The number of facial recognition devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of facial recognition devices, networks, and servers can be included. For example, server 150 could be a server cluster consisting of multiple servers.
[0039] The image processing method provided in the embodiments of this specification can be executed by server 150, and correspondingly, the image processing device can be disposed in server 150. However, it will be readily understood by those skilled in the art that the image processing method provided in the embodiments of this specification can also be executed by face recognition devices 110, 120, and 130, and correspondingly, the image processing device can also be disposed in face recognition devices 110, 120, and 130. This exemplary embodiment does not impose any special limitations on this.
[0040] For example, in one exemplary embodiment, a reference face image is uploaded to a server 150 via face recognition devices 110, 120, and 130. The server 150 generates a two-tone face mask corresponding to the reference face image using the image processing method provided in this embodiment. The two-tone face mask is then overlaid on the reference face image to generate a two-tone face sample image. In other example embodiments, the face recognition device 110 acquires a reference face image; generates a two-tone face mask corresponding to the reference face image; and overlays the two-tone face mask on the reference face image to generate a two-tone face sample image.
[0041] It should be noted that the steps in the image processing method in the example embodiments of this specification may be partially executed by the client, partially executed by the server, or entirely executed by the server or entirely by the client. This specification does not impose any special limitations on this.
[0042] based on Figure 1 The system architecture shown below will be combined with... Figures 2-5 This specification provides a detailed description of the image processing methods provided in the embodiments. It should be noted that the application scenarios described above are merely illustrative for the purpose of understanding the spirit and principles of this specification, and the embodiments are not limited in any way. Rather, the embodiments can be applied to any applicable scenario.
[0043] Figure 2 This is a schematic flowchart illustrating an image processing method provided in an embodiment of this specification. This image processing method can be executed by a terminal device with computing capabilities. Figure 2 As shown, the image processing method in the embodiments of this specification may include the following steps S210 to S230.
[0044] In step S210, a reference face image is obtained.
[0045] In the example embodiment, the reference face image is a reference image used to generate the face mask, and the reference face image contains the face portion of the original image of the target scene. The reference face image can be obtained from the original image containing the face of the target scene. The target scene is a scenario used by a face recognition device, such as a payment scenario or a security check scenario, where face images are prone to appear under complex lighting conditions.
[0046] Furthermore, in the example embodiment, the face portion in the original image of the target scene is cropped to obtain a corresponding reference face image, which contains the face portion of the original image. For example, the crop() function of image processing can be used to crop the face portion in the original image of the target scene. Taking the reference face image as a rectangle as an example, the crop() function includes four parameters: crop(x, y, x+w, y+h), where x represents the distance between the cropping box and the left boundary of the image, y represents the distance between the cropping box and the top boundary of the image, x+w represents the distance x between the cropping box and the left boundary of the image plus the width w of the cropping box, and y+h represents the distance y between the cropping box and the top boundary of the image plus the height h of the cropping box.
[0047] It should be noted that although the example described uses a rectangular shape for the reference face image, those skilled in the art should understand that the shape of the reference face image can also be circular or elliptical, etc., and this specification does not impose any special limitations on this aspect.
[0048] In step S220, a face mask corresponding to the reference face image is generated, which includes a face mask region and a face mask region.
[0049] In the example embodiment, "uneven lighting" refers to a situation where the lighting on a face is uneven due to external illumination. For example, if there is a light source in a certain direction on the face, the uneven lighting on the face will create an uneven lighting effect, resulting in an uneven lighting effect. A mask refers to using a selected image to occlude all or part of an image to be processed, thereby controlling the processing area or process of the image. For example, a mask can be a binary image composed of 0s and 1s. When applying a mask, areas with a value of 1 are processed, and areas with a value of 0 are masked. An uneven lighting mask refers to a mask that includes both shadowed and sunny face areas; for example, the pixel value of the shadowed face area is 0, and the pixel value of the sunny face area is 1.
[0050] Further, in the example embodiment, the two-tone face mask includes a shadow face mask region and a sun face mask region, wherein the pixel value of the shadow face mask region is 0, and the pixel value of the sun face mask region is 1. The size ratio of the shadow face mask region and the sun face mask region in the two-tone face mask can be determined according to a random ratio, and based on this size ratio, a two-tone face mask corresponding to the reference face image is generated. For example, the size ratio of the shadow face mask region and the sun face mask region in the two-tone face mask can be determined by a random function, and a two-tone face mask corresponding to the reference face image can be generated according to this size ratio.
[0051] Figure 3 This is a schematic diagram of a two-tone face mask provided in an embodiment of this specification. Figure 3 In the image, the ratio of the shaded face mask area to the bright face mask area is 1:2, and the image is generated based on this ratio. Figure 3 The image shows a face mask with varying shades. In the face mask area (white area), the pixel value is 0, and in the face mask area (black area), the pixel value is 1.
[0052] It should be noted that although the example given is that the pixel value of the shaded face mask area is 0 and the pixel value of the sun face mask area is 1, those skilled in the art should understand that the pixel value of the sun face mask area can also be other appropriate values, such as the brightness value of 30 simulating a predetermined light source, which is also within the scope of the embodiments in this specification.
[0053] In step S230, the yin-yang face mask is superimposed on the reference face image to generate a yin-yang face sample image. The yin-yang face region of the yin-yang face sample image corresponds to the yin-yang face mask region, and the yang-yang face region of the yin-yang face sample image corresponds to the yang-yang face mask region.
[0054] In some example embodiments, the pixel values at each position of the face mask are added to the corresponding pixel values at the same positions in the reference face image to generate a face sample image. The shadowed areas of the face sample image correspond to the shadowed face mask areas, and the sunny areas correspond to the sunny face mask areas. For example, if the pixel values at each position of the face mask are added to the corresponding pixel values in the reference face image, the pixel value of the shadowed face mask area is 0, and the pixel value of the sunny face mask area is a predetermined value, such as the brightness value of a predetermined light source (30). Therefore, the pixel values of the shadowed face area in the resulting face sample image are the same as the corresponding pixel values of the shadowed face mask area in the reference face image, and the pixel values of the sunny face area are greater than the corresponding pixel values of the sunny face mask area in the reference face image by a predetermined value, such as 30. In other words, the sunny face area in the face sample image is brighter than the sunny face mask area in the reference face image.
[0055] Therefore, by adding the pixel values of corresponding positions in the yin-yang face mask and the reference face image, the effect of light source illumination can be simulated.
[0056] In other example embodiments, the pixel values at each location of the face mask are subtracted from the corresponding pixel values at the locations of the reference face image to generate a face sample image. For example, if the pixel values at each location of the face mask are subtracted from the corresponding pixel values at the locations of the reference face image, the pixel value of the pixels in the positive face mask region of the face mask is 0, and the pixel value of the pixels in the negative face mask region is a predetermined value, such as the brightness value of a predetermined light source of 30. Then, the pixel values of the positive face region in the face sample image after subtraction are the same as the corresponding pixel values of the positive face mask region of the reference face image, and the pixel values of the negative face region in the face sample image are a predetermined value smaller than the corresponding pixel values of the negative face mask region of the reference face image, such as 30. That is, the negative face region in the face sample image is darker than the negative face mask region of the reference face image.
[0057] Therefore, by subtracting the pixel values at corresponding positions in the yin-yang face mask from those in the reference face image, a dark effect can be simulated.
[0058] according to Figure 2 The technical solution in the example embodiment, on the one hand, generates a face mask corresponding to the reference face image, the face mask including a shadow face mask region and a sun face mask region, which can generate face masks simulating various lighting scenarios; on the other hand, the face mask is superimposed on the reference face image to generate a face sample image, the shadow face region of the face sample image corresponds to the shadow face mask region, and the sun face region corresponds to the sun face mask region, which can efficiently and cost-effectively obtain face sample images under various lighting scenarios, thereby solving the problem of low face mask pass rate under complex lighting scenarios.
[0059] Furthermore, in the example embodiment, the face mask is rotated according to a predetermined rotation factor, such as a predetermined angle. Rotating the face mask according to the predetermined rotation factor allows for the simulation of different light source positions, for example, as... Figure 3 As shown, the light source is on the right. This predetermined rotation factor can be determined based on the position and angle of the light source in the scene where the face recognition device will be used. For example, if the light source is 30 degrees to the right, the predetermined rotation factor can be 30 degrees, rotating to the right.
[0060] For example, in an exemplary embodiment, a rotation center for the face mask is determined; based on this rotation center, the face mask is rotated according to a predetermined rotation factor. For instance, the image center position of the face mask is used as the rotation center, and the face mask is rotated according to this rotation center and a predetermined rotation factor.
[0061] According to the technical solution in the above example embodiment, a rotation factor is added to the yin-yang face mask, which can adapt to the lighting characteristics of different directions and ensure that the generated yin-yang face sample images are rich and realistic.
[0062] Furthermore, in the example embodiment, the pixel value of each pixel in the face mask is multiplied by a predetermined light source brightness value. This predetermined light source brightness value is used to simulate the brightness of the light source. For example, if the predetermined light source brightness value is 30, then multiplying the pixel value of each pixel in the face mask by 30 will change the pixel value of the "1" area in the original face mask to "30".
[0063] According to the technical solution in the above example embodiment, multiplying the pixel value of each pixel of the yin-yang face mask by a predetermined light source brightness value can simulate the brightness of different light sources.
[0064] Furthermore, in the example embodiment, when the face mask is "overlaid" with the reference face image—that is, when the pixel values at corresponding positions in the face mask and the reference face image are added or subtracted—pixel value overflow may occur, meaning the pixel value exceeds the maximum pixel value allowed by the data type. In this case, pixel value normalization or truncation can be performed. Normalization involves uniformly scaling the pixel values of the face sample image; for example, normalizing the range of 0-255 to the range of 0-1. Truncation sets the overflowing pixel value to the maximum value of the data type; for example, changing 300 to 255.
[0065] According to the technical solution of the above example embodiment, when pixel value overflow occurs, normalizing or truncating the pixel value can avoid pixel display abnormalities.
[0066] Figure 4 This is a schematic flowchart of another image processing method provided in the embodiments of this specification.
[0067] Reference Figure 4 As shown, in step S410, a reference face image is obtained.
[0068] In the example embodiment, the implementation process and effect of step S410 are similar to those of step S210, and will not be described again here.
[0069] In step S420, a face mask corresponding to the reference face image is generated.
[0070] In an example embodiment, the yin-yang face mask includes a yin face mask region and a yang face mask region, wherein the pixel value of the yin face mask region is 0, and the pixel value of the yang face mask region is a predetermined value, such as the brightness value of a predetermined light source.
[0071] Furthermore, in the example embodiment, the size of the shadow mask region and the sun mask region in the shadow mask can be determined according to a random ratio. For example, the size ratio of the shadow mask region and the sun mask region in the shadow mask can be determined by a random function, and a shadow mask corresponding to the reference face image can be generated according to the size ratio of the region.
[0072] In step S430, the boundary of the shadow face mask region and the shadow face mask region of the shadow face mask is processed to obtain the shadow face mask after boundary processing.
[0073] In the example embodiment, the face mask includes a shadow face mask region and a sun face mask region, wherein the pixel value of the shadow face mask region is 0, and the pixel value of the sun face mask region is 1. Boundary processing includes filtering or erosion processing of the boundaries between the shadow face mask regions and the sun face mask regions. This boundary processing ensures that the pixel values of the boundary regions are no longer only 0 or 1, but rather a floating-point value between 0 and 1, thereby making the boundaries between the shadow face mask regions and the sun face mask regions smoother.
[0074] In some example embodiments, a sliding window convolution process is performed on the boundaries of the shadow and sun face mask regions of the two-tone face mask using a predetermined convolution kernel. The sliding window convolution process involves sliding the window of the predetermined convolution kernel across the two-tone face mask, multiplying the two-tone face mask by the corresponding positions of the predetermined convolution kernel, and summing the results to obtain the convolutional result. This sliding window convolution process allows for low-pass filtering of the boundaries between the shadow and sun face mask regions, resulting in smoother boundaries.
[0075] Furthermore, since the pixel values in the shadow mask region are all 0 and the pixel values in the sun mask region are all 1, in the example embodiment, the boundaries of the shadow mask region and the sun mask region are used as the starting point of the right boundary and the ending point of the left boundary of the window of the predetermined convolution kernel. The window of the predetermined convolution kernel is slid on the shadow and sun masks. If the left boundary of the window of the predetermined convolution kernel slides past the boundary of the shadow mask region and the sun mask region, the convolution process of the sliding window ends.
[0076] For example, the boundaries of the shadow mask region and the sun mask region of the shadow mask can be processed by sliding window convolution using the following predetermined convolution kernel K. The predetermined convolution kernel K is a 3x3 convolution kernel, as shown in equation (1).
[0077]
[0078] It should be noted that although the predetermined convolution kernel is described using the above formula (1) as an example, those skilled in the art should understand that the value of the predetermined convolution kernel K can be determined according to the scenario in which the face recognition device is used, and the embodiments in this specification do not impose any special limitations on this.
[0079] In other example embodiments, the face mask is eroded using a predetermined structuring element to obtain an eroded face mask. The predetermined structuring element can be a rectangle, cross, circle, or other shapes. The erosion process is used to eliminate the boundary points of objects, causing the boundaries to shrink inward. For example, the image to be processed is scanned using a structuring element of a certain shape, and an AND operation is performed between the structuring element and the pixels of the image to be processed it covers. If both results are 1, the pixel value of that pixel in the image to be processed is 1; otherwise, the pixel value of that pixel is 0.
[0080] In step S440, the yin-yang face mask is superimposed on the reference face image to generate a yin-yang face sample image.
[0081] In the example embodiment, both the reference face image and the two-tone face mask include multiple channels. The shadow area of the two-tone face sample image corresponds to the shadow area of the shadow mask, and the sun area of the two-tone face sample image corresponds to the sun area of the sun mask. The multiple channels can be RGB (Red, Green, Blue) channels, or other suitable multi-channel channels such as HSV (Hue, Saturation, Value) channels, which is also within the scope of the embodiments in this specification.
[0082] Furthermore, in some example embodiments, the first pixel value and the second pixel value of the corresponding position of the face mask and the reference face image in the same channel are obtained respectively; the first pixel value and the second pixel value are added together to obtain the face sample image of the same channel; the face sample images of each channel are superimposed to obtain the face sample image. Adding the pixel values of the corresponding position of the face mask and the reference face image can simulate the effect of light source illumination.
[0083] In other example embodiments, the first pixel value and the second pixel value of the corresponding position of the face mask and the reference face image in the same channel are obtained respectively; the first pixel value and the second pixel value are subtracted to obtain the face sample image of the same channel; the face sample images of each channel are superimposed to obtain the face sample image. Subtracting the pixel values of the corresponding position of the face mask and the reference face image can simulate a dark effect.
[0084] according to Figure 4In the example embodiment, the technical solution, on the one hand, performs boundary processing on the boundary between the shadow face mask region and the sun face mask region of the shadow face mask, so that the boundary effect of the shadow face mask is close to the real shadow face effect, thereby making the boundary effect of the shadow face sample image close to the real shadow face effect; on the other hand, the multi-channel shadow face mask is superimposed with the reference face image to generate various multi-channel shadow face sample images.
[0085] Furthermore, in the example embodiment, the face mask is a single-channel mask, and the image processing method further includes: performing channel copying on the face mask after boundary processing to generate face masks corresponding to each channel of the multiple channels; and performing channel superposition on the face masks corresponding to each channel to generate face masks with multiple channels.
[0086] According to the technical solutions in the above embodiments, various multi-channel face masks can be generated by performing channel replication and channel superposition on the face mask.
[0087] Furthermore, in some example embodiments, the generated sample images of faces with varying lighting conditions are input into the face recognition model for training, resulting in a trained face recognition model. This face recognition model can be a neural network model, such as a convolutional neural network model.
[0088] By using a trained face recognition model to identify faces with varying shades of light under different lighting conditions, the pass rate for faces with varying shades of light under complex lighting conditions can be improved.
[0089] Figure 5 This is a flowchart illustrating another image processing method provided in the embodiments of this specification.
[0090] Reference Figure 5 As shown, in step S510, a face mask corresponding to the reference face image is generated.
[0091] In the example embodiment, the reference face image is a reference image used to generate the face mask, and the reference face image contains the face portion of the original image of the target scene. The reference face image can be obtained from the original image containing the face of the target scene. The target scene is a scenario used by a face recognition device, such as a payment scenario or a security check scenario, where face images are prone to appear under complex lighting conditions.
[0092] Furthermore, in the example embodiment, a face mask of the same size as the reference face image is randomly generated. For example... Figure 3 As shown, the pixel value in the white area is 0, and the pixel value in the black area is 1. The size of the white and black areas is random.
[0093] For example, the ratio of white to black area sizes is determined using a random function, and a two-tone mask corresponding to a reference face image is generated based on this ratio. Figure 3 In the image, the ratio of white to black areas is 1:2, and the image is generated based on this ratio. Figure 3 The yin-yang face mask shown.
[0094] In step S520, the yin-yang face mask is rotated according to a predetermined rotation factor.
[0095] In the example embodiment, the face mask is rotated according to a predetermined rotation factor, such as a predetermined angle. Rotating the face mask according to the predetermined rotation factor allows for the simulation of different light source positions, for example, as shown below. Figure 3 As shown, the light source is on the right. This predetermined rotation factor can be determined based on the position and angle of the light source in the scene where the face recognition device will be used. For example, if the light source is 30 degrees to the right, the predetermined rotation factor can be 30 degrees, rotating to the right.
[0096] Furthermore, in the example embodiment, a rotation center of the yin-yang face mask is determined; based on this rotation center, the yin-yang face mask is rotated according to a predetermined rotation factor. For example, the image center position of the yin-yang face mask is used as the rotation center, and based on this rotation center, the yin-yang face mask is rotated according to a predetermined rotation factor.
[0097] In step S530, the pixel value of each pixel of the yin-yang face mask is multiplied by a predetermined light source brightness value.
[0098] In the example embodiment, the pixel value of each pixel in the face mask is multiplied by a predetermined light source brightness value. This predetermined light source brightness value is used to simulate the brightness of the light source. For example, if the predetermined light source brightness value is 30, then multiplying the pixel value of each pixel in the face mask by 30 will change the pixel value of the "1" area in the original face mask to "30".
[0099] In step S540, the boundary processing of the yin-yang face mask is performed.
[0100] In the example embodiment, to ensure that the effect of the two-tone face is closer to a real two-tone face, boundary processing needs to be performed on the two-tone face mask. For example, filtering, such as low-pass filtering, is applied to the boundary of the two-tone face mask so that the boundary region between the two-tone face mask region and the two-tone face mask region is no longer only 0 or 1, but a floating-point value between 0 and 1.
[0101] In some example embodiments, a sliding window convolution process is performed on the boundaries of the shadow and sun face mask regions using a predetermined convolution kernel. For example, since the pixel values in the shadow face mask region are all 0 and the pixel values in the sun face mask region are all 1, in an example embodiment, the boundaries of the shadow and sun face mask regions are used as the starting point of the right boundary and the ending point of the left boundary of the predetermined convolution kernel window. The window of the predetermined convolution kernel is slid across the shadow and sun face mask. If the left boundary of the window of the predetermined convolution kernel slides past the boundaries of the shadow and sun face mask regions, the sliding window convolution process ends.
[0102] Furthermore, in some example embodiments, the yin-yang face mask is a single-channel mask. The yin-yang face mask after boundary processing is copied by channel to generate a yin-yang face mask corresponding to each channel of multiple channels. The yin-yang face masks corresponding to each channel are superimposed by channel to generate a yin-yang face mask with multiple channels.
[0103] In step S550, the yin-yang face mask is superimposed on the reference face image to generate a yin-yang face sample image.
[0104] In the example embodiment, the shadow area of the two-tone face sample image corresponds to the shadow face mask area, and the sunlight area of the two-tone face sample image corresponds to the sunlight face mask area. The processed two-tone face mask is "overlaid" on the reference face image, that is, the pixel values of the two-tone face mask and the reference face image at corresponding positions are added or subtracted; if the pixel values of the two-tone face mask and the reference face image at corresponding positions are added, then a light source effect is simulated; if the pixel values of the two-tone face mask and the reference face image at corresponding positions are subtracted, then a dark effect can be simulated.
[0105] For example, adding the pixel values of each location in the two-tone face mask to the corresponding pixel values in the reference face image generates a two-tone face sample image. Adding the pixel values of the two-tone face mask to the corresponding locations in the reference face image can simulate the effect of light source illumination. Subtracting the pixel values of each location in the two-tone face mask from the corresponding locations in the reference face image generates a two-tone face sample image. Subtracting the pixel values of the two-tone face mask to the corresponding locations in the reference face image can simulate the effect of shadows.
[0106] according to Figure 5The technical solution in the example embodiment, on the one hand, performs boundary processing on the boundary between the shadow face mask region and the sun face mask region of the shadow face mask, so that the boundary effect of the shadow face sample image is close to the real shadow face effect; on the other hand, a rotation factor is added to the shadow face mask, which can adapt to the lighting characteristics of different directions, ensuring that the generated shadow face sample images are rich and realistic; furthermore, the pixel value of each pixel of the shadow face mask is multiplied by a predetermined light source brightness value, which can simulate the brightness of different light sources.
[0107] Furthermore, in the example embodiment, when the face mask is "overlaid" with the reference face image—that is, when the pixel values at corresponding positions in the face mask and the reference face image are added or subtracted—pixel value overflow may occur, meaning the pixel value exceeds the maximum pixel value allowed by the data type. In this case, pixel value normalization or truncation can be performed. Normalization involves uniformly scaling the pixel values of the face sample image. Truncation sets the overflowing pixel value to the maximum value allowed by the data type, for example, changing 300 to 255.
[0108] According to the technical solution of the above example embodiment, when pixel value overflow occurs, normalizing or truncating the pixel value can avoid pixel display abnormalities.
[0109] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0110] Below, we will combine Figure 6 as well as Figure 1 The system architecture shown in this specification provides a detailed description of the image processing apparatus provided in the embodiments. It should be noted that... Figure 6 The image processing apparatus described herein is used to perform the functions described herein. Figures 2-5 The methods shown in the embodiments are illustrated for ease of explanation, showing only the parts related to the embodiments of this specification. For specific technical details not disclosed, please refer to this specification. Figures 2-5 The example shown.
[0111] Please see Figure 6 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of this specification. Figure 6As shown, the image processing apparatus 600 in this embodiment may include: a reference image acquisition module 610, a face mask generation module 620, and an image overlay module 630. Among them,
[0112] Reference image acquisition module 610 is used to acquire a reference face image;
[0113] The yin-yang face mask generation module 620 is used to generate a yin-yang face mask corresponding to the reference face image, wherein the yin-yang face mask includes a yin face mask region and a yang face mask region;
[0114] The image overlay module 630 is used to overlay the yin-yang face mask with the reference face image to generate a yin-yang face sample image, wherein the yin face region of the yin-yang face sample image corresponds to the yin face mask region, and the yang face region of the yin-yang face sample image corresponds to the yang face mask region.
[0115] In some example embodiments, based on the above scheme, the image processing apparatus 600 further includes:
[0116] The boundary processing module is used to perform boundary processing on the boundary between the shadow face mask region and the sun face mask region of the yin-yang face mask before overlaying the yin-yang face mask with the reference face image, so as to obtain the yin-yang face mask after boundary processing.
[0117] In some example embodiments, based on the above scheme, the boundary processing module is configured as follows:
[0118] The boundaries of the shadow face mask region and the slant face mask region of the slant face mask are processed by sliding window convolution using a predetermined convolution kernel.
[0119] or,
[0120] The boundary between the shadow mask region and the sun mask region of the yin-yang face mask is etched by a predetermined structuring element to obtain the etched yin-yang face mask.
[0121] In some example embodiments, based on the above scheme, the reference face image includes multiple channels, and the image processing device 600 further includes:
[0122] The channel copying module is used to copy the boundary-processed face mask through channels to generate face masks corresponding to each of the multiple channels.
[0123] The channel overlay module is used to overlay the face masks corresponding to each channel to generate face masks for the multiple channels.
[0124] In some example embodiments, based on the above scheme, the image overlay module 630 is configured as follows:
[0125] The first pixel value and the second pixel value of the corresponding position of the yin-yang face mask and the reference face image in the same channel are obtained respectively.
[0126] The first pixel value and the second pixel value are added together to obtain the yin-yang face sample image of the same channel; or the first pixel value and the second pixel value are subtracted to obtain the yin-yang face sample image of the same channel.
[0127] The yin-yang face sample images from each channel are superimposed to obtain the yin-yang face sample image.
[0128] In some example embodiments, based on the above scheme, the two-tone face mask generation module 620 is configured as follows:
[0129] Determine the size ratio of the shaded face mask area and the sun face mask area;
[0130] Based on the size ratio of the region, a face mask corresponding to the reference face image is generated.
[0131] In some example embodiments, based on the above scheme, the pixel value of the pixels in the shadow mask region is 0, and the pixel value of the pixels in the sun mask region is 1.
[0132] In some example embodiments, based on the above scheme, before overlaying the two-tone face mask with the reference face image, the image overlay module 630 further includes:
[0133] A rotation center determination module is used to determine the rotation center of the yin-yang face mask;
[0134] A rotation processing module is used to rotate the yin-yang face mask based on the rotation center and according to a predetermined rotation factor.
[0135] In some example embodiments, based on the above scheme, the image overlay module 630 further includes:
[0136] The light source brightness simulation module is used to multiply the pixel value of each pixel of the face mask by a predetermined light source brightness value before superimposing the face mask with the reference face image.
[0137] According to this instruction manual Figure 6The technical solution of the embodiment, on the one hand, generates a face mask corresponding to a reference face image, the face mask including a shadow mask region and a sun mask region, which can generate face masks simulating various lighting scenarios; on the other hand, the face mask is superimposed on the reference face image to generate a face sample image, the shadow region of the face sample image corresponding to the shadow mask region, and the sun region corresponding to the sun mask region, which can efficiently and cost-effectively obtain face sample images under complex lighting scenarios, thereby solving the problem of low pass rate of face masks under complex lighting scenarios.
[0138] The above is an illustrative embodiment of an image processing apparatus according to this specification. It should be noted that the technical solution of this image processing apparatus and the technical solution of the image processing method described above belong to the same concept. Details not described in detail in the technical solution of the image processing apparatus can be found in the description of the technical solution of the image processing method described above.
[0139] This specification also provides a computer storage medium that can store multiple program instructions adapted to be loaded and executed by a processor as described above. Figures 2-5 The method steps of the illustrated embodiment can be found in the following documentation for detailed execution. Figures 2-5 The specific details of the illustrated embodiments will not be elaborated here.
[0140] This specification also provides a computer program product that stores at least one instruction, which is loaded and executed by a processor as described above. Figures 2-5 The image processing method described in the illustrated embodiment can be found in the following document for a detailed execution process. Figures 2-5 The specific details of the illustrated embodiments will not be elaborated here.
[0141] Please refer to Figure 7 This diagram illustrates the structure of an electronic device provided in an exemplary embodiment of this specification. The electronic device in this specification may include one or more components such as a processor 710, a memory 720, an input device 730, an output device 740, and a bus 750. The processor 710, memory 720, input device 730, and output device 740 may be connected via the bus 750.
[0142] The processor 710 may include one or more processing cores. The processor 710 connects to various parts of the electronic device via various interfaces and lines, and performs various functions and processes data of the electronic device 700 by running or executing instructions, programs, code sets, or instruction sets stored in the memory 720, and by calling data stored in the memory 720. Optionally, the processor 710 may be implemented using at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 710 may integrate one or a combination of central processing unit (CPU), graphics processing unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 710, but may be implemented separately through a communication chip.
[0143] The memory 720 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 720 may include a non-transitory computer-readable storage medium. The memory 720 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 720 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (e.g., touch function, sound playback function, image playback function, etc.), instructions for implementing the various method embodiments described below, etc. The operating system may be the Android system, including systems deeply developed based on the Android system, the iOS system developed by Apple Inc., including systems deeply developed based on the iOS system, or other systems.
[0144] In order for the operating system to distinguish the specific application scenarios of third-party applications, it is necessary to establish data communication between the third-party applications and the operating system. This would allow the operating system to obtain the current scenario information of the third-party applications at any time, and then perform targeted system resource adaptation based on the current scenario.
[0145] The input device 730 is used to receive input instructions or data, and includes, but is not limited to, a keyboard, mouse, camera, microphone, or touch device. The output device 740 is used to output instructions or data, and includes, but is not limited to, a display device and a speaker. In one example, the input device 730 and the output device 740 can be combined, and both the input device 730 and the output device 740 can be a touch display screen.
[0146] In addition, those skilled in the art will understand that the structure of the electronic device shown in the above figures does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements. For example, the electronic device may also include radio frequency circuits, input units, sensors, audio circuits, Wireless Fidelity (WiFi) modules, power supplies, Bluetooth modules, etc., which will not be described in detail here.
[0147] exist Figure 7 In the illustrated electronic device, the processor 710 can be used to call the image processing application stored in the memory 720 and specifically perform the following operations:
[0148] Obtain a reference face image;
[0149] Generate a face mask corresponding to the reference face image, wherein the face mask includes a face mask region and a face mask region;
[0150] The yin-yang face mask is superimposed on the reference face image to generate a yin-yang face sample image. The yin-yang face region of the yin-yang face sample image corresponds to the yin-yang face mask region, and the yang-yang face region of the yin-yang face sample image corresponds to the yang-yang face mask region.
[0151] In some example embodiments, before overlaying the two-tone face mask onto the reference face image, the processor 710 also performs the following operations:
[0152] The boundaries of the yin face mask region and the yang face mask region of the yin-yang face mask are processed to obtain the yin-yang face mask after boundary processing.
[0153] In some example embodiments, when the processor 710 performs boundary processing on the boundary between the shadow face mask region and the convex face mask region, it specifically performs the following operations:
[0154] The boundaries of the shadow face mask region and the slant face mask region of the slant face mask are processed by sliding window convolution using a predetermined convolution kernel.
[0155] or,
[0156] The boundary between the shadow mask region and the sun mask region of the yin-yang face mask is etched by a predetermined structuring element to obtain the etched yin-yang face mask.
[0157] In some example embodiments, the reference face image includes multiple channels, and the processor 710 also performs the following operations:
[0158] Channel replication is performed on the boundary-processed face mask to generate face masks corresponding to each of the multiple channels;
[0159] The face masks corresponding to each channel are superimposed to generate face masks for the multiple channels.
[0160] In some example embodiments, when the processor 710 performs the process of overlaying the two-tone face mask with the reference face image to generate a two-tone face sample image, it specifically performs the following operations:
[0161] The first pixel value and the second pixel value of the corresponding position of the yin-yang face mask and the reference face image in the same channel are obtained respectively.
[0162] The first pixel value and the second pixel value are added together to obtain the yin-yang face sample image of the same channel; or the first pixel value and the second pixel value are subtracted to obtain the yin-yang face sample image of the same channel.
[0163] The yin-yang face sample images from each channel are superimposed to obtain the yin-yang face sample image.
[0164] In some example embodiments, when the processor 710 performs the operation of generating a face mask corresponding to the reference face image, it specifically performs the following operations:
[0165] Determine the size ratio of the shaded face mask area and the sun face mask area;
[0166] Based on the size ratio of the region, a face mask corresponding to the reference face image is generated.
[0167] In some example embodiments, the pixel value of the pixels in the shaded face mask region is 0, and the pixel value of the pixels in the sun face mask region is 1.
[0168] In some example embodiments, before overlaying the two-tone face mask onto the reference face image, the processor 710 also performs the following operations:
[0169] Determine the rotation center of the yin-yang face mask;
[0170] Based on the rotation center, the yin-yang face mask is rotated according to a predetermined rotation factor.
[0171] In some example embodiments, before overlaying the two-tone face mask onto the reference face image, the processor 710 also performs the following operations:
[0172] Multiply the pixel value of each pixel in the yin-yang face mask by a predetermined light source brightness value.
[0173] According to this instruction manual Figure 7 The technical solution of the embodiment, on the one hand, generates a face mask corresponding to a reference face image, the face mask including a shadow mask region and a sun mask region, which can generate face masks simulating various lighting scenarios; on the other hand, the face mask is superimposed on the reference face image to generate a face sample image, the shadow region of the face sample image corresponding to the shadow mask region, and the sun region corresponding to the sun mask region, which can efficiently and cost-effectively obtain face sample images under complex lighting scenarios, thereby solving the problem of low pass rate of face masks under complex lighting scenarios.
[0174] The above is an illustrative embodiment of an electronic device according to this specification. It should be noted that the technical solution of this electronic device and the technical solution of the image processing method described above belong to the same concept. Details not described in detail in the technical solution of the electronic device can be found in the description of the technical solution of the image processing method described above.
[0175] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium for the computer program can be a magnetic disk, optical disk, read-only memory, or random access memory, etc.
[0176] The above-disclosed embodiments are merely preferred embodiments of this specification and should not be construed as limiting the scope of this specification. Therefore, any equivalent variations made in accordance with the claims of this specification shall still fall within the scope of this specification.
[0177] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
Claims
1. An image processing method, comprising: Obtain a reference face image; Generate a face mask corresponding to the reference face image, the face mask including a face mask region and a face mask region; the pixel value of the face mask region is 0, and the pixel value of the face mask region is a predetermined value; The yin-yang face mask is superimposed on the reference face image to generate a yin-yang face sample image. The yin-yang face region of the yin-yang face sample image corresponds to the yin-yang face mask region, and the yang-yang face region of the yin-yang face sample image corresponds to the yang-yang face mask region. The method further includes the following steps before overlaying the two-tone face mask with the reference face image: Determine the rotation center of the yin-yang face mask; Based on the rotation center, the yin-yang face mask is rotated according to a predetermined rotation factor; The yin-yang face mask is used to simulate various lighting scenarios, and the yin-yang face sample image is a yin-yang face sample image under various lighting scenarios.
2. The method according to claim 1, wherein, Before overlaying the two-tone face mask with the reference face image, the method further includes: The boundaries of the yin face mask region and the yang face mask region of the yin-yang face mask are processed to obtain the yin-yang face mask after boundary processing.
3. The method according to claim 2, wherein, The boundary processing of the boundary between the shadow face mask region and the shin face mask region of the shadow face mask includes: The boundaries of the shadow face mask region and the slant face mask region of the slant face mask are processed by sliding window convolution using a predetermined convolution kernel. or, The boundary between the shadow mask region and the sun mask region of the yin-yang face mask is etched by a predetermined structuring element to obtain the etched yin-yang face mask.
4. The method according to claim 2, wherein, The reference face image includes multiple channels, and the method further includes: Channel replication is performed on the boundary-processed face mask to generate face masks corresponding to each of the multiple channels; The face masks corresponding to each channel are superimposed to generate face masks for the multiple channels.
5. The method according to claim 4, wherein, The step of overlaying the two-tone face mask with the reference face image to generate a two-tone face sample image includes: The first pixel value and the second pixel value of the corresponding position of the yin-yang face mask and the reference face image in the same channel are obtained respectively. The first pixel value and the second pixel value are added together to obtain the yin-yang face sample image of the same channel; or the first pixel value and the second pixel value are subtracted to obtain the yin-yang face sample image of the same channel. The yin-yang face sample images from each channel are superimposed to obtain the yin-yang face sample image.
6. The method according to claim 2, wherein, The generation of the two-tone face mask corresponding to the reference face image includes: Determine the size ratio of the shaded face mask area and the sun face mask area; Based on the size ratio of the region, a face mask corresponding to the reference face image is generated.
7. The method according to claim 6, wherein, The pixel value of the pixels in the shaded face mask area is 0, and the pixel value of the pixels in the sun face mask area is 1.
8. The method according to any one of claims 1 to 7, wherein, Before overlaying the two-tone face mask with the reference face image, the method further includes: Multiply the pixel value of each pixel in the yin-yang face mask by a predetermined light source brightness value.
9. An image processing apparatus, comprising: The reference image acquisition module is used to acquire reference face images; A face mask generation module is used to generate a face mask corresponding to the reference face image. The face mask includes a face mask region and a face mask region. The pixel values of the face mask region are 0, and the pixel values of the face mask region are predetermined values. A rotation center module is used to determine the rotation center of the yin-yang face mask; A rotation processing module is used to rotate the yin-yang face mask based on the rotation center and according to a predetermined rotation factor; An image overlay module is used to overlay the yin-yang face mask with the reference face image to generate a yin-yang face sample image, wherein the yin face region of the yin-yang face sample image corresponds to the yin face mask region, and the yang face region of the yin-yang face sample image corresponds to the yang face mask region. The yin-yang face mask is used to simulate various lighting scenarios, and the yin-yang face sample image is a yin-yang face sample image under various lighting scenarios.
10. A computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the steps of the method as claimed in any one of claims 1 to 8.
11. An electronic device, comprising: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to execute the steps of the method as claimed in any one of claims 1 to 8.
12. A computer program product comprising instructions that, when run on a computer or processor, cause the computer or processor to perform the steps of the method as described in any one of claims 1-8.
Citation Information
Patent Citations
Face image recognition method and device, computer device and storage medium
CN110046573A
Target face image detection method and device, storage medium and electronic device
CN113326718A