Image object texture replacement method, device, computer equipment and storage medium

By pre-rendering and blurring the texture replacement area, combined with resampling and synthesis processing, the problem of difficult to take into account both texture replacement efficiency and image quality is solved, and efficient and high-quality texture replacement effect is achieved.

CN114241076BActive Publication Date: 2025-05-16HANGZHOU QUNHE INFORMATION TECHNOLOGIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111598978.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-24
Publication Date
2025-05-16
Estimated Expiration
2041-12-24

AI Technical Summary

Technical Problem

The prior art is difficult to take into account both replacement efficiency and picture quality when replacing textures, and texture replacement efficiency is low or picture quality is poor.

Method used

By pre-rendering the texture replacement area, obtaining and blurring the texture map, resampling the texture map and blurring the texture map according to the pre-rendering layer, the sampling results and pre-rendering layers are synthesized to obtain the texture replacement picture.

Benefits of technology

While ensuring the quality of the image after texture replacement, the texture replacement efficiency is improved, making the resulting replacement image more realistic and fast processing speed, which is suitable for batch calculation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114241076B_ABST
    Figure CN114241076B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, computer equipment and storage medium for replacing texture of an image object, including pre-rendering a texture replacement area to obtain a pre-rendering layer; obtaining a texture map and performing blur processing to obtain a blurred texture map; resampling the texture map and the blurred texture map according to the pre-rendering layer, synthesizing the sampling result and the pre-rendering layer to obtain a texture replacement image. The texture replacement process well restores the effects of global illumination, mirror reflection, etc., so that the obtained problem replacement image has a stronger sense of reality, and the quality of the texture replacement image is guaranteed. The entire texture replacement process adopts a pixel-by-pixel addition, subtraction, multiplication and division processing method, batch calculation, fast processing speed, and improves the efficiency of the entire texture replacement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image processing, and in particular relates to a method, device, computer equipment and storage medium for replacing texture of an image object. Background Art

[0002] With wide applications in film and television special effects production, virtual display of clothing fabrics, art and industrial design, texture replacement is gradually becoming a research hotspot in many fields such as computer graphics, vision and image and video processing.

[0003] Texture replacement refers to replacing the original texture with a new texture in the target area of ​​an image or video, so that the replaced texture presents a natural, deformation effect consistent with the original texture, and maintains the lighting and shadow information of the original texture. Natural images are generally captured in relatively complex environments, and it is usually very difficult to accurately restore the geometric shape of objects in the image and the received lighting mapping. Therefore, when the precise geometric information of the target area of ​​the original image is unknown, how to make the replacement texture present a natural deformation effect that is consistent with the original texture and depends on the geometric information of the original image, and how to maintain the lighting and shadow effects of the original texture are key issues that must be solved in the field of image texture replacement.

[0004] Some existing software such as UE4 can achieve real-time texture replacement, and the replacement speed is very fast, but the quality of the replaced image is low. Some replaced images have high quality, but the replacement efficiency is very slow. It is difficult to balance the texture replacement efficiency and the image quality after texture replacement. Summary of the invention

[0005] In view of the above technical problems, the purpose of the present invention is to provide a method, device, computer equipment and storage medium for replacing physical texture of an image, which improves the efficiency of texture replacement while ensuring the quality of the image after texture replacement.

[0006] To achieve the above-mentioned object of the invention, a first embodiment provides a method for replacing physical texture of an image, comprising the following steps:

[0007] Pre-render the texture replacement area to obtain a pre-rendered layer;

[0008] Obtaining a texture map for replacement and performing blur processing to obtain a blurred texture map;

[0009] After resampling the texture map and the blurred texture map according to the pre-rendering layer, the sampling result and the pre-rendering layer are synthesized to obtain a texture replacement image.

[0010] In one embodiment, the pre-rendered layers include: a replaceable material surface diffuse reflection illumination total value layer gray_diffuse_all; a replaceable material surface direct light layer gray_indirect of the mirror reflected part; a replaceable material surface mirror reflected illumination total value layer gray_indirect_all; a replaceable material surface diffuse reflection illumination total value layer gray_diffuse_indirect of other parts; a replaceable material surface mirror reflected direct light part layer gray_indirect_unshadow without shadow; a replaceable material surface mirror reflected UV direct light part layer uv_indirect; a replaceable material surface diffuse reflection UV illumination total value layer uv_diffuse_indirect of other parts; a replaceable material surface mirror reflected UV direct light part layer uv_indirect_unshadow without shadow; a replaceable material surface UV value layer uv_diffuse_filter; and a base color layer residual for synthesis.

[0011] In one embodiment, the pre-rendering layer is obtained in the following manner:

[0012] Render once when all replaceable material diffuses are adjusted to black to get the residual layer;

[0013] Render once when all replaceable material diffuses are adjusted to gray, and obtain the layers gray_diffuse_all, gray_indirect, gray_indirect_all, and gray_diffuse_indirect.

[0014] Adjust the diffuse of all replaceable materials to gray, and render once when the shadow is turned off globally to get the gray_indirect_unshadow layer;

[0015] For each replaceable material, set the diffuse of each replaceable material to the open shading language that grabs the UV, set other replaceable materials to gray and render once, and generate the corresponding layers uv_indirect, uv_diffuse_indirect, and uv_diffuse_filter for each replaceable material;

[0016] The replaceable material diffuse is captured by open shading language UV, and rendered once when the shadow is turned off globally to get the layer uv_indirect_unshadow.

[0017] In one embodiment, Gaussian blur processing is performed on the texture map to obtain a blurred texture map.

[0018] In one embodiment, resampling the texture map and the blurred texture map according to the pre-rendered layer includes:

[0019] Resample the texture map according to the layer uv_diffuse_filter to get the direct light texture color value;

[0020] Resample the texture map according to the layers uv_indirect and gray_indirect to get the texture color value reflected in the mirror;

[0021] Sample the blurred texture map according to the layers uv_diffuse_indirect and gray_diffuse_indirect to get the texture color value of the diffuse indirect light after replacing the texture;

[0022] In one embodiment, resampling the replacement texture data according to the layer uv_diffuse_filter includes: resampling in the texture map using the uv value stored in the layer uv_diffuse_filter to obtain a direct light texture color value;

[0023] The resampling of the texture map according to the layer uv_indirect and the layer gray_indirect includes: using the layer uv_indirect to divide the layer gray_indirect to obtain the mirror reflection uv value, and using the mirror reflection uv value to resample in the texture map to obtain the texture color value reflected in the mirror;

[0024] The layer uv_diffuse_indirect and the layer gray_diffuse_indirect sample the blurred texture map, including: using the layer uv_diffuse_indirect divided by the layer gray_diffuse_indirect to obtain a diffuse reflection uv value, and using the diffuse reflection uv value to resample in the blurred texture map to obtain a texture color value of diffuse reflection indirect light.

[0025] In one embodiment, the layer uv_indirect_unshadow and the layer gray_indirect_unshadow are used to replace the layer uv_indirect and the layer gray_indirect_unshadow; then the texture map is resampled according to the layer uv_indirect_unshadow and the layer gray_indirect_unshadow, including: dividing the layer uv_indirect_unshadow by the layer gray_indirect_unshadow to obtain the mirror reflection uv value, and resampling the texture map using the mirror reflection uv value to obtain the texture color value reflected in the mirror.

[0026] In one embodiment, when calculating the texture color value of diffuse indirect light after replacing the texture, when the texture color value of other replaceable areas is affected by replacing the texture of the current replaceable area, the current texture color value of other replaceable areas also needs to be considered. Specifically, for the current replaceable area, the current texture color value of other replaceable areas is multiplied by the current texture color value of the current replaceable area to update the current texture color value of the current replaceable area.

[0027] In one embodiment, the synthesizing the sampling result and the pre-rendered layer includes:

[0028] On the basis of the base color layer residual, the correction results of the direct light texture color value pair layer gray_indirect_all, the correction results of the mirror reflection texture color value pair layer gray_indirect_all, and the diffuse indirect light texture color value pair layer gray_diffuse_indirect are superimposed in sequence.

[0029] In one embodiment, the following formula is used to synthesize the sampling result and the pre-rendered layer:

[0030] Texture replacement image = background color layer residual + (direct_tex_color × layer gray_diffuse_all × α) + (indirect_tex_color × layer gray_indirect_all × β) + (diffuse_influence_tex_color × layer gray_diffuse_indirect × γ)

[0031] Among them, direct_tex_color represents the direct light texture color value, indirect_tex_color represents the texture color value reflected in the mirror, diffuse_influence_tex_color represents the texture color value of diffuse indirect light, α, β, and γ are all adjustment factors, and the values ​​greater than 0 are real numbers.

[0032] To achieve the above-mentioned object of the invention, a second embodiment provides a device for replacing physical texture of an image, comprising:

[0033] A pre-rendering module is used to pre-render the texture replacement area to obtain a pre-rendering layer;

[0034] A fuzzy processing module is used to obtain a texture map for replacement and perform fuzzy processing to obtain a fuzzy texture map;

[0035] The synthesis processing module is used to resample the texture map and the blurred texture map according to the pre-rendering layer, and synthesize the sampling result and the pre-rendering layer to obtain a texture replacement image.

[0036] To achieve the above-mentioned purpose of the invention, the third aspect embodiment provides a computer device, a memory, a processor and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the steps of the image object texture replacement method provided in the above-mentioned first aspect are implemented.

[0037] To achieve the above-mentioned purpose of the invention, the fourth aspect embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is processed and executed, the steps of the image object texture replacement method provided in the above-mentioned first aspect are implemented.

[0038] Compared with the prior art, the present invention has the following beneficial effects:

[0039] The method, device, computer equipment and storage medium for replacing texture of an object in an image provided by the embodiment pre-render a texture replacement area to obtain a pre-rendered layer. The pre-rendering process is short in time, which improves the efficiency of the entire texture replacement. After obtaining a texture map and blurring it to obtain a blurred texture map, the texture map and the blurred texture map are resampled according to the pre-rendering layer, and the sampling result and the pre-rendering layer are synthesized to obtain a texture replacement image. The texture replacement process well restores the effects of global illumination, mirror reflection, etc., so that the obtained problem replacement image is more realistic and the quality of the texture replacement image is guaranteed. The entire texture replacement process adopts a pixel-by-pixel addition, subtraction, multiplication and division processing method, which can be calculated in batches and has a fast processing speed, thereby improving the efficiency of the entire texture replacement. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0041] Figure 1 is a flow chart of a method for replacing texture of an image object provided by an embodiment;

[0042] Figure 2 An original image and a corresponding texture replacement image provided by an embodiment;

[0043] Figure 3 is an example picture of a pre-rendered layer provided by an embodiment;

[0044] Figure 4 It is a structural schematic diagram of a device for replacing texture of an image object provided by an embodiment. DETAILED DESCRIPTION

[0045] To make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.

[0046] In order to take into account both the image quality and texture replacement efficiency of texture replacement, the embodiments provide a method, apparatus, computer device and storage medium for replacing the texture of an image object. The image results are post-processed based on in-depth use of the information of each layer in offline rendering, so that the image can quickly change its texture based on offline rendering technology, thereby realizing the replacement of image texture with high efficiency and quality.

[0047] The embodiment provides a method and device for replacing the texture of an image object. The technical idea of ​​texture replacement is to mainly utilize the mechanism of layer synthesis. When the offline renderer is rendering, the direct light, indirect light, reflected light, UV information and other layers are rendered, and then the synthesis processing is used in combination with these layer information to obtain the image texture replacement result.

[0048] Figure 2 An embodiment provides an original image and a corresponding texture replacement image. Figure 2 (a) is the original image. The purpose of texture replacement is to replace the floor in the original image. However, since there is a mirror on the upper left and a cabinet on the upper right, which has a reflective function, the floor texture will have a mirror reflection effect after replacement. In fact, the replaceable area in the image needs to be the reflective part of the floor, mirror and cabinet, as shown below. Figure 2The texture replacement result shown in (b) is shown in FIG. 2. Taking this replacement requirement as an example, the image object texture replacement method provided by the embodiment is described below.

[0049] like Figure 1 As shown, the method for replacing texture of an image object provided by the embodiment includes the following steps:

[0050] Step 1: pre-render the texture replacement area to obtain a pre-rendered layer.

[0051] In the embodiment, the texture replacement area is pre-rendered, and the offline renderer light path search rendering layer is used to obtain the direct light, indirect light, light reflected by the mirror, and the influence on the surrounding diffuse material of the texture replacement area. Specifically, the light path expression (light_path_expression) is used to obtain the light value of the specified light path type to obtain different pre-rendered layers. At the same time, the open shading language (OSL) in the shader is used to capture the texture UV information and render it into a layer.

[0052] In the embodiment, the obtained pre-rendered layer includes:

[0053] You can replace the material surface diffuse reflection total value layer gray_diffuse_all, which is rendered by the offline renderer light path search layer in the light path expression = "C<RD'obj1'><R[D]> *(L|B)"; and the diffuse reflection (diffuse) of the replaceable material is set to gray, that is, it is rendered when RGB (128,128,128) is set. The layer gray_diffuse_all mainly obtains the direct illumination value of the replaceable surface and all illumination values ​​after one or more diffuse reflections. The corresponding example picture is as follows Figure 3 Middle (a).

[0054] The direct light layer gray_indirect of the mirror-reflected part of the material surface can be replaced. The gray_indirect layer is rendered by the offline renderer light path search layer in the light path expression = "C<R[GS]><RD'obj1'> (L|B)"; and the replaceable material diffuse is set to gray, that is, it is rendered when RGB (128,128,128) is set. The gray_indirect layer mainly obtains the direct illumination value of the mirror-reflected part of the replaceable surface. The corresponding example picture is as follows Figure 3 Middle (b).

[0055] The total illumination value layer gray_indirect_all of the mirror-reflected surface of the replaceable material is rendered by the offline renderer light path search layer in the light path expression = "C<R[GS]><RD'obj1'><R[D]> *(L|B)"; and the replaceable material diffuse is set to gray, that is, it is rendered when RGB(128,128,128) is set. The layer gray_indirect_all mainly obtains the direct illumination value of the mirror-reflected part of the replaceable surface and all illumination values ​​after one or more diffuse reflections. The corresponding example picture is as follows Figure 3 Middle (c).

[0056] The diffuse reflection of the replaceable material surface affects the total illumination value layer gray_diffuse_indirect of other parts; the layer gray_diffuse_indirect is rendered by the offline renderer light path search layer in the light path expression = "C<R[D]> +<RD'obj1'> (L|B)"; and the replaceable material diffuse is set to gray, that is, it is rendered when RGB (128,128,128) is set. The layer gray_diffuse_indirect mainly obtains the illumination value contributed by the replaceable surface to other diffuse surfaces in the scene. The corresponding example picture is as follows Figure 3 Middle (d).

[0057] The direct light layer gray_indirect_unshadow without shadows reflected by the mirror surface of the replaceable material is rendered by the offline renderer light path search layer in the light path expression = "C<R[GS]><RD'obj1'> (L|B)"; and the replaceable material diffuse is set to gray, that is, RGB (128,128,128) is set, and the global setting turns off the shadow when rendering. The layer gray_indirect_unshadow calculates the direct illumination value of the mirror-reflected part of the replaceable surface without shadows. The corresponding example picture is as follows Figure 3 Chinese (e).

[0058] The UV direct light layer uv_indirect of the surface of the replaceable material is reflected by the mirror. The layer uv_indirect is rendered by the offline renderer light path search layer in the light path expression = "C<R[GS]><RD'obj1'> (L|B)"; and the replaceable material diffuse is rendered by grabbing UV through the open shading language. The uv_indirect layer mainly obtains the direct light UV value of the mirror-reflected part of the replaceable surface. The corresponding example picture is as follows Figure 3Middle (f).

[0059] The diffuse reflection of the replaceable material surface affects the total UV illumination value layer uv_diffuse_indirect of other parts. The layer uv_diffuse_indirect is rendered by the offline renderer light path search layer in the light path expression = "C<R[D]> +<RD'obj1'> (L|B)"; and the replaceable material diffuse is rendered by grabbing UV through the open shading language. The layer uv_diffuse_indirect mainly obtains the total illumination UV value contributed by the replaceable surface to other diffuse surfaces in the scene. The corresponding example picture is as follows Figure 3 Middle (g).

[0060] The UV direct light layer uv_indirect_unshadow without shadows on the surface of the replaceable material is reflected by the mirror. The layer uv_indirect_unshadow is rendered by the offline renderer light path search layer in the light path expression = "C<R[GS]><RD'obj1'> (L|B)"; and the replaceable material diffuse is captured by open shading language UV, and is rendered when the global setting turns off the shadow. The layer uv_indirect_unshadow mainly obtains the direct light UV value of the mirror-reflected part of the replaceable surface without shadow. The corresponding example picture is as follows Figure 3 Middle (h).

[0061] The uv_diffuse_filter layer is used to represent the uv value of the direct light part of the replaceable area. The corresponding example picture is as follows: Figure 3 in(i).

[0062] The residual layer is used as the base map for synthesis. The diffuse of all replaceable areas on the map is set to black. The corresponding example picture is as follows Figure 3 Middle (j).

[0063] It should be noted that the gray_indirect_unshadow layer and the uv_indirect_unshadow layer are two optional preferred layers. Using the data of these two layers for texture replacement can make the replaced texture appear better in the mirror.

[0064] In the embodiment, when pre-rendering multiple replaceable areas, ignoring the output of the optional layer gray_indirect_unshadow and the layer uv_indirect_unshadow, N+2 renderings are required, where N represents the number of renderable areas in the scene. The N+2 renderings include:

[0065] Render once when all replaceable material diffuses are adjusted to black to generate the residual layer;

[0066] Adjust the diffuse reflection of all replaceable materials to gray, that is, render once when setting RGB (128,128,128) to generate the layers gray_diffuse_all, gray_indirect, gray_indirect_all, and gray_diffuse_indirect;

[0067] Set a single replaceable material to osl that grabs uv, and other replaceable materials to gray, that is, render once when setting RGB (128,128,128). In this way, a total of N rendering times are required to generate the layers uv_indirect, uv_diffuse_indirect, and uv_diffuse_filter.

[0068] When the gray_indirect_unshadow and uv_indirect_unshadow layers need to be generated, additional rendering N+1 times is required. In this way, for N renderable areas, the above 10 layers are obtained, and a total of 2n+3 rendering times are required.

[0069] Step 2, obtain the texture map used for replacement and perform blur processing to obtain a blurred texture map.

[0070] In the embodiment, the texture map used for replacement is read and loaded into the memory, and then the texture map loaded into the memory is blurred. Specifically, the texture map can be blurred by a method similar to Gaussian blur to obtain a blurred texture map.

[0071] Step 3: After resampling the texture map and the blurred texture map according to the pre-rendering layer, the sampling result and the pre-rendering layer are synthesized to obtain a texture replacement image.

[0072] In an embodiment, resampling the texture map and the blurred texture map according to the pre-rendering layer includes:

[0073] According to the layer uv_diffuse_filter, the texture map is resampled to obtain the direct light texture color value. Specifically, the uv value stored in the layer uv_diffuse_filter is used to resample the texture map to obtain the direct light texture color value. The formula is: direct_tex_color = sample2D (replace_texture, uv_diffuse_filter); wherein replace_texture represents the replaced texture map, sample2D() represents a two-dimensional resampling operation, and direct_tex_color represents the direct light texture color value;

[0074] The texture map is resampled according to the layers uv_indirect and gray_indirect to obtain the texture color value reflected in the mirror; specifically, the mirror reflection uv value is obtained by dividing the layer uv_indirect by the layer gray_indirect, and the mirror reflection uv value is used to resample in the texture map to obtain the texture color value reflected in the mirror, and the formula is expressed as: indirect_tex_color=sample2D(replace_texture,uv_indirect / gray_indirect); wherein indirect_tex_color represents the texture color value reflected in the mirror;

[0075] It should be noted that when calculating the texture color value reflected in the mirror, the layer uv_indirect_unshadow and the layer gray_indirect_unshadow can be used to replace the layer uv_indirect and the layer gray_indirect_unshadow; then the texture map is resampled according to the layer uv_indirect_unshadow and the layer gray_indirect_unshadow, including: dividing the layer uv_indirect_unshadow by the layer gray_indirect_unshadow to obtain the mirror reflection uv value, and using the mirror reflection uv value to resample in the texture map to obtain the texture color value reflected in the mirror, the formula is: indirect_tex_color = sample2D(replace_texture,uv_indirect_unshadow / gray_indirect_unshadow).

[0076] The blurred texture map is sampled according to the layer uv_diffuse_indirec and the layer gray_diffuse_indirect to obtain the texture color value of the diffuse indirect light after the texture is replaced; specifically, the diffuse uv value is obtained by dividing the layer uv_diffuse_indirec by the layer gray_diffuse_indirect, and the diffuse uv value is used to resample in the blurred texture map to obtain the texture color value of the diffuse indirect light. The formula is: diffuse_influence_tex_color = sample2D (replace_texture_blur, uv_diffuse_indirect / gray_diffuse_indirect); wherein replace_texture_blur represents the blurred texture map, and diffuse_influence_tex_color represents the texture color value of the diffuse indirect light.

[0077] It should be noted that when the current replaceable area replaces the texture and affects the texture color values ​​of other replaceable areas, the current texture color values ​​of other replaceable areas also need to be considered. Specifically, for the current replaceable area, the current texture color values ​​of other replaceable areas are multiplied by the current texture color value of the current replaceable area to update the current texture color value of the current replaceable area.

[0078] In the embodiment, after obtaining the resampling result, that is, obtaining the texture color value of direct light, the texture color value of mirror reflection, and the texture color value of diffuse indirect light, the resampling result and the pre-rendering layer are synthesized to obtain a texture replacement image, specifically including:

[0079] On the basis of the base color layer residual, the correction results of the direct light texture color value pair layer gray_indirect_all, the correction results of the mirror reflection texture color value pair layer gray_indirect_all, and the diffuse indirect light texture color value pair layer gray_diffuse_indirect are superimposed in sequence.

[0080] In a possible implementation, the following formula is used to synthesize the sampling result and the pre-rendering layer:

[0081] Texture replacement image = background color layer residual + (direct_tex_color × layer gray_diffuse_all × α) + (indirect_tex_color × layer gray_indirect_all × β) + (diffuse_influence_tex_color × layer gray_diffuse_indirect × γ)

[0082] Among them, α, β, and γ are adjustment factors, and their value range is a real number greater than 0. Generally, they are all 1. If there are special needs, such as wanting the mirror reflection effect to be weaker, β can be set to be greater than 0 and less than 1. A smaller γ value means that the diffuse reflection on the final image is weaker. direct_tex_color×layer gray_diffuse_all means the correction result of direct_tex_color×layer gray_diffuse_all, indirect_tex_color×layer gray_indirect_all means the correction result of indirect_tex_color on layer gray_indirect_all, and diffuse_influence_tex_color×layer gray_diffuse_indirect means the correction result of diffuse_influence_tex_color on layer gray_diffuse_indirect.

[0083] In the embodiment, each pixel in each texture replacement area is calculated in turn according to step 3 to obtain a texture replacement image. When the texture replacement area is larger, it takes more time to calculate the texture replacement image.

[0084] It should be noted that the process of calculating the texture replacement image in step 3 is to divide the light field of the texture replacement drag into an original part and an overlay part, wherein the original part is the residual layer, which contains the mirror reflection information of the replaceable material area, the diffuse reflection and mirror reflection between the non-replaceable material areas, but does not include: the diffuse reflection direct light of the replaceable material itself, the illumination of the replaceable material area by the non-replaceable material area through diffuse reflection, the diffuse reflection and mirror reflection between the replaceable material areas, and the diffuse reflection and mirror reflection of the replaceable material area by the non-replaceable material area. Therefore, it is necessary to add the original part to increase the overlay part.

[0085] The superposition part includes: the diffuse direct light of the replaceable material itself (contained in direct_tex_color*gray_diffuse_all*2.0); the replaceable material area is illuminated by the non-replaceable material area through diffuse reflection (contained in direct_tex_color*gray_diffuse_all*2.0); the diffuse reflection between the replaceable material areas (contained in direct_tex_color*gray_diffuse_all*2.0 and diffuse_influence_tex_color*gray_diffuse_indirect*2.0); the specular reflection between the replaceable material areas (contained in indirect_tex_color*gray_indirect_all*2.0); the non-replaceable material area is illuminated by the replaceable material area through specular reflection (contained in indirect_tex_color*gray_indirect_all*2.0); the non-replaceable material area is illuminated by the replaceable material area through diffuse reflection (contained in diffuse_influence_tex_color*gray_diffuse_indirect*2.0).

[0086] The method for replacing textures of image objects provided by the above embodiment has the beneficial effects of shorter preprocessing time and higher efficiency. Among them, the processing time refers to the time required for pre-offline rendering after supporting texture replacement areas in a scene. The experiment verified that when it is decided to adopt the most basic algorithm (excluding the uv_indirect_unshadow and gray_indirect_unshadow layers, and ignoring the problem of diffuse reflection duplication calculation that may exist between replaceable materials), the number of pre-rendering times required is N+2 times. Assuming that the target panorama size is 7500*1250, and the target scene is a single bathroom scene, it is tested that the residual layer is rendered to convergence on a 32-core 2.6GHz machine for about 3 hours, and other layers require about 8 hours (other layers have higher convergence requirements). A single machine rendering requires a total of 8*(N+1)+3 hours. However, since these layers can be rendered in a distributed manner, it takes a total of 8 hours to render one picture per machine. That is, the preprocessing time is greatly shortened and the efficiency is improved.

[0087] The image object texture replacement method provided in the above embodiment can well restore the effects of global illumination, mirror reflection, etc., so that the obtained problem replacement image is more realistic and the quality of the texture replacement image is guaranteed. The entire texture replacement process adopts a pixel-by-pixel addition, subtraction, multiplication and division processing method, which can be calculated in batches and has a fast processing speed, thereby improving the efficiency of the entire texture replacement.

[0088] Figure 4 FIG. 1 is a schematic diagram of the structure of a device for replacing texture of an image object provided by an embodiment. Figure 4 As shown, the apparatus for replacing texture of an image object provided by the embodiment includes:

[0089] A pre-rendering module is used to pre-render the texture replacement area to obtain a pre-rendering layer;

[0090] A fuzzy processing module is used to obtain a texture map for replacement and perform fuzzy processing to obtain a fuzzy texture map;

[0091] The synthesis processing module is used to resample the texture map and the blurred texture map according to the pre-rendering layer, and synthesize the sampling result and the pre-rendering layer to obtain a texture replacement image.

[0092] It should be noted that the image object texture replacement device provided in the above embodiment should be illustrated by the division of the above functional modules when performing image object texture replacement. The above functional distribution can be completed by different functional modules as needed, that is, the internal structure of the terminal or server is divided into different functional modules to complete all or part of the functions described above. In addition, the image object texture replacement device provided in the above embodiment belongs to the same concept as the image object texture replacement method embodiment. The specific implementation process is detailed in the image object texture replacement method embodiment, which will not be repeated here.

[0093] The embodiment further provides a computer device, a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the above-mentioned image object texture replacement method is implemented, that is, the following steps are implemented:

[0094] Step 1, pre-rendering the texture replacement area to obtain a pre-rendering layer;

[0095] Step 2, obtaining a texture map to be replaced and performing blur processing to obtain a blurred texture map;

[0096] Step 3: After resampling the texture map and the blurred texture map according to the pre-rendering layer, the sampling result and the pre-rendering layer are synthesized to obtain a texture replacement image.

[0097] The embodiment further provides a computer-readable storage medium on which a computer program is stored. When the computer program is processed and executed, the above-mentioned image object texture replacement method is implemented, that is, the following steps are implemented:

[0098] Step 1, pre-rendering the texture replacement area to obtain a pre-rendering layer;

[0099] Step 2, obtaining a texture map to be replaced and performing blur processing to obtain a blurred texture map;

[0100] Step 3: After resampling the texture map and the blurred texture map according to the pre-rendering layer, the sampling result and the pre-rendering layer are synthesized to obtain a texture replacement image.

[0101] It should be noted that the computer memory can be a volatile memory at the near end, such as RAM, or a non-volatile memory, such as ROM, FLASH, floppy disk, mechanical hard disk, etc., or a remote storage cloud. The computer processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), that is, the steps of the image object texture replacement method can be implemented by these processors.

[0102] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for replacing texture of an image object, characterized in that: The following steps are involved: Pre-render the texture replacement area, and use the offline renderer light path search rendering layer to obtain the direct light, indirect light, mirror-reflected light, and the layer of influence on the surrounding diffuse reflection material of the texture replacement area, and obtain different pre-rendering layers, including: the total value layer of diffuse reflection light on the replaceable material surface gray_diffuse_all; the direct light layer of the mirror-reflected part of the replaceable material surface gray_indirect; the total value layer of mirror-reflected light on the replaceable material surface gray_indirect_all; the total value layer of light affected by diffuse reflection on the replaceable material surface gray_diffuse_indirect irect; replace the material surface by the mirror reflection of the direct light part of the layer without shadow gray_indirect_unshadow; replace the material surface by the mirror reflection of the UV direct light part of the layer uv_indirect; replace the material surface diffuse reflection of the UV lighting total value layer uv_diffuse_indirect that affects other parts; replace the material surface by the mirror reflection of the UV direct light part of the layer uv_indirect_unshadow; replace the material surface UV value layer uv_diffuse_filter; the base color layer used for synthesis residual; Obtaining a texture map for replacement and performing blur processing to obtain a blurred texture map; Resampling the texture map and the blurred texture map according to the pre-rendered layer, including: resampling the texture map according to the layer uv_diffuse_filter to obtain the direct light texture color value; resampling the texture map according to the layer uv_indirect and the layer gray_indirect to obtain the texture color value of the mirror reflection; sampling the blurred texture map according to the layer uv_diffuse_indirect and the layer gray_diffuse_indirect to obtain the texture color value of the diffuse indirect light after the texture is replaced; The sampling results and the pre-rendered layers are synthesized, including: on the basis of the background color layer residual, the correction results of the direct light texture color value pair layer gray_indirect_all, the correction results of the mirror reflection texture color value pair layer gray_indirect_all, and the diffuse indirect light texture color value pair layer gray_diffuse_indirect are superimposed in sequence to obtain the texture replacement image.

2. The method for replacing physical texture of an image according to claim 1, characterized in that: Method for obtaining the pre-rendered layer: Render once when all replaceable material diffuses are adjusted to black to get the residual layer; Render once when all replaceable material diffuses are adjusted to gray, and obtain the layers gray_diffuse_all, gray_indirect, gray_indirect_all, and gray_diffuse_indirect. Adjust the diffuse of all replaceable materials to gray, and render once when the shadow is turned off globally to get the gray_indirect_unshadow layer; For each replaceable material, set the diffuse reflection diffuse of each replaceable material to the open shading language that grabs the UV, and set other replaceable materials to gray and render once, and generate the corresponding layers uv_indirect, uv_diffuse_indirect, and uv_diffuse_filter for each replaceable material; The replaceable material diffuse is captured by open shading language and rendered once when the shadow is turned off globally to get the layer uv_indirect_unshadow.

3. The method for replacing physical texture of an image according to claim 1, characterized in that: Perform Gaussian blur processing on the texture image to obtain a blurred texture image.

4. The method for replacing physical texture of an image according to claim 1, characterized in that: The resampling of the replacement texture data according to the layer uv_diffuse_filter includes: resampling in the texture map using the uv value stored in the layer uv_diffuse_filter to obtain the direct light texture color value; The resampling of the texture map according to the layer uv_indirect and the layer gray_indirect includes: using the layer uv_indirect to divide the layer gray_indirect to obtain the mirror reflection uv value, and using the mirror reflection uv value to resample in the texture map to obtain the texture color value reflected in the mirror; The layer uv_diffuse_indirect and the layer gray_diffuse_indirect sample the blurred texture map, including: using the layer uv_diffuse_indirect divided by the layer gray_diffuse_indirect to obtain a diffuse reflection uv value, and using the diffuse reflection uv value to resample in the blurred texture map to obtain a texture color value of diffuse reflection indirect light.

5. The method for replacing physical texture of an image according to claim 1, characterized in that: The uv_indirect layer and the gray_indirect layer are replaced by the uv_indirect_unshadow layer and the gray_indirect_unshadow layer; and then the texture map is resampled according to the uv_indirect_unshadow layer and the gray_indirect_unshadow layer, including: dividing the uv_indirect_unshadow layer by the gray_indirect_unshadow layer to obtain the mirror reflection uv value, and resampling the texture map by using the mirror reflection uv value to obtain the texture color value reflected in the mirror.

6. The method for replacing physical texture of an image according to claim 1, characterized in that: When calculating the texture color value of diffuse indirect light after replacing the texture, when the texture color value of other replaceable areas is affected by replacing the texture of the current replaceable area, the current texture color value of other replaceable areas also needs to be considered. Specifically, for the current replaceable area, the current texture color value of other replaceable areas is multiplied by the current texture color value of the current replaceable area to update the current texture color value of the current replaceable area.

7. The method for replacing physical texture of an image according to claim 1, characterized in that: The following formula is used to synthesize the sampling results and pre-rendered layers: Texture replacement image = background layer residual + (direct_tex_color × layer gray_diffuse_all × α ) + (indirect_tex_color × layer gray_indirect_all × β) + (diffuse_influence_tex_color × layer gray_diffuse_indirect × γ) Among them, direct_tex_color represents the direct light texture color value, indirect_tex_color represents the texture color value reflected in the mirror, and diffuse_influence_tex_color represents the texture color value of diffuse indirect light. α , β, and γ are all adjustment factors, and their value range is a real number greater than 0.

8. A device for replacing texture of an image object, characterized in that: include: The pre-rendering module is used to pre-render the texture replacement area, and use the offline renderer light path search rendering layer to obtain the direct light, indirect light, mirror-reflected light, and the layer of influence on the surrounding diffuse reflection material of the texture replacement area. Specifically, the light path expression is used to obtain the illumination value of the specified light path type to obtain different pre-rendering layers, including: the total value layer of diffuse reflection illumination on the replaceable material surface gray_diffuse_all; the direct light layer of the mirror-reflected part of the replaceable material surface gray_indirect; the total value layer of mirror-reflected light on the replaceable material surface gray_indirect_all; the total value layer of diffuse reflection on the replaceable material surface that affects other parts ray_diffuse_indirect; replace the material surface by the mirror reflection of the direct light part of the layer without shadow gray_indirect_unshadow; replace the material surface by the mirror reflection of the UV direct light part of the layer uv_indirect; replace the material surface diffuse reflection of the UV lighting total value layer uv_diffuse_indirect that affects other parts; replace the material surface by the mirror reflection of the UV direct light part of the layer uv_indirect_unshadow; replace the material surface UV value layer uv_diffuse_filter; the base color layer used for synthesis residual; A fuzzy processing module is used to obtain a texture map for replacement and perform fuzzy processing to obtain a fuzzy texture map; A synthesis processing module is used to resample the texture map and the blurred texture map according to the pre-rendered layer, including: resampling the texture map according to the layer uv_diffuse_filter to obtain the direct light texture color value; resampling the texture map according to the layer uv_indirect and the layer gray_indirect to obtain the texture color value of the mirror reflection; sampling the blurred texture map according to the layer uv_diffuse_indirect and the layer gray_diffuse_indirect to obtain the texture color value of the diffuse indirect light after the texture is replaced; The sampling results and the pre-rendered layers are synthesized, including: on the basis of the background color layer residual, the correction results of the direct light texture color value pair layer gray_indirect_all, the correction results of the mirror reflection texture color value pair layer gray_indirect_all, and the diffuse indirect light texture color value pair layer gray_diffuse_indirect are superimposed in sequence to obtain the texture replacement image.

9. A computer device, a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the image object texture replacement method described in any one of claims 1-7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is processed and executed, the steps of the image object texture replacement method described in any one of claims 1-7 are implemented.

Citation Information

Patent Citations

  • Method based on physical coloring and system thereof

    CN106780702A

  • Panoramic image display method and device, electronic equipment and storage medium

    CN113554738A