Method and device for processing human body lighting rendering based on normal map

Through the normal map-based processing method, Opengl simulates the lighting effect, the problem that the mobile terminal cannot generate portrait lighting effect in real time is solved, and multiple light sources and light parameter editing is realized, reducing resource consumption.

CN114187398BActive Publication Date: 2025-06-27GUANGZHOU GUANGZHUIYUAN INFORMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111532414.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-15
Publication Date
2025-06-27
Estimated Expiration
2041-12-15

AI Technical Summary

Technical Problem

The prior art cannot generate portrait lighting effects in real time on the mobile terminal, and cannot adjust the parameters of light, such as the color and direction of light.

Method used

Using a normal map-based processing method, the actual lighting effect is simulated through the Opengl application, normal map is generated and rendered, and combining the human mask image and background lighting effect to realize the editing of multiple light sources and light parameters.

Benefits of technology

Real-time lighting effect under multiple light sources is realized on the mobile terminal, supporting adjustment of light color, direction and other parameters, reducing resource consumption and no neural network processing is required.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114187398B_ABST
    Figure CN114187398B_ABST
Patent Text Reader

Abstract

The present invention relates to a processing method and device for human body lighting rendering based on normal mapping. The method includes obtaining an original image, obtaining a human body mask map according to the original image to obtain a to-be-processed human body mask map; generating a normal map according to the original image; using an Opengl application program to render the normal map to obtain a rendered image, mixing the to-be-processed human body mask map with the first rendered image to obtain a rendered portrait image; rendering the background of the original image to obtain a background lighting effect diagram; and mixing the rendered portrait image with the background lighting effect diagram to output an image mixing result. By simulating the actual lighting effect through opengl, the present invention provides diverse editing capabilities such as supporting multiple light sources, adjusting the color of light, the direction of light, the type of light, etc. while maintaining support for real-time editing, making the simulated lighting have a relatively realistic lighting effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image processing, and particularly relates to a processing method and device for human body lighting rendering based on normal map. Background Art

[0002] With the development of the existing technology, there are more and more functions for processing human body pictures nowadays, such as acne removal, skin beautification, body shaping, etc., which can beautify the photos. However, for the post-processing of photos due to poor shooting light, there are few corresponding solutions in the current market. The existing methods generally perform simulated lighting processing on a single picture, basically through the machine learning method of neural network. After a large number of portrait lighting picture trainings, the position of the light source is calculated based on the input picture, and the corresponding lighting result is generated. The advantage of this kind of implementation is that as long as the data set is large enough, a sufficiently realistic effect can be simulated. But it has the following two disadvantages: First, it requires a large amount of resources for training. For example, Google's portrait lighting effect uses 64 different cameras, 331 LED light sources, and nearly 100 people to help the neural network train, with a relatively high cost. Second, the trained data set is relatively large, dozens of megabytes, resulting in it being unable to be directly placed on the mobile phone side and needing to be placed on the server side for interaction. Therefore, it cannot meet the millisecond-level processing requirements, and due to its training model, it cannot provide multi-light source and multi-color lighting effects.

[0003] In summary, the existing portrait lighting is all through the machine learning method of neural network. After a large amount of data learning, a relatively good re-lighting effect can be returned. However, the method of using machine learning for human body lighting cannot be directly placed on the mobile side and needs to be deployed on the server side, resulting in the inability to generate real-time lighting effects on the mobile side and the inability to adjust light parameters, such as the color and direction of the light. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to overcome the deficiencies of the existing technology and provide a processing method and device for human body lighting rendering based on normal map, so as to solve the problems in the existing technology that real-time lighting effects cannot be generated on the mobile side and the light parameters, such as the color and direction of the light, cannot be adjusted.

[0005] To achieve the above purpose, the present invention adopts the following technical scheme: A processing method for human body lighting rendering based on normal map, including:

[0006] Obtain the original image, obtain the human body mask map according to the original image, and preprocess the human body mask map to obtain the to-be-processed human body mask map;

[0007] Generate a normal map based on the original image; wherein, each pixel of the normal map corresponds to the normal vector of each pixel in the original image;

[0008] Use an Opengl application to render the normal map to obtain a rendered image, and mix the to-be-processed human body mask image with the first rendered image to obtain a rendered portrait image;

[0009] Render the background of the original image to obtain a background lighting effect diagram;

[0010] Mix the rendered portrait image with the background lighting effect diagram and output the image mixing result.

[0011] Further, the obtaining of the human body mask image according to the original image includes:

[0012] Input the original image into a pre-trained human body recognition model to obtain a human body mask image.

[0013] Further, the preprocessing of the human body mask image includes:

[0014] Perform anti-aliasing processing on the edge of the human body mask image, and determine the image obtained after the anti-aliasing processing as the to-be-processed image.

[0015] Further, the generating of the normal map according to the original image includes:

[0016] Obtain the pixel points around the current pixel in the original image;

[0017] Generate two mutually perpendicular vectors through the surrounding pixel points; wherein, both of the two vectors are perpendicular to the normal, and generate a normal according to the orthogonal method.

[0018] Further, render the normal map based on the Phong illumination reflection model to obtain a rendered image.

[0019] Further, the rendering of the normal map based on the Phong illumination reflection model to obtain a rendered image includes:

[0020] Calculate the diffuse light value of each pixel of the normal map under a single or multiple light sources based on the Phong illumination reflection model to obtain a processed image;

[0021] Linearly lighten and mix the processed image with the color of the original image to obtain a rendered image.

[0022] Further, the rendering of the background of the original image to obtain a background lighting effect diagram includes:

[0023] By weakening the intensity of the light source and setting the normal coordinates of each pixel point, the effect of the diffuse light is only related to the direction of the light, so that the diffuse light effect of each pixel point is the same, and the background lighting effect diagram is obtained.

[0024] Further, the obtaining of the original image includes:

[0025] Taking a photo through the camera of the mobile device or obtaining the original image through the photo library of the mobile device.

[0026] An embodiment of the present application provides a processing device for human body lighting rendering based on normal mapping, including:

[0027] An acquisition module, configured to acquire an original image, acquire a human body mask map according to the original image, and preprocess the human body mask map to obtain a to-be-processed human body mask map;

[0028] A generation module, configured to generate a normal map according to the original image; wherein, each pixel point of the normal map corresponds to the normal vector of each pixel point in the original image;

[0029] A processing module, configured to render the normal map by using an Opengl application program to obtain a rendered image, and perform a mixing process on the to-be-processed human body mask map and the first rendered image to obtain a rendered portrait image;

[0030] A rendering module, configured to render the background of the original image to obtain a background lighting effect diagram;

[0031] A mixing module, configured to perform a mixing process on the rendered portrait image and the background lighting effect diagram, and output an image mixing result.

[0032] The present application provides a computer device, including: a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the processing method for human body lighting rendering based on normal mapping provided in any of the above embodiments.

[0033] The beneficial effects that the present invention can achieve by adopting the above technical solutions include:

[0034] The present invention provides a processing method and device for human body lighting rendering based on normal maps. This application simulates the actual lighting effect through an OpenGL application program, provides editing capabilities such as supporting multiple light sources, adjusting the color, direction, and type of light, and can simulate rich lighting effects. Compared with the server side, it can also ensure that the processing time is within a few milliseconds under multiple light sources, has no requirements for the performance of the mobile phone, and can be implemented on the mobile side. Since it does not require neural network processing, it also does not consume resources for training and is more convenient to use. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.

[0036] Figure 1 It is a schematic diagram of the steps of the processing method for human body lighting rendering based on normal maps according to the present invention;

[0037] Figure 2 It is a schematic flowchart of the processing method for human body lighting rendering based on normal maps according to the present invention;

[0038] Figure 3 It is a schematic diagram of the normal map according to the present invention;

[0039] Figure 4 It is a schematic structural diagram of the processing device for human body lighting rendering based on normal maps according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0040] To make the objectives, technical solutions, and advantages of the present invention clearer, the following will describe the technical solutions of the present invention in detail. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art without creative efforts based on the embodiments of the present invention belong to the scope protected by the present invention.

[0041] The following introduces a specific processing method and device for human body lighting rendering based on normal maps provided in the embodiments of the present application in conjunction with the drawings.

[0042] As Figure 1 shown, the processing method for human body lighting rendering based on normal maps provided in the embodiments of the present application includes:

[0043] S101. Obtain the original image, obtain a human body mask image according to the original image, and preprocess the human body mask image to obtain a to-be-processed human body mask image;

[0044] In this application, the original image can be a picture taken by the user through the camera of the mobile terminal or a picture stored in the mobile terminal. The processing method for human body lighting rendering based on normal mapping provided by this application can be implemented through the mobile terminal. After obtaining the original image, a human body mask image can be obtained according to the original image.

[0045] S102. Generate a normal map according to the original image; wherein, each pixel point of the normal map corresponds to the normal vector of each pixel point in the original image;

[0046] Simultaneously with step 101, the original image is processed to generate a normal map.

[0047] S103. Render the normal map using an Opengl application to obtain a rendered image, and perform a blending process on the to-be-processed human body mask image and the first rendered image to obtain a rendered portrait image;

[0048] Among them, OpenGL is a software interface independent of hardware and can be ported between different platforms such as Windows 95, Windows NT, Unix, Linux, MacOS, and OS / 2. Therefore, software that supports OpenGL has good portability and can be widely applied.

[0049] Among them, the normal map is rendered using an Opengl application to obtain a rendered image, and the pixels of the rendered image and the to-be-processed human body mask image obtained in step S101 are blended to obtain a rendered portrait image.

[0050] S104. Render the background of the original image to obtain a background lighting effect diagram.

[0051] Simultaneously with step S103, the background of the original image is rendered to obtain a background lighting effect diagram.

[0052] S105. Blend the rendered portrait image and the background lighting effect diagram to output an image blending result.

[0053] The working principle of the processing method for human body lighting rendering based on normal mapping is: Refer to Figure 2, the original image is obtained through the mobile device, and then the human body mask image is obtained from the original image. The human body mask image is preprocessed to obtain the human body mask image to be processed; a normal map is generated according to the original image; wherein, each pixel point of the normal map corresponds to the normal vector of each pixel point in the original image; the normal map is rendered using an Opengl application program to obtain a rendered image, and the human body mask image to be processed is mixed with the first rendered image to obtain a rendered portrait image; the background of the original image is rendered to obtain a background lighting effect image; the rendered portrait image is mixed with the background lighting effect image to output an image mixing result.

[0054] This application simulates the actual lighting effect through opengl, provides the editing ability to support multiple light sources, adjust the color of light, the direction of light, the type of light, etc., and can simulate very rich lighting effects. Compared with the server side, it can also ensure that the processing time is within a few milliseconds under multiple light sources, and there is no requirement for the performance of the mobile phone. Therefore, the above functions can be implemented on the mobile device. Since it does not require neural network processing, it does not consume resources for training and saves resources.

[0055] In some embodiments, obtaining the human body mask image according to the original image includes:

[0056] Inputting the original image into a pre-trained human body recognition model to obtain a human body mask image.

[0057] Preferably, preprocessing the human body mask image includes:

[0058] Performing anti-aliasing processing on the edge of the human body mask image, and determining the image obtained after the anti-aliasing processing as the image to be processed.

[0059] Specifically, in this application, by inputting the original image into a pre-trained human body recognition model, the human body recognition model can directly output the human body mask image. It can be understood that the human body recognition model is the result of machine learning training and is implemented using existing technologies, which will not be elaborated in this application. Perform a certain anti-aliasing processing on the edge of the obtained human body mask image. In this application, since only the human body mask image is obtained, the data set is relatively small and will not cause much pressure on the mobile device side. The human body mask image is mainly used to extract the portrait part from the entire image after lighting.

[0060] In some embodiments, generating the normal map according to the original image includes:

[0061] Obtaining the pixel points around the current pixel in the original image;

[0062] Generate two mutually perpendicular vectors through the pixel points around the perimeter; wherein, both of the two vectors are perpendicular to the normal, and the normal is generated according to the orthogonal method.

[0063] Specifically, as Figure 3 shown, each pixel point of the normal map corresponds to the normal vector of each pixel point in the original image. Since the normal vector is a three-dimensional vector and the range of the normalized coordinates of each dimension is (-1, 1), while the range of each dimension of the RGB color is (0, 1), a conversion is required. The conversion equation is as follows:

[0064] normal = normal * 0.5 + vec3(0.5); (1)

[0065] The conversion will make the normal map bluish.

[0066] The principle of generating the normal is to generate two mutually perpendicular vectors tx and ty (also called the tangent and the binormal) by taking the pixel points around the current pixel. They will be perpendicular to the normal at the same time. Therefore, the normal normal can be calculated by the orthogonal method, and vec3 represents a 3-dimensional vector.

[0067] In some embodiments, the normal map is rendered based on the Phong lighting reflection model to obtain a rendered image.

[0068] The commonly used model for simulating real-world lighting in Opengl is the Phong lighting reflection model. In the Phong lighting reflection model, there are three types of lighting data, namely ambient light, diffuse reflection, and specular reflection (highlight). In the technical solution provided in this application, only diffuse light is used. Among them, the Phong lighting model: The lighting in the real world is extremely complex and is affected by many factors, which cannot be simulated by our limited computing power. Therefore, the lighting in OpenGL uses a simplified model to approximate the real situation, which is easier to process and looks almost the same. These lighting models are all based on the understanding of the physical properties of light. One of the models is called the Phong lighting model.

[0069] Preferably, the rendering the normal map based on the Phong lighting reflection model to obtain a rendered image includes:

[0070] Calculating the diffuse light value of each pixel point of the normal map under a single or multiple light sources based on the Phong lighting reflection model to obtain a processed image;

[0071] Performing linear dodge blending on the processed image and the color of the original image to obtain a rendered image.

[0072] Preferably, rendering the background of the original image to obtain a background lighting effect diagram includes:

[0073] By weakening the intensity of the light source and setting the normal coordinates of each pixel point, the effect of diffuse light only depends on the direction of the light, so that the diffuse light effect of each pixel point is the same, and a background lighting effect diagram is obtained.

[0074] Specifically, the calculation method of the Phong lighting reflection model is as follows:

[0075] float diff = max(dot(normal, lightDir), 0.0); (2)

[0076] vec3 diffuse = light.diffuse * diff * light.lightIntensity * tex.rgb; (3)

[0077] Where normal is the normal vector, lightDir is the direction of the light, light.diffuse is the color of the light, light.lightIntensity is the intensity of the light, and tex.rgb is the RGB value of the original image. Through the above formula, the diffuse light value of each pixel point in the picture under a single light source can be calculated. If there are multiple light sources, the processing method in this application is different from the traditional Opengl processing method. When traditional Opengl processes multiple light sources, it will simply and violently directly superimpose the calculated light colors. This will cause the color to gradually tend to white light under multiple light sources, rather than the effect of the fusion of two lights, and at the same time, it is easy to have an overexposure effect. The processing method in this application is to mix them through a lightening blend mode. The blending formula is as follows:

[0078] Color = max(layer1, layer2); (4)

[0079] Where layer1 is the previously synthesized diffuse light color, and layer2 is the currently processed diffuse light color.

[0080] After processing the diffuse effects of all light sources, linearly lighten and mix it with the original image color to obtain a better lighting effect under multiple light sources.

[0081] Mix the rendered image obtained above with the portrait mask image to be processed to obtain a rendered portrait image. Among them, the rendered portrait image is only the picture of the lit part of the portrait. The advantage of doing this is to avoid the unreasonable state of the edge part under the light due to image cropping, thus affecting the final effect.

[0082] Then, light the background of the original image. It should be noted that since the background is actually just an ambient light and does not require the use of normal maps. Therefore, in this step, by weakening the intensity of the light source and setting the normal of each pixel to (0, 0, 1), at this time, the effect of the diffuse light only depends on the direction of the light, and the diffuse light effect of each pixel is the same. In this way, under the effect of the parallel light, the background presents a feeling of ambient light, and a background lighting effect diagram is obtained.

[0083] Finally, perform a blending process on the rendered portrait image and the background lighting effect diagram. That is, blend the obtained background lighting effect diagram with the portrait lighting image cut out through a blending mode to obtain the final effect. The blending formula is:

[0084] Color = layer1 + layer2 - layer1 * layer2.a; (5)

[0085] Where layer1 is the background lighting effect, layer2 is the portrait lighting effect, and a is the transparency.

[0086] As Figure 4 shown, the present application provides a processing device for human body lighting rendering based on normal maps, including:

[0087] An acquisition module 401, configured to acquire an original image, acquire a human body mask map according to the original image, and preprocess the human body mask map to obtain a to-be-processed human body mask map;

[0088] A generation module 402, configured to generate a normal map according to the original image; wherein, each pixel point of the normal map corresponds to the normal vector of each pixel point in the original image;

[0089] A processing module 403, configured to render the normal map by using an Opengl application program to obtain a rendered image, and perform a blending process on the to-be-processed human body mask map and the first rendered image to obtain a rendered portrait image;

[0090] A rendering module 404, configured to render the background of the original image to obtain a background lighting effect diagram;

[0091] A blending module 405, configured to perform a blending process on the rendered portrait image and the background lighting effect diagram and output an image blending result.

[0092] The working principle of the processing device for human body lighting rendering based on normal map provided by the embodiments of the present application is as follows: The acquisition module 401 acquires the original image, obtains the human body mask map according to the original image, and preprocesses the human body mask map to obtain the to-be-processed human body mask map; the generation module 402 generates a normal map according to the original image; wherein, each pixel point of the normal map corresponds to the normal vector of each pixel point in the original image; the processing module 403 renders the normal map by using an Opengl application program to obtain a rendered image, and mixes the to-be-processed human body mask map with the first rendered image to obtain a rendered portrait image; the rendering module 404 renders the background of the original image to obtain a background lighting effect diagram; the mixing module 405 mixes the rendered portrait image with the background lighting effect diagram and outputs an image mixing result.

[0093] The present application provides a computer device, including: a memory and a processor, and may further include a network interface. The memory stores a computer program. The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in forms such as read-only memory (ROM) or flash memory (flash RAM). The computer device stores an operating system, and the memory is an example of a computer-readable medium. When the computer program is executed by the processor, the processor is caused to execute a processing method for human body lighting rendering based on a normal map.

[0094] In one embodiment, the method for generating an intellectual property status provided by the present application can be implemented in the form of a computer program, and the computer program can run on a computer device.

[0095] In some embodiments, when the computer program is executed by the processor, the processor is caused to perform the following steps: acquire an original image, obtain a human body mask map according to the original image, and preprocess the human body mask map to obtain a to-be-processed human body mask map; generate a normal map according to the original image; wherein, each pixel point of the normal map corresponds to the normal vector of each pixel point in the original image; render the normal map by using an Opengl application program to obtain a rendered image, and mix the to-be-processed human body mask map with the first rendered image to obtain a rendered portrait image; render the background of the original image to obtain a background lighting effect diagram; mix the rendered portrait image with the background lighting effect diagram and output an image mixing result.

[0096] In summary, the present invention provides a processing method and device for human body lighting rendering based on normal mapping. The method includes obtaining an original image, obtaining a human body mask map according to the original image to obtain a to-be-processed human body mask map; generating a normal map according to the original image; using an Opengl application program to render the normal map to obtain a rendered image, mixing the to-be-processed human body mask map with the first rendered image to obtain a rendered portrait image; rendering the background of the original image to obtain a background lighting effect diagram; and mixing the rendered portrait image with the background lighting effect diagram to output an image mixing result. By simulating the actual lighting effect through opengl, the present invention provides diverse editing capabilities such as supporting multiple light sources, adjusting the color of light, the direction of light, and the type of light while maintaining support for real-time editing, making the simulated lighting have a relatively realistic lighting effect.

[0097] It can be understood that the above-provided method embodiment corresponds to the above device embodiment, and the corresponding specific content can be referred to each other and will not be elaborated here.

[0098] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.

[0099] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0100] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction method that implements the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1The functions specified in one or more boxes.

[0101] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide for implementing the steps of the functions specified in one Figure 1 One process or more processes and / or boxes Figure 1 or more boxes.

[0102] As described above, this is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A processing method for human body lighting rendering based on normal mapping, characterized in that, Including: Obtain an original image, obtain a human body mask map according to the original image, and preprocess the human body mask map to obtain a to-be-processed human body mask map; Meanwhile, generate a normal map according to the original image; wherein, each pixel point of the normal map corresponds to the normal vector of each pixel point in the original image; Render the normal map by using an Opengl application program to obtain a first rendered image, and perform a blending process on the to-be-processed human body mask map and the first rendered image to obtain a rendered portrait image; Meanwhile, render the background of the original image to obtain a background lighting effect image; Perform a blending process on the rendered portrait image and the background lighting effect image, and output an image blending result; The rendering the normal map by using an Opengl application program to obtain a first rendered image includes: Render the normal map based on the Phong illumination reflection model to obtain a first rendered image; The rendering the normal map based on the Phong illumination reflection model to obtain a first rendered image includes: Calculate the diffuse light value of each pixel point of the normal map under a single or multiple light sources based on the Phong illumination reflection model to obtain a processed image; Perform a linear dodge blend on the processed image and the color of the original image to obtain a first rendered image; The rendering the background of the original image to obtain a background lighting effect image includes: By weakening the intensity of the light source and setting the normal coordinates of each pixel point at the same time, making the effect of the diffuse light only related to the direction of the light, and making the diffuse light effect of each pixel point the same, to obtain a background lighting effect image; Wherein, the calculation method of the Phong illumination reflection model is: float diff = max(dot(normal, lightDir), 0.0); vec3 diffuse = light.diffuse * diff * light.lightIntensity * tex.rgb; Wherein, normal is the normal vector, lightDir is the direction of the light, light.diffuse is the color of the light, light.lightIntensity is the intensity of the light, and tex.rgb is the RGB value of the original image; When there are multiple light sources, the calculating the diffuse light value of each pixel point of the normal map under a single or multiple light sources based on the Phong illumination reflection model to obtain a processed image includes: respectively calculating the diffuse light color generated by each light source at each pixel point of the normal map, and then using a lighten blend mode to blend the diffuse light colors of each light source to obtain the processed image; the blending formula of the lighten blend mode is: Color = max(layer1, layer2); Wherein, layer1 is the already synthesized diffuse light color, and layer2 is the currently processed diffuse light color.

2. The method according to claim 1, wherein The obtaining the human body mask map according to the original image includes: Input the original image into a pre-trained human body recognition model to obtain a human body mask map.

3. The method according to claim 1 or 2, characterized in that, The preprocessing of the human body mask image includes: Perform anti-aliasing processing on the edge of the human body mask image, and determine the image obtained after anti-aliasing processing as the image to be processed.

4. The method according to claim 1, wherein The generation of the normal map according to the original image includes: Obtain the pixel points around the current pixel in the original image; Generate two mutually perpendicular vectors through the pixel points around; among them, both vectors are perpendicular to the normal, and the normal is generated according to the orthogonal method.

5. The method according to claim 1, wherein The obtaining of the original image includes: Obtain the original image by taking a photo with the camera of the mobile terminal or through the photo library of the mobile terminal.

6. A processing device for human body lighting rendering based on normal mapping, characterized in that It includes: An acquisition module for acquiring the original image, acquiring the human body mask image according to the original image, and preprocessing the human body mask image to obtain the human body mask image to be processed; A generation module for generating a normal map according to the original image; wherein, each pixel point of the normal map corresponds to the normal vector of each pixel point in the original image; A processing module for rendering the normal map by using an Opengl application program to obtain a first rendered image, and performing a blending process on the human body mask image to be processed and the first rendered image to obtain a rendered portrait image; A rendering module for rendering the background of the original image to obtain a background lighting effect diagram; A blending module for performing a blending process on the rendered portrait image and the background lighting effect diagram and outputting an image blending result; The processing module is further used for rendering the normal map based on the Phong lighting reflection model to obtain a first rendered image, specifically including: Calculating the diffuse light value of each pixel point of the normal map under a single or multiple light sources based on the Phong lighting reflection model to obtain a processed image; Performing a linear dodge blend on the processed image and the color of the original image to obtain a first rendered image; The rendering module is further used for weakening the intensity of the light source and setting the normal coordinates of each pixel point at the same time, so that the effect of the diffuse light is only related to the direction of the light, and the diffuse light effect of each pixel point is the same, to obtain a background lighting effect diagram; Among them, the calculation method of the Phong lighting reflection model is: float diff = max(dot(normal, lightDir), 0.0); vec3 diffuse = light.diffuse * diff * light.lightIntensity * tex.rgb; Wherein, normal is the normal vector, lightDir is the direction of the light, light.diffuse is the color of the light, light.lightIntensity is the intensity of the light, and tex.rgb is the RGB value of the original image; The processing module is further configured to, when there are multiple light sources, calculate the diffuse light value of each pixel of the normal map under single or multiple light sources based on the Phong illumination reflection model, and obtain a processed image, including: calculating the diffuse light color generated by each light source at each pixel of the normal map respectively, and then using the lighten blending mode to blend the diffuse light colors of each light source to obtain the processed image; the blending formula of the lighten blending mode is: Color = max(layer1, layer2); wherein, layer1 is the already synthesized diffuse light color, and layer2 is the currently processed diffuse light color.

7. A computer device, characterized in that, Including: a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the processing method for human body illumination rendering based on the normal map according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Virtual reality model rendering method and device

    CN109377546A

  • Image-based lighting effect processing method and device, equipment and storage medium

    CN112270759A

  • Virtual object shadow rendering method for head-mounted augmented reality equipment

    CN112700528A