Identity photo optimization processing method and device and storage medium

Through artificial intelligence technology, the document photo is optimized, including segmenting the foreground and background, adjusting the lighting, replacing the background and details enhancement, solving the problems of cumbersome manual operations and unstable results in the existing technology, and achieving stable and significant optimization effects.

CN119579477APending Publication Date: 2025-03-07BEIJING THUNDERSTONE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411723087.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

The existing document photo optimization method requires manually setting parameters such as brightness, contrast and saturation of the image. The operation is cumbersome and the results are unstable, especially for complex photos.

Method used

By detecting the face area of ​​the source image, it is divided into foreground and background, adjust the image intensity according to the lighting conditions, replace the background color to the standard ID photo background color, and enhance the details of the face image to generate ID photo.

Benefits of technology

The stability and consistency of the optimization processing of ID licenses is achieved, especially for complex pictures, without manual intervention, avoiding the uncertainty of manual operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119579477A_ABST
    Figure CN119579477A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, and provides an identification photo optimization processing method, and the method comprises the steps: carrying out the segmentation of a foreground and a background of a source image through detecting a face region of the source image; adjusting the intensity of the source image according to the illumination condition of the source image to obtain an optimized image; replacing the background color in the optimized image with the background color of the standard identification photo according to the foreground and background segmentation result of the source image; and performing detail enhancement on the face image corresponding to the foreground in the optimized image to generate the identification photo. According to the technical scheme, the identification photo with a stable optimization effect can be obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device and storage medium for optimizing ID photo processing. Background Art

[0002] ID photos refer to photos used on various ID cards (such as ID cards, passports, driver's licenses, student ID cards, etc.). Since ID photos are an important basis for proving identity, they must be able to clearly show personal features, and strict shooting standards and specifications can reduce the risk of forgery and abuse of ID cards and maintain social security. Therefore, ID photos usually need to meet certain standards and requirements to ensure that individuals can be accurately and clearly identified when verifying identity. Generally speaking, when taking ID photos, users will optimize and enhance the images taken for the first time to meet the standards of ID photos. However, the existing ID photo optimization processing methods all manually set parameters such as image brightness, contrast, and saturation. This manual processing method is not only cumbersome to operate, but also has unstable results (for example, different users have different processing effects on the same photo, or the same user has different processing effects on the same photo at different times) or for complex photos, the effect is poor. Summary of the invention

[0003] The present application provides a method, device and storage medium for optimizing ID photos, which can obtain ID photos with stable optimization effects.

[0004] On the one hand, the present application provides a method for optimizing ID photos, the method comprising:

[0005] By detecting the face area of ​​the source image, the foreground and background of the source image are segmented;

[0006] Adjusting the intensity of the source image according to the illumination condition of the source image to obtain an optimized image;

[0007] According to the foreground and background segmentation results of the source image, the background color in the optimized image is replaced with the background color of the standard ID photo;

[0008] The facial image corresponding to the foreground in the optimized image is enhanced in detail to generate an ID photo.

[0009] On the other hand, the present application provides a device for optimizing and processing a certificate photo, the device comprising:

[0010] A segmentation module, used for segmenting the foreground and background of the source image by detecting the face area of ​​the source image;

[0011] An optimization module, used for adjusting the intensity of the source image according to the illumination condition of the source image to obtain an optimized image;

[0012] A replacement module, used to replace the background color in the optimized image with the background color of the standard ID photo according to the foreground and background segmentation results of the source image;

[0013] The enhancement module is used to enhance the details of the facial image corresponding to the foreground in the optimized image to generate an ID photo.

[0014] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the technical solution of the above-mentioned ID photo optimization processing method when executing the computer program.

[0015] In a fourth aspect, the present application provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of the technical solution of the above-mentioned ID photo optimization processing method.

[0016] From the technical solution provided by the present application, it can be seen that after the foreground and background of the source image are segmented, the intensity of the source image is adjusted according to the lighting conditions of the source image to obtain an optimized image, and then the color of the background in the optimized image is replaced with the background color of the standard ID photo according to the foreground and background segmentation results of the source image, and finally the facial image corresponding to the foreground in the optimized image is enhanced in detail to generate the ID photo. Compared with the existing ID photo optimization processing methods that manually set the image brightness, contrast, saturation and other parameters, the technical solution of the present application can be completed based on artificial intelligence. Therefore, the technical solution of the present application does not require manual intervention, avoids the uncertainty of manual operation, and can obtain a stable optimization effect, especially for complex pictures, the optimization effect is more significant, and can also be personalized according to the specific needs of the ID photo. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0018] Figure 1 is a flow chart of a method for optimizing ID photo processing provided in an embodiment of the present application;

[0019] Figure 2 It is a structural schematic diagram of a device for optimizing ID photo processing provided in an embodiment of the present application;

[0020] Figure 3It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0022] In this specification, adjectives such as first and second may be used only to distinguish one element or action from another element or action, without necessarily requiring or implying any actual such relationship or order. Where circumstances permit, reference to an element or component or step (etc.) should not be interpreted as being limited to only one of the elements, components, or steps, but may be one or more of the elements, components, or steps, etc.

[0023] In this specification, for the convenience of description, the sizes of various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0024] ID photos refer to photos used on various ID cards (such as ID cards, passports, driver's licenses, student ID cards, etc.). Since ID photos are an important basis for proving identity, they must be able to clearly show personal features, and strict shooting standards and specifications can reduce the risk of forgery and abuse of ID cards and maintain social security. Therefore, ID photos usually need to meet certain standards and requirements to ensure that individuals can be accurately and clearly identified when verifying identity. Generally speaking, when taking ID photos, users will optimize and enhance the images taken for the first time to meet the standards of ID photos. However, the existing ID photo optimization processing methods all manually set parameters such as image brightness, contrast, and saturation. This manual processing method is not only cumbersome to operate, but also has unstable results (for example, different users have different processing effects on the same photo, or the same user has different processing effects on the same photo at different times) or for complex photos, the effect is poor.

[0025] In view of the above problems of the prior art, this application proposes a method for optimizing the processing of ID photos, the flow chart of which is shown in the attached Figure 1 As shown, it mainly includes steps S101 to S104, which are described in detail as follows:

[0026] Step S101: Segment the foreground and background of the source image by detecting the face area of ​​the source image.

[0027] In the embodiments of the present application, the source image is a photo containing a face taken by various image acquisition devices, such as a camera, and this photo is also the photo to be processed into an ID photo later. Since the ID photo mainly focuses on the face part, it is first necessary to detect the face area from the source image. From the perspective of image processing, the face area is actually a closed geometric figure, that is, the face area has a boundary or edge. Therefore, an edge detection algorithm can be used to detect the face area of ​​the source image. For example, an edge detection algorithm based on the sobel operator, canny operator or other operators can detect the face area from the source image. This application does not limit the specific algorithm.

[0028] From the pixel perspective, an image can be divided into foreground pixels and background pixels. The so-called foreground pixels are the parts of the image that people pay attention to. For example, for an image to be processed into an ID photo, people pay attention to the face part. Therefore, in an embodiment of the present application, the source image can also be input into a pre-trained segmentation model to obtain an output mask, which will mark the foreground and background to achieve the segmentation of the foreground and background of the source image. It should be noted that the output mask is the result generated by the segmentation model after performing pixel-level prediction on the source image. Each pixel value in the output mask represents the category to which the pixel belongs. For example, in a foreground-background segmentation task, the output mask is usually a binary image, in which: the area with a pixel value of 1 represents the foreground (such as a person or object), and the area with a pixel value of 0 represents the background.

[0029] Step S102: adjusting the intensity of the source image according to the illumination conditions of the source image to obtain an optimized image.

[0030] In an embodiment of the present application, the intensity of the source image includes image characteristic parameters such as brightness and contrast. Due to the lighting conditions during shooting, such as insufficient light or excessive light, the source image taken does not meet the requirements of an ID photo. Therefore, it is necessary to adjust the intensity of the source image according to the lighting conditions of the source image. In one embodiment of the present application, if the intensity of the source image refers to the brightness of the source image, then the intensity of the source image is adjusted according to the lighting conditions of the source image, and the optimized image can be obtained by: calculating the average brightness of the source image, adjusting the brightness of the source image to a standard value, or adjusting the brightness of the source image by linear transformation, or adjusting the brightness of the source image by adjusting the contrast of the source image. If I(x,y) is used to represent the pixel value of the source image at position (x, y), Represents the average brightness of the source image, L target The target brightness is the expected brightness of the source image after adjustment. Then the average brightness of the source image is calculated. The brightness of the source image is adjusted to the standard value, which can be expressed as I'(x,y)=I(x,y)+(L target - ). The above formula shows that if L target Greater than , then by increasing the value of each pixel of the source image, the source image becomes brighter; if L target Less than , the source image becomes darker by reducing the value of each pixel of the source image. The brightness of the source image is adjusted by linear transformation, which is generally achieved by superimposing a brightness value on the brightness value of the source image or multiplying it by a brightness adjustment factor.

[0031] It should be noted that by adjusting the contrast of the source image, the brightness of the source image is adjusted, considering that in the field of image processing, brightness and contrast are closely related. This close correlation makes the adjustment of the image contrast also indirectly affect the brightness distribution of the image. Specifically, when the contrast of a local area of ​​the source image is enhanced, the pixel value of the dark area may be lowered, and the pixel value of the bright area may be increased, which will make those local areas with uneven brightness more uniform as a whole. This enhancement of local contrast will cause some details in the source image to be more prominent, thereby causing the brightness perceived by the human eye to change. As for how to adjust the contrast of the source image, reference can be made to the relevant description of the subsequent embodiments.

[0032] In one embodiment of the present application, if the intensity of the source image refers to the contrast of the source image, then the intensity of the source image is adjusted according to the illumination condition of the source image, and obtaining the optimized image can be achieved through steps S1021 to S1024, which are described in detail as follows:

[0033] Step S1021: Divide the source image into a number of non-overlapping sub-image blocks.

[0034] The main purpose of dividing the source image into several non-overlapping sub-image blocks is to perform histogram equalization in the local area to adapt to the local contrast of the image. Specifically, by dividing the source image into blocks, histogram equalization can be performed independently in each sub-block, so that the enhancement of local details can be maintained while avoiding excessive enhancement in the entire image range, thereby maintaining the naturalness of the source image; on the other hand, different areas of the source image may have different lighting conditions and contrasts, especially in images with non-uniform lighting (such as shadow areas, bright areas, etc.). Through block processing, the local brightness and contrast of each sub-block can be equalized, so that the details of each area can be effectively enhanced. In addition, by dividing the source image into blocks, the histogram equalization in each sub-block only focuses on the local grayscale range, thereby effectively reducing the problem of noise amplification.

[0035] In the scheme of dividing the source image into several non-overlapping sub-image blocks, the size of the block (i.e., the size of each sub-block) is an important parameter that directly affects the effect of the algorithm. If the sub-block is too small, the algorithm can better capture the change of local contrast, but it may introduce noise due to over-processing of the local area, resulting in artifacts in the source image; on the contrary, if the sub-block is too large, the equalization of the entire area may be too rough, and the details of the source image cannot be effectively distinguished, and some local information may be lost. Usually, the size of the block is selected between a few hundredths and a few thousandths of the size of the source image. If the source image has less noise and more uniform contrast, a larger block size may work better. If the source image has strong local differences, a smaller block size can better adapt to local illumination changes. In addition, if the resolution of the source image is low, smaller blocks are generally used to capture local details, while larger blocks can be selected for source images with higher resolution.

[0036] Step S1022: performing contrast limitation on the grayscale histogram of each sub-image block by using a set threshold.

[0037] Specifically, the contrast of the histogram of each sub-block is limited, and the gray level frequency exceeding the set threshold is limited to a maximum value to avoid over-enhancement. For the part exceeding the maximum value, it is evenly distributed to all gray levels.

[0038] Step S1023: for the grayscale histogram after contrast limitation, calculate the cumulative distribution function and normalize it to the grayscale range.

[0039] Specifically, if H″ ij (t) represents the grayscale histogram after contrast limitation. Then, the cumulative distribution function C is calculated for the grayscale histogram after contrast limitation. ij (k) can be expressed as:

[0040]

[0041] Wherein, k is the gray level of the grayscale histogram.

[0042] Then, normalize to the grayscale range:

[0043]

[0044] Where L is the number of gray levels.

[0045] Step S1024: Based on the normalization to the grayscale range, the grayscale value of the source image is mapped to a new grayscale value by a bilinear interpolation method to obtain an optimized image.

[0046] By processing the source image from step S1021 to step S1023, there may be visual discontinuity between sub-blocks, especially at the boundaries of sub-blocks, which may easily cause seams and jumps in the image. The main purpose of interpolation is to eliminate this discontinuity and make the transition of the image between sub-blocks smoother. Through the bilinear interpolation method, the final grayscale value of each pixel will not only depend on the equalization result of the sub-block where it is located, but also refer to the equalization information of the adjacent sub-blocks. Specifically, for each pixel in the source image, it can be weighted according to the distance between the pixel and the center of the sub-block. The sub-block closer to the center will have a greater impact on the pixel, while the sub-block farther away will have a smaller impact. In other words, the new value of each pixel is calculated by the enhanced results of the four sub-blocks near it according to the distance weighted calculation. In this way, the grayscale value of each pixel not only reflects the adjustment effect of the sub-block where it is located, but also takes into account the influence of the adjacent area, ensuring the smooth transition of the image.

[0047] In another embodiment of the present application, if the intensity of the source image refers to the contrast of the source image, then the intensity of the source image is adjusted according to the illumination condition of the source image, and the optimized image can be obtained by steps S'1021 to S'1024, which are described in detail as follows:

[0048] Step S'1021: Construct a Gaussian pyramid layer by performing Gaussian filtering on the source image.

[0049] Since constructing Gaussian pyramid layers helps to view the details of the image at different scales, for example, at a lower resolution level, the global structure of the image can be analyzed, and at a high resolution level, the details of the image can be analyzed, the Gaussian pyramid layers can be constructed by Gaussian filtering the source image. Specifically, starting from the input source image, the source image can be gradually Gaussian filtered and downsampled, and each layer is a blurred and reduced version of the previous layer image until a predetermined minimum size is reached.

[0050] Step S'1022: construct a Laplacian pyramid layer based on the Gaussian pyramid layer.

[0051] Since the Laplacian pyramid emphasizes the details and high-frequency information of the image, which are the differences between high-resolution images and low-resolution images, it can effectively capture the details such as edges and textures in the image. In other words, the Laplacian pyramid layer can be used to enhance the details of the image, especially when performing multi-scale image enhancement, it helps to adjust, enhance or smooth the details of the image while retaining the global structure of the image. Therefore, the Laplacian pyramid layer can be constructed based on the Gaussian pyramid layer. Specifically, each layer of the image of the Gaussian pyramid layer can be upsampled (usually doubling the image size); Gaussian filtering can be performed on the upsampled image; and the image of this layer of the Gaussian pyramid layer is subtracted from the image obtained in the previous step to obtain the Laplacian pyramid image of this layer.

[0052] Step S'1023: Enhance the Laplacian pyramid layer to obtain an enhanced Laplacian pyramid layer.

[0053] Specifically, the enhancement of the Laplace pyramid layer may be simply multiplied by an amplification factor, or a more complex enhancement method may be used as needed. As an embodiment of the present application, the enhancement of the Laplace pyramid layer to obtain the enhanced Laplace pyramid layer may be: calculating the local contrast of each layer in the Laplace pyramid layer and analyzing its noise level; dynamically adjusting the enhancement coefficient according to the local contrast and noise level of each layer; applying the adjusted enhancement coefficient to each layer in the Laplace pyramid layer to obtain the enhanced Laplace pyramid layer. It should be noted that in the above embodiment, the reason why the enhancement coefficient needs to be dynamically adjusted is that the contrast and noise levels of different regions of each Laplace pyramid layer are different. If a unified enhancement coefficient is used, some regions may be over-enhanced and some regions may be under-enhanced. Therefore, for any Laplace pyramid layer, if the contrast of a region is lower than a certain set threshold and / or the noise level is lower than a certain set threshold, the enhancement coefficient of the region should be increased. Conversely, if its contrast is higher than a certain set threshold and / or the noise level is higher than a certain set threshold, the enhancement coefficient of the region should be appropriately reduced, and so on.

[0054] Step S'1024: reconstruct the enhanced Laplacian pyramid layer to obtain an optimized image.

[0055] Specifically, step S'1024 may be implemented by: starting from the smallest-sized layer in the enhanced Laplacian pyramid layer, upsampling it; adding the upsampled image to the enhanced Laplacian pyramid layer of the previous layer to obtain a reconstructed image of the current layer; repeating the above steps, layer by layer, until an optimized image of the original size is reconstructed.

[0056] It should be noted that the above-mentioned embodiments of adjusting the intensity of the source image according to the lighting conditions of the source image to obtain an optimized image can all be applied to the aforementioned embodiments of adjusting the brightness of the source image by adjusting the contrast of the source image, that is, in the embodiments of adjusting the intensity of the source image according to the lighting conditions of the source image to obtain an optimized image, the schemes of adjusting the contrast of the source image can all be applied to adjusting the contrast of the source image in "adjusting the brightness of the source image by adjusting the contrast of the source image".

[0057] Step S103: According to the foreground and background segmentation results of the source image, the background color in the optimized image is replaced with the background color of the standard ID photo.

[0058] Specifically, a new background image (all standard background colors) can be created, and then according to the output mask mentioned in the aforementioned embodiment, the part of the source image that belongs to the background is replaced with this new background color, for example, blue or white, thereby replacing the color of the background in the optimized image with the background color of the standard ID photo.

[0059] Step S104: performing detail enhancement on the facial image corresponding to the foreground in the optimized image to generate an ID photo.

[0060] As an embodiment of the present application, the facial image corresponding to the foreground in the optimized image is enhanced in detail to generate an ID photo by: applying a Laplace operator to the facial image corresponding to the foreground in the optimized image to generate a Laplace image; applying a nonlinear function to transform the Laplace image to obtain a transformed Laplace image; and weightedly superimposing the facial image corresponding to the foreground in the optimized image and the transformed Laplace image to obtain the ID photo.

[0061] As another embodiment of the present application, the facial image corresponding to the foreground in the optimized image is enhanced in detail, and the ID photo can also be generated by: decomposing the facial image corresponding to the foreground in the optimized image into sub-bands of different scales and directions, wherein the sub-bands include high-frequency sub-bands and low-frequency sub-bands; amplifying or nonlinearly transforming the high-frequency sub-bands to obtain enhanced high-frequency sub-bands; combining the low-frequency sub-bands and the enhanced high-frequency sub-bands and performing inverse transformation to obtain the ID photo. In the above embodiment, the high-frequency sub-bands include LH, HL and HH, which represent the details of the horizontal, vertical and diagonal directions of the facial image, respectively, and the low-frequency sub-bands represent the general outline and overall structure of the facial image. The reason why the high-frequency sub-bands (LH, HL, HH) are enhanced is to highlight the details of the facial image, while the low-frequency sub-band (LL) is kept unchanged because it contains the overall structure and main information of the facial image. Combining the low-frequency sub-bands with the enhanced high-frequency sub-bands means rearranging the enhanced high-frequency sub-bands and the unchanged low-frequency sub-bands according to the structure of the original decomposition. Specifically, if the facial image corresponding to the foreground in the optimized image is decomposed into sub-bands of different scales and directions in the order of LL, LH, HL, and HH, then it needs to be rearranged in the same order during reorganization, that is, the order of the reorganized sub-bands is still LL, LH', HL', and HH', where LL is the original low-frequency sub-band, and LH', HL', and HH' are the enhanced high-frequency sub-bands corresponding to LH, HL, and HH.

[0062] From the above attached Figure 1 It can be seen from the example ID photo optimization processing method that after the foreground and background of the source image are segmented, the intensity of the source image is adjusted according to the lighting conditions of the source image to obtain an optimized image. Then, based on the foreground and background segmentation results of the source image, the color of the background in the optimized image is replaced with the background color of the standard ID photo. Finally, the facial image corresponding to the foreground in the optimized image is enhanced in detail to generate the ID photo. Compared with the existing ID photo optimization processing methods that manually set parameters such as image brightness, contrast, and saturation, the technical solution of the present application can be completed based on artificial intelligence. Therefore, the technical solution of the present application does not require manual intervention, avoiding the uncertainty of manual operation, so as to obtain a stable optimization effect, especially for complex images, the optimization effect is more significant, and can also be personalized according to the specific needs of ID photos.

[0063] Please see attached Figure 2 , is a document photo optimization processing device provided in an embodiment of the present application, the device may include a segmentation module 201, an optimization module 202, a replacement module 203 and an enhancement module 204, which are described in detail as follows:

[0064] The segmentation module 201 is used to segment the foreground and background of the source image by detecting the face area of ​​the source image;

[0065] An optimization module 202, used to adjust the intensity of the source image according to the illumination conditions of the source image to obtain an optimized image;

[0066] A replacement module 203 is used to replace the background color of the optimized image with the background color of the standard ID photo according to the foreground and background segmentation results of the source image;

[0067] The enhancement module 204 is used to enhance the details of the facial image corresponding to the foreground in the optimized image to generate an ID photo.

[0068] From the above attached Figure 2 It can be seen from the example ID photo optimization processing device that after segmenting the foreground and background of the source image, the intensity of the source image is adjusted according to the lighting conditions of the source image to obtain an optimized image. Then, based on the foreground and background segmentation results of the source image, the color of the background in the optimized image is replaced with the background color of the standard ID photo. Finally, the facial image corresponding to the foreground in the optimized image is enhanced in detail to generate the ID photo. Compared with the existing ID photo optimization processing methods that manually set parameters such as image brightness, contrast, and saturation, the technical solution of the present application can be completed based on artificial intelligence. Therefore, the technical solution of the present application does not require manual intervention, avoiding the uncertainty of manual operation, so as to obtain a stable optimization effect, especially for complex images, the optimization effect is more significant, and can also be personalized according to the specific needs of ID photos.

[0069] Figure 3 Schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Figure 3 As shown, the electronic device 3 of this embodiment mainly includes: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30, such as a program of the ID photo optimization processing method. When the processor 30 executes the computer program 32, the steps in the ID photo optimization processing method embodiment are implemented, such as Figure 1 Alternatively, when the processor 30 executes the computer program 32, the functions of each module / unit in the above-mentioned device embodiments are implemented, for example Figure 2 The functions of the segmentation module 201, the optimization module 202, the replacement module 203 and the enhancement module 204 are shown.

[0070] Exemplarily, the computer program 32 of the ID photo optimization processing method mainly includes: by detecting the face area of ​​the source image, segmenting the foreground and background of the source image; adjusting the intensity of the source image according to the lighting conditions of the source image to obtain an optimized image; according to the foreground and background segmentation results of the source image, replacing the color of the background in the optimized image with the background color of the standard ID photo; enhancing the details of the facial image corresponding to the foreground in the optimized image to generate the ID photo. The computer program 32 can be divided into one or more modules / units, one or more modules / units are stored in the memory 31 and executed by the processor 30 to complete the present application. One or more modules / units can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program 32 in the electronic device 3. For example, the computer program 32 can be divided into the functions of a segmentation module 201, an optimization module 202, a replacement module 203 and an enhancement module 204 (modules in the virtual device), and the specific functions of each module are as follows: the segmentation module 201 is used to segment the foreground and background of the source image by detecting the face area of ​​the source image; the optimization module 202 is used to adjust the intensity of the source image according to the lighting conditions of the source image to obtain an optimized image; the replacement module 203 is used to replace the color of the background in the optimized image with the background color of the standard ID photo based on the foreground and background segmentation results of the source image; the enhancement module 204 is used to enhance the details of the facial image corresponding to the foreground in the optimized image to generate an ID photo.

[0071] The electronic device 3 may include but is not limited to a processor 30 and a memory 31. Those skilled in the art will appreciate that Figure 3 It is only an example of the electronic device 3 and does not constitute a limitation of the electronic device 3. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0072] The processor 30 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0073] The memory 31 may be an internal storage unit of the electronic device 3, such as a hard disk or memory of the electronic device 3. The memory 31 may also be an external storage device of the electronic device 3, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 3. Further, the memory 31 may also include both an internal storage unit of the electronic device 3 and an external storage device. The memory 31 is used to store computer programs and other programs and data required by the electronic device. The memory 31 may also be used to temporarily store data that has been output or is to be output.

[0074] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0075] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0076] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0077] In the embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0078] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0079] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0080] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program of the ID photo optimization processing method can be stored in a storage medium. When the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments, that is, by detecting the face area of ​​the source image, the foreground and background of the source image are segmented; the intensity of the source image is adjusted according to the lighting conditions of the source image to obtain an optimized image; according to the foreground and background segmentation results of the source image, the color of the background in the optimized image is replaced with the background color of the standard ID photo; the facial image corresponding to the foreground in the optimized image is enhanced in detail to generate an ID photo. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. Storage media may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, mobile hard disks, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content contained in the storage medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, storage media do not include electric carrier signals and telecommunication signals.

[0081] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application is described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some of the technical features therein by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. The specific implementation methods described above further describe the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only the specific implementation method of the present application, and is not used to limit the protection scope of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present invention.

Claims

1. A method for optimizing ID photos, characterized in that: The method comprises: By detecting the face area of ​​the source image, the foreground and background of the source image are segmented; Adjusting the intensity of the source image according to the illumination condition of the source image to obtain an optimized image; According to the foreground and background segmentation results of the source image, the background color in the optimized image is replaced with the background color of the standard ID photo; The facial image corresponding to the foreground in the optimized image is enhanced in detail to generate an ID photo.

2. The ID photo optimization processing method according to claim 1, characterized in that: The intensity of the source image includes the brightness of the source image, and adjusting the intensity of the source image according to the illumination condition of the source image to obtain an optimized image includes: Calculating the average brightness of the source image and adjusting the brightness of the source image to a standard value; or adjusting the brightness of the source image by linear transformation; or The brightness of the source image is adjusted by adjusting the contrast of the source image.

3. The ID photo optimization processing method according to claim 1, characterized in that: The intensity of the source image includes the contrast of the source image, and adjusting the intensity of the source image according to the illumination condition of the source image to obtain an optimized image includes: Dividing the source image into a plurality of non-overlapping sub-image blocks; Performing contrast limitation on the grayscale histogram of each sub-image block by setting a threshold; For the grayscale histogram after contrast limitation, a cumulative distribution function is calculated and normalized to a grayscale range; According to the normalization to the grayscale range, the grayscale value of the source image is mapped to a new grayscale value by a bilinear interpolation method to obtain the optimized image.

4. The ID photo optimization processing method according to claim 1, characterized in that: The intensity of the source image includes the contrast of the source image, and adjusting the intensity of the source image according to the illumination condition of the source image to obtain an optimized image includes: Constructing a Gaussian pyramid layer by performing Gaussian filtering on the source image; Based on the Gaussian pyramid layer, a Laplacian pyramid layer is constructed; Enhance the Laplace pyramid layer to obtain an enhanced Laplace pyramid layer; Performing image reconstruction on the enhanced Laplacian pyramid layer to obtain the optimized image.

5. The ID photo optimization processing method according to claim 4, characterized in that: The step of enhancing the Laplace pyramid layer to obtain an enhanced Laplace pyramid layer includes: Calculating the local contrast of each layer in the Laplacian pyramid layer; Dynamically adjust the enhancement factor according to the local contrast and noise level of each layer; The adjusted enhancement coefficient is applied to each layer in the Laplacian pyramid layer to obtain the enhanced Laplacian pyramid layer.

6. The ID photo optimization processing method according to claim 1, characterized in that: The step of performing detail enhancement on the facial image corresponding to the foreground in the optimized image to generate an ID photo includes: Applying a Laplacian operator to a facial image corresponding to a foreground in the optimized image to generate a Laplacian image; Applying a nonlinear function to transform the Laplace image to obtain a transformed Laplace image; The facial image corresponding to the foreground in the optimized image and the transformed Laplace image are weightedly superimposed to obtain the ID photo.

7. The ID photo optimization processing method according to claim 1, characterized in that: The step of performing detail enhancement on the facial image corresponding to the foreground in the optimized image to generate an ID photo includes: Decomposing the facial image corresponding to the foreground in the optimized image into sub-bands of different scales and directions, wherein the sub-bands include high-frequency sub-bands and low-frequency sub-bands; Amplifying or nonlinearly transforming the high frequency sub-band to obtain an enhanced high frequency sub-band; The low-frequency sub-band and the enhanced high-frequency sub-band are combined and then inversely transformed to obtain the ID photo.

8. A device for optimizing and processing ID photos, characterized in that: The device comprises: A segmentation module, used for segmenting the foreground and background of the source image by detecting the face area of ​​the source image; An optimization module, used for adjusting the intensity of the source image according to the illumination condition of the source image to obtain an optimized image; A replacement module, used to replace the background color in the optimized image with the background color of the standard ID photo according to the foreground and background segmentation results of the source image; The enhancement module is used to enhance the details of the facial image corresponding to the foreground in the optimized image to generate an ID photo.

9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.