A system and method for rendering specific areas of an image based on auxiliary grids
Through the auxiliary grid-based specific area rendering system of pictures, combined with deep learning and computer vision technology, the grid distortion parameters and light and shadow effects are automatically calculated, which solves the problems of low rendering efficiency and large errors in the existing technology, and achieves high efficiency and accuracy. rendering effect.
Patent Information
- Application Number
- CN202210292384.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-24
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-03-24
AI Technical Summary
In the existing technology, image rendering based on 3D modeling has a long cycle and high resource consumption, while 2D rendering technology is inefficient and relies on manual operations, resulting in long modeling time and large errors.
It adopts an auxiliary grid-based image-specific area rendering system, combines deep learning and computer vision technology, and automatically calculates grid distortion parameters and light and shadow effects through template shooting, grid detection, texture and light and shadow extraction models, replacing manual operations and shortening construction. Module cycle to improve rendering accuracy.
It greatly improves rendering efficiency, shortens the modeling cycle, reduces errors caused by manual modeling, improves rendering accuracy, and only consumes GPU resources during modeling and a small amount of CPU resources during rendering.
Smart Images

Figure CN114972610B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of picture rendering and machine vision, and in particular relates to a picture specific area rendering system and rendering method based on an auxiliary grid. Background Art
[0002] Rendering technology is a technology that renders designed textures, materials, light and shadow parameters to a specified area in a picture, and is widely used in the design field. Designers use rendering technology to quickly generate picture effects in real scenes, and perform iterative optimization based on effect feedback, which can greatly improve design efficiency and shorten product iteration cycles. Currently, there are two main types of rendering technologies: one is image rendering technology based on 3D modeling, which builds a mesh model in a three-dimensional scene, and renders through texture mapping and calculation of light reflection and refraction parameters. The rendering effect is good, but the modeling cycle is long and the resource consumption is large; the other is 2D-based image rendering technology, which achieves a better naked eye rendering effect by distorting the texture in two-dimensional space and superimposing light and shadow effects. However, this technology mainly uses manual methods and also has the problems of long modeling time and low efficiency. Summary of the invention
[0003] The present invention aims to solve the above technical problems and provides a system and method for rendering a specific area of an image based on an auxiliary grid.
[0004] In order to achieve the above object, the present invention adopts the following technical solution:
[0005] A system for rendering specific areas of an image based on an auxiliary grid comprises: a template shooting module, a grid target detection module, a grid key point detection module, a grid removal module, a texture and light and shadow effect extraction module, and a rendering module; the template shooting module is used to shoot an object as a rendering template, and a specific area of the object is printed with a designed grid; the grid target detection module is used to perform grid detection on the image, and obtain the grid's circumscribed rectangle parameters and the coordinate information of the four vertices of the grid; the grid key point detection module cuts out the grid area from the image through the obtained circumscribed rectangle parameters, and inputs them into the grid intersection detection model to obtain the segmentation of all horizontal and vertical axes. The grid removal module cuts out the grid area from the picture through the obtained circumscribed rectangle parameters, and inputs it into the image generation network to obtain the picture with the grid removed; the texture and light and shadow effect extraction module is used to input the picture into the texture and light and shadow extraction model to obtain the texture and light and shadow information of the picture; the rendering module is used to align the input pattern with the set pattern template, calculate the deformation parameters according to the key point parameters obtained by the grid key point detection module and distort the pattern, and then perform a multiply operation on it with the light and shadow and texture information, and finally replace the grid area corresponding to the point picture with the pattern.
[0006] A method for rendering a specific area of an image based on an auxiliary grid comprises the following steps:
[0007] S1: Design the auxiliary grid, print the auxiliary grid on the designated area of the object to be rendered, and hand over the finished product to the photographer to shoot it as a template to be rendered;
[0008] S2: Build a grid detection model, and obtain the maximum circumscribed rectangle and four vertex coordinates of the grid in the input image through the grid detection model;
[0009] S3: Build a grid intersection detection model, crop the grid area from the image using the obtained bounding rectangle parameters, input it into the grid intersection detection model to obtain the segmentation masks of all horizontal and vertical axes, and find the intersection points between them to obtain the coordinate information of the key points;
[0010] S4: construct a mesh removal model, and obtain the effect image after the mesh is removed from the input image through the mesh removal model;
[0011] S5: construct a texture and light and shadow effect extraction model, and obtain the texture and light and shadow effect image in the input image through the texture and light and shadow effect extraction model;
[0012] S6: Build a rendering module, align the input pattern with the set pattern template, calculate the deformation parameters according to the key point parameters obtained in S3 and distort the pattern, then perform a multiply operation on it with the light and texture information, and finally replace the grid area corresponding to the original image with the pattern.
[0013] Preferably, in S2, constructing a grid detection model includes the following steps: obtaining grid detection samples based on manual annotation; obtaining grid detection samples based on image synthesis; preprocessing the grid detection samples, scaling them to a fixed size, and using them as training samples, whose corresponding labels are the coordinates of the center point and width and height of the rectangular position of the grid on the image, and the coordinates of the four vertices and the default width and height; conducting training after setting the training conditions, and saving the grid detection model after the training is completed.
[0014] Preferably, in S3, constructing a grid intersection detection model includes the following steps: obtaining grid line segmentation mask samples based on image synthesis; preprocessing the RGB grid image samples and scaling them to a fixed size, whose corresponding labels are the segmentation masks of the grid lines; training after setting the training conditions, and saving the grid intersection detection model after the training is completed.
[0015] Preferably, in S4, constructing the grid removal model includes the following steps: obtaining grid removal samples based on image synthesis; preprocessing the RGB grid image samples, scaling them to a fixed size, and the corresponding label is a grid-free RGB image; training is performed after setting training conditions, and the grid removal model is saved after the training is completed.
[0016] Preferably, in S5, constructing a texture and light and shadow effect extraction model includes the following steps: the texture and light and shadow effect extraction model is manually annotated through pictures; the RGB grid picture samples are preprocessed and scaled to a fixed size, and the corresponding label is a 4-channel RGBA picture, which contains the texture and light and shadow information of the picture; training is performed after setting the training conditions, and the texture and light and shadow effect extraction model is saved after the training is completed.
[0017] After adopting the above technical solution, the present invention has the following advantages:
[0018] The present invention has developed a new 2D-based image rendering technology, which combines deep learning and computer vision technology to replace manual prediction of mesh distortion parameters and extraction of light and shadow effects, greatly improving efficiency. The present invention uses deep learning and machine vision technology to develop key point extraction models, texture and light and shadow effect extraction models, and uses computer simulation to replace manual operations, greatly shortening the modeling cycle, and reducing the error between rendering and actual production caused by manual modeling, and improving rendering accuracy; and the rendering system only needs to consume a certain amount of GPU resources when modeling, and only a small amount of CPU resources are used when rendering. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A schematic diagram of the structure of a system for rendering a specific area of an image based on an auxiliary grid;
[0020] Figure 2 Grid images for design;
[0021] Figure 3 Training flow chart for mesh detection model;
[0022] Figure 4 Flowchart for training the grid intersection detection model;
[0023] Figure 5 Flowchart for mesh removal model training;
[0024] Figure 6 Extract model training flow chart for texture and lighting effects;
[0025] Figure 7 This is a flowchart of step S6. DETAILED DESCRIPTION
[0026] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0027] like Figure 1 As shown, a system for rendering a specific area of an image based on an auxiliary grid includes: a template shooting module, a grid target detection module, a grid key point detection module, a grid removal module, a texture and light and shadow effect extraction module, and a rendering module.
[0028] The template shooting module is used to shoot objects as rendering templates, such as Figure 2 As shown, a specific area of the object is printed with a designed grid. The production center prints the grid designed by the developer onto a specific area of the object and then delivers it to be photographed by a professional photographer.
[0029] In particular, such as Figure 3 As shown, the grid is designed to ensure that each adjacent grid line has a different color, the center grid line is blue, and the width of the center grid line in the positive direction of the horizontal and vertical axes is twice the standard line width. More specifically, when shooting, try to ensure that the grid is facing the lens, without large-scale obstruction and distortion.
[0030] The grid object detection module is used to perform grid detection on the image, obtain the grid's circumscribed rectangle parameters and the coordinate information of the grid's four vertices. Target detection is to obtain the minimum enclosing rectangle of a specified object by inputting an image. By inputting an image with an auxiliary grid into the grid object detection model, the minimum enclosing rectangle of the grid and the coordinates of the four vertices are obtained.
[0031] The grid key point detection module cuts out the grid area from the image by obtaining the bounding rectangle parameters, and inputs them into the grid intersection detection model to obtain the segmentation masks of all horizontal and vertical axes, and finds the intersection points between them to obtain the key point coordinate information. The segmentation mask is the output obtained by inputting the object target area image into the grid intersection detection model. It is used to locate the precise position of the object in the image at the pixel level, that is, the binary image of the segmentation mask. The grid in the image is cut out by the minimum bounding rectangle of the grid obtained by the grid target detection module, and sent to the grid intersection detection model to obtain the segmentation mask of each grid line. The center point coordinates of the overlapping area of the grid line mask are used as the intersection coordinates of the grid line. The number of intersections is consistent with the number of intersections of the grid designed by the developer and corresponds one to one.
[0032] The grid removal module cuts out the grid area from the image by using the bounding rectangle parameters obtained, and inputs it into the image generation network to obtain the image without the grid. The grid in the image is cut out by using the minimum bounding rectangle of the grid obtained by the grid object detection module, and then input into the image generation model to obtain the image without the grid.
[0033] The texture and light and shadow effect extraction module is used to input the image into the texture and light and shadow extraction model to obtain the texture and light and shadow information of the image. The image with the auxiliary grid is input into the texture and light and shadow extraction model to obtain a 4-channel RGBA format image, which stores the texture and light and shadow information.
[0034] The rendering module is used to align the input pattern with the set pattern template, calculate the deformation parameters according to the key point parameters obtained by the grid key point detection module and distort the pattern, then perform a multiplication operation on it with the light and texture information, and finally replace the grid area corresponding to the point image with the pattern. The size of the pattern to be rendered is stretched to the same size as the grid template, and the deformation parameters are calculated by the deformed grid point coordinates learned by the grid key point detection module and the standard grid point coordinates, and the pattern to be rendered is distorted according to the parameters; the distorted pattern and texture are multiplied with the texture and light and shadow pictures of the light and shadow effect extraction module to obtain a more realistic photosensitivity effect; the fused part replaces the corresponding part of the picture after the auxiliary grid is removed in the grid removal module.
[0035] A method for rendering a specific area of an image based on an auxiliary grid comprises the following steps:
[0036] S1: Design the auxiliary grid, print the auxiliary grid on the designated area of the object to be rendered, and hand over the finished product to the photographer to shoot it as a template to be rendered;
[0037] S2: Build a grid detection model, and obtain the maximum enclosing rectangle and four vertex coordinates of the grid in the input image through the grid detection model;
[0038] Among them, building a grid detection model includes the following steps: obtaining grid detection samples based on manual annotation; obtaining grid detection samples based on image synthesis; preprocessing the grid detection samples, scaling them to a fixed size, and using them as training samples, whose corresponding labels are the coordinates and width and height of the center point of the rectangular position of the grid on the image, the coordinates of the four vertices and the default width and height; training is performed after setting the training conditions, and the grid detection model is saved after the training is completed.
[0039] S3: Build a grid intersection detection model, crop the grid area from the image using the obtained bounding rectangle parameters, input it into the grid intersection detection model to obtain the segmentation masks of all horizontal and vertical axes, and find the intersection points between them to obtain the coordinate information of the key points;
[0040] Among them, building a grid intersection detection model includes the following steps: obtaining grid line segmentation mask samples based on image synthesis; preprocessing RGB grid image samples and scaling them to a fixed size, whose corresponding labels are the segmentation masks of grid lines; training after setting training conditions, and saving the grid intersection detection model after training.
[0041] like Figure 4 As shown, specifically, the grid intersection detection model training includes the following steps:
[0042] S801, randomly rotating and distorting the constructed grid image, then randomly selecting an image on the constructed grid-free image dataset, pasting the distorted grid onto the image and calculating the segmentation mask of each grid line;
[0043] The number of horizontal grid lines and vertical grid lines ranges from 11 to 19, and the number of vertical axes ranges from 11 to 19, and the grid lines are coded accordingly.
[0044] S802, preprocess the data set, scale the long side of the image to 512x512, then subtract 127.5 from each pixel value on the RGB channel, divide by 255, and perform onehot processing on the label;
[0045] S803. Use Pytorch to build a grid intersection detection model. The model uses u2net. Set the initial learning rate to 0.01 and the number of termination iterations to 100. Select the optimizer as the SGD training model. Use two-dimensional cross entropy as the training loss.
[0046] S804. Output the grid intersection detection model file.
[0047] S4: construct a mesh removal model, and obtain the effect image after the mesh is removed from the input image through the mesh removal model;
[0048] Among them, building a grid removal model includes the following steps: obtaining grid removal samples based on image synthesis; preprocessing RGB grid image samples, scaling them to a fixed size, and their corresponding labels are grid-free RGB images; training is performed after setting training conditions, and the grid removal model is saved after training.
[0049] like Figure 5 As shown, specifically, the mesh removal model training includes the following steps:
[0050] S901, selecting 20,000 pictures from business scenarios to form a picture set, randomly selecting a picture from the picture set and pasting a grid, labeling it as the original picture without the grid pasted, and cropping the grid area from the picture as a training data set;
[0051] S902, preprocessing the data set, such as scaling the long side of the image to 512x512, then subtracting 127.5 from the RGB channel of the channel, and then dividing by 127.5;
[0052] S903. Use Pytorch to build a mesh removal model. The model uses unet, the activation function uses tanh, the initial learning rate is set to 0.01 and the number of termination iterations is set to 100. Select the optimizer as SGD training model, and use l1 loss and perceptual loss as loss.
[0053] S904: Output the mesh removal model file.
[0054] S5: construct a texture and light and shadow effect extraction model, and obtain the texture and light and shadow effect image in the input image through the texture and light and shadow effect extraction model;
[0055] Among them, building a texture and light and shadow effect extraction model includes the following steps: the texture and light and shadow effect extraction model is manually annotated through pictures; the RGB grid picture samples are preprocessed and scaled to a fixed size, and the corresponding label is a 4-channel RGBA picture, which contains the texture and light and shadow information of the picture; training is carried out after setting the training conditions, and the texture and light and shadow effect extraction model is saved after the training is completed.
[0056] like Figure 6 Specifically, the texture and light and shadow effect extraction model training includes the following steps:
[0057] S1001. Select 20,000 pictures from business scenarios to form a picture set. The annotation team uses Photoshop software to generate corresponding texture and light and shadow effect pictures as labels.
[0058] S1002, preprocessing the data set, such as scaling the long side of the image to 512x512, then subtracting 127.5 from the RGB channel of the channel, and then dividing by 127.5;
[0059] S1003. Use Pytorch to build a mesh removal model. The model uses unet, the activation function uses tanh, the initial learning rate is set to 0.01 and the number of termination iterations is set to 100. Select the optimizer as SGD training model, and the loss uses l1 loss and perceptual loss.
[0060] S1004. Output texture and light and shadow effect model files.
[0061] S6: Build a rendering module, align the input pattern with the set pattern template, calculate the deformation parameters according to the key point parameters obtained in S3 and distort the pattern, then perform a multiply operation on it with the light and texture information, and finally replace the grid area corresponding to the original image with the pattern.
[0062] like Figure 7 As shown, step S6 specifically includes:
[0063] S1061, scaling the pattern to be rendered to the size of the grid template and aligning it;
[0064] S1062, using TPS (thin plate matching algorithm) to calculate deformation parameters according to the key point positions of the grid template and the key point positions detected in step S3, and using the parameters to distort the aligned pattern to be rendered;
[0065] S1063, performing a multiply fusion method on the distorted pattern to be rendered and the extracted texture and light and shadow images, wherein if the rendered pattern is an RGB image, the alpha channel is automatically filled, and the value of the channel is 255;
[0066] S1064, replacing the corresponding area of the blank image obtained in step S4 with the fused image area to obtain a rendered image;
[0067] S1065. Return the rendering result.
[0068] In addition to the above preferred embodiments, the present invention has other implementation modes. Those skilled in the art may make various changes and modifications based on the present invention. As long as they do not depart from the spirit of the present invention, they should all fall within the scope defined by the claims attached to the present invention.
Claims
1. A method for rendering a specific area of an image based on an auxiliary grid, characterized in that: The following steps are involved: S1: Design the auxiliary grid, print the auxiliary grid on the designated area of the object to be rendered, and hand over the finished product to the photographer to shoot it as a template to be rendered; S2: Build a grid detection model, and obtain the maximum circumscribed rectangle and four vertex coordinates of the grid in the input image through the grid detection model; Building a grid detection model includes the following steps: obtaining grid detection samples based on manual annotation; obtaining grid detection samples based on image synthesis; preprocessing the grid detection samples based on manual annotation and the grid detection samples based on image synthesis, scaling them to a fixed size, and using them as training samples. The labels of the grid detection training samples based on manual annotation are the coordinates of the center point of the rectangular position of the grid on the image and the width and height, and the labels of the grid detection training samples based on image synthesis are the coordinates of the four vertices of the grid and the default width and height; training is performed after setting the training conditions, and the grid detection model is saved after the training is completed; S3: Build a grid intersection detection model, crop the grid area from the image using the obtained bounding rectangle parameters, input it into the grid intersection detection model to obtain the segmentation masks of all horizontal and vertical axes, and find the intersection points between them to obtain the coordinate information of the key points; Building a grid intersection detection model includes the following steps: obtaining grid line segmentation mask samples based on image synthesis; preprocessing RGB grid image samples and scaling them to a fixed size, whose corresponding labels are grid line segmentation masks; training after setting training conditions, and saving the grid intersection detection model after training; S4: construct a mesh removal model, and obtain the effect image after the mesh is removed from the input image through the mesh removal model; Building a grid removal model includes the following steps: obtaining grid removal samples based on image synthesis; preprocessing RGB grid image samples, scaling them to a fixed size, and their corresponding labels are RGB images without grids; training after setting training conditions, and saving the grid removal model after training; S5: construct a texture and light and shadow effect extraction model, and obtain the texture and light and shadow effect image in the input image through the texture and light and shadow effect extraction model; Building a texture and light and shadow effect extraction model includes the following steps: the texture and light and shadow effect extraction model is manually annotated through pictures; the RGB grid picture samples are preprocessed and scaled to a fixed size, and the corresponding label is a 4-channel RGBA picture, which contains the texture and light and shadow information of the picture; training is performed after setting the training conditions, and the texture and light and shadow effect extraction model is saved after the training is completed; S6: Build a rendering module, align the input pattern with the set pattern template, calculate the deformation parameters according to the key point coordinate information obtained in S3 and distort the pattern, then perform a multiply operation on it with the light and texture information, and finally replace the grid area corresponding to the original image with the pattern.
2. A system for rendering a specific area of an image based on an auxiliary grid, used to implement the method of claim 1, characterized in that: include: Template shooting module, grid target detection module, grid key point detection module, grid removal module, texture and light and shadow effect extraction module, rendering module; The template shooting module is used to shoot an object as a rendering template, and a designed grid is printed on a specific area of the object; the grid target detection module is used to perform grid detection on the image, and obtain the grid's circumscribed rectangle parameters and the coordinate information of the grid's four vertices; The grid key point detection module cuts out the grid area from the image by using the obtained circumscribed rectangle parameters, inputs the obtained circumscribed rectangle parameters into the grid intersection detection model to obtain the segmentation masks of all horizontal and vertical axes, and calculates the intersection points of the two axes to obtain the key point coordinate information. The grid removal module cuts the grid area from the image by obtaining the circumscribed rectangle parameters, and inputs it into the image generation network to obtain the image with the grid removed; the texture and light and shadow effect extraction module is used to input the image into the texture and light and shadow extraction model to obtain the texture and light and shadow information of the image; the rendering module is used to align the input pattern with the set pattern template, calculate the deformation parameters according to the key point parameters obtained by the grid key point detection module and distort the pattern, and then perform a multiply operation on it with the light and shadow and texture information, and finally replace the grid area corresponding to the original image with the pattern.
