Light removal methods, devices, electronic equipment and storage media

Through the deep learning model based on the image consistency constraint, combined with the illumination model and the discriminant model for cyclic adversarial training, the problems of poor robustness and loss of color information of the existing de-illumination method are solved, and a real and natural matte image is generated, which is suitable for in complex lighting environments.

CN113781352BActive Publication Date: 2024-08-27IFLYTEK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111087980.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-16
Publication Date
2024-08-27
Estimated Expiration
2041-09-16

AI Technical Summary

Technical Problem

Existing delighting methods have poor robustness under complex lighting scenarios, and the binarization algorithm needs to convert the image into a grayscale image, resulting in the loss of color information.

Method used

A deep learning model based on image consistency constraints is used, and circular adversarial training is performed by combining the illumination model and the discriminant model to generate a more realistic and natural matte image and retain the color information of the input image.

Benefits of technology

The robustness of the delighting method is improved, the loss of color information is avoided, and better processing effects can be maintained in complex lighting scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113781352B
    Figure CN113781352B
Patent Text Reader

Abstract

The present invention provides a de-illumination method, device, electronic device and storage medium, the method comprising: determining an image to be de-illuminated; based on a de-illumination model, performing a de-illumination operation on the image to obtain a matte image corresponding to the image; the de-illumination model is obtained by cyclic training based on sample image pairs and a joint illumination model with image consistency as a constraint, the sample image pairs include sample illuminated images and sample matte images; the image consistency includes the consistency between the sample matte image and the predicted matte image, and / or the consistency between the sample illuminated image and the predicted illuminated image, the predicted matte image is generated by the de-illumination model based on the sample illuminated image, and the predicted illuminated image is generated by the illumination model based on the sample matte image. The method, device, electronic device and storage medium provided by the present invention can obtain a more realistic and natural matte image, and can avoid the problems of poor robustness and loss of image color information in existing methods.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision technology, and in particular to a de-illumination method, device, electronic device and storage medium. Background Art

[0002] With the rapid development and application of computer vision technology, electronic document recognition technology has very important research value. However, directly using photos for electronic document recognition will face a major problem in the field of visual processing - the lighting problem. Under the influence of lighting, photos are prone to shadows, strong light and other areas, which greatly increases the difficulty of electronic document recognition. Therefore, how to remove the light from the photos before recognition has become an urgent problem to be solved.

[0003] At present, the main method for deillumination of images is to use the binarization strategy in traditional image processing. Among them, the binarization strategy with better effect is to divide the document image into multiple regions and perform binarization in each region separately, which can alleviate the problem of uneven illumination. However, this method is subject to the setting of artificial rules and is not robust enough. The processing effect is poor in complex lighting scenarios. In addition, the premise of the binarization algorithm is that the image needs to be converted into a grayscale image, which will lead to the loss of color information. Summary of the invention

[0004] The present invention provides a de-illumination method, a device, an electronic device and a storage medium, which are used to solve the defect of poor robustness in the prior art and improve the robustness of the de-illumination method.

[0005] The present invention provides a method for removing light, comprising:

[0006] Determine the image to be de-illuminated;

[0007] Based on the de-illumination model, performing a de-illumination operation on the image to obtain a matte image corresponding to the image;

[0008] The de-illumination model is obtained by cyclic training of a sample image pair and a combined illumination model based on image consistency constraints, wherein the sample image pair includes a sample illuminated image and a sample dark image;

[0009] The image consistency includes the consistency between the sample matte image and the predicted matte image, and / or the consistency between the sample illuminated image and the predicted illuminated image, wherein the predicted matte image is generated by the de-illuminated model based on the sample illuminated image, and the predicted illuminated image is generated by the illuminated model based on the sample matte image.

[0010] According to a de-illumination method provided by the present invention, the de-illumination model is specifically constrained by the image consistency and is obtained by cyclic adversarial training based on the sample image pair and the combined illumination model, the first discriminant model and the second discriminant model. The first discriminant model is used to discriminate the authenticity of the predicted light-free image and the sample light-free image, and the second discriminant model is used to discriminate the authenticity of the predicted lighted image and the sample lighted image.

[0011] According to a de-illumination method provided by the present invention, the loss function of the cyclic adversarial training is determined based on an image consistency loss function and a cyclic adversarial loss function;

[0012] The image consistency loss function is used to characterize the loss value of the image consistency;

[0013] The cyclic adversarial loss function is used to characterize the classification loss value of the sample dark image and the predicted dark image, the classification loss value of the sample light image and the predicted light image, the loss value between the restored dark image and the sample dark image, and the loss value between the restored light image and the sample light image;

[0014] The restored matte image is generated by the de-illumination model based on the predicted illuminated image, and the restored illuminated image is generated by the illumination-added model based on the predicted matte image.

[0015] According to a de-illumination method provided by the present invention, the sample illuminated image is determined based on the sample dark image in the sample image pair and a pre-constructed illuminated image pair, the sample dark image is obtained by scanning, the illuminated image pair includes an all-white image and a corresponding illuminated image, and the illuminated image is obtained by adding illumination to the all-white image.

[0016] According to a de-illumination method provided by the present invention, the illumination image is determined based on the following steps:

[0017] Build 3D models;

[0018] The all-white image is pasted on the three-dimensional grid of the three-dimensional model, and a virtual camera is used to take a photo of the pasted all-white image to obtain the illumination image.

[0019] According to a deillumination method provided by the present invention, a sample light image corresponding to any sample dark image is determined based on the following steps:

[0020] Based on the multiple sets of illumination image pairs, determining a target image pair;

[0021] The sample illuminated image is determined based on the ratio of the illuminated image to the all-white image in the target image pair and any one of the sample dark images.

[0022] According to a deillumination method provided by the present invention, the image is obtained by photographing a target document;

[0023] The step of performing a delighting operation on the image based on the delighting model to obtain a matte image corresponding to the image further includes:

[0024] Text line detection is performed on the matte image to obtain text information of the target document.

[0025] The present invention also provides a method for adding illumination, comprising:

[0026] Determine the image to be illuminated;

[0027] Based on the image and the illumination image pair, determining a lighted image corresponding to the image;

[0028] The illumination image pair includes an all-white image and a corresponding illumination image, and the illumination image is obtained by illuminating the all-white image.

[0029] The present invention also provides a light removal device, comprising:

[0030] A determination module, used for determining an image to be de-illuminated;

[0031] A delighting module, used for performing a delighting operation on the image based on a delighting model to obtain a matte image corresponding to the image;

[0032] The de-illumination model is obtained by cyclic training of a sample image pair and a combined illumination model based on image consistency constraints, wherein the sample image pair includes a sample illuminated image and a sample dark image;

[0033] The image consistency includes the consistency between the sample matte image and the predicted matte image, and / or the consistency between the sample illuminated image and the predicted illuminated image, wherein the predicted matte image is generated by the de-illuminated model based on the sample illuminated image, and the predicted illuminated image is generated by the illuminated model based on the sample matte image.

[0034] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any one of the above-mentioned de-illumination methods or the above-mentioned illumination methods are implemented.

[0035] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-mentioned de-illumination methods or the above-mentioned illumination methods.

[0036] The delighting method, device, electronic device and storage medium provided by the present invention obtain a delighting model by taking image consistency as a constraint and based on sample image pairs and jointly adding a lighting model for cyclic training, thereby ensuring the delighting effect of the delighting model. On this basis, the image is delighted based on the delighting model, thereby obtaining a more realistic and natural light-free image, ensuring that the information of the input image is not lost, and avoiding the problems of poor robustness of existing methods and loss of image color information. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the present invention or 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 some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0038] Figure 1 It is a schematic diagram of the process of the light removal method provided by the present invention;

[0039] Figure 2 It is a flow chart of the cyclic adversarial training method provided by the present invention;

[0040] Figure 3 It is a schematic flow chart of the method for determining the illumination image provided by the present invention;

[0041] Figure 4 It is a flow chart of a method for determining a sample light image provided by the present invention;

[0042] Figure 5 is a schematic diagram of the network structure of the de-illumination model provided by the present invention;

[0043] Figure 6 is a schematic diagram of the network structure of the first discriminant model provided by the present invention;

[0044] Figure 7 It is a schematic diagram of the process of the illumination method provided by the present invention;

[0045] Figure 8 It is a schematic diagram of the structure of the light removal device provided by the present invention;

[0046] Fig. 9 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] With the rapid development and application of computer vision technology, electronic document recognition technology has very important research value. However, directly using photographs for electronic document recognition will face a major problem in the field of visual processing - the illumination problem. Under the influence of illumination, photographs are prone to shadows, strong light and other areas, which greatly increases the difficulty of electronic document recognition. Studies have shown that if document recognition is performed directly on photos, the recognition effect of shadows or highlights in the photos will be poor, while if document recognition is performed directly on scanned images, the recognition effect of the overall image will be better. Analysis of the reason shows that the scanned image obtained by the scanner has uniform illumination and can be regarded as an unilluminated image, so that text line detection is not affected by illumination problems. However, in real life, the usage rate of mobile phone cameras is much higher than that of scanners, and it is not easy to obtain scanned images. Therefore, how to de-illuminate photos before document recognition has become an urgent problem to be solved.

[0049] To this end, the present invention provides a method for removing light. Figure 1 Schematic diagram of the process of the light removal method provided by the present invention, such as Figure 1 As shown, the method includes:

[0050] Step 110: determine the image to be de-illuminated.

[0051] Here, the image to be de-illuminated is an image that needs to be de-illuminated, and can be an image acquired by an image acquisition device such as a mobile phone or a camera, or an image crawled from the Internet using crawler technology, and the embodiment of the present invention does not specifically limit this. The target represented by the image to be de-illuminated can be a document, a face, a license plate, etc. For example, if the image to be de-illuminated is an image representing a face, de-illuminating can help achieve the effect of face recognition. For another example, if the image to be de-illuminated is an image representing a document, de-illuminating can help achieve the effect of document recognition.

[0052] Step 120, performing a de-illumination operation on the image based on the de-illumination model to obtain a matte image corresponding to the image;

[0053] The de-illumination model is obtained by cyclic training based on sample image pairs and combined with illumination model, with image consistency as a constraint. The sample image pairs include sample illuminated images and sample dark images.

[0054] Image consistency includes the consistency between the sample matte image and the predicted matte image, and / or the consistency between the sample illuminated image and the predicted illuminated image, where the predicted matte image is generated by a de-illumination model based on the sample illuminated image, and the predicted illuminated image is generated by an illumination-added model based on the sample matte image.

[0055] Specifically, considering that the existing de-illumination method mainly adopts the binarization strategy in traditional image processing, this method is subject to the setting of artificial rules, is not robust enough, and has poor processing effect in complex lighting scenarios. In addition, the premise of the binarization algorithm is that the image needs to be converted into a grayscale image, which will lead to the loss of color information. To address this problem, an embodiment of the present invention applies a deep learning model to realize de-illumination of an image, specifically, a de-illumination model is used to perform a de-illumination operation on the image to be de-illuminated, thereby obtaining a light-free image corresponding to the image.

[0056] Since the deep learning model is driven by big data and is learned based on a large amount of sample data, the deep learning model has stronger robustness than the existing artificial rule method, and can still guarantee a good processing effect in complex lighting scenarios. In addition, the de-illumination method based on the deep learning model does not need to convert the image into a grayscale image. The image can be directly input to obtain the dark image output by the deep learning model. If the input image is a three-channel color image, the corresponding dark image will also be a three-channel color image, so that the color information in the input image can be retained. Therefore, the de-illumination model is applied in the embodiment of the present invention to perform de-illumination processing on the image. In order to ensure that the de-illumination model can pre-learn the mapping relationship between the light graphics and the dark images, the de-illumination model can be pre-trained based on the sample image pairs. The sample image pairs here include paired sample light images and sample dark images. The sample light images and the sample dark images are paired images representing the same target. For example, the sample light image is a light image representing a document, and the sample dark image is a dark image representing the same document.

[0057] Before executing step 120, a de-illumination model may be pre-trained. Specifically, the de-illumination model may be trained in the following manner:

[0058] First, a large number of sample image pairs are collected. The sample image pairs here can be directly obtained by technologies such as web crawlers, or sample illuminated images / sample dark images can be first obtained, and corresponding sample dark images / sample illuminated images are generated through de-illumination / addition of illumination operations, and then the two are combined to form sample image pairs.

[0059] Then, considering that de-illumination can be regarded as a style transfer problem, an image with light style is converted into an image without light style. For this, the embodiment of the present invention applies a generative model to construct a de-illumination model. On this basis, considering that the image generated by the generative model obtained by the unidirectional training method is not realistic and natural enough, and it is easy to lose the information of the original image, for this, the embodiment of the present invention also applies a generative model to construct an illumination model. Then, using sample image pairs, the de-illumination model and the illumination model are cyclically trained under image consistency constraints, thereby obtaining a trained de-illumination model.

[0060] Here, the loop training under the image consistency constraint is to update the parameters of the model in combination with the image consistency loss during the loop training process. Image consistency can include the consistency between the sample dark image and the predicted dark image, and can also include the consistency between the sample illuminated image and the predicted illuminated image, and can also include the consistency between the sample dark image and the predicted dark image and the consistency between the sample illuminated image and the predicted illuminated image, wherein the predicted dark image is generated by the de-illumination model based on the input sample illuminated image, and the predicted illuminated image is generated by the illumination model based on the input sample dark image.

[0061] It should be noted that the traditional CycleGAN (Cycle Generative Adversarial Networks) uses two unpaired image sets C and D to perform cyclic training on two generative models. The constraints of the cyclic training are the consistency between the restored C and C generated by the two generative models in sequence, and the consistency between the restored D and D generated by the two generative models in sequence. Although the generative model obtained by this training method is less likely to lose the information of the original image than the generative model obtained by the unidirectional training method, it actually focuses on ensuring the effect of the image generated by the combination of the two generative models, resulting in the image generated by a single generative model is still prone to deformation compared to the original image.

[0062] Different from the traditional CycleGAN, the embodiment of the present invention uses paired sample illuminated images A and sample dark images B to perform cyclic training on the de-illumination model and the illumination model, and the constraints of the cyclic training include not only the constraints of the above-mentioned cyclic training itself, but also the consistency between the predictions B generated by the de-illumination model and B, and / or the consistency between the predictions A generated by the illumination model and A. That is to say, in the cyclic training of the two generative models, the de-illumination model and the illumination model, the paired sample images are used as inputs of one model and as labels to supervise the output of the other model, so that the de-illumination model can generate an image as close to B as possible, and because B and A are paired images representing the same target, the image generated by the de-illumination model is consistent with B, which is equivalent to the generated image being consistent with A in content, thereby ensuring that the image generated by the de-illumination model does not lose the information of the input image, is not easily deformed, and is more realistic and natural.

[0063] By performing cyclic training on the de-illumination model and the illumination model, on the one hand, it can be ensured that the combination of the two models has the ability to restore the training samples A / B to A / B, thereby ensuring the effect of the image generated by the combination of the two interacting models. On the other hand, because the cyclic training is performed under the constraint of image consistency, the single de-illumination model has the ability to transform A into B, and the illumination model has the ability to transform B into A. The superposition of the training effects of the two aspects greatly improves the de-illumination effect of the de-illumination model, making the images generated by the de-illumination model more realistic and natural.

[0064] The method provided by the embodiment of the present invention, by taking image consistency as a constraint and based on sample image pairs, jointly adding an illumination model for cyclic training to obtain a de-illumination model, thereby ensuring the de-illumination effect of the de-illumination model. On this basis, the image is de-illuminationed based on the de-illumination model, thereby obtaining a more realistic and natural light-free image, ensuring that the information of the input image is not lost, and avoiding the problems of poor robustness of existing methods and loss of image color information.

[0065] Based on any of the above embodiments, the de-illumination model is specifically constrained by image consistency and is obtained by cyclic adversarial training of a joint illumination model, a first discriminant model and a second discriminant model based on sample image pairs. The first discriminant model is used to discriminate the authenticity of a predicted light-free image and a sample light-free image, and the second discriminant model is used to discriminate the authenticity of a predicted lighted image and a sample lighted image.

[0066] Specifically, a sample image pair can be used to perform cyclic adversarial training on the de-illumination model, the illumination model, the first discriminant model, and the second discriminant model under image consistency constraints, thereby obtaining a trained de-illumination model. Here, the first discriminant model can be used to discriminate the authenticity of the input predicted dark image and the sample dark image, and the second discriminant model can be used to discriminate the authenticity of the input predicted illuminated image and the sample illuminated image.

[0067] In the process of cyclic adversarial training under the constraint of image consistency, the de-illumination model is not only supervised by the corresponding first discriminant model based on the authenticity discrimination results of the predicted matte image and the sample matte image, but also needs to be trained under the constraint of image consistency, that is, it is necessary to ensure that the generated image is more and more similar to the sample matte image, so that the de-illumination model can generate more and more realistic matte images.

[0068] The de-illumination model in the embodiment of the present invention takes image consistency as a constraint, and jointly performs cyclic adversarial training with the illumination model, the first discriminant model and the second discriminant model, so that the de-illumination model can accurately transfer the feature information of the target represented by the original image to the matte image, that is, the content contained in the matte image is consistent with the content contained in the original image. Compared with the traditional CycleGAN, the embodiment of the present invention can further accurately generate a matte image consistent with the content of the original image, avoiding the problem that images generated based on the traditional CycleGAN are prone to deformation.

[0069] Based on any of the above embodiments, the loss function of the cyclic adversarial training is determined based on the image consistency loss function and the cyclic adversarial loss function;

[0070] The image consistency loss function is used to characterize the loss value of image consistency;

[0071] The cyclic adversarial loss function is used to characterize the classification loss value between the sample dark image and the predicted dark image, the classification loss value between the sample light image and the predicted light image, the loss value between the restored dark image and the sample dark image, and the loss value between the restored light image and the sample light image;

[0072] The restored matte image is generated by the de-illumination model based on the predicted illuminated image, and the restored illuminated image is generated by the added illumination model based on the predicted matte image.

[0073] Specifically, the image consistency loss function is used to characterize the loss value of image consistency, that is, the degree of consistency between the sample dark image and the predicted dark image, and / or the degree of consistency between the sample illuminated image and the predicted illuminated image. The smaller the loss value of image consistency, the higher the degree of consistency, the stronger the ability of the deillumination model to transfer the illuminated style sample image to the dark style predicted image, and the lower the probability of style shift in the predicted image generated in subsequent applications.

[0074] The image consistency loss function thus constructed is used to maximize the image consistency between the sample dark image and the predicted dark image, and / or maximize the image consistency between the sample illuminated image and the predicted illuminated image, so that the de-illumination model can learn as many features of the sample dark image as possible during the training process, and the illumination model can learn as many features of the sample illuminated image as possible during the training process, so that the dark image output by the trained de-illumination model can fully approximate the real dark image.

[0075] In addition, the cyclic adversarial loss function is used to characterize the classification loss values ​​of the sample dark image and the predicted dark image, the classification loss values ​​of the sample illuminated image and the predicted illuminated image, the loss value between the restored dark image and the sample dark image, and the loss value between the restored illuminated image and the sample illuminated image. Among them, the classification loss values ​​of the sample dark image and the predicted dark image can be the loss values ​​of the classification labels obtained by the first discriminant model distinguishing the authenticity of the sample dark image and the predicted dark image, and the classification loss values ​​of the sample illuminated image and the predicted illuminated image can be the loss values ​​of the classification labels obtained by the second discriminant model distinguishing the authenticity of the sample illuminated image and the predicted illuminated image. The restored dark image is generated by the de-illumination model based on the input predicted illuminated image, and the restored illuminated image is generated by the illumination model based on the input predicted dark image.

[0076] The loss function of cyclic adversarial training is constructed based on the image consistency loss function and the cyclic adversarial loss function. It can be to directly add the loss value of image consistency and the loss value of cyclic adversarial training, or to perform a weighted sum of the two, etc., which is not specifically limited in the embodiments of the present invention. The loss function of cyclic adversarial training obtained in this way not only covers some loss values ​​of cyclic adversarial training itself, but also takes into account the loss value of image consistency, so that the matte image output by the de-illumination model obtained by training can fully approximate the real matte image, and at the same time can fully retain the characteristic information of the target represented by the original image.

[0077] Based on any of the above embodiments, research has shown that if document recognition is performed directly on a photo, the recognition effect of the shadow or highlight area in the photo will be poor. On the contrary, if document recognition is performed directly on a scanned image, the recognition effect of the entire image will be better. However, in real life, the usage rate of mobile phone cameras is much higher than that of scanners, and it is not easy to obtain scanned images. Therefore, how to convert photos obtained by mobile phone cameras into scanned images is particularly important.

[0078] In this regard, an embodiment of the present invention proposes a solution for photo de-illumination. De-illumination can be regarded as a style transfer problem, which converts a photo-style image into a scanned-style image. Based on this, an embodiment of the present invention implements style transfer based on the CycleGAN model. In the training stage of the model, two paired training data sets are required: training set A and training set B, where A is a sample light image with diverse illumination, and B is a sample dark image obtained by scanning.

[0079] The CycleGAN model is used to process the illumination in the image. The principle is to use the special ring structure of CycleGAN to translate the images in the two data sets in a loop, so as to achieve the migration of the illumination style in the two data sets. The CycleGAN model consists of two generative models and two discriminative models. The generative model is responsible for generating images and constantly makes the images it generates more similar to the original data set to achieve "false and real"; the discriminative model should strengthen its own resolution ability to determine whether the image comes from a real sample or from the generative model, so as to guide the generation process of the generative model.

[0080] Figure 2 It is a flow chart of the cyclic adversarial training method provided by the present invention, such as Figure 2 As shown in the figure, the two generative models are the de-illumination model Ga2b and the illumination model Gb2a, and the two discriminative models are the first discriminative model Db and the second discriminative model Da. After the image in the dataset A is input into Ga2b, Ga2b will generate a predicted non-illuminated image fakeB, and then the first discriminative model Db will classify fakeB to determine whether fakeB comes from B or from the image generated by Ga2b, and feed the result back to Ga2b, so as to strengthen Ga2b so that it can generate more realistic images. Therefore, under the supervision of Db, fakeB will continue to narrow the gap with the images in the dataset B, that is, the illumination style should be as similar as possible to the non-illuminated style in the dataset B. If fakeB is input into Gb2a again, another restored illuminated image cycA will be generated, and the illumination style of cycA should be as similar as possible to the real illumination style in the dataset A.

[0081] On the contrary, after inputting the image in B into Gb2a, a predicted lighted image fakeA is generated. The lighting style of fakeA should be as similar to the real lighting style in A as possible under the supervision of the second discriminant model Da, and the lighting style of the restored dark image cycB generated by fakeA through Ga2b should be as similar to the dark style in B as possible. In other words, the generative model should not only be able to transform A into B (Ga2b), but also have the ability to restore B to A (Gb2a), and vice versa. This is the special ring structure of the CycleGAN model provided by the present invention.

[0082] The generative model and the discriminative model compete with each other. Db trains Ga2b, and Da trains Gb2a, so that the two generative models can generate more and more realistic images. The generative models in turn train the discriminative models to continuously enhance their resolution. The generation process of cycA and cycB can be regarded as a verification process, which is used to verify whether the generative model has been well trained to generate images that are realistic enough. When the model training is completed, the illuminated image with the lighting style in the data set A is input, and the de-illumination model Ga2b can generate a non-illuminated image with the scanning style of the data set B, that is, the lighting style of A is transformed to B, and vice versa, so that the image lighting style is transferred. Although the process of transforming from B to A must exist in order to train the model, for practical needs, the output result only retains the result of the transformation from A to B, that is, fakeB, to achieve de-illumination of the image.

[0083] Based on any of the above embodiments, the sample illuminated image is determined based on the sample dark image in the sample image pair and a pre-constructed illuminated image pair, the sample dark image is obtained by scanning, and the illuminated image pair includes an all-white image and a corresponding illuminated image, and the illuminated image is obtained by adding illumination to the all-white image.

[0084] Specifically, considering that paired sample data is difficult to obtain directly, the embodiment of the present invention first obtains a large number of sample dark images by scanning with a scanner, then performs an illumination operation on each sample dark image to obtain a corresponding sample illuminated image, and forms a group of sample image pairs with the sample dark image and the sample illuminated image, and finally obtains a large number of sample image pairs for subsequent training of the de-illumination model. It can be understood that the image obtained by scanning with a scanner has uniform illumination, which can avoid illumination problems, so the image can be used as a sample dark image.

[0085] On this basis, considering the existing method of using image processing tools to directly add illumination to images, the illumination process is usually more complicated, resulting in a longer program running time, poor real-time performance, and is not suitable for batch processing. In addition, if errors occur during the illumination process, it is easy to cause errors between the illuminated image and the original image.

[0086] To address this problem, an embodiment of the present invention proposes a solution for adding illumination to scanned images, namely, using an image processing tool to illuminate the all-white image in advance to obtain a corresponding illuminated image, and combining the all-white image and the corresponding illuminated image to form an illumination image pair. When it is necessary to perform illumination on the sample dark image, only simple operations such as multiplication, division, and weighted summation need to be performed on the sample dark image and the illumination image pair to obtain the corresponding sample illuminated image. The whole process is convenient and fast, and is suitable for illumination processing of a large number of sample dark images. In addition, by not directly illuminating the sample dark image, errors between the generated sample illuminated image and the sample dark image can be avoided.

[0087] Here, the specific method for determining the sample lighted image can be to calculate the entire sample dark image and the illuminated image to obtain the sample lighted image, or to calculate several sub-regions in the sample dark image and the illuminated image to obtain the sample lighted image. The embodiment of the present invention does not make specific limitations on this.

[0088] Based on any of the above embodiments, Figure 3 is a flow chart of the method for determining the illumination image provided by the present invention, such as Figure 3 As shown, the illumination image is determined based on the following steps:

[0089] Step 310, constructing a three-dimensional model;

[0090] Step 320 , pasting the all-white image on the three-dimensional grid of the three-dimensional model, and using a virtual camera to take a photo of the pasted all-white image to obtain a lighting image.

[0091] Specifically, the illumination image can be obtained in the following manner: first, a three-dimensional model is constructed in an image processing tool, and then a full white image can be pasted on the three-dimensional grid of the three-dimensional model. After the full white image is pasted, a virtual camera in the three-dimensional model is used to take a photo of the full white image, thereby obtaining the illumination image corresponding to the full white image. Here, the image processing tool can be Blender software, and the full white image is an image with all pixel values ​​of 255.

[0092] Based on any of the above embodiments, Figure 4 FIG. 1 is a flow chart of a method for determining a sample light image provided by the present invention. Figure 4 As shown, the sample light image corresponding to any sample dark image is determined based on the following steps:

[0093] Step 410, determining a target image pair based on the plurality of sets of illumination image pairs;

[0094] Step 420 , determining the sample lighted image based on the ratio of the illuminated image to the all-white image in the target image pair and the sample dark image.

[0095] Specifically, before adding illumination to the sample dark image, multiple sets of illumination image pairs can be pre-constructed. For any sample dark image, a target image pair can be first determined based on the multiple sets of illumination image pairs, and then the target image pair is applied to perform an illumination operation on the sample dark image to obtain the corresponding sample illuminated image, which can be specifically achieved by the following formula:

[0096]

[0097] Among them, IL is the sample light image, I is the sample dark image, L is the illuminated image in the target image pair, and B is the all-white image in the target image pair.

[0098] Here, the specific method for determining the target image pair can be to select one of the multiple groups of illumination image pairs as the target image pair, or to select multiple groups from the multiple groups of illumination image pairs for fusion to obtain the final target image pair. The embodiment of the present invention does not make specific limitations on this.

[0099] Based on any of the above embodiments, the image is obtained by photographing the target document;

[0100] After step 120, the following steps are also included:

[0101] Perform text line detection on the matte image to obtain the text information of the target document.

[0102] Specifically, when the image to be de-illuminated is an image obtained by photographing the target document using a mobile phone, camera or other device, after the image is de-illuminated to obtain a matte image, text line detection can be performed on the matte image to obtain character detection results for each text line in the matte image, and then the text information of the corresponding target document can be obtained based on the character detection results.

[0103] It is understandable that, since the matte image is obtained after the de-illumination operation, the influence of illumination on the text line detection can be avoided, so that more accurate text information can be obtained. Here, the specific method of text line detection can be to perform text line detection on the matte image using an image segmentation method, or to perform text line detection on the matte image using a text detection model, which is not specifically limited in the embodiment of the present invention.

[0104] Based on any of the above embodiments, considering that the image illumination operation can usually be implemented using Blender software, the specific process is as follows: (1) A three-dimensional model of the real world is established in Blender software, and the three-dimensional model includes a light source, a virtual camera, and a scanned image; (2) Objects in the real world are three-dimensional, so the texture of the two-dimensional image needs to be pasted on the three-dimensional grid of the three-dimensional model, where the three-dimensional grid needs to collect the real target shape through a depth camera; (3) After the image is pasted on the three-dimensional grid, use the virtual camera in the three-dimensional model to take a photo, thereby obtaining a lighted image with illumination, but since the three-dimensional grid is generally not flat, the lighted image obtained by taking the photo is also uneven; (4) The lighted image is flattened according to the information of the three-dimensional grid, and finally a flattened lighted image is obtained.

[0105] As can be seen from the above, the existing process of adding illumination using Blender is very complicated, resulting in a long program running time, poor real-time performance, and is not suitable for batch processing. In addition, due to the acquisition error of the three-dimensional grid, the illuminated image may have errors with the original image after flattening. On this basis, the embodiment of the present invention proposes a new solution for scanning images and adding illumination. The solution is to first use Blender software as a tool to create an illumination library, which includes multiple groups of illumination image pairs. The method for making each group of illumination image pairs can be to first add illumination to the all-white image to obtain an illumination image, thereby forming an illumination image pair of all-white image + illumination image; then determine the target image pair based on the multiple groups of illumination image pairs in the illumination library, and multiply the scanned image by the ratio of the illumination image to the all-white image in the target image pair to obtain the illuminated image corresponding to the image.

[0106] Compared with the existing method of adding lighting using Blender, the method provided by the embodiment of the present invention has the following advantages: (1) Simple operation: You only need to operate the Blender software once, and then you only need to perform simple operations to obtain a lighted image with lighting; (2) Fast speed: The multiplication and division of images is much faster than the speed of mapping, taking pictures, and flattening; (3) Flexible: Different lighting images can be combined to obtain a lighted image under complex lighting scenarios; (4) No error: Since there is no flattening process, it is ensured that the lighted image corresponds to the original image one by one.

[0107] Based on any of the above embodiments, Figure 5 is a schematic diagram of the network structure of the de-illumination model provided by the present invention, such as Figure 5As shown in the figure, the de-illumination model consists of 4 convolutional layers (conv1-conv3, conv4), 9 residual module layers (resnet1-resnet9), and 2 transposed convolutional layers (deconv1, deconv2). The input and output of the de-illumination model are both three-channel color images of 256×256 pixels. After the input image is symmetrically padded, it is extracted through 3 convolutional layers (conv1-conv3) and then input into the residual module (resnet1-9). Each residual module layer contains two convolutional layers, and part of the input is directly added to the output at the end, which can realize the image conversion while protecting the integrity of the original image information. The feature vector of the image output by the residual module is restored to a low-level feature through the transposed convolutional layer (deconv1-2), and then converted into the output image by the last convolutional layer (conv4). It should be noted that InstanceNormalization is used instead of Batch Normalization after each convolutional layer to realize the normalization operation of a single image, thereby improving the quality of the generated image on the basis of accelerating model convergence and preventing gradient explosion. In addition, the network structure of the illumination model can refer to the network structure of the illumination model.

[0108] Figure 6 is a schematic diagram of the network structure of the first discriminant model provided by the present invention, such as Figure 6 As shown in the figure, the input of the first discriminant model is a 256×256 pixel image, which is used to determine whether the image is the original sample dark image or the image generated by the de-illumination model. Therefore, the output of the first discriminant model is a one-dimensional vector. When the first discriminant model determines that the image is the original sample dark image, the output label is 1, and if the image is determined to be the image generated by the de-illumination model, the output label is 0. The first discriminant model is a fully convolutional network composed of 5 convolutional layers (conv1-4, conv5). The input image is extracted through 4 convolutional layers (conv1-4), and then a one-dimensional vector is generated through the last convolutional layer (conv5) to realize the judgment function. Except for the first and last layers, Instance Normalization is also used to realize normalization. In addition, the network structure of the second discriminant model can refer to the network structure of the first discriminant model.

[0109] Based on the above embodiments, the present invention proposes a solution for adding illumination to scanned images and removing illumination from photos. The solution includes two parts: light image data production and a removal illumination model, forming a complete illumination and removal process.

[0110] The part of producing illuminated image data is to use the rendering tool Blender to render the all-white image, so as to produce multiple sets of illuminated image pairs. Then, for each scanned sample matte image, a set of target image pairs is randomly selected from the multiple sets of illuminated image pairs for illumination operation, so as to form a sample illuminated image. The sample matte image obtained by the original scan and the sample illuminated image constitute a sample image pair, and the multiple sets of sample image pairs thus constituted can be used as the training sample set of the de-illumination model. This part realizes the acquisition of the illuminated image set according to the scanned image set, and finally obtains the training sample set.

[0111] The de-illumination model includes the training stage and the application stage of the de-illumination model. In the training stage of the de-illumination model, the training sample set prepared in the above part is used to perform cyclic adversarial training on the de-illumination model, the illumination model, the first discriminant model and the second discriminant model, and finally obtain the trained de-illumination model. In the application stage of the de-illumination model, the input of the de-illumination model is the image obtained by shooting, that is, the illuminated image, and the output is the dark image after de-illumination.

[0112] Based on any of the above embodiments, considering the existing method of using image processing tools to directly illuminate the image, the illumination process is usually more complicated, resulting in a longer program running time, poor real-time performance, and is not suitable for batch processing. In addition, if an error occurs during the illumination process, it is easy to cause an error between the illuminated image and the original image.

[0113] To this end, an embodiment of the present invention provides a method for adding illumination. Figure 7 : is a schematic diagram of the process of adding illumination provided by the present invention, such as Figure 7 As shown, the method includes:

[0114] Step 710, determining the image to be illuminated;

[0115] Step 720, based on the image and the illumination image pair, determining a lighted image corresponding to the image;

[0116] The illumination image pair includes an all-white image and a corresponding illumination image, and the illumination image is obtained by adding illumination to the all-white image.

[0117] Specifically, considering that the existing method of using image processing tools to directly illuminate images has poor real-time performance, is not suitable for batch processing, and the image after illumination is prone to errors with the original image. In response to this problem, the embodiment of the present invention pre-illuminates the all-white image using an image processing tool to obtain a corresponding illuminated image, and the all-white image and the corresponding illuminated image form an illuminated image pair. On this basis, after determining the image to be illuminated, it is only necessary to perform simple operations such as multiplication, division, and weighted summation on the image and the illuminated image pair to obtain the corresponding illuminated image, thereby improving the real-time performance of illumination by not directly illuminating the image through the image processing tool, and avoiding errors between the generated illuminated image and the original image.

[0118] Here, the image to be illuminated is an image that needs to be illuminated, and can be obtained by scanning with a scanner. The specific method of determining the illuminated image can be to calculate the entire image to be illuminated and the illuminated image pair to obtain the illuminated image, or to calculate several sub-regions in the image to be illuminated and the illuminated image pair to obtain the illuminated image, which is not specifically limited in the embodiment of the present invention.

[0119] The method provided by the embodiment of the present invention determines the illuminated image corresponding to the image based on the image and a pre-constructed illumination image pair, thereby realizing illumination of the image. The whole process is convenient and fast, and is suitable for illumination processing of a large number of images. The image processing tool does not directly illuminate the image, thereby avoiding errors between the generated illuminated image and the original image.

[0120] Based on any of the above embodiments, the illumination image is determined based on the following steps:

[0121] Build 3D models;

[0122] The all-white image is pasted on the three-dimensional grid of the three-dimensional model, and a virtual camera is used to take a photo of the pasted all-white image to obtain a lighting image.

[0123] Specifically, the illumination image can be obtained in the following manner: first, a three-dimensional model is constructed in an image processing tool, and then a full white image can be pasted on the three-dimensional grid of the three-dimensional model. After the full white image is pasted, a virtual camera in the three-dimensional model is used to take a photo of the full white image, thereby obtaining the illumination image corresponding to the full white image. Here, the image processing tool can be Blender software, and the full white image is an image with all pixel values ​​of 255.

[0124] Based on any of the above embodiments, step 720 includes:

[0125] Based on the multiple sets of illumination image pairs, determining a target image pair;

[0126] Based on the ratio of the illuminated image to the all-white image in the target image pair and the image, the illuminated image is determined.

[0127] Specifically, before illuminating the image to be illuminated, multiple sets of illuminated image pairs can be pre-constructed. Then, a target image pair can be first determined based on the multiple sets of illuminated image pairs, and then the target image pair can be used to perform an illumination operation on the image to be illuminated to obtain a corresponding illuminated image, which can be specifically achieved by the following formula:

[0128]

[0129] Among them, IL is the illuminated image, I is the image to be illuminated, L is the illuminated image in the target image pair, and B is the all-white image in the target image pair.

[0130] Here, the specific method for determining the target image pair can be to select one of the multiple groups of illumination image pairs as the target image pair, or to select multiple groups from the multiple groups of illumination image pairs for fusion to obtain the final target image pair. The embodiment of the present invention does not make specific limitations on this.

[0131] The delighting device provided by the present invention is described below. The delighting device described below and the delighting method described above can be referenced to each other.

[0132] Based on any of the above embodiments, an embodiment of the present invention provides a light removal device. Figure 8 Schematic diagram of the structure of the light removal device provided by the present invention. Figure 8 As shown, the device comprises:

[0133] A determination module 810, used to determine an image to be de-illuminated;

[0134] A de-illumination module 820 is used to perform a de-illumination operation on the image based on a de-illumination model to obtain a matte image corresponding to the image;

[0135] The de-illumination model is obtained by cyclic training based on sample image pairs and combined with illumination model, with image consistency as a constraint. The sample image pairs include sample illuminated images and sample dark images.

[0136] Image consistency includes the consistency between the sample matte image and the predicted matte image, and / or the consistency between the sample illuminated image and the predicted illuminated image, where the predicted matte image is generated by a de-illumination model based on the sample illuminated image, and the predicted illuminated image is generated by an illumination-added model based on the sample matte image.

[0137] The device provided by the embodiment of the present invention obtains a de-lighting model by taking image consistency as a constraint and based on sample image pairs, jointly adding an illumination model for cyclic training, thereby ensuring the de-lighting effect of the de-lighting model. On this basis, the image is de-lighted based on the de-lighting model, thereby obtaining a more realistic and natural light-free image, ensuring that the information of the input image is not lost, and avoiding the problems of poor robustness of existing methods and loss of image color information.

[0138] Based on any of the above embodiments, the de-illumination model is specifically constrained by image consistency and is obtained by cyclic adversarial training of a joint illumination model, a first discriminant model and a second discriminant model based on sample image pairs. The first discriminant model is used to discriminate the authenticity of a predicted light-free image and a sample light-free image, and the second discriminant model is used to discriminate the authenticity of a predicted lighted image and a sample lighted image.

[0139] Based on any of the above embodiments, the loss function of the cyclic adversarial training is determined based on the image consistency loss function and the cyclic adversarial loss function;

[0140] The image consistency loss function is used to characterize the loss value of image consistency;

[0141] The cyclic adversarial loss function is used to characterize the classification loss value between the sample dark image and the predicted dark image, the classification loss value between the sample light image and the predicted light image, the loss value between the restored dark image and the sample dark image, and the loss value between the restored light image and the sample light image;

[0142] The restored matte image is generated by the de-illumination model based on the predicted illuminated image, and the restored illuminated image is generated by the added illumination model based on the predicted matte image.

[0143] Based on any of the above embodiments, the sample illuminated image is determined based on the sample dark image in the sample image pair and a pre-constructed illuminated image pair, the sample dark image is obtained by scanning, and the illuminated image pair includes an all-white image and a corresponding illuminated image, and the illuminated image is obtained by adding illumination to the all-white image.

[0144] Based on any of the above embodiments, the illumination image is determined based on the following steps:

[0145] Build 3D models;

[0146] The all-white image is pasted on the three-dimensional grid of the three-dimensional model, and a virtual camera is used to take a photo of the pasted all-white image to obtain a lighting image.

[0147] Based on any of the above embodiments, the sample lighted image corresponding to any sample dark image is determined based on the following steps:

[0148] Based on the multiple sets of illumination image pairs, determining a target image pair;

[0149] The illuminated image of the sample is determined based on the ratio of the illuminated image to the all-white image in the target image pair and the dark image of the sample.

[0150] Based on any of the above embodiments, the image is obtained by photographing the target document;

[0151] The device also includes a detection module, which is used to:

[0152] Perform text line detection on the matte image to obtain the text information of the target document.

[0153] Based on any of the above embodiments, an embodiment of the present invention provides a lighting device, the device comprising:

[0154] A determination module, used for determining an image to be illuminated;

[0155] An illumination module is provided for determining a lighted image corresponding to the image based on the image and the illumination image pair;

[0156] The illumination image pair includes an all-white image and a corresponding illumination image, and the illumination image is obtained by adding illumination to the all-white image.

[0157] The device provided by the embodiment of the present invention determines the illuminated image corresponding to the image based on the image and a pre-constructed illumination image pair, thereby realizing illumination of the image. The whole process is convenient and fast, and is suitable for illumination processing of a large number of images. The image processing tool does not directly illuminate the image, thereby avoiding errors between the generated illuminated image and the original image.

[0158] Based on any of the above embodiments, the illumination image is determined based on the following steps:

[0159] Build 3D models;

[0160] The all-white image is pasted on the three-dimensional grid of the three-dimensional model, and a virtual camera is used to take a photo of the pasted all-white image to obtain a lighting image.

[0161] Based on any of the above embodiments, the illumination module is specifically used for:

[0162] Based on the multiple sets of illumination image pairs, determining a target image pair;

[0163] Based on the ratio of the illuminated image to the all-white image in the target image pair and the image, the illuminated image is determined.

[0164] Fig. 9 An example of a physical structure diagram of an electronic device is shown in FIG. Fig. 9As shown, the electronic device may include: a processor 910, a communication interface 920, a memory 930 and a communication bus 940, wherein the processor 910, the communication interface 920 and the memory 930 communicate with each other through the communication bus 940. The processor 910 may call the logic instructions in the memory 930 to execute the de-illumination method, which includes: determining an image to be de-illuminated; performing a de-illumination operation on the image based on a de-illumination model to obtain a light-free image corresponding to the image; the de-illumination model is obtained by cyclic training based on sample image pairs and a combined illumination model with image consistency as a constraint, and the sample image pairs include sample illuminated images and sample light-free images; the image consistency includes the consistency of the sample light-free image and the predicted light-free image, and / or the consistency of the sample illuminated image and the predicted illuminated image, the predicted light-free image is generated by the de-illumination model based on the sample illuminated image, and the predicted illuminated image is generated by the illumination model based on the sample light-free image;

[0165] Alternatively, a lighting method is performed, the method comprising: determining an image to be illuminated; based on the image and a lighting image pair, determining a lighted image corresponding to the image; wherein the lighting image pair comprises an all-white image and a corresponding lighting image, and the lighting image is obtained by lighting the all-white image.

[0166] In addition, the logic instructions in the above-mentioned memory 930 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0167] On the other hand, the present invention further provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the de-illumination method provided by the above methods, which includes: determining an image to be de-illuminated; based on a de-illumination model, performing a de-illumination operation on the image to obtain a light-free image corresponding to the image; the de-illumination model is obtained by cyclic training based on sample image pairs and a combined illumination model with image consistency as a constraint, and the sample image pairs include sample illuminated images and sample light-free images; the image consistency includes consistency between the sample light-free image and the predicted light-free image, and / or consistency between the sample illuminated image and the predicted illuminated image, the predicted light-free image is generated by the de-illumination model based on the sample illuminated image, and the predicted illuminated image is generated by the illumination model based on the sample light-free image;

[0168] Alternatively, the illumination method provided by the above methods is executed, the method comprising: determining an image to be illuminated; based on the image and an illumination image pair, determining a lighted image corresponding to the image; wherein the illumination image pair comprises an all-white image and a corresponding illumination image, and the illumination image is obtained after illumination is added to the all-white image.

[0169] On the other hand, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the processor executes the de-illumination method provided by the above methods, the method comprising: determining an image to be de-illuminated; performing a de-illumination operation on the image based on a de-illumination model to obtain a light-free image corresponding to the image; the de-illumination model is obtained by cyclic training based on sample image pairs and a combined illumination model with image consistency as a constraint, the sample image pairs comprising a sample illuminated image and a sample light-free image; the image consistency comprises the consistency between the sample light-free image and the predicted light-free image, and / or the consistency between the sample illuminated image and the predicted illuminated image, the predicted light-free image is generated by the de-illumination model based on the sample illuminated image, and the predicted illuminated image is generated by the illumination model based on the sample light-free image;

[0170] Alternatively, the illumination method provided by the above methods is executed, the method comprising: determining an image to be illuminated; based on the image and an illumination image pair, determining a lighted image corresponding to the image; wherein the illumination image pair comprises an all-white image and a corresponding illumination image, and the illumination image is obtained after illumination is added to the all-white image.

[0171] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0172] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0173] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been 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 make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method of removing light, It is characterized in that include: Determine the image to be de-illuminated; Based on the de-illumination model, performing a de-illumination operation on the image to obtain a matte image corresponding to the image; The de-illumination model is obtained by cyclic training based on sample image pairs and a joint illumination model with image consistency as a constraint, wherein the sample image pairs include a sample illuminated image and a sample dark image, and the sample illuminated image and the sample dark image are paired images representing the same target; the loss function of the cyclic training is determined based on an image consistency loss function, and the image consistency loss function is used to characterize the loss value of the image consistency; The image consistency includes consistency between the sample dark image and the predicted dark image, and / or consistency between the sample illuminated image and the predicted illuminated image, wherein the predicted dark image is generated by the de-illumination model based on the sample illuminated image, and the predicted illuminated image is generated by the illumination-added model based on the sample dark image; The sample lighted image is determined based on a sample dark image in the sample image pair and a pre-constructed illuminated image pair, wherein the sample dark image is obtained by scanning, and the illuminated image pair includes an all-white image and a corresponding illuminated image, wherein the illuminated image is obtained by illuminating the all-white image; The illumination image is determined based on the following steps: Build 3D models; Pasting the all-white image on the three-dimensional grid of the three-dimensional model, and taking a photo of the pasted all-white image using a virtual camera to obtain the illumination image; The sample light image corresponding to any sample matte image is determined based on the following steps: Based on the multiple sets of illumination image pairs, determining a target image pair; The sample illuminated image is determined based on the ratio of the illuminated image to the all-white image in the target image pair and any one of the sample dark images.

2. The method for removing light according to claim 1, It is characterized in that The de-illumination model is specifically constrained by the image consistency and is obtained by cyclic adversarial training based on the sample image pair and the combined illumination model, the first discriminant model and the second discriminant model. The first discriminant model is used to discriminate the authenticity of the predicted light-free image and the sample light-free image, and the second discriminant model is used to discriminate the authenticity of the predicted lighted image and the sample lighted image.

3. The method for removing light according to claim 2, It is characterized in that The loss function of the cyclic adversarial training is determined based on the image consistency loss function and the cyclic adversarial loss function; The cyclic adversarial loss function is used to characterize the classification loss value of the sample dark image and the predicted dark image, the classification loss value of the sample light image and the predicted light image, the loss value between the restored dark image and the sample dark image, and the loss value between the restored light image and the sample light image; The restored matte image is generated by the de-illumination model based on the predicted illuminated image, and the restored illuminated image is generated by the illumination-added model based on the predicted matte image.

4. The method for removing light according to any one of claims 1 to 3, It is characterized in that The image is obtained by photographing the target document; The step of performing a delighting operation on the image based on the delighting model to obtain a matte image corresponding to the image further includes: Text line detection is performed on the matte image to obtain text information of the target document.

5. A light removal device, It is characterized in that include: A determination module, used for determining an image to be de-illuminated; A delighting module, used for performing a delighting operation on the image based on a delighting model to obtain a matte image corresponding to the image; The de-illumination model is obtained by cyclic training based on sample image pairs and a joint illumination model with image consistency as a constraint, wherein the sample image pairs include a sample illuminated image and a sample dark image, and the sample illuminated image and the sample dark image are paired images representing the same target; the loss function of the cyclic training is determined based on an image consistency loss function, and the image consistency loss function is used to characterize the loss value of the image consistency; The image consistency includes consistency between the sample dark image and the predicted dark image, and / or consistency between the sample illuminated image and the predicted illuminated image, wherein the predicted dark image is generated by the de-illumination model based on the sample illuminated image, and the predicted illuminated image is generated by the illumination-added model based on the sample dark image; The sample lighted image is determined based on a sample dark image in the sample image pair and a pre-constructed illuminated image pair, wherein the sample dark image is obtained by scanning, and the illuminated image pair includes an all-white image and a corresponding illuminated image, wherein the illuminated image is obtained by illuminating the all-white image; The illumination image is determined based on the following steps: Build 3D models; Pasting the all-white image on the three-dimensional grid of the three-dimensional model, and taking a photo of the pasted all-white image using a virtual camera to obtain the illumination image; The sample light image corresponding to any sample matte image is determined based on the following steps: Based on the multiple sets of illumination image pairs, determining a target image pair; The sample illuminated image is determined based on the ratio of the illuminated image to the all-white image in the target image pair and any one of the sample dark images.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the de-illumination method according to any one of claims 1 to 4 are implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the de-illumination method according to any one of claims 1 to 4 are implemented.