Image processing method and apparatus
By identifying and segmenting image regions in NPR rendering and adjusting brightness and lighting, the problem of clear boundaries between dark and bright areas was solved, enhancing the realism of the image.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHUHAI KINGSOFT ONLINE GAME TECH CO LTD
- Filing Date
- 2022-06-09
- Publication Date
- 2026-05-29
Smart Images

Figure CN115018961B_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification relate to the field of animation rendering technology, and in particular to an image processing method. Background Technology
[0002] The existing NPR rendering technology (NPR is a type of computer graphics, namely non-photorealistic rendering, mainly used to simulate artistic drawing styles, and also used to develop new drawing styles, generally in the form of cartoon shadows) mainly includes binary shadows (binary lighting refers to a way of expressing the light and shadow of an object with a sense of volume by simplifying and generalizing the image), binary highlights, stylized edge lighting, and stylized lighting models.
[0003] In a binary shadow, the dark and light areas appear clearly separated, which can result in a poor visual experience in animation. Summary of the Invention
[0004] In view of the above, embodiments of this specification provide an image processing method. One or more embodiments of this specification also relate to an image processing apparatus, a computing device, a computer-readable storage medium, and a computer program, to address the technical deficiencies existing in the prior art.
[0005] According to a first aspect of the embodiments of this specification, an image processing method is provided, comprising:
[0006] In the target image, a first region image and a second region image are determined, wherein the brightness of the first region image and the second region image are different;
[0007] Determine the boundary line between the first region image and the second region image, and determine the first boundary line and the second boundary line on both sides of the boundary line;
[0008] The region image between the first boundary and the second boundary is segmented to obtain at least two region images to be processed;
[0009] The brightness of each region of the image to be processed is determined according to the preset brightness processing rules.
[0010] According to a second aspect of the embodiments of this specification, an image processing apparatus is provided, comprising:
[0011] The region determination module is configured to determine a first region image and a second region image in a target image, wherein the brightness of the first region image and the second region image is different;
[0012] The boundary determination module is configured to determine the boundary line between the first region image and the second region image, and to determine the first boundary line and the second boundary line on both sides of the boundary line;
[0013] The segmentation module is configured to segment the region image between the first boundary and the second boundary to obtain at least two region images to be processed;
[0014] The rendering module is configured to determine the brightness of each region of the image to be processed according to preset brightness processing rules.
[0015] According to a third aspect of the embodiments of this specification, a computing device is provided, comprising:
[0016] Memory and processor;
[0017] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the above-described image processing method.
[0018] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions that, when executed by a processor, implement the steps of the image processing method described above.
[0019] According to a fifth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described image processing method.
[0020] This specification provides an image processing method and apparatus. The image processing method includes: determining a first region image and a second region image in a target image, wherein the first region image and the second region image have different brightness; determining a boundary line between the first region image and the second region image, and determining a first boundary line and a second boundary line on both sides of the boundary line; segmenting the region image between the first boundary line and the second boundary line to obtain at least two region images to be processed; and determining the brightness of each region image to be processed according to a preset brightness processing rule. By defining the region images to be processed by the boundary line between the first region image and the second region image, and setting different brightness levels for each region in the region images to be processed, a transition from the brightness of the first region image to the brightness of the second region image is achieved, making the transition region appear more realistic.
[0021] Furthermore, this embodiment of the specification determines the color of the outline image based on the color of the environment image or the color of the person image, making the outline image more realistic. This embodiment of the specification also inserts a new lighting direction, allowing the target material to obtain more highlights in the viewing direction, thus making the target material appear more realistic. This embodiment of the specification further enhances the realism of shadows by cropping the image that creates shadows, processing the shadow-creating image into a shadow image, and then pasting the processed shadow image onto the corresponding shadow area. This embodiment of the specification also achieves unilateral edge lighting by offsetting the direction of the main light source in screen space. The processed edge lighting is identical to the edge lighting seen in reality, making the image appear more realistic. In summary, through the combined effect of these five parts in NPR rendering, the entire image appears more realistic, improving the realism of NPR rendering. Attached Figure Description
[0022] Figure 1 This is a flowchart illustrating an image processing method provided in one embodiment of this specification;
[0023] Figure 2 This is a flowchart illustrating the processing procedure of an image processing method provided in one embodiment of this specification.
[0024] Figure 3 This is a schematic diagram of the structure of an image processing apparatus provided in one embodiment of this specification;
[0025] Figure 4 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0026] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0027] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0028] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."
[0029] First, the terms and concepts used in one or more embodiments of this specification will be explained.
[0030] Outlining: This refers to creating the outline of a shape, or simply adding a border to the edge.
[0031] Unity is a real-time 3D interactive content creation and operation platform.
[0032] NPR: is a type of computer graphics called non-photorealistic rendering. It is mainly used to simulate artistic rendering styles and also to develop new rendering styles. It is generally in the form of cartoon animation.
[0033] SDF: Signed distance field, which means that each pixel (voxel) records the distance between itself and the nearest object. If it is inside the object, the distance is negative, and if it is exactly on the boundary of the object, the distance is 0.
[0034] Dichotomy: also known as dichotomy shadow, it is the process of accurately distinguishing the light and dark sides of an object based on the direction of the light source. It is a simplified and generalized expression of light and shadow on an object.
[0035] Sub-surface scattering (3S): This term describes the illumination phenomenon where light is scattered when it passes through a transparent / semi-transparent surface. It refers to the process by which light enters an object from its surface, is scattered internally, and then exits through other vertices on the object's surface.
[0036] Softening: In life, we know that the transition of shadows is gradual, and the purpose of softening shadows is to simulate this gradual transition of shadows and create a blurring effect around the shadows.
[0037] Shader: A programmable program used to implement image rendering, replacing the fixed rendering pipeline.
[0038] Frame buffer memory (also known as frame cache or video memory) is a direct image of the screen's display, also called a bit map or raster. Each storage unit in the frame buffer corresponds to a pixel on the screen, and the entire frame buffer corresponds to one frame of image.
[0039] Rim lighting: This is light shining directly in the direction of the camera, creating a backlighting effect. Also known as rim lighting, rim lighting is used to outline the subject. When the subject and background tones overlap (e.g., both the subject and background are dark), rim lighting helps to separate the subject from the background.
[0040] This specification provides an image processing method, and also relates to an image processing apparatus, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
[0041] Before determining the first region image and the second region image in the target image, the embodiments of this specification further include:
[0042] Identify the human figure in the initial image and determine the outline of the human figure;
[0043] The outline is rendered based on the environmental image surrounding the character image to obtain an outline image;
[0044] The person image, the environment image, and the outline image are combined into a person outline image.
[0045] The initial image can be understood as an unprocessed image, such as an image including grass and people; the image of people can be understood as an image of people in the initial image, such as a little girl, an old man, an old woman, etc.; the image of the environment can be understood as an image of the environment in the initial image, such as an image of grass, the sun, trees, etc.
[0046] In practical applications, NPR rendering performs screen sampling on the outline, so that the outline color is determined by the color of the character itself after rendering.
[0047] For example, if a person is identified in the initial image, and the outline of that person is determined, and the background environment image of the upper body of the person is trees, and the background environment image of the lower body of the person is grass, then the outline of the upper body is determined to be dark green, and the outline of the lower body is determined to be light green.
[0048] In one possible implementation, rendering the outline based on the environmental image surrounding the person image to obtain an outline image includes:
[0049] The color of the outline is determined based on the distance between the environmental image and the character image, and the outline is rendered to obtain the outline image.
[0050] Specifically, determining the color of the outline based on the distance between the environment image and the person image, and rendering the outline to obtain the outline image, includes:
[0051] If the distance between the environment image and the person image is greater than a distance threshold, the color of the outline is determined to be the color of the environment image, and the outline is rendered to obtain the outline image;
[0052] If the distance between the environment image and the person image is less than or equal to the distance threshold, the color of the outline is determined to be the color of the person image, and the outline is rendered to obtain the outline image.
[0053] The distance between the environment image and the person image can be understood as the difference between the depth of the environment image and the depth of the person image; the distance threshold can be understood as the threshold of the depth difference.
[0054] For example, with a distance threshold of 7, a person is identified in the initial image, and the outline of that person is determined. The background environment image of the upper body of the person is trees, and the background environment image of the lower body of the person is grass. The depth of the trees in the background environment image of the upper body is 10, and the depth of the grass in the background environment image of the lower body is 2. The depth difference is 8, which exceeds the distance threshold. Therefore, the outline of the upper body is determined to be the color of the adjacent person, and the outline of the lower body is determined to be light green.
[0055] Correspondingly, if the distance between the environment image and the person image is greater than a distance threshold, the color of the outline can be determined to be the color of the person image, and the outline can be rendered to obtain the outline image.
[0056] If the distance between the environment image and the person image is less than or equal to the distance threshold, the color of the outline is determined to be the color of the environment image, and the outline is rendered to obtain the outline image.
[0057] For example, if the distance threshold is 7, a person is identified in the initial image, and the outline of that person is determined. The background environment image of the upper body of the person is trees, and the background environment image of the lower body of the person is grass. The depth of the trees in the background environment image of the upper body is 10, and the depth of the grass in the background environment image of the lower body is 2. The depth difference is 8, which exceeds the distance threshold. Therefore, the outline of the upper body is determined to be light green, and the outline of the lower body is determined to be the color of the adjacent person.
[0058] It should be noted that the outline color can be set as needed, and this specification does not limit the examples.
[0059] The embodiments in this specification determine the color of the outlined image based on the color of the environment image or the color of the person image, which can make the outlined image more realistic.
[0060] In one possible implementation, after combining the person image, the environment image, and the outline image into a person outline image, the method further includes:
[0061] If a target material image exists in the outlined image of the person, the target material image is subjected to lighting processing to obtain the target image.
[0062] The target material image can be understood as an anisotropic material, such as silk material.
[0063] In practical applications, since sunlight rarely shines directly onto a character in games, the range of highlights seen from the character's perspective when looking directly at anisotropic materials is very small. However, in NPR rendering, it is desirable to have good highlight display from all angles. Special lighting model processing is used for silk materials. A custom half-length vector is added in the early calculation of the GGX micro-surface lighting model (GGX is a micro-surface reflection lighting model, which can better represent the dissipation (trailing) effect of the highlights on the metal). This ensures that the highlights of the silk material can be seen from most angles.
[0064] In one feasible approach, the illumination processing of the target material image to obtain the target image includes:
[0065] An initial incident light source is determined in the initial image, and the normal of the target material image is determined;
[0066] A target incident light source is inserted between the initial incident light source and the normal to obtain a target image.
[0067] In practical applications, a new incident light is obtained by interpolating the source light direction to the normal direction. This results in a new half-path vector with an angle significantly smaller than the original half-path vector. The closer the new light source direction is to the normal vector, the smaller the angle of the new half-path vector becomes. The focus then shifts to the interpolated value: 0 represents the original lighting direction, and 1 represents the normal vector. The larger the angle between the source light direction and the normal, the closer the new half-path vector is to the normal vector; in other words, the closer the interpolated value is to 1. This yields two specular highlights: one strongest when the angle between the light source and the object's surface normal is minimal, and the other strongest when the angle is maximum. Adding these two highlights together gives the final specular highlight, completing the lighting model calculation.
[0068] For example, in an image, if the original lighting direction makes a 60° angle with the normal direction of a piece of silk material, then a new lighting direction is inserted between the original lighting direction and the normal direction. The angle between the new lighting direction and the normal direction is 0°, that is, the new lighting direction illuminates the normal direction perpendicularly. This will create a new highlight when viewing the silk material.
[0069] The embodiments in this specification insert new lighting directions, allowing the target material to obtain more highlights in the viewing direction, thereby making the target material look more realistic.
[0070] See Figure 1 , Figure 1 A flowchart of an image processing method according to an embodiment of this specification is shown, which specifically includes the following steps.
[0071] Step 102: Determine a first region image and a second region image in the target image, wherein the brightness of the first region image and the second region image is different.
[0072] The first region image can be a low-brightness image, and the second region image can be a high-brightness image. For example, with a brightness level of 0-9, the first region image can be any value among 0, 1, 2, 3, and 4, and the second region image can be any value among 5, 6, 7, 8, and 9.
[0073] It should be noted that the first region image can be a low-brightness image, and the second region image can be a high-brightness image. In other words, there just needs to be a difference in brightness between the first region image and the second region image.
[0074] In practical applications, based on existing SDF (Signed Distance Fields)-based lighting and shadow rendering, the SDF and the mask generated by the lighting angle are remapped to further soften the shadows, allowing the bipartite shadow rendering to approach realistic shadows by modifying parameters. At the same time, the shadows generated by SDF are encoded into the subsurface scattering buffer for subsurface scattering processing, achieving a fusion of cartoon rendering (a fascinating topic in computer graphics, belonging to the category of non-realistic computer graphics (NPR)) and partial realism.
[0075] For example, in an image, there is a person A. There is an area on person A's face that is obscured by the shadow of hair. The area not obscured by the shadow of hair can be identified as the first region of the image, and the area obscured by the shadow of hair can be identified as the second region of the image.
[0076] Step 104: Determine the boundary line between the first region image and the second region image, and determine the first boundary line and the second boundary line on both sides of the boundary line.
[0077] The boundary line between the first region image and the second region image can be understood as the boundary line between the dark region and the bright region; the first boundary line is the boundary line in the first region image, and the second boundary line is the boundary line in the second region image.
[0078] In practical applications, during the NPR rendering process, it is desirable to have complete control over the shape of the shadow and highlight areas of the character in the SDF image. However, in traditional lighting, the shadow and highlight areas are determined by the object's normal and the direction of the light source. In order to achieve complete control over the shape of the shadow area, the SDF algorithm was introduced. That is, when you hand-draw a region, the white areas are composed of negative vectors perpendicular to the tangent at the edge, and the black areas are composed of vectors perpendicular to the tangent.
[0079] In one possible implementation, determining the first and second boundary lines on both sides of the dividing line includes:
[0080] A first boundary line is determined on the first side of the dividing line according to a preset width, and a second boundary line is determined on the second side of the dividing line according to the preset width, wherein the shape of the first boundary line and the shape of the second boundary line are the same as the shape of the dividing line.
[0081] For example, an image contains black and gray areas. The gray area is b. To blur the edges of the gray area, we increase the x-distance of b to get a, and decrease the x-distance to get c. We then set the brightness of a to 1 and the brightness of c to 0. The edge of a is the first boundary, and the edge of c is the second boundary.
[0082] Step 106: Divide the region image between the first boundary and the second boundary to obtain at least two region images to be processed.
[0083] The image to be processed can be understood as the image whose brightness needs to be determined.
[0084] In practical applications, the distance from the first boundary to the second boundary is increased by a certain distance each time, and the brightness value is decreased by a certain value each time, until it is reduced to 0, at which point the remapping is completed.
[0085] In one possible implementation, segmenting the region image between the first boundary and the second boundary to obtain at least two region images to be processed includes:
[0086] The region between the first boundary and the second boundary is divided into a preset number of regions to be processed, wherein the preset number of regions to be processed have the same width, and the boundaries of the regions to be processed have the same shape as the dividing line.
[0087] For example, an image contains black and gray areas. The gray area is b. To blur its edges, we increase the x-distance of b to get a, and decrease the x-distance to get c. At this point, we set the brightness of a to 1 and the brightness of c to 0. The edge of a is the first boundary, and the edge of c is the second boundary. Each step from a to c results in at least two regions of the image to be processed.
[0088] Step 108: Determine the brightness of each region of the image to be processed according to the preset brightness processing rules.
[0089] Among them, the preset brightness processing rules can be understood as the rules for setting the brightness of the image in the area to be processed.
[0090] In practical applications, based on the existing SDF-based lighting and shadow rendering, the SDF and the mask generated by the lighting angle are remapped to further soften the image, so that the bipartite shadow rendering can approach realistic shadows by modifying the parameters. The realistic shadows here can be understood as areas that are relatively dark in the real world. At the same time, the shadows generated by SDF are encoded into the subsurface scattering buffer for subsurface scattering processing, realizing the fusion of cartoon rendering (a fun topic in computer graphics, belonging to non-realistic computer graphics (NPR)) and partial realism.
[0091] In one feasible approach, determining the brightness of each region of the image to be processed according to a preset brightness processing rule includes:
[0092] The brightness difference is determined based on the brightness of the first region image and the brightness of the second region image;
[0093] A preset brightness processing rule is determined based on the brightness difference and the number of images in the region to be processed;
[0094] The brightness of the image in the area to be processed is set sequentially according to the preset brightness processing rules.
[0095] For example, an image contains black and gray areas. The gray area is b. To blur its edges, we increase the x-distance of b to get a, and decrease the x-distance to get c. At this point, we set the brightness of a to 1, and the brightness of c to 0. The edge of a is the first boundary, and the edge of c is the second boundary. We take a certain step from a to c each time to obtain at least two images of the region to be processed, and decrease the brightness value by a certain amount each time until it reaches 0. This completes the remapping.
[0096] In one feasible approach, after determining the brightness of each region of the image to be processed according to a preset brightness processing rule, the method further includes:
[0097] The image of the region to be processed is marked as a dark region, and subsurface scattering rendering is performed on the dark region.
[0098] Dark areas can be understood as areas with lower brightness.
[0099] In practical applications, in the Unity engine, when subsurface scattering is enabled, only the dark areas calculated in the original shader can be encoded into the subsurface scattering buffer for subsurface reflection processing. In this NPR rendering, since most of the dark areas are custom, in order to add the dark areas in the original shader, the part that processes shadows is added to the custom dark areas. Finally, the data is encoded into a buffer and handed over to the subsurface lighting model for processing.
[0100] The embodiments in this specification give these custom shadows the physical properties of subsurface scattering.
[0101] In one feasible approach, after determining the brightness of each region of the image to be processed according to a preset brightness processing rule, the method further includes:
[0102] Obtain the first part image of the person's image;
[0103] A shadow is drawn based on the first part image, wherein the shape of the shadow is the same as the shape of the first part image;
[0104] The shadow of the aforementioned part is rendered in the image of the person.
[0105] The first part of the image can be bangs, hands, nose, etc.
[0106] In practical applications, the first part of the image is the bangs. In the shader, the main light source vector is converted to screen space. The main light source vector is in world standard space. It is transformed to the screen space seen by the player through the transformation matrix (available in the shader) and the clipping matrix (available in the shader). By multiplying the main light source vector converted to screen space by a custom length, the real-time buffer above is offset, so that the bangs shadow changes with the angle of the light source. The white areas are the shadow areas. The shadow areas can be cropped and pasted onto the corresponding area of the character image, thus completing the screen space bangs shadow implementation.
[0107] The embodiments in this specification cut out an image that causes shadows, process the image that causes shadows into a shadow image, and then paste the processed shadow image onto the corresponding shadow area to make the shadow part look more realistic.
[0108] In one possible implementation, after rendering the shadow of the said part into the image of the person, the method further includes:
[0109] The target edge light image of the person image is generated using a screen space algorithm;
[0110] The edge light image is added to the target image.
[0111] In practical applications, unlike traditional Fresnel edge lighting, to achieve same-side edge lighting in cartoons, the character's depth buffer is copied in screen space, and the direction is offset from the main light source direction in screen space to achieve single-side edge lighting. This process produces edge lighting that is identical to edge lighting seen in reality, making the image appear more realistic.
[0112] In one possible implementation, generating the target edge light image of the person image using a screen space algorithm includes:
[0113] An edge light image is generated around the image of the person using a screen space algorithm;
[0114] The target edge light image is obtained by moving the image of the person towards the light source and covering the edge light image.
[0115] For example, if there is an edge light around a character, copying the character and the edge light into the screen space and moving the character to the right will block the edge light on the right, leaving only the edge light on the left.
[0116] This specification provides an image processing method and apparatus. The image processing method includes: determining a first region image and a second region image in a target image, wherein the first region image and the second region image have different brightness; determining a boundary line between the first region image and the second region image, and determining a first boundary line and a second boundary line on both sides of the boundary line; segmenting the region image between the first boundary line and the second boundary line to obtain at least two region images to be processed; and determining the brightness of each region image to be processed according to a preset brightness processing rule. By defining the region images to be processed by the boundary line between the first region image and the second region image, and setting different brightness levels for each region in the region images to be processed, a transition from the brightness of the first region image to the brightness of the second region image is achieved, making the transition region appear more realistic.
[0117] The following is in conjunction with the appendix Figure 2 Taking the application of the image processing method provided in this specification on a server as an example, the image processing method will be further explained. Among them, Figure 2 A flowchart illustrating the processing steps of an image processing method according to an embodiment of this specification is shown, specifically including the following steps.
[0118] Step 202: Determine the figure image in the initial image and determine the outline of the figure image.
[0119] Step 204: Render the outline based on the environmental image surrounding the character image to obtain the outline image.
[0120] Step 206: If a target material image exists in the character outline image, perform lighting processing on the target material image to obtain the target image.
[0121] Step 208: Determine a first region image and a second region image in the target image, wherein the brightness of the first region image and the second region image is different.
[0122] Step 210: Determine the boundary line between the first region image and the second region image, and determine the first boundary line and the second boundary line on both sides of the boundary line.
[0123] Step 212: Divide the region image between the first boundary and the second boundary to obtain at least two region images to be processed.
[0124] Step 214: Determine the brightness of each region of the image to be processed according to the preset brightness processing rules.
[0125] Step 216: Mark the image of the area to be processed as a dark area, and perform subsurface scattering rendering on the dark area.
[0126] Step 218: Generate a target edge light image of the person image using a screen space algorithm, and add the edge light image to the target image.
[0127] By defining the region to be processed by the boundary line between the first and second region images, and setting different brightness levels for each region in the region to be processed, the brightness transitions from the first region image to the second region image, making the transition region look more realistic.
[0128] Corresponding to the above method embodiments, this specification also provides embodiments of an image processing apparatus. Figure 3 A schematic diagram of the structure of an image processing apparatus provided in one embodiment of this specification is shown. Figure 3 As shown, the device includes:
[0129] The region determination module 302 is configured to determine a first region image and a second region image in a target image, wherein the brightness of the first region image and the second region image is different;
[0130] The boundary determination module 304 is configured to determine the boundary line between the first region image and the second region image, and to determine the first boundary line and the second boundary line on both sides of the boundary line.
[0131] The segmentation module 306 is configured to segment the region image between the first boundary and the second boundary to obtain at least two region images to be processed;
[0132] The rendering module 308 is configured to determine the brightness of each region of the image to be processed according to a preset brightness processing rule.
[0133] In one possible implementation, the region determination module 302 is further configured as follows:
[0134] Identify the human figure in the initial image and determine the outline of the human figure;
[0135] The outline is rendered based on the environmental image surrounding the character image to obtain an outline image;
[0136] The person image, the environment image, and the outline image are combined into a person outline image.
[0137] In one possible implementation, the region determination module 302 is further configured as follows:
[0138] If the distance between the environment image and the person image is greater than a distance threshold, the color of the outline is determined to be the color of the environment image, and the outline is rendered to obtain the outline image;
[0139] If the distance between the environment image and the person image is less than or equal to the distance threshold, the color of the outline is determined to be the color of the person image, and the outline is rendered to obtain the outline image.
[0140] In one possible implementation, the region determination module 302 is further configured as follows:
[0141] If a target material image exists in the outlined image of the person, the target material image is subjected to lighting processing to obtain the target image.
[0142] In one possible implementation, the region determination module 302 is further configured as follows:
[0143] An initial incident light source is determined in the initial image, and the normal of the target material image is determined;
[0144] A target incident light source is inserted between the initial incident light source and the normal to obtain a target image.
[0145] In one possible implementation, the boundary determination module 304 is also configured as follows:
[0146] A first boundary line is determined on the first side of the dividing line according to a preset width, and a second boundary line is determined on the second side of the dividing line according to the preset width, wherein the shape of the first boundary line and the shape of the second boundary line are the same as the shape of the dividing line.
[0147] In one possible implementation, the segmentation module 306 is also configured as follows:
[0148] The region between the first boundary and the second boundary is divided into a preset number of regions to be processed, wherein the preset number of regions to be processed have the same width, and the boundaries of the regions to be processed have the same shape as the dividing line.
[0149] In one possible implementation, rendering module 308 is also configured as follows:
[0150] The brightness difference is determined based on the brightness of the first region image and the brightness of the second region image;
[0151] A preset brightness processing rule is determined based on the brightness difference and the number of images in the region to be processed;
[0152] The brightness of the image in the area to be processed is set sequentially according to the preset brightness processing rules.
[0153] In one possible implementation, rendering module 308 is also configured as follows:
[0154] The image of the region to be processed is marked as a dark region, and subsurface scattering rendering is performed on the dark region.
[0155] In one possible implementation, rendering module 308 is also configured as follows:
[0156] Obtain the first part image of the person's image;
[0157] A shadow is drawn based on the first part image, wherein the shape of the shadow is the same as the shape of the first part image;
[0158] The shadow of the aforementioned part is rendered in the image of the person.
[0159] In one possible implementation, rendering module 308 is also configured as follows:
[0160] The target edge light image of the person image is generated using a screen space algorithm;
[0161] The edge light image is added to the target image.
[0162] In one possible implementation, rendering module 308 is also configured as follows:
[0163] An edge light image is generated around the image of the person using a screen space algorithm;
[0164] The target edge light image is obtained by moving the image of the person towards the light source and covering the edge light image.
[0165] This specification provides an image processing method and apparatus. The image processing apparatus determines a first region image and a second region image in a target image, wherein the first region image and the second region image have different brightness levels; determines a boundary line between the first region image and the second region image, and determines a first boundary line and a second boundary line on both sides of the boundary line; segments the region image between the first boundary line and the second boundary line to obtain at least two region images to be processed; and determines the brightness of each region image to be processed according to a preset brightness processing rule. By defining the region images to be processed by the boundary line between the first region image and the second region image, and setting different brightness levels for each region in the region images to be processed, a transition from the brightness of the first region image to the brightness of the second region image is achieved, making the transition region appear more realistic.
[0166] The above is an illustrative scheme of an image processing apparatus according to this embodiment. It should be noted that the technical solution of this image processing apparatus and the technical solution of the image processing method described above belong to the same concept. For details not described in detail in the technical solution of the image processing apparatus, please refer to the description of the technical solution of the image processing method described above.
[0167] Figure 4 A structural block diagram of a computing device 400 according to one embodiment of this specification is shown. The components of the computing device 400 include, but are not limited to, a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and a database 450 is used to store data.
[0168] The computing device 400 also includes an access device 440, which enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 440 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0169] In one embodiment of this specification, the aforementioned components of the computing device 400 and Figure 4 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 4 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0170] The computing device 400 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 400 can also be a mobile or stationary server.
[0171] The processor 420 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the above-described image processing method.
[0172] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the image processing method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the image processing method described above.
[0173] An embodiment of this specification also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the above-described image processing method.
[0174] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the image processing method described above belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the image processing method described above.
[0175] An embodiment of this specification also provides a computer program, wherein when the computer program is executed in a computer, it causes the computer to perform the steps of the above-described image processing method.
[0176] The above is an illustrative example of a computer program according to this embodiment. It should be noted that the technical solution of this computer program and the technical solution of the image processing method described above belong to the same concept. Details not described in detail in the computer program's technical solution can be found in the description of the technical solution of the image processing method described above.
[0177] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0178] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0179] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0180] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0181] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. An image processing method, characterized in that, include: When a target material image exists in the character outline image, an initial incident light source is determined in the initial image, and the normal of the target material image is determined. The character outline image is obtained by outlining the character image based on the environmental image around the character image, and the color of the outline is determined based on the depth difference between the environmental image around the character image and the character image. A target incident light source is inserted between the initial incident light source and the normal to obtain a target image; In the target image, a first region image and a second region image are determined, wherein the brightness of the first region image and the second region image are different; Determine the boundary line between the first region image and the second region image, and determine the first boundary line and the second boundary line on both sides of the boundary line; The region image between the first boundary and the second boundary is segmented to obtain at least two region images to be processed; The brightness of each region image to be processed is determined according to a preset brightness processing rule, wherein the determination of the brightness of each region image to be processed according to the preset brightness processing rule includes: subtracting a certain brightness value from each region image to be processed each time to complete the remapping; The image of the region to be processed is marked as a dark region, and subsurface scattering rendering is performed on the dark region.
2. The method according to claim 1, further comprising, before determining the first region image and the second region image in the target image: Identify the human figure in the initial image and determine the outline of the human figure; The outline is rendered based on the environmental image surrounding the character image to obtain an outline image; The person image, the environment image, and the outline image are combined into a person outline image.
3. The method according to claim 1, wherein rendering the outline based on the environmental image surrounding the person image to obtain the outline image includes: The color of the outline is determined based on the distance between the environmental image and the character image, and the outline is rendered to obtain the outline image.
4. The method according to claim 1, wherein determining the first boundary line and the second boundary line on both sides of the dividing line comprises: A first boundary line is determined on the first side of the dividing line according to a preset width, and a second boundary line is determined on the second side of the dividing line according to the preset width, wherein the shape of the first boundary line and the shape of the second boundary line are the same as the shape of the dividing line.
5. The method according to claim 1, wherein segmenting the region image between the first boundary and the second boundary to obtain at least two region images to be processed includes: The region between the first boundary and the second boundary is divided into a preset number of regions to be processed, wherein the preset number of regions to be processed have the same width, and the boundaries of the regions to be processed have the same shape as the dividing line.
6. The method according to claim 1, wherein determining the brightness of each region of the image to be processed according to a preset brightness processing rule comprises: The brightness difference is determined based on the brightness of the first region image and the brightness of the second region image; A preset brightness processing rule is determined based on the brightness difference and the number of images in the region to be processed; The brightness of the image in the area to be processed is set sequentially according to the preset brightness processing rules.
7. The method according to claim 2, after determining the brightness of each region of the image to be processed according to a preset brightness processing rule, further comprising: Obtain the first part image of the person's image; A shadow is drawn based on the first part image, wherein the shape of the shadow is the same as the shape of the first part image; The shadow of the aforementioned part is rendered in the image of the person.
8. The method of claim 7, further comprising, after rendering the shadow of the said part into the image of the person: The target edge light image of the person image is generated using a screen space algorithm; The edge light image is added to the target image.
9. The method according to claim 8, wherein generating the target edge light image of the person image using a screen space algorithm comprises: An edge light image is generated around the image of the person using a screen space algorithm; The target edge light image is obtained by moving the image of the person towards the light source and covering the edge light image.
10. An image processing apparatus, comprising: The region determination module is configured to, when a target material image exists in a character outline image, determine an initial incident light source in an initial image and determine the normal of the target material image, wherein the character outline image is obtained by outlining the character image based on the surrounding environment image, and the color of the outline is determined based on the depth difference between the surrounding environment image and the character image; insert a target incident light source between the initial incident light source and the normal to obtain a target image; and determine a first region image and a second region image in the target image, wherein the brightness of the first region image and the second region image is different. The boundary determination module is configured to determine the boundary line between the first region image and the second region image, and to determine the first boundary line and the second boundary line on both sides of the boundary line; The segmentation module is configured to segment the region image between the first boundary and the second boundary to obtain at least two region images to be processed; The rendering module is configured to determine the brightness of each image to be processed according to a preset brightness processing rule. The step of determining the brightness of each image to be processed according to the preset brightness processing rule includes: reducing the brightness value of each image to be processed by a certain amount each time to complete the remapping; marking the image to be processed as a dark area and performing subsurface scattering rendering on the dark area.
11. A computing device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the image processing method according to any one of claims 1 to 9.
12. A computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the image processing method according to any one of claims 1 to 9.
13. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps of the image processing method according to any one of claims 1 to 9.