Image relighting method based on inverse rendering and controllable image generation of illumination
By using a method based on inverse rendering and controllable lighting image generation, and by adjusting lighting parameters using a controllable lighting geometric perception network, the problem of time-consuming and laborious image lighting adjustment in traditional methods is solved, and efficient lighting unification and image enhancement are achieved.
Patent Information
- Application Number
- CN202311434219.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-31
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-10-31
AI Technical Summary
Traditional methods for adjusting image lighting parameters require specialized skills, are time-consuming and labor-intensive, and are inefficient, making it difficult to achieve simple and efficient lighting uniformity.
A method based on inverse rendering and controllable lighting image generation is adopted. By using a controllable lighting geometric perception network, the lighting parameters are adjusted using parameters such as the lighting direction and color temperature of the target image, and the image is re-rendered.
It simplifies the tedious manual editing process, significantly reduces labor costs, improves image enhancement efficiency, and achieves simple and efficient lighting uniformity.
Smart Images

Figure CN117496041B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and more specifically, relates to a method for image relighting based on inverse rendering and controlled lighting image generation. Background Technology
[0002] From 2000 to 2003, before digital photography became widespread, image editing was mainly used in graphic design. After 2004, with the increasing popularity of digital cameras, especially the decreasing price of SLR cameras, image editing for photo processing became more and more common. Tutorials and textbooks became readily available online and in bookstores, and various processing techniques emerged. After 2008, with the advent of smartphones, especially camera phones, it became easier to publish photos online. We could take and upload photos anytime, anywhere, and at this point, relighting photos became widespread.
[0003] To align the lighting direction of one image with that of another, and to minimize incongruity and achieve a more realistic result, you must consider perspective, proportions, lighting conditions, the tones and colors of the subject and background, as well as contrast and sharpness when editing. Camera compatibility is also crucial; if the camera position or lens parameters are incorrect, adjustments are nearly impossible. Furthermore, the perspective relationships between the materials must be reasonable, the brightness and shadows must be accurate, and the ambient color, inherent color, and light source color must be harmoniously matched.
[0004] Specifically, the first thing to consider is perspective. If the perspective is too wrong, any adjustments will result in a strong sense of disharmony. Therefore, the selected material should only have a slight, not overly obvious, misalignment. Secondly, determine the main direction of the light, clearly identifying where the light is coming from and which parts of the object are bright and which are dark. Simultaneously, based on the direction of the light, determine the shape of the shadows and the transition of their edges. When adjusting the shadows, pay attention to adjusting the color and brightness, adjusting the color of the bright areas according to the color of the light. Finally, apply filters again to unify the overall tone and brightness, and sharpen the image.
[0005] Therefore, changing the lighting parameters of an image requires highly specialized skills, and traditional methods are time-consuming, labor-intensive, and inefficient. Summary of the Invention
[0006] The purpose of this invention is to overcome the shortcomings of existing technologies and provide an image relighting method based on inverse rendering and controllable lighting image generation. The method involves inputting an image into a controllable lighting geometry-aware network, using parameters such as the target image's lighting direction and intensity to adjust the image's lighting parameters, and then re-rendering and relighting to obtain a new image. This method is simple and efficient, avoiding the tedious manual image editing process, significantly reducing labor costs, and improving the efficiency of image enhancement.
[0007] To achieve the above-mentioned objectives, the present invention provides a method for image relighting based on inverse rendering and lighting-controllable image generation, characterized by comprising the following steps:
[0008] (1) Image acquisition;
[0009] In the same scene, use a camera to capture color images of the same target under different light intensities and directions, and simultaneously capture depth images under the same conditions;
[0010] Let P be the color image acquired under the i-th light intensity and j-th light direction. ij The corresponding depth image is Q. ij i = 1, 2, ..., N, j = 1, 2, ..., M, where N is the maximum value of the light intensity level number and M is the maximum value of the light direction number;
[0011] (2) Image preprocessing;
[0012] (2.1) Normalize each depth image so that the pixel value of each pixel in the depth image is between 0 and 1;
[0013] (2.2) For each normalized depth image, first transform the coordinates of each pixel to the camera coordinate system to obtain a 3D image, and then convert the 3D image into a normal map T. ij ;
[0014] (2.3) P for each color image ij With the corresponding depth image Q ij Normal diagram T ij As a set of training data, it constitutes the training dataset;
[0015] (3) Construct a geometry perception network based on inverse rendering and image controllable lighting;
[0016] The network has three layers, labeled U1, U2, and U3 from top to bottom. Each layer contains an encoder, a decoder, and a bottleneck structure that bridges the encoder and decoder. The encoder downsamples the features twice, and the decoder upsamples the features twice. The output of U3 is fed back to the input of U2, the output of U2 is fed back to the input of U1, and the output of U1 is used as the network's prediction result.
[0017] The bottleneck structure consists of four interconnected lighting geometric texture feature extraction blocks, each of which includes a geometric texture feature extraction block and a lighting feature extraction block.
[0018] Among them, the geometric texture feature extraction block and the illumination feature extraction block both take the encoder output as input and are used to extract the texture features and illumination features of the image, respectively;
[0019] (4) Training a geometric perception network based on inverse rendering and image controllable lighting;
[0020] (4.1) Randomly select a set of training data from the training dataset, and extract the depth map Q from the training data. ij and normal diagram T ij First, features are extracted separately using an external encoder. Then, the extracted features are fused to obtain the output feature Z. ij ;
[0021] (4.2) Take the color image P from the training data ij The input is fed into the encoder of the U3 layer, and the encoder processes the color image P. ij Perform downsampling twice to extract downsampling features. Then With Z ij After concatenation, the feature information Fin is obtained. ij ;
[0022] (4.3) Extract texture and lighting features through the bottleneck structure of the U3 layer;
[0023] (4.3.1) Feature Information Fin ij After being input into the illumination feature extraction block, the color image P is approximated using the spherical harmonic illumination method. ij Corresponding illumination feature information G ij :
[0024]
[0025] Among them, c λ Y represents the coefficient of the λ-th spherical harmonic basis. λ It is the λth spherical harmonic basis, and ⊙ denotes the dot product;
[0026] (4.3.2) Given a color image P ij Corresponding light source property Desc ij and characteristic bias ij Then calculate the color image P ij Corresponding lighting conditions Rori ij ;
[0027] Rori ij =G ij +Desc ij +Bias ij
[0028] (4.3.3) Regarding the lighting conditions, Rori ij Perform a re-render to obtain the corresponding rendering parameters Re. ij :
[0029]
[0030] (4.3.4) Based on the rendering parameters Re ij and feature information Fin ij Extracting illumination features F ij ;
[0031] F ij =Re ij +Fin ij
[0032] (4.4) Feature Information Fin ij After being input into the geometric texture feature extraction block, it is processed by the texture generator G. t Extracting texture features
[0033]
[0034] (4.5) The illumination feature F ij With texture features The concatenated feature output F serves as the bottleneck module's feature output. ij (out):
[0035]
[0036] (4.6) Output the feature F of the bottleneck block ij (out) is used as the input to the decoder of the U3 layer, and then the decoder outputs the feature F. ij (out) is upsampled twice to obtain the relighting rendering map U3(out) output by the U3 layer;
[0037] (4.7) Feed the re-illumination rendering map U3(out) output from layer U3 back to the encoder of layer U2, and then process the re-illumination rendering map U3(out) and the color image P through the encoder of layer U2 respectively. ij Perform downsampling twice to extract downsampling features. and Then and Z ij After concatenation, the feature information Fin is obtained. ij Then repeat steps (4.3) to (4.6) to obtain the relighting rendering map U2(out) output by layer U2;
[0038] (4.8) Feed the re-illumination rendering map U2(out) output from layer U2 back to the encoder of U1, and then process the re-illumination rendering map U2(out) and the color image P through the encoder of layer U1 respectively. ij Perform downsampling twice to extract downsampling features. and Then and Z ij After concatenation, the feature information Fin is obtained. ij Then repeat steps (4.3) to (4.6) to obtain the relighting rendering map U1(out) output by layer U1, and use it as the final output of the network;
[0039] (4.9) Calculate the loss function value:
[0040] L SSIM (φ(U1(out)),φ(P ij ))=1-SSIM(φ(U1(out)),φ(P ij ))
[0041] Where φ() represents converting a color image to a grayscale image, and SSIM() represents calculating the structural similarity between two images;
[0042] (4.10) Repeatedly train the geometric perception network based on inverse rendering and image controllable lighting according to steps (4.1) to (4.9) until the loss function value of the network converges, thereby obtaining the trained geometric perception network based on inverse rendering and image controllable lighting.
[0043] (5) Image relighting;
[0044] A color image P to be detected, along with its corresponding depth image Q and normal map T, is input into a trained geometric perception network based on inverse rendering and image-controlled illumination, thereby outputting the corresponding re-illumination rendering map.
[0045] The objective of this invention is achieved as follows:
[0046] This invention discloses a method for image relighting based on inverse rendering and image-controlled illumination generation. By using an image-controlled illumination geometric perception network (ECN) based on inverse rendering, the method extracts illumination parameters such as illumination direction and color temperature, as well as geometric texture information, from an input image using inverse rendering. Another image is then input into the ECN, and its illumination parameters are adjusted using the parameters from the first image. The image is then re-rendered and relit to obtain a new image. This method is simple and efficient, avoiding tedious manual image editing, significantly reducing labor costs, and improving the efficiency of image enhancement. Attached Figure Description
[0047] Figure 1 This invention provides a method for image relighting based on inverse rendering and controllable lighting image generation.
[0048] Figure 2 This is a schematic diagram of the training images;
[0049] Figure 3 It is a diagram of a geometry-aware network structure based on inverse rendering and image-controlled lighting.
[0050] Figure 4 This is a schematic diagram of the block structure for extracting lighting geometric texture features;
[0051] Figure 5 It is a relighting rendering that does not change the light intensity and light direction;
[0052] Figure 6 It is a heavily lit rendering that changes the light intensity and direction. Detailed Implementation
[0053] The specific embodiments of the present invention will now be described with reference to the accompanying drawings to enable those skilled in the art to better understand the invention. It should be particularly noted that in the following description, detailed descriptions of known functions and designs that might obscure the main content of the invention will be omitted here.
[0054] Example
[0055] Figure 1 This is a flowchart of an image relighting method based on inverse rendering and controllable lighting image generation according to the present invention.
[0056] In this embodiment, as Figure 1 As shown, the present invention provides a method for image relighting based on inverse rendering and lighting-controllable image generation, comprising the following steps:
[0057] S1, Image Acquisition;
[0058] In the same scene, use a camera to capture color images of the same target under different light intensities and directions, and simultaneously capture depth images under the same conditions;
[0059] Let P be the color image acquired under the i-th light intensity and j-th light direction. ij The corresponding depth image is Q. ij i = 1, 2, ..., N, j = 1, 2, ..., M, where N is the maximum value of the light intensity level number and M is the maximum value of the light direction number;
[0060] In this embodiment, an Intel RealSense Depth Camera D435i with a resolution of 1280×720 is selected. The depth map exposure time is set to 0.5 seconds, and the ISO sensitivity is set to 500. Additionally, five light intensities are set: 2500K, 3500K, 4500K, 5500K, and 6500K. The light directions are: east, southeast, northeast, south, southwest, west, northwest, and north.
[0061] S2, Image preprocessing;
[0062] S2.1 Normalize each depth image so that the pixel value of each pixel in the depth image is between 0 and 1;
[0063] S2.2 For each normalized depth image, first transform the coordinates of each pixel to the camera coordinate system to obtain a 3D image, and then convert the 3D image into a normal map T. ij ;
[0064] S2.3, transfer each color image P ij With the corresponding depth image Q ij Normal diagram T ij As a set of training data, it constitutes the training dataset;
[0065] In this embodiment, the color image P ij With the corresponding depth image Q ij and normal diagram T ij like Figure 2 As shown in (a) to (c);
[0066] S3. Construct a geometry-aware network based on inverse rendering and image-controllable lighting;
[0067] In this embodiment, as Figure 3As shown, the overall network structure consists of three layers, denoted as U1, U2, and U3 from top to bottom. Each layer contains an encoder, a decoder, and a bottleneck structure that bridges the encoder and decoder. The encoder performs downsampling on the features twice, and the decoder performs upsampling on the features twice. The output of U3 is fed back to the input of U2, the output of U2 is fed back to the input of U1, and the output of U1 is used as the prediction result of the network.
[0068] The bottleneck structure consists of four interconnected lighting geometric texture feature extraction blocks, such as... Figure 4 As shown, the lighting geometric texture feature extraction block includes a geometric texture feature extraction block and a lighting feature extraction block;
[0069] Among them, the geometric texture feature extraction block and the illumination feature extraction block both take the encoder output as input and are used to extract the texture features and illumination features of the image, respectively;
[0070] S4. Training a geometry-aware network based on inverse rendering and image-controlled lighting;
[0071] S4.1. Randomly select a set of training data from the training dataset, and extract the depth map Q from the training data. ij and normal diagram T ij First, features are extracted separately using an external encoder. Then, the extracted features are fused to obtain the output feature Z. ij ;
[0072] S4.2, Take the color image P from the training data ij The input is fed into the encoder of the U3 layer, and the encoder processes the color image P. ij Perform downsampling twice to extract downsampling features. Then With Z ij After concatenation, the feature information Fin is obtained. ij ;
[0073] S4.3 Extract texture and lighting features through the bottleneck structure of the U3 layer;
[0074] S4.3.1, Feature Information Fin ij After being input into the illumination feature extraction block, the color image P is approximated using the spherical harmonic illumination method. ij Corresponding illumination feature information G ij :
[0075]
[0076] Among them, c λ Y represents the coefficient of the λ-th spherical harmonic basis. λ It is the λth spherical harmonic basis, and ⊙ denotes the dot product;
[0077] S4.3.2, Given a color image P ij Corresponding light source property Desc ij and characteristic bias ij Then calculate the color image P ij Corresponding lighting conditions Rori ij ;
[0078] Rori ij =G ij +Desc ij +Bias ij
[0079] S4.3.3, Regarding the illumination conditions Rori ij Perform a re-render to obtain the corresponding rendering parameters Re. ij :
[0080]
[0081] S4.3.4, Based on rendering parameters Re ij and feature information Fin ij Extracting illumination features F ij ;
[0082] F ij =Re ij +Fin ij
[0083] S4.4, Feature Information Fin ij After being input into the geometric texture feature extraction block, it is processed by the texture generator G. t Extracting texture features
[0084]
[0085] S4.5, Illumination characteristics F ij With texture features The concatenated feature output F serves as the bottleneck module's feature output. ij (out):
[0086]
[0087] S4.6 Output the characteristics of the bottleneck block F ij (out) is used as the input to the decoder of the U3 layer, and then the decoder outputs the feature F. ij (out) is upsampled twice to obtain the relighting rendering map U3(out) output by the U3 layer;
[0088] S4.7. Feed the re-illumination rendering image U3(out) output from layer U3 back to the encoder of layer U2. Then, the encoder of layer U2 processes the re-illumination rendering image U3(out) and the color image P respectively. ij Perform downsampling twice to extract downsampling features. and Then and Z ij After concatenation, the feature information Fin is obtained. ij Then repeat steps S4.3 to S4.6 to obtain the relighting rendering map U2(out) output by layer U2;
[0089] S4.8. Feed the re-illumination rendering image U2(out) output from layer U2 back to the encoder of U1, and then process the re-illumination rendering image U2(out) and the color image P through the encoder of layer U1 respectively. ij Perform downsampling twice to extract downsampling features. and Then and Z ij After concatenation, the feature information Fin is obtained. ij Then repeat steps S4.3 to S4.6 to obtain the relighting rendering map U1(out) output by layer U1, and use it as the final output of the network.
[0090] S4.9 Calculate the loss function value:
[0091] L SSIM (φ(U1(out)),φ(P ij ))=1-SSIM(φ(U1(out)),φ(P ij ))
[0092] Where φ() represents converting a color image to a grayscale image, and SSIM() represents calculating the structural similarity between two images;
[0093] In this embodiment, the heavily illuminated rendering image U1(out) and the color image P are first... ij Convert to grayscale, then calculate the pixel mean, standard deviation, and covariance respectively;
[0094] The pixel mean of the heavily illuminated rendering map U1(out) is: Color image P ij The average pixel value is:
[0095] The pixel standard deviation of the heavily illuminated render image U1(out) is: Color image P ij The pixel standard deviation is:
[0096] Heavy lighting rendering image U1(out) and color image P ij The pixel covariance is:
[0097] Where, ∑I o ∑I represents the sum of the pixel values of each pixel in U1(out). g P represents ij The sum of pixel values of each pixel in the image, where N is the sum of the pixel values of the relit rendering image U1(out) or the color image P. ij The number of pixels in the middle;
[0098] Structural similarity (SSIM) = Contrast similarity × Structural similarity;
[0099] Contrast similarity = (2 × σ) o ×σ g ) / (σ o 2 +σ g 2 );
[0100] S4.10. Repeatedly train the geometric perception network based on inverse rendering and image controllable lighting according to steps S4.1 to S4.9 until the loss function value of the network converges, thereby obtaining the trained geometric perception network based on inverse rendering and image controllable lighting.
[0101] S5, Image Relighting;
[0102] A color image P to be detected, along with its corresponding depth image Q and normal map T, is input into a trained geometric perception network based on inverse rendering and image-controlled illumination, thereby outputting the corresponding re-illumination rendering map.
[0103] In this embodiment, we input a color image with an illumination intensity of 4500K and an illumination direction of southwest (SW), along with its corresponding depth image and normal map. After our network re-renders the image, it outputs a rendered image with an illumination intensity of 4500K and an illumination direction of southwest (SW), as shown below. Figure 5 As shown, the rendered image on the right is clearer than the input image on the left; furthermore, we can adjust the network weight parameters to output a rendered image with a light intensity of 2500K and a light direction of east (E), as shown. Figure 6 As shown, this invention can not only increase the clarity of images, but also change the illumination direction and intensity of the input image, which plays an important role in generating new images for data augmentation.
[0104] Although the illustrative specific embodiments of the present invention have been described above to enable those skilled in the art to understand the invention, it should be understood that the invention is not limited to the scope of the specific embodiments. For those skilled in the art, various changes are obvious as long as they are within the spirit and scope of the invention as defined and determined by the appended claims, and all inventions utilizing the concept of the present invention are protected.
Claims
1. A method for image relighting based on inverse rendering and illumination-controllable image generation, characterized in that, Includes the following steps: (1) Image acquisition; In the same scene, use a camera to capture color images of the same target under different light intensities and directions, and simultaneously capture depth images under the same conditions; Let P be the color image acquired under the i-th light intensity and j-th light direction. ij The corresponding depth image is Q. ij i = 1, 2, ..., N, j = 1, 2, ..., M, where N is the maximum value of the light intensity level number and M is the maximum value of the light direction number; (2) Image preprocessing; (2.1) Normalize each depth image so that the pixel value of each pixel in the depth image is between 0 and 1; (2.2) For each normalized depth image, first transform the coordinates of each pixel to the camera coordinate system to obtain a 3D image, and then convert the 3D image into a normal map T. ij ; ( 2.3) P for each color image ij With the corresponding depth image Q ij Normal diagram T ij As a set of training data, it constitutes the training dataset; (3) Construct a geometry perception network based on inverse rendering and image controllable lighting; The network has three layers, labeled U1, U2, and U3 from top to bottom. Each layer contains an encoder, a decoder, and a bottleneck structure that bridges the encoder and decoder. The encoder downsamples the features twice, and the decoder upsamples the features twice. The output of U3 is fed back to the input of U2, the output of U2 is fed back to the input of U1, and the output of U1 is used as the network's prediction result. The bottleneck structure consists of four interconnected lighting geometric texture feature extraction blocks, each of which includes a geometric texture feature extraction block and a lighting feature extraction block. Among them, the geometric texture feature extraction block and the illumination feature extraction block both take the encoder output as input and are used to extract the texture features and illumination features of the image, respectively; (4) Training a geometric perception network based on inverse rendering and image controllable lighting; (4.1) Randomly select a set of training data from the training dataset, and extract the depth map Q from the training data. ij and normal diagram T ij First, features are extracted separately using an external encoder. Then, the extracted features are fused to obtain the output feature Z. ij ; (4.2) Take the color image P from the training data ij The input is fed into the encoder of the U3 layer, and the encoder processes the color image P. ij Perform downsampling twice to extract downsampling features. Then With Z ij After splicing, the feature information Fin is obtained ij ; (4.3) Extract texture and lighting features through the bottleneck structure of the U3 layer; (4.3.1) Feature Information Fin ij After being input into the illumination feature extraction block, the color image P is approximated using the spherical harmonic illumination method. ij Corresponding illumination feature information G ij : Among them, c λ Y represents the coefficient of the λ-th spherical harmonic basis. λ It is the λth spherical harmonic basis, and ⊙ denotes the dot product; (4.3.2) Given a color image P ij Corresponding light source property Desc ij and characteristic bias ij Then calculate the color image P ij Corresponding lighting conditions Rori ij ; Rain ij =G ij +Desc ij +Bias ij (4.3.3) Regarding the lighting conditions, Rori ij Perform a re-render to obtain the corresponding rendering parameters Re. ij : (4.3.4) Based on the rendering parameters Re ij and feature information Fin ij Extracting illumination features F ij ; F ij =Re ij +Fin ij (4.4) Feature Information Fin ij After being input into the geometric texture feature extraction block, it is processed by the texture generator G. t Extracting texture features (4.5) The illumination feature F ij With texture features The concatenated feature output F serves as the bottleneck module's feature output. ij (out): (4.6) Output the feature F of the bottleneck block ij (out) is used as the input to the decoder of the U3 layer, and then the decoder outputs the feature F. ij (out) is upsampled twice to obtain the relighting rendering map U3(out) output by the U3 layer; (4.7) Feed the re-illumination rendering map U3(out) output from layer U3 back to the encoder of U2, and then process the re-illumination rendering map U3(out) and the color image P through the encoder of layer U2 respectively. ij Perform downsampling twice to extract downsampling features. and Then and Z ij After splicing, the feature information Fin is obtained ij Then repeat steps (4.3) to (4.6) to obtain the relighting rendering map U2(out) output by the U2 layer; (4.8) Feed the re-illumination rendering map U2(out) output from layer U2 back to the encoder of U1, and then process the re-illumination rendering map U2(out) and the color image P through the encoder of layer U1 respectively. ij Perform downsampling twice to extract downsampling features. and Then and Z ij After splicing, the feature information Fin is obtained ij Then repeat steps (4.3) to (4.6) to obtain the relighting rendering map U1(out) output by layer U1, and use it as the final output of the network; (4.9) Calculate the loss function value: L SSIM (φ(U1(out)),φ(P ij ))=1-SSIM(φ(U1(out)),φ(P ij )) Where φ() represents converting a color image to a grayscale image, and SSIM() represents calculating the structural similarity between two images; (4.10) Repeatedly train the geometric perception network based on inverse rendering and image controllable lighting according to steps (4.1) to (4.9) until the loss function value of the network converges, thereby obtaining the trained geometric perception network based on inverse rendering and image controllable lighting. (5) Image relighting; A color image P to be detected, along with its corresponding depth image Q and normal map T, is input into a trained geometric perception network based on inverse rendering and image-controlled illumination, thereby outputting the corresponding re-illumination rendering map.
