Image processing method, device, equipment and storage medium
By obtaining the two-dimensional original image and generating a mask image and a three-dimensional model, and integrating it with the three-dimensional scene information, the problem in the existing technology that the image generation effect does not match the input image is solved, and a highly controllable three-dimensional display effect is achieved.
Patent Information
- Application Number
- CN202410860965.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-06-28
AI Technical Summary
The image effects generated by existing mapping tools based on artificial intelligence algorithms are prone to finished images that do not conform to the input images and lack controllability.
By obtaining the two-dimensional original image, generating a mask image and a three-dimensional model, fusing it with the category-matching three-dimensional scene information, and rendering to generate a display rendering, the fusion effect of the three-dimensional model and the three-dimensional scene information is improved.
The generated three-dimensional display renderings have a strong correlation with the target object, and the effect is highly controllable, avoiding the randomness problem of images generated by AI algorithms.
Smart Images

Figure CN118397202B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to the field of intelligent design and image processing technology. Background Art
[0002] Some mapping tools based on artificial intelligence (AI) algorithms have a graphics generation mode, which can use AI algorithms to process input images, text, etc. to generate corresponding finished images. However, the effect of the images generated by AI mapping tools is mainly determined by the AI algorithms or AI models they use, which have a certain degree of randomness and are prone to generating finished images that do not conform to the input images. Summary of the invention
[0003] The present disclosure provides an image processing method, apparatus, device and storage medium to solve or alleviate one or more technical problems in the prior art.
[0004] In a first aspect, the present disclosure provides an image processing method, comprising:
[0005] Obtain the original two-dimensional image of the target object;
[0006] Generate a mask image of the target object according to the two-dimensional original image;
[0007] Generate a three-dimensional model of the target object according to the mask image of the target object, wherein the two-dimensional original image is used to generate a material map of the three-dimensional model, and the mask image is used to generate a transparent channel image of the three-dimensional model;
[0008] Obtaining three-dimensional scene information matching the category of the target object;
[0009] fusing the three-dimensional model with the three-dimensional scene information to obtain fused information;
[0010] A display effect diagram of the target object is generated based on the fusion information.
[0011] In a second aspect, the present disclosure provides an image processing device, comprising:
[0012] A two-dimensional image acquisition module is used to acquire a two-dimensional original image of a target object;
[0013] A mask image generating module, used for generating a mask image of the target object according to the two-dimensional original image;
[0014] A three-dimensional model generation module, used to generate a three-dimensional model of the target object according to the mask image of the target object, wherein the two-dimensional original image is used to generate a material map of the three-dimensional model, and the mask image is used to generate a transparent channel image of the three-dimensional model;
[0015] A three-dimensional scene acquisition module is used to acquire three-dimensional scene information matching the category of the target object;
[0016] A fusion module, used for fusing the three-dimensional model with the three-dimensional scene information to obtain fusion information;
[0017] The display effect generation module is used to render and generate a display effect diagram of the target object according to the fusion information.
[0018] In a third aspect, an electronic device is provided, including:
[0019] at least one processor; and
[0020] a memory communicatively connected to the at least one processor; wherein,
[0021] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute any method in the embodiments of the present disclosure.
[0022] In a fourth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute any method according to the embodiments of the present disclosure.
[0023] In a fifth aspect, a computer program product is provided, comprising a computer program, which implements any method according to the embodiments of the present disclosure when executed by a processor.
[0024] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments provided according to the present disclosure and should not be regarded as limiting the scope of the present disclosure.
[0026] Figure 1 is a flowchart of an image processing method according to an embodiment of the present disclosure;
[0027] Figure 2 is a flowchart of an image processing method according to another embodiment of the present disclosure;
[0028] Figure 3 is a flowchart of an image processing method according to another embodiment of the present disclosure;
[0029] Figure 4 It is a schematic diagram of the two-dimensional original graph;
[0030] Figure 5 It is a schematic diagram of the main image obtained by cutting out the two-dimensional original image;
[0031] Figure 6 It is a schematic diagram of a mask image generated based on a subject image;
[0032] Figure 7 is a flowchart of an image processing method according to another embodiment of the present disclosure;
[0033] Figure 8 is a flowchart of an image processing method according to another embodiment of the present disclosure;
[0034] Fig. 9 This is a schematic diagram of adding material mapping to a patch;
[0035] Fig.10 This is a schematic diagram of adding a transparent channel map to a patch;
[0036] Fig.11 It is a schematic diagram of the patch model before transformation in the three-dimensional scene;
[0037] Fig.12 It is a schematic diagram of the patch model after transformation in the three-dimensional scene;
[0038] Fig.13 is a structural schematic diagram of an image processing device according to an embodiment of the present disclosure;
[0039] Fig.14 It is a schematic diagram of the process of generating a three-dimensional rendering based on a two-dimensional image;
[0040] Fig.15 is a block diagram of an electronic device for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION
[0041] The present disclosure will be further described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0042] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the main purpose of the present disclosure.
[0043] Figure 1is a flowchart of an image processing method according to an embodiment of the present disclosure, which may include:
[0044] S101, obtaining a two-dimensional original image of a target object;
[0045] S102, generating a three-dimensional model of the target object according to the two-dimensional original image;
[0046] S103, obtaining three-dimensional scene information matching the category of the target object;
[0047] S104, fusing the three-dimensional model with the three-dimensional scene information to obtain fused information;
[0048] S105: Rendering and generating a display effect diagram of the target object according to the fusion information.
[0049] In the disclosed embodiment, the two-dimensional original image (which may be referred to as the original image) may include an image captured by an image acquisition device such as a camera or a webcam. The two-dimensional original image may be displayed on the front end of an electronic device such as a mobile phone, a tablet computer, or a laptop computer. The two-dimensional original image may include one or more objects. For example, a two-dimensional original image of a study may include objects such as a table, a chair, and a bookcase. A two-dimensional original image of a bedroom may include a bed, a wardrobe, and the like. The object to be processed in the two-dimensional original image may be understood as a target object. The target object may be determined based on manual selection, model recognition, default, preset, and the like, and the specific method of determining the target object is not limited. After generating a three-dimensional model of the target object according to the two-dimensional original image, the three-dimensional model of the target object may be fused with the three-dimensional scene information matching the category of the target object to obtain fused information.
[0050] In the disclosed embodiment, three-dimensional scene information can be matched from a three-dimensional scene database according to the category of the target object. The three-dimensional scene information can be used to generate a three-dimensional background image of the target object, and therefore can also be referred to as three-dimensional background information. If a variety of three-dimensional scene information is matched, the three-dimensional scene information to be used can be determined by user selection, random selection, etc. For example, if the category of the target object is a sofa, three-dimensional living room scene information, three-dimensional hotel scene information, etc. may be matched. For another example, if the category of the target object is a dog, three-dimensional lawn scene information, three-dimensional pet hospital information, etc. may be matched. There are many ways to determine the category of the target object, such as using presets, inputs, selections, object recognition model recognition, etc. to determine the category of the target object. Using the fusion information of the three-dimensional model and the three-dimensional scene information, a display effect diagram of the target object can be rendered and generated at the front end of the electronic device. The display effect diagram can include not only a three-dimensional scene effect diagram corresponding to the three-dimensional scene information, but also a three-dimensional model of the target object fused at a certain position of the three-dimensional scene effect diagram.
[0051] In an embodiment of the present disclosure, if the two-dimensional original image includes multiple target objects, the categories of different target objects can be compared. If the categories of all target objects are the same, the three-dimensional scene information matching the category can be used to merge with the three-dimensional models of the multiple target objects. If the multiple target objects have more than two categories, a main category can be selected. For example, the category of most objects is used as the main category, the category of the object in the middle is used as the main category, or the main category is randomly selected, etc. The three-dimensional scene information matching the main category is used to merge with the three-dimensional models of the multiple target objects. The display effect map generated by rendering according to the fusion information can include not only the three-dimensional scene effect map corresponding to the three-dimensional scene information, but also the three-dimensional models of multiple target objects merged on the three-dimensional scene effect map.
[0052] In the disclosed embodiment, the three-dimensional model of the target object and the three-dimensional scene information are fused and rendered to generate a display effect diagram, which is beneficial to improving the fusion effect of the three-dimensional model and the three-dimensional scene information, generating a three-dimensional display effect diagram that is highly correlated with the target object, and the generated effect is highly controllable.
[0053] In one embodiment, the method further includes: identifying the two-dimensional original image or main image of the target object to obtain the category of the target object.
[0054] In the embodiments of the present disclosure, an artificial intelligence model such as a classification model, an object recognition model or a large model can be used to identify the category of the target object from the two-dimensional original image or the main image. For example, the two-dimensional original image or the main image is input into the artificial intelligence model, and the category of the target object is determined according to the output result of the artificial intelligence model.
[0055] According to the embodiments of the present disclosure, by identifying the category of the target object in the two-dimensional original image or the main image, a more suitable three-dimensional scene can be adapted for the target object as the background, which is beneficial to improving the fusion effect of the main body and the background and improving the accuracy of the generated model.
[0056] Figure 2 is a flow chart of an image processing method according to another embodiment of the present disclosure, and the method may include one or more features of the above-mentioned image processing method. In one embodiment, S102 generates a three-dimensional model of the target object according to the two-dimensional original image, including:
[0057] S201, generating a mask image of the target object according to the two-dimensional original image;
[0058] S202: Generate a three-dimensional model of the target object according to the mask image of the target object.
[0059] In one embodiment, the two-dimensional original image is used to generate a material map of the three-dimensional model, and the mask image is used to generate a transparent channel image of the three-dimensional model.
[0060] In the disclosed embodiments, the mask may also be referred to as an occlusion, a cover, etc. By adjusting the RGB value of the image, part of the image content may be blocked and the image content of a specific area may be displayed, thereby generating a mask image. If the two-dimensional original image contains only one target object, the two-dimensional original image may be directly masked to obtain a mask image of the target object. If the two-dimensional original image includes multiple objects, the main image of the target object may be extracted from the two-dimensional original image, and then the main image of the target object may be masked to obtain a mask image of the target object. The mask image may have a variety of colors. For example, the area where the target object is located in the mask image is white, and the area other than the target object is black.
[0061] In one example, a three-dimensional model can be constructed based on a mask image and a two-dimensional original image of a target object, the two-dimensional original image of the target object is used as a material map of the three-dimensional model, and the mask image of the target object is used as a transparent channel map of the three-dimensional model. In another example, a three-dimensional model can also be constructed based on a mask image and a main image of a target object, the main image of the target object is used as a material map of the three-dimensional model, and the mask image of the target object is used as a transparent channel map of the three-dimensional model. In some examples, the file type of the three-dimensional model can be an objective (OBJ) file or other types of files.
[0062] According to the embodiment of the present disclosure, a mask image is generated by a two-dimensional original image, and then a three-dimensional model of the target object is generated, so that a three-dimensional model that is more relevant to the target object to be displayed can be obtained, and then a display effect image that is more relevant to the target object can be obtained.
[0063] Figure 3 FIG. 1 is a flow chart of an image processing method according to another embodiment of the present disclosure, and the method may include one or more features of the above-mentioned image processing method. In one embodiment, S201 generates a mask image of the target object according to the two-dimensional original image, including:
[0064] S301, identifying the two-dimensional original image to obtain a main image of the target object;
[0065] S302: Generate a mask image of the target object according to the main image of the target object.
[0066] In the disclosed embodiment, the two-dimensional original image can be identified, such as by cutting out the image, to obtain the main image of the target object included in the two-dimensional original image. For example, the two-dimensional original image of the furniture is cut out to obtain the main image of the sofa. If the two-dimensional original image is identified to obtain the main images of multiple objects, one or more main images of the target object can be selected therefrom. For example, in response to the user's selection operation on an object on the two-dimensional original image on the interface of the terminal device, the two-dimensional original image is cut out to obtain the main image of the target object. If the cutout result includes multiple objects, the main image of the target object can be obtained by random selection, user selection or default selection from the multiple objects. For example, the main image in the middle of the two-dimensional original image is the main image of the target object by default. For another example, the main image with the largest size is the main image of the target object by default. By adjusting the RGB value of the main image of the target object, a mask image of the target object can be generated.
[0067] In some examples, when performing a cutout process on a two-dimensional original image, the area where the target object is located in the two-dimensional original image can be determined first, and then the other parts outside the area can be cut out. The image retained after cutting can be used as the main image of the target object, or the image retained after cutting can be enlarged or reduced in proportion to be used as the main image of the target object. In other words, the size ratio of the target object in the two-dimensional original image is consistent with the size ratio of the target object in the main image and the mask image.
[0068] See also Figure 4 , Figure 5 and Figure 6 ,right Figure 4 The two-dimensional original image is cut out and the Figure 5 The main image of the table and chair combination shown in FIG. The main image of the table and chair combination is masked to obtain Figure 6 The mask image of the table and chair combination is shown. In the mask image, the area corresponding to the table and chair combination can be white, and the other parts can be black.
[0069] According to the embodiment of the present disclosure, a mask image of the target object is generated based on the main image of the target object, and a three-dimensional model of the target object can be subsequently generated based on the main image and the mask image to obtain a three-dimensional model that is more relevant to the target object to be displayed. Compared with images generated based on AI algorithms, the three-dimensional model is more controllable.
[0070] Figure 7 FIG. 1 is a flow chart of an image processing method according to another embodiment of the present disclosure, and the method may include one or more features of the above-mentioned image processing method. In one embodiment, S201 generates a mask image of the target object according to the two-dimensional original image, including:
[0071] S701, identifying the two-dimensional original image to obtain multiple main images;
[0072] S702, selecting a main body diagram of the target object from the multiple main body diagrams;
[0073] S703: Generate a mask image of the target object according to the main image of the target object.
[0074] In an embodiment of the present disclosure, if the two-dimensional original image includes multiple objects, multiple main images may be identified from the two-dimensional original image. For example, the two-dimensional original image is cut out to obtain main images of multiple objects. In this case, the main image of one or more target objects to be displayed can be selected from the main images of the multiple objects. The selection method can be random selection, selection based on the position of the main image in the two-dimensional original image, selection based on the size of the main image, selection in response to user operation, etc. For example, if the two-dimensional original image of the furniture is cut out, the main images of the sofa, table and bed are obtained. The main image of the table closest to the center point of the two-dimensional original image can be selected, the main image of the bed can be selected in response to user operation, or any main image can be randomly selected. The RGB value of the main image of the selected target object can be adjusted to generate a mask image of the target object, see Figure 6 .
[0075] According to an embodiment of the present disclosure, if multiple main images are identified from a two-dimensional original image, a corresponding mask image can be generated based on the main image of the selected target object, and then a three-dimensional model of the target object can be generated based on the main image and the mask image, thereby obtaining a three-dimensional model that is more relevant to the target object to be displayed.
[0076] In one implementation, S202 generates a three-dimensional model of the target object according to the mask image of the target object, including: generating a three-dimensional patch model according to the main image of the target object, the mask image of the target object and primitive information.
[0077] In one implementation, the graphic element information includes at least one of: size information of the two-dimensional original image, size information of the main image of the target object, and main anchor point information.
[0078] In the disclosed embodiment, the size information of the image may include the length, width, aspect ratio, etc. of the image. If the two-dimensional original image is not subjected to a cutout process, but the RGB value of the two-dimensional original image is directly adjusted to obtain a mask image of the target object, the two-dimensional original image may be equivalent to the main image of the target object, and the size information of the two is consistent. If the two-dimensional original image is subjected to a cutout process to obtain the main image of the target object, the size of the two-dimensional original image may be larger than the size of the main image.
[0079] In the disclosed embodiment, the subject anchor point information may include the center position of the subject image of the target object. For example, if the subject image is a regular image, such as a rectangle, a circle, or a square, the subject anchor point information may include the center point coordinates of the regular image. For another example, if the subject image is an irregular image such as an irregular quadrilateral, an irregular polygon, etc., the center point coordinates may be calculated according to certain rules based on the edge coordinates of the irregular image.
[0080] The size of the patch model of the target object can be determined based on the size information of the 2D original image, or the size of the patch model of the target object can be determined based on the size information of the main image. The main anchor point information can be used to determine the position of the main image of the target object in the 2D original image, and then the target point of the camera that generates the display effect image (i.e. the position where the camera is aimed) can be determined.
[0081] According to the embodiments of the present disclosure, based on the size information of the two-dimensional original image, the size information of the main image of the target object, the main anchor point information and other graphic element information, the size, position and other information of the target object's mesh model can be determined, so that the mesh model can be closer to the target object to be displayed.
[0082] Figure 8 1 is a flow chart of an image processing method according to another embodiment of the present disclosure, and the method may include one or more features of the above-mentioned image processing method. In one embodiment, a three-dimensional patch model is generated according to the main image of the target object, the mask image of the target object and the primitive information, including:
[0083] S801, constructing a face patch according to the size of the main image of the target object, wherein the size ratio of the face patch is consistent with the size ratio of the main image of the target object;
[0084] S802, generating material information according to the mask image and the main image of the target object;
[0085] S803 . According to the material information, the main image of the target object is used as the material map of the patch, and the mask image of the target object is used as the transparent channel image of the patch to obtain a patch model of the target object.
[0086] In the disclosed embodiment, a facet is constructed based on the size, shape, etc. of the main image of the target object. For example, if the main image of the target object is a rectangle and the size ratio is 3:4, a rectangular facet with a size ratio of 3:4 can be generated. For another example, if the main image of the target object is a quadrilateral and the size ratio is 2:2:3:3, a quadrilateral facet with a size ratio of 2:2:3:3 can be generated. Material information related to the color, texture, size, etc. of the target object can be obtained from the main image of the target object. Material information related to the transparency of the target object can be obtained from the mask image. In addition, some material information can be preset, such as parameters related to reflection, refraction, brightness, etc. The main image of the target object, such as a table and chair combination, is used as the material map of the facet, see Fig. 9 Then, the mask map of the target object is used as the transparent channel map of the patch, see Fig.10 . The transparency channel is also called the alpha channel, which can represent the transparency information of the pixels in the digital image. For example, the white alpha pixels in the transparency channel map are used to define opaque color pixels, while the black alpha pixels are used to define transparent pixels. In addition, the grayscale pixels between black and white can define the semi-transparent parts in the color image. After adding the material map and the transparency channel map to the patch, the patch model of the target object can be obtained.
[0087] According to an embodiment of the present disclosure, using the main image of the target object as the material map of the patch model can make the material of the generated patch model of the target object closer to the material of the target object in the two-dimensional original image, and using the mask image of the target object as the transparent channel image of the patch model can highlight the part of the patch model of the target object with the material map.
[0088] In one implementation, S104 fuses the three-dimensional model with the three-dimensional scene information to obtain fused information, including: fusing the patch model of the target object with the three-dimensional scene information according to the calibration information of the two-dimensional original image to obtain fused information.
[0089] In the disclosed embodiment, the calibration information of the two-dimensional original image may include the pitch angle, field of view angle, etc. determined based on the camera that shoots the two-dimensional original image. The calibration information may be used to adjust the pitch angle, field of view angle, and other parameters of the patch model of the target object, thereby adjusting the position of the rendered target object in the background image, and improving the fusion effect of the target object and the background image.
[0090] In one embodiment, the calibration information includes the perspective relationship of the two-dimensional original image. According to the calibration information of the two-dimensional original image, the mesh model of the target object and the three-dimensional scene information are fused to obtain fusion information, including: correcting the mesh model of the target object according to the perspective relationship of the two-dimensional original image; fusing the corrected mesh model with the three-dimensional scene information to obtain fusion information.
[0091] In one implementation, the perspective relationship of the two-dimensional original image includes: a pitch angle and / or a field angle of view of the two-dimensional original image.
[0092] In the disclosed embodiment, the pitch angle may be the angle between the X-axis of the coordinate system and the horizontal plane; the field of view angle may be the angle formed by the two edges of the maximum range of the shooting angle of the two-dimensional original image, with the shooting angle of the two-dimensional original image as the vertex. The relative position relationship between the patch model and the background image can be adjusted according to the pitch angle and / or the field of view angle of the two-dimensional original image.
[0093] In the disclosed embodiments, the default pitch angle, field of view angle, etc. of the mesh model in the three-dimensional scene information can be set, and then the mesh model can be transformed (transformed) using the perspective relationship of the two-dimensional original image, which can also be understood as correcting the mesh model using the perspective relationship. Before the transformation (i.e., before the perspective relationship correction), the fusion effect between the mesh model of the target object and the background image corresponding to the three-dimensional scene information may not be good. After the perspective relationship transformation is used, the fusion effect between the mesh model of the target object and the background image can be improved. For example, the rotation of the mesh model can be controlled based on the pitch angle of the two-dimensional original image so that the mesh model is perpendicular to the direction of the camera (the virtual camera used to generate the effect image). For example, if the pitch angle of the two-dimensional original image is 30 degrees, the mesh model can be controlled to rotate downward 30 degrees to be perpendicular to the camera. After the rotation, the field of view angle of the two-dimensional original image can be used as the field of view angle of the camera to generate a display effect image. For example, see Fig.11 , before the transformation, the table and chair combination does not fit tightly with the carpet in the background image. Fig.12 ,After the transformation, the perspective relationship between the face model of the table and chair combination and the ,pitch angle and field of view in the background image is corrected, so that the face model of the table and chair combination is ,perpendicular to the camera, so that the table and chair combination fits ,the carpet more closely. Fig.11 It can be understood as an intermediate state effect diagram, which may not be displayed on the front end Fig.11 Show only Fig.12 , or you can display Fig.11 Show again Fig.12 .
[0094] In one embodiment, a display effect diagram of the target object is generated based on the rendering of the fusion information, including: adding lighting information and / or effect information to the fusion information, and rendering to generate a display effect diagram of the target object, wherein the display effect diagram includes the lighting effects and / or shadow effects of the surface model of the target object.
[0095] For example, adding highlights to the patch model of the target object, adding stage lights to the surrounding area of the patch model of the target object, adding shadow effects to one side of the patch model of the target object, etc.
[0096] According to the embodiments of the present disclosure, in order to add lighting information and / or effect information to the display effect diagram, the fusion effect of the surface model and the background image can be improved, making the surface model more realistic and improving the overall visual effect of the display effect diagram.
[0097] Fig.13 1 is a schematic diagram of the structure of an image processing device 1300 according to an embodiment of the present disclosure. The device may include:
[0098] A two-dimensional image acquisition module 1310 is used to acquire a two-dimensional original image of a target object;
[0099] A mask image generating module 1320 is used to generate a mask image of the target object according to the two-dimensional original image;
[0100] A three-dimensional model generation module 1330 is used to generate a three-dimensional model of the target object according to the mask image of the target object, wherein the two-dimensional original image is used to generate a material map of the three-dimensional model, and the mask image is used to generate a transparent channel image of the three-dimensional model;
[0101] A three-dimensional scene acquisition module 1340 is used to acquire three-dimensional scene information matching the category of the target object;
[0102] A fusion module 1350, used for fusing the 3D model with the 3D scene information to obtain fusion information;
[0103] The display effect generation module 1360 is used to render and generate a display effect diagram of the target object according to the fusion information.
[0104] In one implementation, the mask image generating module 1320 is used to identify the two-dimensional original image to obtain a main image of the target object; and generate a mask image of the target object according to the main image of the target object.
[0105] In one embodiment, the mask image generating module 1320 is used to identify the two-dimensional original image to obtain multiple main images; select the main image of the target object from the multiple main images;
[0106] A mask image of the target object is generated according to the main image of the target object.
[0107] In one embodiment, the three-dimensional model generation module 1330 is used to generate a three-dimensional patch model based on the main image of the target object, the mask image of the target object and the primitive information, wherein the primitive information includes: size information of the two-dimensional original image, size information of the main image of the target object, and at least one of the main anchor point information.
[0108] In one implementation, the three-dimensional model generation module 1330 is used to:
[0109] Constructing a face patch according to the size of the main image of the target object, the size ratio of the face patch is consistent with the size ratio of the main image of the target object, and the face patch is a three-dimensional model;
[0110] Generate material information according to the mask image and the main image of the target object;
[0111] According to the material information, the main image of the target object is used as the material map of the patch, and the mask image of the target object is used as the transparent channel image of the patch to obtain the patch model of the target object.
[0112] In one implementation, the fusion module 1350 is used to fuse the patch model of the target object and the three-dimensional scene information according to the calibration information of the two-dimensional original image to obtain fusion information.
[0113] In one embodiment, the calibration information includes the perspective relationship of the two-dimensional original image. According to the calibration information of the two-dimensional original image, the fusion module 1350 is used to correct the mesh model of the target object according to the perspective relationship of the two-dimensional original image; and fuse the corrected mesh model with the three-dimensional scene information to obtain fusion information.
[0114] In one implementation, the perspective relationship of the two-dimensional original image includes: a pitch angle and / or a field angle of view of the two-dimensional original image.
[0115] In one implementation, the image processing apparatus further includes: an identification module 1370, configured to identify the main image of the target object and obtain a category corresponding to the main image of the target object.
[0116] In one embodiment, the display effect generation module 1360 is used to add lighting information and / or effect information to the fusion information, and render to generate a display effect diagram of the target object, which includes the lighting effect and / or shadow effect of the mesh model of the target object.
[0117] The image processing method of the disclosed embodiment can perform secondary creation in a three-dimensional (3D) scene based on a two-dimensional (2D) image, and can adjust the model of the 2D image to improve the controllability of the finished image. In the 3D scene, it can further provide the ability to adjust the perspective relationship, material editing, lighting editing, etc., to achieve a better fusion effect between the subject and the background, and finally provide a realistic 3D design effect finished image through rendering by the rendering engine.
[0118] like Fig.14 As shown, a process of generating a three-dimensional rendering based on a two-dimensional image is as follows:
[0119] Step 1: In the image generation tool (or platform), users can upload and use any ordinary 2D image. The 2D image can be the original image with background, or a cutout image with only the subject.
[0120] Step 2: Automatically process the image to generate a series of data:
[0121] (1) Cut out the original image to generate the main image, see Figure 4 and Figure 5 ;
[0122] (2) For the subject image, a black and white mask image (also called the subject mask image) is generated based on the RGB values to describe the subject outline, see Figure 6 ;
[0123] (3) Generate image primitive information based on the original image. For example, the image primitive information may include the original image size and subject anchor point information (such as the center point of the original image).
[0124] (4) Obtain algorithm calibration information, classify and identify subject categories, and obtain the perspective relationship of the original image (the original image shooting pitch angle, field of view, etc.). The perspective relationship can represent the visual effects of the image being larger near and smaller far away, sparse near and dense far away, high near and low far away, etc., at different positions and angles of the image on the screen.
[0125] Step 3: Generate the main body patch model through the main body image, main body mask image, and primitive information obtained in step 2. The specific generation method is as follows:
[0126] (1) Construct a patch, keep the size ratio of the patch and the image (subject image) consistent, and generate a 3D model file such as an obj file;
[0127] (2) Generate material information based on the subject mask map and the subject map, use the subject map as the material map of the patch, and use the subject mask map as the transparent channel map of the patch. The mask map describes the outline of the subject. After using the mask map as the transparent channel map of the patch, the patch can only show the subject and the rest can be transparent.
[0128] Step 4: Adapt the 3D scene using the algorithm calibration information obtained in step 2 and the main body patch model obtained in step 3, and perform one or more of the following automatic adjustment operations:
[0129] (1) Suitable 3D scenes can be recommended based on subject categories;
[0130] (2) Restoration of perspective relationship: the perspective relationship of the original image can automatically complete the transformation of the main face model, see Fig.11 and Fig.12 , to achieve the effect of visual harmony;
[0131] (3) Automatically generate lights to create shadows on the mesh model, making it more integrated with the 3D scene.
[0132] Step 5: After the above steps, the camera can be freely adjusted to generate the effect map. The above steps can provide the ability of secondary creation of 2D images in 3D scenes, and can provide realistic 3D design effects through mask patch model construction, perspective relationship restoration, lighting scene adaptation, etc.
[0133] Fig.15 FIG. 1 is a structural block diagram of an electronic device according to an embodiment of the present disclosure. Fig.15 As shown, the electronic device includes: a memory 1510 and a processor 1520, and the memory 1510 stores a computer program that can be run on the processor 1520. The number of memories 1510 and processors 1520 can be one or more. The memory 1510 can store one or more computer programs. When the one or more computer programs are executed by the electronic device, the electronic device executes the method provided by the above method embodiment. The electronic device may also include: a communication interface 1530, which is used to communicate with external devices and perform data exchange transmission.
[0134] If the memory 1510, the processor 1520 and the communication interface 1530 are implemented independently, the memory 1510, the processor 1520 and the communication interface 1530 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.15Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0135] Optionally, in a specific implementation, if the memory 1510, the processor 1520 and the communication interface 1530 are integrated on a chip, the memory 1510, the processor 1520 and the communication interface 1530 can communicate with each other through an internal interface.
[0136] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the Advanced RISC Machines (ARM) architecture.
[0137] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory, and may also include a non-volatile random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DR RAM).
[0138] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instruction is loaded and executed on a computer, the process or function according to the embodiment of the present disclosure is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instruction can be transmitted from a website site, computer, server or data center by wired (for example: coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (for example: infrared, Bluetooth, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)), etc. It is worth noting that the computer-readable storage medium mentioned in the present disclosure may be a non-volatile storage medium, in other words, a non-transient storage medium.
[0139] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0140] In the description of the embodiments of the present disclosure, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0141] In the description of the embodiments of the present disclosure, unless otherwise specified, " / " means or, for example, A / B can mean A or B. "And / or" in this article is only a way to describe the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0142] In the description of the embodiments of the present disclosure, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "plurality" means two or more.
[0143] The above description is only an exemplary embodiment of the present disclosure and is not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. An image processing method, include: Obtain the original two-dimensional image of the target object; Generating a mask image of the target object according to the two-dimensional original image; According to the mask map of the target object, a three-dimensional model of the target object is generated, wherein the two-dimensional original map is used to generate a material map of the three-dimensional model, and the mask map is used to generate a transparent channel map of the three-dimensional model; wherein, according to the mask map of the target object, generating the three-dimensional model of the target object includes: generating a three-dimensional patch model according to the main map of the target object, the mask map of the target object and the primitive information; the primitive information includes the size information of the main map of the target object; wherein, according to the main map of the target object, the mask map of the target object and the primitive information, generating the three-dimensional patch model includes: constructing a patch according to the size of the main map of the target object, and the size ratio of the patch is consistent with the size ratio of the main map of the target object; generating material information according to the mask map and the main map of the target object; according to the material information, using the main map of the target object as the material map of the patch, and using the mask map of the target object as the transparent channel map of the patch, to obtain the patch model of the target object; obtaining the three-dimensional scene information of the category matching of the target object; Fusing the three-dimensional model with the three-dimensional scene information to obtain fused information; A display effect diagram of the target object is generated according to the fusion information rendering.
2. The method according to claim 1, in, Generating a mask image of the target object according to the two-dimensional original image includes: Recognize the two-dimensional original image to obtain a main image of the target object; A mask image of the target object is generated according to the main image of the target object.
3. The method according to claim 1, in, Generating a mask image of the target object according to the two-dimensional original image includes: Recognize the two-dimensional original image to obtain multiple subject images; selecting a subject image of the target object from among the plurality of subject images; A mask image of the target object is generated according to the main image of the target object.
4. The method according to any one of claims 1 to 3, in, The graphic element information also includes: at least one of size information of the two-dimensional original graphic and main body anchor point information.
5. The method according to claim 1, in, The three-dimensional model and the three-dimensional scene information are fused to obtain fused information, including: According to the calibration information of the two-dimensional original image, the patch model of the target object and the three-dimensional scene information are fused to obtain fused information.
6. The method according to claim 5, in, The calibration information includes the perspective relationship of the two-dimensional original image. According to the calibration information of the two-dimensional original image, the patch model of the target object and the three-dimensional scene information are fused to obtain fusion information, including: Correcting the patch model of the target object according to the perspective relationship of the two-dimensional original image; The corrected patch model is fused with the three-dimensional scene information to obtain fused information.
7. The method according to claim 5, in, The perspective relationship of the two-dimensional original image includes: a pitch angle and / or a field angle of view of the shooting of the two-dimensional original image.
8. The method according to any one of claims 1 to 3, in, The method further comprises: The two-dimensional original image or main image of the target object is identified to obtain the category of the target object.
9. The method according to any one of claims 1 to 3, in, Generating a display effect diagram of the target object according to the fusion information rendering includes: Lighting information and / or effect information are added to the fusion information, and a display effect diagram of the target object is generated by rendering, wherein the display effect diagram includes the lighting effect and / or shadow effect of the mesh model of the target object.
10. An image processing device, include: A two-dimensional image acquisition module is used to acquire a two-dimensional original image of a target object; A mask image generating module, used for generating a mask image of the target object according to the two-dimensional original image; A three-dimensional model generation module, used to generate a three-dimensional model of the target object according to the mask map of the target object, wherein the two-dimensional original map is used to generate a material map of the three-dimensional model, and the mask map is used to generate a transparent channel map of the three-dimensional model; wherein the three-dimensional model generation module is used to generate a three-dimensional patch model according to the main map of the target object, the mask map of the target object and the primitive information; the primitive information includes the size information of the main map of the target object; wherein the three-dimensional model generation module is used to construct a patch according to the size of the main map of the target object, and the size ratio of the patch is consistent with the size ratio of the main map of the target object; material information is generated according to the mask map and the main map of the target object; according to the material information, the main map of the target object is used as the material map of the patch, and the mask map of the target object is used as the transparent channel map of the patch to obtain the patch model of the target object; a three-dimensional scene acquisition module is used to acquire the three-dimensional scene information of the category matching of the target object; A fusion module, used for fusing the three-dimensional model with the three-dimensional scene information to obtain fusion information; A display effect generation module is used to render and generate a display effect diagram of the target object according to the fusion information.
11. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-9.
13. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 9.
