WO2020211573A1 - Method and device for processing image - Google Patents

Method and device for processing image Download PDF

Info

Publication number
WO2020211573A1
WO2020211573A1 PCT/CN2020/078582 CN2020078582W WO2020211573A1 WO 2020211573 A1 WO2020211573 A1 WO 2020211573A1 CN 2020078582 W CN2020078582 W CN 2020078582W WO 2020211573 A1 WO2020211573 A1 WO 2020211573A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
shadow
illumination
network
target object
Prior art date
Application number
PCT/CN2020/078582
Other languages
French (fr)
Chinese (zh)
Inventor
王光伟
Original Assignee
北京字节跳动网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京字节跳动网络技术有限公司 filed Critical 北京字节跳动网络技术有限公司
Publication of WO2020211573A1 publication Critical patent/WO2020211573A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration using two or more images, e.g. averaging or subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20084Artificial neural networks [ANN]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging

Definitions

  • the embodiments of the present disclosure relate to the field of computer technology, and more particularly to methods and devices for processing images.
  • the virtual object image used for adding to the real scene image is usually an image preset by the technician according to the shape of the virtual object.
  • the embodiments of the present disclosure propose methods and devices for processing images.
  • an embodiment of the present disclosure provides a method for processing an image, the method includes: acquiring a target object illumination image and a target virtual object image, wherein the target object illumination image includes the object image and the corresponding object image Shadow image; input the target object illumination image into the pre-trained shadow extraction model to obtain the resulting shadow image including distance information, where the distance information is used to represent the pixel points of the shadow image and the pixel corresponding to the object image in the target object illumination image The distance of the point; based on the resulting shadow image, generate the illumination direction information corresponding to the target object illumination image; based on the illumination direction information, generate the virtual object illumination image corresponding to the target virtual object image, where the virtual shadow image in the virtual object illumination image The corresponding light direction matches the light direction indicated by the light direction information; the virtual object light image and the target object light image are merged to add the virtual object light image to the target object light image to obtain the result image.
  • generating the illumination direction information corresponding to the target object illumination image includes: inputting the resulting shadow image into a pre-trained illumination direction recognition model to obtain the illumination direction information.
  • the distance information is the pixel value of the pixel in the resulting shadow image.
  • the shadow extraction model is obtained by training in the following steps: obtaining a preset training sample set, where the training samples include a sample object illumination image and a sample result shadow image predetermined for the sample object illumination image; obtaining a pre-established Generative confrontation network, where the generative confrontation network includes a generation network and a discriminant network.
  • the generation network is used to identify the input object lighting image and output the resulting shadow image
  • the discriminant network is used to determine whether the input image is a generation network
  • the output image based on the machine learning method, the sample object illumination image included in the training samples in the training sample set is used as the input of the generation network, and the resulting shadow image output by the network and the sample corresponding to the input sample object illumination image are generated
  • the shadow image is used as the input of the discriminant network, the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
  • the method further includes: displaying the obtained result image.
  • the method further includes: sending the obtained result image to a user terminal connected in communication, and controlling the user terminal to display the result image.
  • an embodiment of the present disclosure provides an apparatus for processing an image.
  • the apparatus includes: an image acquisition unit configured to acquire a target object illumination image and a target virtual object image, wherein the target object illumination image includes an object The shadow image corresponding to the image and the object image; the image input unit is configured to input the target object illumination image into the pre-trained shadow extraction model to obtain the resulting shadow image including distance information, where the distance information is used to characterize the illumination of the target object In the image, the distance between the pixel point of the shadow image and the pixel point corresponding to the object image; the information generation unit is configured to generate light direction information corresponding to the target object illumination image based on the resulting shadow image; the image generation unit is configured to be based on The illumination direction information generates the virtual object illumination image corresponding to the target virtual object image, wherein the illumination direction corresponding to the virtual shadow image in the virtual object illumination image matches the illumination direction indicated by the illumination direction information; the image fusion unit is It is configured to fuse the lighting image of the virtual object and the lighting image of the
  • the information generating unit is further configured to: input the resulting shadow image into a pre-trained light direction recognition model to obtain light direction information.
  • the distance information is the pixel value of the pixel in the resulting shadow image.
  • the shadow extraction model is obtained by training in the following steps: obtaining a preset training sample set, where the training samples include a sample object illumination image and a sample result shadow image predetermined for the sample object illumination image; obtaining a pre-established Generative confrontation network, where the generative confrontation network includes a generation network and a discriminant network.
  • the generation network is used to identify the input object lighting image and output the resulting shadow image
  • the discriminant network is used to determine whether the input image is a generation network
  • the output image based on the machine learning method, the sample object illumination image included in the training samples in the training sample set is used as the input of the generation network, and the resulting shadow image output by the network and the sample corresponding to the input sample object illumination image are generated
  • the shadow image is used as the input of the discriminant network, the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
  • the device further includes: an image display unit configured to display the obtained result image.
  • the device further includes: an image sending unit configured to send the obtained result image to a user terminal connected in communication, and control the user terminal to display the result image.
  • the embodiments of the present disclosure provide an electronic device, including: one or more processors; a storage device, on which one or more programs are stored, when one or more programs are processed by one or more The processor executes, so that one or more processors implement the method of any one of the foregoing methods for processing images.
  • the embodiments of the present disclosure provide a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the method of any one of the above methods for processing an image is implemented.
  • the method and device for processing an image provided by the embodiments of the present disclosure acquire a target object illumination image and a target virtual object image, where the target object illumination image includes the object image and the shadow image corresponding to the object image, and then the target object The illumination image is input into the pre-trained shadow extraction model to obtain the resulting shadow image including distance information.
  • the distance information is used to characterize the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image, and then based on As a result, the shadow image generates the illumination direction information corresponding to the illumination image of the target object, and then based on the illumination direction information, the virtual object illumination image corresponding to the target virtual object image is generated, where the illumination corresponding to the virtual shadow image in the virtual object illumination image
  • the direction matches the light direction indicated by the light direction information, and finally the virtual object light image and the target object light image are merged to add the virtual object light image to the target object light image to obtain the result image, which can be used as the target
  • the shadow image corresponding to the virtual object image is generated, so that the virtual object image can be better integrated into the target object lighting image, which improves the reality of the result image It can improve the display effect of the image.
  • FIG. 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure can be applied
  • Fig. 2 is a flowchart of an embodiment of a method for processing an image according to the present disclosure
  • FIG. 3 is a schematic diagram of an application scenario of the method for processing images according to an embodiment of the present disclosure
  • FIG. 4 is a flowchart of another embodiment of a method for processing an image according to the present disclosure.
  • Fig. 5 is a schematic structural diagram of an embodiment of an image processing apparatus according to the present disclosure.
  • Fig. 6 is a schematic structural diagram of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure.
  • FIG. 1 shows an exemplary system architecture 100 to which an embodiment of the method for processing images or the apparatus for processing images of the present disclosure can be applied.
  • the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105.
  • the network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105.
  • the network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables.
  • the user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages and so on.
  • Various communication client applications such as image processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, and social platform software, can be installed on the terminal devices 101, 102, and 103.
  • the terminal devices 101, 102, and 103 may be hardware or software.
  • the terminal devices 101, 102, 103 can be various electronic devices with cameras, including but not limited to smart phones, tablets, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, dynamic Video experts compress standard audio layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, dynamic image experts compress standard audio layer 4) players, laptop portable computers and desktop computers, etc.
  • the terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, multiple software or software modules for providing distributed services), or as a single software or software module. There is no specific limitation here.
  • the server 105 may be a server that provides various services, for example, an image processing server that processes the illumination images of the target object obtained by shooting the terminal devices 101, 102, and 103.
  • the image processing server can analyze and process the received data such as the illumination image of the target object, and obtain the processing result (for example, the result image).
  • the server can also feed back the obtained processing result to the terminal device.
  • the method for processing images provided by the embodiments of the present disclosure can be executed by the server 105, and can also be executed by the terminal devices 101, 102, 103. Accordingly, the device for processing images can be set in the server. 105 can also be set in the terminal devices 101, 102, 103.
  • the server can be hardware or software.
  • the server can be implemented as a distributed server cluster composed of multiple servers, or as a single server.
  • the server is software, it can be implemented as multiple software or software modules (for example, multiple software or software modules for providing distributed services), or as a single software or software module. There is no specific limitation here.
  • terminal devices, networks, and servers in FIG. 1 are merely illustrative. According to implementation needs, there can be any number of terminal devices, networks and servers.
  • the above system architecture may not include the network, but only include the terminal device or the server.
  • the method for processing images includes the following steps:
  • Step 201 Obtain a target object illumination image and a target virtual object image.
  • the execution subject of the method for processing images may remotely or locally obtain the target object illumination image and the target virtual object image through a wired connection or a wireless connection.
  • the illumination image of the target object is the image to be processed.
  • the illumination image of the target object includes the object image and the shadow image corresponding to the object image.
  • the illuminated image of the target object may be an image obtained by shooting an object in the illuminated scene.
  • the light source in the illumination scene in which the illumination image of the target object is captured is parallel light or sunlight. It can be understood that in an illuminated scene, when an object blocks the light source, shadows will be generated.
  • the target virtual object image is an image used to process the illumination image of the target object.
  • the target virtual object image may be an image predetermined according to the shape of the virtual object. Specifically, it may be a pre-drawn image, or it may be an image pre-extracted from an existing image according to the contour of the object.
  • the "virtual" of the target virtual object image is relative to the target object illumination image, which means that the virtual object corresponding to the target virtual object image does not actually exist in the target virtual object image. Objects in the real scene of the illuminated image.
  • Step 202 Input the illumination image of the target object into a pre-trained shadow extraction model to obtain a resultant shadow image including distance information.
  • the above-mentioned execution subject may input the target object illumination image into a pre-trained shadow extraction model to obtain a resultant shadow image including distance information.
  • the resulting shadow image may be a shadow image extracted from the illumination image of the target object and added with distance information.
  • the distance information is used to characterize the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image. Specifically, because a certain point in the object blocks the light source, a shadow point will be generated on the projection surface (such as the ground, wall, desktop, etc.). Furthermore, here, the point on the object used to generate the shadow point can be used.
  • the shadow point in the shadow corresponds to the pixel point in the shadow image, which can then be used to generate the shadow image corresponding to the pixel point
  • the pixel point corresponding to the object point of the shadow point is regarded as the pixel point corresponding to the pixel point in the shadow image.
  • the distance information can be embodied in the resulting shadow image in various forms.
  • the distance information can be recorded in the resulting shadow image in digital form.
  • each pixel in the resulting shadow image may correspond to a number, and the number may be the distance between the corresponding pixel and the corresponding pixel in the object image.
  • the distance information may be the pixel value of the pixel in the resulting shadow image.
  • various ways can be used to characterize the distance using pixel values. As an example, the larger the pixel value, the longer the distance; or the smaller the pixel value, the longer the distance.
  • the shadow extraction model can be used to characterize the correspondence between the illumination image of the object and the resulting shadow image.
  • the shadow extraction model may be pre-made by technicians based on statistics of a large number of object illumination images and result shadow images corresponding to the object illumination image, and stores multiple object illumination images and corresponding result shadows.
  • Correspondence table of the image it can also be a model obtained after training an initial model (such as a neural network) using a machine learning method based on a preset training sample.
  • the shadow extraction model may be trained by the above-mentioned executive body or other electronic devices through the following steps:
  • the illuminated image of the sample object may be an image obtained by shooting the sample object in an illuminated scene.
  • the sample object illumination image may include a sample object image and a sample shadow image.
  • the sample result shadow image may be an image obtained by extracting a sample shadow image from a sample object illumination image, and adding sample distance information to the extracted sample shadow image.
  • a pre-established generative confrontation network is obtained, where the generative confrontation network includes a generation network and a discrimination network.
  • the generation network is used to recognize the input object illumination image and output the resulting shadow image
  • the discrimination network is used to determine the input Whether the image of is the image output by the generation network.
  • the above-mentioned generative confrontation network may be a generative confrontation network of various structures.
  • the generative adversarial network may be a deep convolutional generative adversarial network (Deep Convolutional Generative Adversarial Network, DCGAN).
  • DCGAN Deep Convolutional Generative Adversarial Network
  • the above-mentioned generative confrontation network may be an untrained generative confrontation network after initializing parameters, or a trained generative confrontation network.
  • the generation network may be a convolutional neural network for image processing (for example, a convolutional neural network with various structures including a convolutional layer, a pooling layer, a depooling layer, and a deconvolutional layer).
  • the above-mentioned discriminant network may also be a convolutional neural network (for example, a convolutional neural network of various structures including a fully connected layer, where the above-mentioned fully connected layer can implement a classification function).
  • the discriminant network can also be other models used to implement classification functions, such as Support Vector Machine (SVM).
  • SVM Support Vector Machine
  • the discriminant network determines that the image input to the discriminant network is an image output by the generation network, it can output 1 (or 0); if it determines that it is not an image output by the generation network, it can output 0 (or 1). It should be noted that the discrimination network can also output other preset information to characterize the discrimination result, which is not limited to the values 1 and 0.
  • the sample object illumination image included in the training samples in the training sample set is used as the input of the generation network, and the resulting shadow image output by the network and the sample result shadow image corresponding to the input sample object illumination image are generated.
  • the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
  • the parameters of any one of the generating network and the discriminating network (which can be called the first network) can be fixed first, and the network with no fixed parameters (which can be called the second network) can be optimized; then the parameters of the second network can be fixed. Parameters to improve the first network. Continuously carry out the above iterations, so that the judgment network cannot distinguish whether the input image is output by the generation network. At this time, the result shadow image generated by the above generation network is close to the sample result shadow image, and the above discrimination network cannot accurately distinguish between the real data and the generated data (that is, the accuracy rate is 50%).
  • the generation network at this time can be determined as the shadow extraction model.
  • the above-mentioned executive body or other electronic devices can use the existing back propagation algorithm and gradient descent algorithm to train the generation network and the discrimination network.
  • the parameters of the generation network and the discrimination network after each training will be adjusted, and the generation network and the discrimination network obtained after each adjustment of the parameters are used as the generation network and the discrimination network used in the next training.
  • Step 203 Based on the resulting shadow image, generate light direction information corresponding to the light image of the target object.
  • the above-mentioned execution subject may generate the illumination direction information corresponding to the illumination image of the target object.
  • the light direction information can be used to indicate the light direction, which can include but is not limited to at least one of the following: text, numbers, symbols, and images.
  • the illumination direction information may be an arrow marked in the resulting shadow image.
  • the direction of the arrow may be the illumination direction; or the illumination direction information may be a two-dimensional vector, where the two-dimensional vector corresponds to The direction can be the light direction.
  • the light direction indicated by the light direction information is the projection of the actual light direction in the three-dimensional coordinate system on the projection surface where the shadow in the three-dimensional coordinate system is located. It can be understood that in practice, the light direction (that is, the projection of the actual light direction on the projection surface of the shadow) is usually the same as the extension direction of the shadow. Furthermore, the above-mentioned execution subject may determine the extension direction of the shadow based on the pixel points in the resulting shadow image and the distance information corresponding to the pixel points, and then determine the light direction.
  • the above-mentioned execution subject may select, from the resulting shadow image, the pixel with the closest distance represented by the corresponding distance information as the first pixel, and select the pixel with the farthest distance represented by the corresponding distance information
  • the dot is used as the second pixel, and further, the above-mentioned execution subject may determine the direction in which the first pixel points to the second pixel as the illumination direction.
  • Step 204 based on the illumination direction information, generate a virtual object illumination image corresponding to the target virtual object image.
  • the above-mentioned execution subject may generate the virtual object illumination image corresponding to the target virtual object image.
  • the lighting image of the virtual object includes the above-mentioned target virtual object image and the virtual shadow image corresponding to the target virtual object image.
  • the lighting direction corresponding to the virtual shadow image in the lighting image of the virtual object matches the lighting direction indicated by the lighting direction information.
  • the matching means that the angular deviation of the illumination direction corresponding to the virtual shadow image with respect to the illumination direction indicated by the illumination direction information is less than or equal to the preset angle.
  • the above-mentioned execution subject may use various methods to generate the virtual object illumination image corresponding to the target virtual object image based on the illumination direction information.
  • a light source can be constructed in the rendering engine based on the light direction indicated by the light direction information, and then the target virtual object image can be rendered based on the constructed light source to obtain the virtual object light image.
  • the light direction indicated by the light direction information is the actual light direction projected on the projection surface where the shadow is located, in the process of constructing the light source, it is necessary to first determine the actual light direction based on the light direction information, and then based on the actual light The direction builds the light source.
  • the actual light direction can be determined by the light direction on the projection surface where the shadow is located and the light direction on the projection surface perpendicular to the projection surface where the shadow is located, and in this embodiment, it is perpendicular to the projection surface where the shadow is located.
  • the direction of illumination on the projection surface can be predetermined.
  • the above-mentioned execution subject pre-stores an initial virtual shadow image corresponding to the target virtual object image. Then the execution subject can adjust the initial virtual shadow image based on the illumination direction information to obtain the virtual shadow image, and then combine the virtual shadow image and the target virtual object image to generate the virtual object illumination image.
  • the light source corresponding to the illumination image of the target object is parallel light or sunlight, here, it can be considered that the illumination direction corresponding to the virtual shadow image in the illumination image of the virtual object is the same as the illumination direction indicated by the aforementioned illumination direction information. It does not need to consider the influence of the position of the virtual object illumination image added to the target object illumination image on the illumination direction corresponding to the virtual shadow image.
  • Step 205 Fusion of the lighting image of the virtual object and the lighting image of the target object to add the lighting image of the virtual object to the lighting image of the target object to obtain a result image.
  • the above-mentioned execution subject may fuse the virtual object illumination image and the target object illumination image to add the virtual object illumination image to the target object illumination image to obtain the result image.
  • the result image is the target object illumination image with the virtual object illumination image added.
  • the position where the virtual object illumination image is added to the target object illumination image can be predetermined (for example, the center position of the image), or it can be determined after recognizing the target object illumination image (for example, it can be After the object image and shadow image in the illumination image of the target object are obtained, the area in the illumination image of the target object that does not include the object image and shadow image is determined as the location for adding the virtual object illumination image).
  • the execution subject may display the obtained result image.
  • the above-mentioned execution subject may also send the obtained result image to the user terminal connected in communication, and control the user terminal to display the result image.
  • the user terminal is a terminal used by the user to communicate with the execution subject.
  • the above-mentioned execution subject may send a control signal to the user terminal, thereby controlling the user terminal to display the result image.
  • this implementation can control the user terminal Display a more realistic result image to improve the display effect of the image.
  • Fig. 3 is a schematic diagram of an application scenario of the method for processing an image according to this embodiment.
  • the server 301 first obtains the cat's lighting image 302 (target object lighting image) and the football image 303 (target virtual object image), where the cat lighting image 302 includes the cat's image (object image) and The shadow image of the cat (shadow image). Then, the server 301 can input the cat's light image 302 into the pre-trained shadow extraction model 304 to obtain the cat's shadow image 305 (resulting shadow image) including distance information, where the distance information is used to represent the cat's light image 302 , The distance between the pixel of the cat’s shadow image and the pixel of the cat’s image.
  • the server 301 may generate the light direction information 306 corresponding to the light image 302 of the cat based on the shadow image 305 of the cat including the distance information. Then, the server 301 can generate a football illumination image 307 (virtual object illumination image) corresponding to the football image 304 based on the illumination direction information 306, where the football shadow image (virtual shadow image) in the football illumination image 307 corresponds to the illumination direction It matches the light direction indicated by the light direction information 306. Finally, the server 301 may merge the football lighting image 307 and the cat lighting image 302 to add the football lighting image 307 to the cat lighting image 302 to obtain a result image 308.
  • a football illumination image 307 virtual object illumination image
  • the server 301 may merge the football lighting image 307 and the cat lighting image 302 to add the football lighting image 307 to the cat lighting image 302 to obtain a result image 308.
  • the method provided by the above-mentioned embodiments of the present disclosure can generate the virtual object illumination image corresponding to the virtual object image, so that the corresponding virtual shadow image can be added to the virtual object image, and then the illumination image of the virtual object and the illumination image of the target object can be added.
  • the authenticity of the generated result image can be improved; in addition, the present disclosure can determine the illumination direction of the virtual shadow image corresponding to the virtual object image based on the illumination direction of the shadow image in the target object illumination image.
  • the virtual object image is better integrated into the target object illumination image, and the authenticity of the result image is further improved, which helps to improve the display effect of the result image.
  • FIG. 4 shows a flow 400 of another embodiment of a method for processing an image.
  • the process 400 of the method for processing an image includes the following steps:
  • Step 401 Obtain a target object illumination image and a target virtual object image.
  • the execution subject of the method for processing images may remotely or locally obtain the target object illumination image and the target virtual object image through a wired connection or a wireless connection.
  • the illumination image of the target object is the image to be processed.
  • the illumination image of the target object includes the object image and the shadow image corresponding to the object image.
  • the target virtual object image is an image used to process the illumination image of the target object.
  • the target virtual object image may be an image predetermined according to the shape of the virtual object.
  • Step 402 Input the illumination image of the target object into a pre-trained shadow extraction model, and obtain a resulting shadow image including distance information.
  • the above-mentioned execution subject may input the target object illumination image into a pre-trained shadow extraction model to obtain a resulting shadow image including distance information.
  • the resulting shadow image may be a shadow image extracted from the illumination image of the target object and added with distance information.
  • the distance information is used to characterize the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image.
  • the shadow extraction model can be used to characterize the correspondence between the illumination image of the object and the resulting shadow image.
  • Step 403 Input the resulting shadow image into a pre-trained light direction recognition model to obtain light direction information.
  • the above-mentioned execution subject may input the result shadow image into a pre-trained light direction recognition model to obtain light direction information.
  • the light direction information can be used to indicate the light direction, which can include but is not limited to at least one of the following: text, numbers, symbols, and images.
  • the light direction recognition model can be used to characterize the corresponding relationship between the resulting shadow image and light direction information.
  • the illumination direction recognition model may be pre-made by technicians based on statistics of a large number of result shadow images and the illumination direction information corresponding to the result shadow images, and store multiple result shadow images and corresponding illumination.
  • Correspondence table of direction information it can also be a model obtained after training an initial model (such as a neural network) using a machine learning method based on preset training samples.
  • Step 404 based on the illumination direction information, generate a virtual object illumination image corresponding to the target virtual object image.
  • the above-mentioned execution subject may generate the virtual object illumination image corresponding to the target virtual object image.
  • the lighting image of the virtual object includes the above-mentioned target virtual object image and the virtual shadow image corresponding to the target virtual object image.
  • the lighting direction corresponding to the virtual shadow image in the lighting image of the virtual object matches the lighting direction indicated by the lighting direction information.
  • the matching means that the angular deviation of the illumination direction corresponding to the virtual shadow image with respect to the illumination direction indicated by the illumination direction information is less than or equal to the preset angle.
  • Step 405 Fusion of the lighting image of the virtual object and the lighting image of the target object to add the lighting image of the virtual object to the lighting image of the target object to obtain a result image.
  • the above-mentioned execution subject may merge the illumination image of the virtual object and the illumination image of the target object to add the illumination image of the virtual object to the illumination image of the target object to obtain the result image.
  • the result image is the target object illumination image with the virtual object illumination image added.
  • step 401, step 402, step 404, and step 405 can be respectively performed in a manner similar to step 201, step 202, step 204, and step 205 in the foregoing embodiment.
  • the above is for step 201, step 202, step 204, and step 205.
  • the description of 205 is also applicable to step 401, step 402, step 404, and step 405, and will not be repeated here.
  • the process 400 of the method for processing an image in this embodiment highlights the step of using the light direction recognition model to generate light direction information. Therefore, the solution described in this embodiment can more conveniently determine the illumination direction corresponding to the illumination image of the target object, thereby can generate the result image more quickly, and improve the efficiency of image processing.
  • the present disclosure provides an embodiment of a device for processing images.
  • the device embodiment corresponds to the method embodiment shown in FIG.
  • the device can be specifically applied to various electronic devices.
  • the apparatus 500 for processing images in this embodiment includes: an image acquisition unit 501, an image input unit 502, an information generation unit 503, an image generation unit 504, and an image fusion unit 505.
  • the image acquisition unit 501 is configured to acquire a target object illumination image and a target virtual object image, where the target object illumination image includes the object image and a shadow image corresponding to the object image;
  • the image input unit 502 is configured to illuminate the target object image Input the pre-trained shadow extraction model to obtain the resulting shadow image including distance information, where the distance information is used to represent the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image;
  • information generation unit 503 Is configured to generate illumination direction information corresponding to the target object illumination image based on the resulting shadow image;
  • the image generating unit 504 is configured to generate the virtual object illumination image corresponding to the target virtual object image based on the illumination direction information, wherein the virtual object illuminates The illumination direction corresponding to the virtual shadow image in the image matches the
  • the image acquisition unit 501 of the apparatus 500 for processing images may remotely or locally acquire the target object illumination image and the target virtual object image through a wired connection or a wireless connection.
  • the illumination image of the target object is the image to be processed.
  • the illumination image of the target object includes the object image and the shadow image corresponding to the object image.
  • the target virtual object image is an image used to process the illumination image of the target object.
  • the target virtual object image may be an image predetermined according to the shape of the virtual object.
  • the image input unit 502 may input the illumination image of the target object into a pre-trained shadow extraction model to obtain a resulting shadow image including distance information.
  • the resulting shadow image may be a shadow image extracted from the illumination image of the target object and added with distance information.
  • the distance information is used to characterize the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image.
  • the distance information can be embodied in the resulting shadow image in various forms.
  • the shadow extraction model can be used to characterize the correspondence between the illumination image of the object and the resulting shadow image.
  • the information generating unit 503 may generate light direction information corresponding to the light image of the target object.
  • the light direction information can be used to indicate the light direction, which can include but is not limited to at least one of the following: text, numbers, symbols, and images.
  • the image generating unit 504 Based on the lighting direction information obtained by the information generating unit 503, the image generating unit 504 generates a virtual object lighting image corresponding to the target virtual object image.
  • the lighting image of the virtual object includes the above-mentioned target virtual object image and the virtual shadow image corresponding to the target virtual object image.
  • the lighting direction corresponding to the virtual shadow image in the lighting image of the virtual object matches the lighting direction indicated by the lighting direction information.
  • the matching means that the angular deviation of the illumination direction corresponding to the virtual shadow image with respect to the illumination direction indicated by the illumination direction information is less than or equal to the preset angle.
  • the image fusion unit 505 may fuse the virtual object illumination image and the target object illumination image to add the virtual object illumination image to the target object illumination image. Obtain the resulting image. Among them, the result image is the target object illumination image with the virtual object illumination image added.
  • the information generating unit 503 may be further configured to input the resulting shadow image into a pre-trained light direction recognition model to obtain light direction information.
  • the distance information is the pixel value of the pixel in the resulting shadow image.
  • the shadow extraction model can be obtained by training in the following steps: Obtain a preset training sample set, where the training samples include sample object illumination images and samples predetermined for the sample object illumination images Result shadow image; obtain a pre-established generative confrontation network, where the generative confrontation network includes a generation network and a discriminant network.
  • the generation network is used to identify the input object illumination image and output the resulting shadow image
  • the discriminant network is used to determine Whether the input image is the image output by the generation network; based on the machine learning method, the illumination image of the sample object included in the training sample in the training sample set is used as the input of the generation network, and the resulting shadow image output by the generation network is combined with the input
  • the sample result shadow image corresponding to the illumination image of the sample object is used as the input of the discriminant network, the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
  • the apparatus 500 may further include: an image display unit (not shown in the figure), configured to display the obtained result image.
  • the apparatus 500 may further include: an image sending unit (not shown in the figure) configured to send the obtained result image to the user terminal connected in communication, and to control the user The terminal displays the result image.
  • an image sending unit (not shown in the figure) configured to send the obtained result image to the user terminal connected in communication, and to control the user The terminal displays the result image.
  • the apparatus 500 provided by the above-mentioned embodiment of the present disclosure can generate the virtual object illumination image corresponding to the virtual object image, and thereby can add a corresponding virtual shadow image to the virtual object image, and then illuminate the virtual object illumination image and the target object illumination image After the fusion, the authenticity of the generated result image can be improved; in addition, the present disclosure can determine the illumination direction of the virtual shadow image corresponding to the virtual object image based on the illumination direction of the shadow image in the target object illumination image, so as to: The virtual object image can be better integrated into the target object illumination image, further improving the authenticity of the result image, and helping to improve the display effect of the result image.
  • FIG. 6 shows a schematic structural diagram of an electronic device (such as the terminal device or the server in FIG. 1) 600 suitable for implementing the embodiments of the present disclosure.
  • the terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablets), PMPs (portable multimedia players), vehicle-mounted terminals (e.g. Mobile terminals such as car navigation terminals) and fixed terminals such as digital TVs, desktop computers, etc.
  • the electronic device shown in FIG. 6 is only an example, and should not bring any limitation to the function and use range of the embodiments of the present disclosure.
  • the electronic device 600 may include a processing device (such as a central processing unit, a graphics processor, etc.) 601, which can be loaded into a random access device according to a program stored in a read-only memory (ROM) 602 or from a storage device 608.
  • the program in the memory (RAM) 603 executes various appropriate actions and processing.
  • the RAM 603 also stores various programs and data required for the operation of the electronic device 600.
  • the processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604.
  • An input/output (I/O) interface 605 is also connected to the bus 604.
  • the following devices can be connected to the I/O interface 605: including input devices 606 such as touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, liquid crystal display (LCD), speakers, vibration An output device 607 such as a device; a storage device 608 such as a magnetic tape and a hard disk; and a communication device 609.
  • the communication device 609 may allow the electronic device 600 to perform wireless or wired communication with other devices to exchange data.
  • FIG. 6 shows an electronic device 600 having various devices, it should be understood that it is not required to implement or have all the illustrated devices. It may alternatively be implemented or provided with more or fewer devices.
  • the process described above with reference to the flowchart can be implemented as a computer software program.
  • the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart.
  • the computer program may be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602.
  • the processing device 601 the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
  • the computer-readable medium described in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two.
  • the computer-readable storage medium may be, for example, but not limited to, an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium.
  • the computer-readable signal medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device .
  • the program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wire, optical cable, RF (Radio Frequency), etc., or any suitable combination of the above.
  • the above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist alone without being assembled into the electronic device.
  • the above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains the target object illumination image and the target virtual object image, where the target object illumination image includes The object image and the shadow image corresponding to the object image; input the target object illumination image into the pre-trained shadow extraction model to obtain the resulting shadow image including distance information, where the distance information is used to characterize the shadow image in the target object illumination image The distance between the pixel point and the pixel point corresponding to the object image; based on the resulting shadow image, the illumination direction information corresponding to the target object illumination image is generated; based on the illumination direction information, the virtual object illumination image corresponding to the target virtual object image is generated, where the virtual The lighting direction corresponding to the virtual shadow image in the object lighting image matches the lighting direction indicated by the lighting
  • the computer program code used to perform the operations of the present disclosure can be written in one or more programming languages or a combination thereof.
  • the programming languages include object-oriented programming languages—such as Java, Smalltalk, C++, and also conventional Procedural programming language-such as "C" language or similar programming language.
  • the program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server.
  • the remote computer can be connected to the user’s computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to pass Internet connection).
  • LAN local area network
  • WAN wide area network
  • Internet service provider for example, using an Internet service provider to pass Internet connection.
  • each block in the flowchart or block diagram can represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logical function Executable instructions.
  • the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown in succession can actually be executed substantially in parallel, or they can sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
  • the units involved in the embodiments described in the present disclosure may be implemented in a software manner, or may be implemented in a hardware manner.
  • the name of the unit does not constitute a limitation on the unit itself under certain circumstances.
  • the image acquisition unit can also be described as "a unit that acquires the illumination image of the target object and the image of the virtual object".

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)

Abstract

The embodiments of the present disclosure disclose a method and a device for processing an image. An embodiment of the method comprises: acquiring a target object illumination image and a target virtual object image, the target object illumination image including an object image and a shadow image corresponding to the object image; inputting the target object illumination image into a pre-trained shadow extraction model, and obtaining a resulting shadow image comprising distance information; generating, on the basis of the resulting shadow image, illumination direction information corresponding to the target object illumination image; generating, on the basis of the illumination direction information, a virtual object illumination image corresponding to the target virtual object image; and fusing the virtual object illumination image and the target object illumination image, so as to add the virtual object illumination image to the target object illumination image, so as to obtain a resulting image. According to the embodiment, a virtual object image can be better fused into a target object illumination image, improving the authenticity of the resulting image, and thus facilitating the improvement of the display effect of the image.

Description

用于处理图像的方法和装置Method and device for processing image
相关申请的交叉引用Cross references to related applications
本申请基于申请号为201910302471.0、申请日为2019年04月16日,发明名称为“用于处理图像的方法和装置”的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on a Chinese patent application with the application number 201910302471.0, the application date being April 16, 2019, and the invention title "Method and Apparatus for Processing Images", and it claims the priority of the Chinese patent application. The Chinese patent The entire content of the application is hereby incorporated into this application as a reference.
技术领域Technical field
本公开的实施例涉及计算机技术领域,尤其涉及用于处理图像的方法和装置。The embodiments of the present disclosure relate to the field of computer technology, and more particularly to methods and devices for processing images.
背景技术Background technique
随着图像处理技术的发展,人们可以在拍摄的图像中添加虚拟物体图像,以此增强图像的显示效果。With the development of image processing technology, people can add virtual object images to the captured images to enhance the display effect of the images.
目前,用于添加到真实场景图像中的虚拟物体图像通常为技术人员根据虚拟物体的外形预先设置的图像。At present, the virtual object image used for adding to the real scene image is usually an image preset by the technician according to the shape of the virtual object.
发明内容Summary of the invention
本公开的实施例提出了用于处理图像的方法和装置。The embodiments of the present disclosure propose methods and devices for processing images.
第一方面,本公开的实施例提供了一种用于处理图像的方法,该方法包括:获取目标物体光照图像和目标虚拟物体图像,其中,目标物体光照图像包括物体图像和物体图像所对应的阴影图像;将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像,其中,距离信息用于表征在目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离;基于结果阴影图像,生成目标物体光照图像所对应的光照方向信息;基于光照方向信息,生成目标虚拟物体图像所对应的虚拟物体光照图像,其中,虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与光照方向信息所指示的 光照方向相匹配;对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像。In the first aspect, an embodiment of the present disclosure provides a method for processing an image, the method includes: acquiring a target object illumination image and a target virtual object image, wherein the target object illumination image includes the object image and the corresponding object image Shadow image; input the target object illumination image into the pre-trained shadow extraction model to obtain the resulting shadow image including distance information, where the distance information is used to represent the pixel points of the shadow image and the pixel corresponding to the object image in the target object illumination image The distance of the point; based on the resulting shadow image, generate the illumination direction information corresponding to the target object illumination image; based on the illumination direction information, generate the virtual object illumination image corresponding to the target virtual object image, where the virtual shadow image in the virtual object illumination image The corresponding light direction matches the light direction indicated by the light direction information; the virtual object light image and the target object light image are merged to add the virtual object light image to the target object light image to obtain the result image.
在一些实施例中,基于结果阴影图像,生成目标物体光照图像所对应的光照方向信息包括:将结果阴影图像输入预先训练的光照方向识别模型,获得光照方向信息。In some embodiments, based on the resulting shadow image, generating the illumination direction information corresponding to the target object illumination image includes: inputting the resulting shadow image into a pre-trained illumination direction recognition model to obtain the illumination direction information.
在一些实施例中,距离信息为结果阴影图像中的像素点的像素值。In some embodiments, the distance information is the pixel value of the pixel in the resulting shadow image.
在一些实施例中,阴影提取模型通过以下步骤训练得到:获取预置的训练样本集,其中,训练样本包括样本物体光照图像和针对样本物体光照图像预先确定的样本结果阴影图像;获取预先建立的生成式对抗网络,其中,生成式对抗网络包括生成网络和判别网络,生成网络用于对所输入的物体光照图像进行识别并输出结果阴影图像,判别网络用于确定所输入的图像是否为生成网络所输出的图像;基于机器学习方法,将训练样本集中的训练样本包括的样本物体光照图像作为生成网络的输入,将生成网络输出的结果阴影图像和与所输入的样本物体光照图像相对应的样本结果阴影图像作为判别网络的输入,对生成网络和判别网络进行训练,将训练后的生成网络确定为阴影提取模型。In some embodiments, the shadow extraction model is obtained by training in the following steps: obtaining a preset training sample set, where the training samples include a sample object illumination image and a sample result shadow image predetermined for the sample object illumination image; obtaining a pre-established Generative confrontation network, where the generative confrontation network includes a generation network and a discriminant network. The generation network is used to identify the input object lighting image and output the resulting shadow image, and the discriminant network is used to determine whether the input image is a generation network The output image; based on the machine learning method, the sample object illumination image included in the training samples in the training sample set is used as the input of the generation network, and the resulting shadow image output by the network and the sample corresponding to the input sample object illumination image are generated As a result, the shadow image is used as the input of the discriminant network, the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
在一些实施例中,该方法还包括:对所获得的结果图像进行显示。In some embodiments, the method further includes: displaying the obtained result image.
在一些实施例中,该方法还包括:将所获得的结果图像发送给通信连接的用户终端,以及控制用户终端对结果图像进行显示。In some embodiments, the method further includes: sending the obtained result image to a user terminal connected in communication, and controlling the user terminal to display the result image.
第二方面,本公开的实施例提供了一种用于处理图像的装置,该装置包括:图像获取单元,被配置成获取目标物体光照图像和目标虚拟物体图像,其中,目标物体光照图像包括物体图像和物体图像所对应的阴影图像;图像输入单元,被配置成将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像,其中,距离信息用于表征在目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离;信息生成单元,被配置成基于结果阴影图像,生成目标物体光照图像所对应的光照方向信息;图像生成单元,被配置成基于光照方向信息,生成目标虚拟物体图像所对应的虚拟物体光照图像,其中,虚拟物体光照图像中的虚拟阴影图像所对应的光 照方向与光照方向信息所指示的光照方向相匹配;图像融合单元,被配置成对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像。In a second aspect, an embodiment of the present disclosure provides an apparatus for processing an image. The apparatus includes: an image acquisition unit configured to acquire a target object illumination image and a target virtual object image, wherein the target object illumination image includes an object The shadow image corresponding to the image and the object image; the image input unit is configured to input the target object illumination image into the pre-trained shadow extraction model to obtain the resulting shadow image including distance information, where the distance information is used to characterize the illumination of the target object In the image, the distance between the pixel point of the shadow image and the pixel point corresponding to the object image; the information generation unit is configured to generate light direction information corresponding to the target object illumination image based on the resulting shadow image; the image generation unit is configured to be based on The illumination direction information generates the virtual object illumination image corresponding to the target virtual object image, wherein the illumination direction corresponding to the virtual shadow image in the virtual object illumination image matches the illumination direction indicated by the illumination direction information; the image fusion unit is It is configured to fuse the lighting image of the virtual object and the lighting image of the target object to add the lighting image of the virtual object to the lighting image of the target object to obtain a result image.
在一些实施例中,信息生成单元进一步被配置成:将结果阴影图像输入预先训练的光照方向识别模型,获得光照方向信息。In some embodiments, the information generating unit is further configured to: input the resulting shadow image into a pre-trained light direction recognition model to obtain light direction information.
在一些实施例中,距离信息为结果阴影图像中的像素点的像素值。In some embodiments, the distance information is the pixel value of the pixel in the resulting shadow image.
在一些实施例中,阴影提取模型通过以下步骤训练得到:获取预置的训练样本集,其中,训练样本包括样本物体光照图像和针对样本物体光照图像预先确定的样本结果阴影图像;获取预先建立的生成式对抗网络,其中,生成式对抗网络包括生成网络和判别网络,生成网络用于对所输入的物体光照图像进行识别并输出结果阴影图像,判别网络用于确定所输入的图像是否为生成网络所输出的图像;基于机器学习方法,将训练样本集中的训练样本包括的样本物体光照图像作为生成网络的输入,将生成网络输出的结果阴影图像和与所输入的样本物体光照图像相对应的样本结果阴影图像作为判别网络的输入,对生成网络和判别网络进行训练,将训练后的生成网络确定为阴影提取模型。In some embodiments, the shadow extraction model is obtained by training in the following steps: obtaining a preset training sample set, where the training samples include a sample object illumination image and a sample result shadow image predetermined for the sample object illumination image; obtaining a pre-established Generative confrontation network, where the generative confrontation network includes a generation network and a discriminant network. The generation network is used to identify the input object lighting image and output the resulting shadow image, and the discriminant network is used to determine whether the input image is a generation network The output image; based on the machine learning method, the sample object illumination image included in the training samples in the training sample set is used as the input of the generation network, and the resulting shadow image output by the network and the sample corresponding to the input sample object illumination image are generated As a result, the shadow image is used as the input of the discriminant network, the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
在一些实施例中,该装置还包括:图像显示单元,被配置成对所获得的结果图像进行显示。In some embodiments, the device further includes: an image display unit configured to display the obtained result image.
在一些实施例中,该装置还包括:图像发送单元,被配置成将所获得的结果图像发送给通信连接的用户终端,以及控制用户终端对结果图像进行显示。In some embodiments, the device further includes: an image sending unit configured to send the obtained result image to a user terminal connected in communication, and control the user terminal to display the result image.
第三方面,本公开的实施例提供了一种电子设备,包括:一个或多个处理器;存储装置,其上存储有一个或多个程序,当一个或多个程序被一个或多个处理器执行,使得一个或多个处理器实现上述用于处理图像的方法中任一实施例的方法。In a third aspect, the embodiments of the present disclosure provide an electronic device, including: one or more processors; a storage device, on which one or more programs are stored, when one or more programs are processed by one or more The processor executes, so that one or more processors implement the method of any one of the foregoing methods for processing images.
第四方面,本公开的实施例提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理器执行时实现上述用于处理图像的方法中任一实施例的方法。In a fourth aspect, the embodiments of the present disclosure provide a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the method of any one of the above methods for processing an image is implemented.
本公开的实施例提供的用于处理图像的方法和装置,通过获取目 标物体光照图像和目标虚拟物体图像,其中,目标物体光照图像包括物体图像和物体图像所对应的阴影图像,而后将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像,其中,距离信息用于表征在目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离,接着基于结果阴影图像,生成目标物体光照图像所对应的光照方向信息,然后基于光照方向信息,生成目标虚拟物体图像所对应的虚拟物体光照图像,其中,虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与光照方向信息所指示的光照方向相匹配,最后对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像,从而可以在为目标物体光照图像添加虚拟物体图像时,基于所确定的光照方向,生成虚拟物体图像所对应的阴影图像,以此可以使虚拟物体图像更好地融合到目标物体光照图像中,提高了结果图像的真实性,有助于提高图像的显示效果。The method and device for processing an image provided by the embodiments of the present disclosure acquire a target object illumination image and a target virtual object image, where the target object illumination image includes the object image and the shadow image corresponding to the object image, and then the target object The illumination image is input into the pre-trained shadow extraction model to obtain the resulting shadow image including distance information. The distance information is used to characterize the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image, and then based on As a result, the shadow image generates the illumination direction information corresponding to the illumination image of the target object, and then based on the illumination direction information, the virtual object illumination image corresponding to the target virtual object image is generated, where the illumination corresponding to the virtual shadow image in the virtual object illumination image The direction matches the light direction indicated by the light direction information, and finally the virtual object light image and the target object light image are merged to add the virtual object light image to the target object light image to obtain the result image, which can be used as the target When adding a virtual object image to the lighting image of the object, based on the determined light direction, the shadow image corresponding to the virtual object image is generated, so that the virtual object image can be better integrated into the target object lighting image, which improves the reality of the result image It can improve the display effect of the image.
附图说明Description of the drawings
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本公开的其它特征、目的和优点将会变得更明显:By reading the detailed description of the non-limiting embodiments with reference to the following drawings, other features, purposes and advantages of the present disclosure will become more apparent:
图1是本公开的一个实施例可以应用于其中的示例性系统架构图;FIG. 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure can be applied;
图2是根据本公开的用于处理图像的方法的一个实施例的流程图;Fig. 2 is a flowchart of an embodiment of a method for processing an image according to the present disclosure;
图3是根据本公开的实施例的用于处理图像的方法的一个应用场景的示意图;3 is a schematic diagram of an application scenario of the method for processing images according to an embodiment of the present disclosure;
图4是根据本公开的用于处理图像的方法的又一个实施例的流程图;FIG. 4 is a flowchart of another embodiment of a method for processing an image according to the present disclosure;
图5是根据本公开的用于处理图像的装置的一个实施例的结构示意图;Fig. 5 is a schematic structural diagram of an embodiment of an image processing apparatus according to the present disclosure;
图6是适于用来实现本公开的实施例的电子设备的计算机系统的结构示意图。Fig. 6 is a schematic structural diagram of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure.
具体实施方式detailed description
下面结合附图和实施例对本公开作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。The present disclosure will be further described in detail below in conjunction with the drawings and embodiments. It can be understood that the specific embodiments described here are only used to explain the related invention, but not to limit the invention. In addition, it should be noted that, for ease of description, only the parts related to the relevant invention are shown in the drawings.
需要说明的是,在不冲突的情况下,本公开中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本公开。It should be noted that the embodiments in the present disclosure and the features in the embodiments can be combined with each other if there is no conflict. Hereinafter, the present disclosure will be described in detail with reference to the drawings and in conjunction with embodiments.
图1示出了可以应用本公开的用于处理图像的方法或用于处理图像的装置的实施例的示例性系统架构100。FIG. 1 shows an exemplary system architecture 100 to which an embodiment of the method for processing images or the apparatus for processing images of the present disclosure can be applied.
如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables.
用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种通讯客户端应用,例如图像处理类应用、网页浏览器应用、购物类应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等。The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages and so on. Various communication client applications, such as image processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, and social platform software, can be installed on the terminal devices 101, 102, and 103.
终端设备101、102、103可以是硬件,也可以是软件。当终端设备101、102、103为硬件时,可以是具有摄像头的各种电子设备,包括但不限于智能手机、平板电脑、电子书阅读器、MP3播放器(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面4)播放器、膝上型便携计算机和台式计算机等等。当终端设备101、102、103为软件时,可以安装在上述所列举的电子设备中。其可以实现成多个软件或软件模块(例如用来提供分布式服务的多个软件或软件模块),也可以实现成单个软件或软件模块。在此不做具体限定。The terminal devices 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they can be various electronic devices with cameras, including but not limited to smart phones, tablets, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, dynamic Video experts compress standard audio layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, dynamic image experts compress standard audio layer 4) players, laptop portable computers and desktop computers, etc. When the terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, multiple software or software modules for providing distributed services), or as a single software or software module. There is no specific limitation here.
服务器105可以是提供各种服务的服务器,例如对终端设备101、 102、103拍摄获得的目标物体光照图像进行处理的图像处理服务器。图像处理服务器可以对接收到的目标物体光照图像等数据进行分析等处理,并获得处理结果(例如结果图像)。实践中,服务器还可以将所获得的处理结果反馈给终端设备。The server 105 may be a server that provides various services, for example, an image processing server that processes the illumination images of the target object obtained by shooting the terminal devices 101, 102, and 103. The image processing server can analyze and process the received data such as the illumination image of the target object, and obtain the processing result (for example, the result image). In practice, the server can also feed back the obtained processing result to the terminal device.
需要说明的是,本公开的实施例所提供的用于处理图像的方法可以由服务器105执行,也可以由终端设备101、102、103执行,相应地,用于处理图像的装置可以设置于服务器105中,也可以设置于终端设备101、102、103中。It should be noted that the method for processing images provided by the embodiments of the present disclosure can be executed by the server 105, and can also be executed by the terminal devices 101, 102, 103. Accordingly, the device for processing images can be set in the server. 105 can also be set in the terminal devices 101, 102, 103.
需要说明的是,服务器可以是硬件,也可以是软件。当服务器为硬件时,可以实现成多个服务器组成的分布式服务器集群,也可以实现成单个服务器。当服务器为软件时,可以实现成多个软件或软件模块(例如用来提供分布式服务的多个软件或软件模块),也可以实现成单个软件或软件模块。在此不做具体限定。It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster composed of multiple servers, or as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, multiple software or software modules for providing distributed services), or as a single software or software module. There is no specific limitation here.
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。在生成结果图像的过程中所使用的数据不需要从远程获取的情况下,上述系统架构可以不包括网络,而只包括终端设备或服务器。It should be understood that the numbers of terminal devices, networks, and servers in FIG. 1 are merely illustrative. According to implementation needs, there can be any number of terminal devices, networks and servers. In the case that the data used in the process of generating the result image does not need to be obtained remotely, the above system architecture may not include the network, but only include the terminal device or the server.
继续参考图2,示出了根据本公开的用于处理图像的方法的一个实施例的流程200。该用于处理图像的方法,包括以下步骤:With continued reference to FIG. 2, there is shown a flow 200 of an embodiment of the method for processing an image according to the present disclosure. The method for processing images includes the following steps:
步骤201,获取目标物体光照图像和目标虚拟物体图像。Step 201: Obtain a target object illumination image and a target virtual object image.
在本实施例中,用于处理图像的方法的执行主体(例如图1所示的服务器105)可以通过有线连接方式或者无线连接方式从远程或者本地获取目标物体光照图像和目标虚拟物体图像。其中,目标物体光照图像为待对其进行处理的图像。目标物体光照图像包括物体图像和物体图像所对应的阴影图像。具体的,目标物体光照图像可以为对光照场景中的物体进行拍摄所获得的图像。拍摄获得目标物体光照图像的光照场景中的光源为平行光或者太阳光。可以理解,在光照场景下,当物体遮挡光源时,会产生阴影。In this embodiment, the execution subject of the method for processing images (for example, the server 105 shown in FIG. 1) may remotely or locally obtain the target object illumination image and the target virtual object image through a wired connection or a wireless connection. Among them, the illumination image of the target object is the image to be processed. The illumination image of the target object includes the object image and the shadow image corresponding to the object image. Specifically, the illuminated image of the target object may be an image obtained by shooting an object in the illuminated scene. The light source in the illumination scene in which the illumination image of the target object is captured is parallel light or sunlight. It can be understood that in an illuminated scene, when an object blocks the light source, shadows will be generated.
在本实施例中,目标虚拟物体图像为用于对目标物体光照图像进 行处理的图像。目标虚拟物体图像可以为根据虚拟物体的外形预先确定的图像。具体的,可以为预先绘制的图像,或者,也可以为按照物体的轮廓预先从已有的图像中提取的图像。需要说明的是,在这里,目标虚拟物体图像的“虚拟”是相对于目标物体光照图像而言的,指的是目标虚拟物体图像所对应的虚拟物体实质上并不存在于用于拍摄获得目标物体光照图像的真实场景中。In this embodiment, the target virtual object image is an image used to process the illumination image of the target object. The target virtual object image may be an image predetermined according to the shape of the virtual object. Specifically, it may be a pre-drawn image, or it may be an image pre-extracted from an existing image according to the contour of the object. It should be noted that, here, the "virtual" of the target virtual object image is relative to the target object illumination image, which means that the virtual object corresponding to the target virtual object image does not actually exist in the target virtual object image. Objects in the real scene of the illuminated image.
步骤202,将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像。Step 202: Input the illumination image of the target object into a pre-trained shadow extraction model to obtain a resultant shadow image including distance information.
在本实施例中,基于步骤201中得到的目标物体光照图像,上述执行主体可以将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像。其中,结果阴影图像可以为从目标物体光照图像中提取出的、添加了距离信息的阴影图像。距离信息用于表征在目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离。具体的,物体中的某个点由于遮挡光源,会在投影面(例如地面、墙面、桌面等)上产生阴影点,进而,在这里,可以将用于产生阴影点的、物体上的点作为与阴影点对应的物体点,而物体上的物体点对应物体图像中的像素点,阴影中的阴影点对应阴影图像中的像素点,进而可以将用于产生阴影图像中的像素点所对应的阴影点的物体点所对应的像素点作为与阴影图像中的像素点对应的像素点。In this embodiment, based on the target object illumination image obtained in step 201, the above-mentioned execution subject may input the target object illumination image into a pre-trained shadow extraction model to obtain a resultant shadow image including distance information. Among them, the resulting shadow image may be a shadow image extracted from the illumination image of the target object and added with distance information. The distance information is used to characterize the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image. Specifically, because a certain point in the object blocks the light source, a shadow point will be generated on the projection surface (such as the ground, wall, desktop, etc.). Furthermore, here, the point on the object used to generate the shadow point can be used. As the object point corresponding to the shadow point, and the object point on the object corresponds to the pixel point in the object image, the shadow point in the shadow corresponds to the pixel point in the shadow image, which can then be used to generate the shadow image corresponding to the pixel point The pixel point corresponding to the object point of the shadow point is regarded as the pixel point corresponding to the pixel point in the shadow image.
在本实施例中,距离信息可以以各种形式在结果阴影图像中得以体现。作为示例,距离信息可以以数字的形式记录在结果阴影图像中。具体的,结果阴影图像中的每个像素点可以对应一个数字,该数字可以为所对应的像素点与物体图像中对应的像素点的距离。In this embodiment, the distance information can be embodied in the resulting shadow image in various forms. As an example, the distance information can be recorded in the resulting shadow image in digital form. Specifically, each pixel in the resulting shadow image may correspond to a number, and the number may be the distance between the corresponding pixel and the corresponding pixel in the object image.
在本实施例的一些可选的实现方式中,距离信息可以为结果阴影图像中的像素点的像素值。具体的,可以采用各种方式利用像素值表征距离。作为示例,可以采用像素值越大,距离越远的方式;或者,也可以采用像素值越小,距离越远的方式。In some optional implementation manners of this embodiment, the distance information may be the pixel value of the pixel in the resulting shadow image. Specifically, various ways can be used to characterize the distance using pixel values. As an example, the larger the pixel value, the longer the distance; or the smaller the pixel value, the longer the distance.
在本实施例中,阴影提取模型可以用于表征物体光照图像与结果阴影图像的对应关系。具体的,作为示例,阴影提取模型可以是技术 人员预先基于对大量的物体光照图像和物体光照图像所对应的结果阴影图像的统计而预先制定的、存储有多个物体光照图像与对应的结果阴影图像的对应关系表;也可以为基于预设的训练样本,利用机器学习方法对初始模型(例如神经网络)进行训练后得到的模型。In this embodiment, the shadow extraction model can be used to characterize the correspondence between the illumination image of the object and the resulting shadow image. Specifically, as an example, the shadow extraction model may be pre-made by technicians based on statistics of a large number of object illumination images and result shadow images corresponding to the object illumination image, and stores multiple object illumination images and corresponding result shadows. Correspondence table of the image; it can also be a model obtained after training an initial model (such as a neural network) using a machine learning method based on a preset training sample.
在本实施例的一些可选的实现方式中,阴影提取模型可以由上述执行主体或其他电子设备通过以下步骤训练得到:In some optional implementations of this embodiment, the shadow extraction model may be trained by the above-mentioned executive body or other electronic devices through the following steps:
首先,获取预置的训练样本集,其中,训练样本包括样本物体光照图像和针对样本物体光照图像预先确定的样本结果阴影图像。First, obtain a preset training sample set, where the training sample includes a sample object illumination image and a sample result shadow image predetermined for the sample object illumination image.
在这里,样本物体光照图像可以为对处于光照场景下的样本物体进行拍摄获得的图像。样本物体光照图像可以包括样本物体图像和样本阴影图像。样本结果阴影图像可以为通过从样本物体光照图像中提取样本阴影图像,并在所提取的样本阴影图像中添加样本距离信息后获得的图像。Here, the illuminated image of the sample object may be an image obtained by shooting the sample object in an illuminated scene. The sample object illumination image may include a sample object image and a sample shadow image. The sample result shadow image may be an image obtained by extracting a sample shadow image from a sample object illumination image, and adding sample distance information to the extracted sample shadow image.
然后,获取预先建立的生成式对抗网络,其中,生成式对抗网络包括生成网络和判别网络,生成网络用于对所输入的物体光照图像进行识别并输出结果阴影图像,判别网络用于确定所输入的图像是否为生成网络所输出的图像。Then, a pre-established generative confrontation network is obtained, where the generative confrontation network includes a generation network and a discrimination network. The generation network is used to recognize the input object illumination image and output the resulting shadow image, and the discrimination network is used to determine the input Whether the image of is the image output by the generation network.
在这里,上述生成式对抗网络可以是各种结构的生成式对抗网络。例如,生成式对抗网络可以是深度卷积生成式对抗网络(Deep Convolutional Generative Adversarial Network,DCGAN)。需要说明的是,上述生成式对抗网络可以是未经训练的、初始化参数后的生成对抗网络,也可以是已经训练过的生成对抗网络。Here, the above-mentioned generative confrontation network may be a generative confrontation network of various structures. For example, the generative adversarial network may be a deep convolutional generative adversarial network (Deep Convolutional Generative Adversarial Network, DCGAN). It should be noted that the above-mentioned generative confrontation network may be an untrained generative confrontation network after initializing parameters, or a trained generative confrontation network.
具体的,生成网络可以是用于进行图像处理的卷积神经网络(例如包含卷积层、池化层、反池化层、反卷积层的各种结构的卷积神经网络)。上述判别网络也可以是卷积神经网络(例如包含全连接层的各种结构的卷积神经网络,其中,上述全连接层可以实现分类功能)。此外,判别网络也可以是用于实现分类功能的其他模型,例如支持向量机(Support Vector Machine,SVM)。此处,判别网络若判定输入判别网络的图像是生成网络所输出的图像,则可以输出1(或0);若判定不是生成网络所输出的图像,则可以输出0(或1)。需要说明的是, 判别网络也可以输出其他预先设置的信息来表征判别结果,不限于数值1和0。Specifically, the generation network may be a convolutional neural network for image processing (for example, a convolutional neural network with various structures including a convolutional layer, a pooling layer, a depooling layer, and a deconvolutional layer). The above-mentioned discriminant network may also be a convolutional neural network (for example, a convolutional neural network of various structures including a fully connected layer, where the above-mentioned fully connected layer can implement a classification function). In addition, the discriminant network can also be other models used to implement classification functions, such as Support Vector Machine (SVM). Here, if the discriminant network determines that the image input to the discriminant network is an image output by the generation network, it can output 1 (or 0); if it determines that it is not an image output by the generation network, it can output 0 (or 1). It should be noted that the discrimination network can also output other preset information to characterize the discrimination result, which is not limited to the values 1 and 0.
最后,基于机器学习方法,将训练样本集中的训练样本包括的样本物体光照图像作为生成网络的输入,将生成网络输出的结果阴影图像和与所输入的样本物体光照图像相对应的样本结果阴影图像作为判别网络的输入,对生成网络和判别网络进行训练,将训练后的生成网络确定为阴影提取模型。Finally, based on the machine learning method, the sample object illumination image included in the training samples in the training sample set is used as the input of the generation network, and the resulting shadow image output by the network and the sample result shadow image corresponding to the input sample object illumination image are generated. As the input of the discriminant network, the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
具体地,可以首先固定生成网络和判别网络中的任一网络(可称为第一网络)的参数,对未固定参数的网络(可称为第二网络)进行优化;再固定第二网络的参数,对第一网络进行改进。不断进行上述迭代,使判别网络无法区分输入的图像是否是生成网络所输出的。此时,上述生成网络所生成的结果阴影图像与样本结果阴影图像接近,上述判别网络无法准确区分真实数据和生成数据(即准确率为50%),可以将此时的生成网络确定为阴影提取模型。Specifically, the parameters of any one of the generating network and the discriminating network (which can be called the first network) can be fixed first, and the network with no fixed parameters (which can be called the second network) can be optimized; then the parameters of the second network can be fixed. Parameters to improve the first network. Continuously carry out the above iterations, so that the judgment network cannot distinguish whether the input image is output by the generation network. At this time, the result shadow image generated by the above generation network is close to the sample result shadow image, and the above discrimination network cannot accurately distinguish between the real data and the generated data (that is, the accuracy rate is 50%). The generation network at this time can be determined as the shadow extraction model.
需要说明的是,上述执行主体或其他电子设备可以利用现有的反向传播算法和梯度下降算法对生成网络和判别网络进行训练。每次训练后的生成网络和判别网络的参数会被调整,将每次调整参数后得到的生成网络和判别网络作为下次训练所使用的生成网络和判别网络。It should be noted that the above-mentioned executive body or other electronic devices can use the existing back propagation algorithm and gradient descent algorithm to train the generation network and the discrimination network. The parameters of the generation network and the discrimination network after each training will be adjusted, and the generation network and the discrimination network obtained after each adjustment of the parameters are used as the generation network and the discrimination network used in the next training.
步骤203,基于结果阴影图像,生成目标物体光照图像所对应的光照方向信息。Step 203: Based on the resulting shadow image, generate light direction information corresponding to the light image of the target object.
在本实施例中,基于步骤202中得到的结果阴影图像,上述执行主体可以生成目标物体光照图像所对应的光照方向信息。其中,光照方向信息可以用于指示光照方向,可以包括但不限于以下至少一项:文字、数字、符号、图像。具体的,作为示例,光照方向信息可以为在结果阴影图像中标注出的箭头,这里,箭头的指向可以为光照方向;或者,光照方向信息可以为二维向量,这里,二维向量所对应的方向可以为光照方向。In this embodiment, based on the resulting shadow image obtained in step 202, the above-mentioned execution subject may generate the illumination direction information corresponding to the illumination image of the target object. Wherein, the light direction information can be used to indicate the light direction, which can include but is not limited to at least one of the following: text, numbers, symbols, and images. Specifically, as an example, the illumination direction information may be an arrow marked in the resulting shadow image. Here, the direction of the arrow may be the illumination direction; or the illumination direction information may be a two-dimensional vector, where the two-dimensional vector corresponds to The direction can be the light direction.
需要说明的是,在本实施例中,光照方向信息所指示的光照方向为三维坐标系下的实际光照方向在三维坐标系下的阴影所在的投影面上的投影。可以理解,实践中,光照方向(即实际光照方向在阴影所 在投影面上的投影)通常与阴影的延伸方向一致。进而,上述执行主体可以基于结果阴影图像中的像素点和像素点所对应的距离信息,确定阴影的延伸方向,进而确定出光照方向。具体的,作为示例,上述执行主体可以从结果阴影图像中选取所对应的距离信息所表征的距离最近的像素点作为第一像素点,以及选取所对应的距离信息所表征的距离最远的像素点作为第二像素点,进而,上述执行主体可以将第一像素点指向第二像素点的方向确定为光照方向。It should be noted that, in this embodiment, the light direction indicated by the light direction information is the projection of the actual light direction in the three-dimensional coordinate system on the projection surface where the shadow in the three-dimensional coordinate system is located. It can be understood that in practice, the light direction (that is, the projection of the actual light direction on the projection surface of the shadow) is usually the same as the extension direction of the shadow. Furthermore, the above-mentioned execution subject may determine the extension direction of the shadow based on the pixel points in the resulting shadow image and the distance information corresponding to the pixel points, and then determine the light direction. Specifically, as an example, the above-mentioned execution subject may select, from the resulting shadow image, the pixel with the closest distance represented by the corresponding distance information as the first pixel, and select the pixel with the farthest distance represented by the corresponding distance information The dot is used as the second pixel, and further, the above-mentioned execution subject may determine the direction in which the first pixel points to the second pixel as the illumination direction.
步骤204,基于光照方向信息,生成目标虚拟物体图像所对应的虚拟物体光照图像。 Step 204, based on the illumination direction information, generate a virtual object illumination image corresponding to the target virtual object image.
在本实施例中,基于步骤203中获得的光照方向信息,上述执行主体可以生成目标虚拟物体图像所对应的虚拟物体光照图像。其中,虚拟物体光照图像包括上述目标虚拟物体图像和目标虚拟物体图像所对应的虚拟阴影图像。虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与光照方向信息所指示的光照方向相匹配。这里,相匹配指的是虚拟阴影图像所对应的光照方向相对于光照方向信息所指示的光照方向的角度偏差小于等于预设角度。In this embodiment, based on the illumination direction information obtained in step 203, the above-mentioned execution subject may generate the virtual object illumination image corresponding to the target virtual object image. The lighting image of the virtual object includes the above-mentioned target virtual object image and the virtual shadow image corresponding to the target virtual object image. The lighting direction corresponding to the virtual shadow image in the lighting image of the virtual object matches the lighting direction indicated by the lighting direction information. Here, the matching means that the angular deviation of the illumination direction corresponding to the virtual shadow image with respect to the illumination direction indicated by the illumination direction information is less than or equal to the preset angle.
具体的,上述执行主体可以基于光照方向信息,采用各种方法生成目标虚拟物体图像所对应的虚拟物体光照图像。Specifically, the above-mentioned execution subject may use various methods to generate the virtual object illumination image corresponding to the target virtual object image based on the illumination direction information.
作为示例,可以基于光照方向信息所指示的光照方向在渲染引擎中构建光源,进而基于构建的光源对目标虚拟物体图像进行渲染,即可得到虚拟物体光照图像。需要说明的是,由于光照方向信息所指示的光照方向为实际光照方向在阴影所在投影面上投影,所以,在构建光源的过程中,需要首先基于光照方向信息确定实际光照方向,进而基于实际光照方向构建光源。需要说明的是,实践中,实际光照方向可以由阴影所在投影面上的光照方向和与阴影所在投影面垂直的投影面上的光照方向确定,而在本实施例中,与阴影所在投影面垂直的投影面上的光照方向可以是预先确定的。As an example, a light source can be constructed in the rendering engine based on the light direction indicated by the light direction information, and then the target virtual object image can be rendered based on the constructed light source to obtain the virtual object light image. It should be noted that since the light direction indicated by the light direction information is the actual light direction projected on the projection surface where the shadow is located, in the process of constructing the light source, it is necessary to first determine the actual light direction based on the light direction information, and then based on the actual light The direction builds the light source. It should be noted that, in practice, the actual light direction can be determined by the light direction on the projection surface where the shadow is located and the light direction on the projection surface perpendicular to the projection surface where the shadow is located, and in this embodiment, it is perpendicular to the projection surface where the shadow is located. The direction of illumination on the projection surface can be predetermined.
作为又一个示例,上述执行主体预先存储有目标虚拟物体图像所对应的初始虚拟阴影图像。则上述执行主体可以基于光照方向信息,对初始虚拟阴影图像进行调整,获得上述虚拟阴影图像,进而,对虚 拟阴影图像和目标虚拟物体图像进行组合,生成虚拟物体光照图像。As another example, the above-mentioned execution subject pre-stores an initial virtual shadow image corresponding to the target virtual object image. Then the execution subject can adjust the initial virtual shadow image based on the illumination direction information to obtain the virtual shadow image, and then combine the virtual shadow image and the target virtual object image to generate the virtual object illumination image.
需要说明的是,由于目标物体光照图像所对应的光源为平行光或太阳光,所以这里,可以认为虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与上述光照方向信息所指示的光照方向相匹配,而无需考虑虚拟物体光照图像添加到目标物体光照图像中的位置对虚拟阴影图像所对应的光照方向的影响。It should be noted that since the light source corresponding to the illumination image of the target object is parallel light or sunlight, here, it can be considered that the illumination direction corresponding to the virtual shadow image in the illumination image of the virtual object is the same as the illumination direction indicated by the aforementioned illumination direction information. It does not need to consider the influence of the position of the virtual object illumination image added to the target object illumination image on the illumination direction corresponding to the virtual shadow image.
步骤205,对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像。Step 205: Fusion of the lighting image of the virtual object and the lighting image of the target object to add the lighting image of the virtual object to the lighting image of the target object to obtain a result image.
在本实施例中,基于步骤204中得到的虚拟物体光照图像,上述执行主体可以对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像。其中,结果图像为添加了虚拟物体光照图像的目标物体光照图像。In this embodiment, based on the virtual object illumination image obtained in step 204, the above-mentioned execution subject may fuse the virtual object illumination image and the target object illumination image to add the virtual object illumination image to the target object illumination image to obtain the result image. Among them, the result image is the target object illumination image with the virtual object illumination image added.
在这里,虚拟物体光照图像添加到目标物体光照图像中的位置可以为预先确定的(例如可以为图像的中心位置),也可以为通过对目标物体光照图像进行识别后确定的(例如可以在识别出目标物体光照图像中的物体图像和阴影图像后,将目标物体光照图像中不包括物体图像和阴影图像的区域确定为用于添加虚拟物体光照图像的位置)。Here, the position where the virtual object illumination image is added to the target object illumination image can be predetermined (for example, the center position of the image), or it can be determined after recognizing the target object illumination image (for example, it can be After the object image and shadow image in the illumination image of the target object are obtained, the area in the illumination image of the target object that does not include the object image and shadow image is determined as the location for adding the virtual object illumination image).
在本实施例的一些可选的实现方式中,获得结果图像之后,上述执行主体可以对所获得的结果图像进行显示。In some optional implementation manners of this embodiment, after obtaining the result image, the execution subject may display the obtained result image.
在本实施例的一些可选的实现方式中,上述执行主体还可以将所获得的结果图像发送给通信连接的用户终端,以及控制用户终端对结果图像进行显示。其中,用户终端为用户所使用的、与上述执行主体通信连接的终端。具体的,上述执行主体可以向用户终端发送控制信号,进而控制用户终端对结果图像进行显示。In some optional implementation manners of this embodiment, the above-mentioned execution subject may also send the obtained result image to the user terminal connected in communication, and control the user terminal to display the result image. Wherein, the user terminal is a terminal used by the user to communicate with the execution subject. Specifically, the above-mentioned execution subject may send a control signal to the user terminal, thereby controlling the user terminal to display the result image.
在这里,由于结果图像中的虚拟物体图像对应有虚拟阴影图像,且所对应的虚拟阴影图像的光照方向与真实物体图像所对应的阴影图像的光照方向相匹配,所以本实现方式可以控制用户终端显示更为真实的结果图像,以此,提高图像的显示效果。Here, since the virtual object image in the result image corresponds to a virtual shadow image, and the illumination direction of the corresponding virtual shadow image matches the illumination direction of the shadow image corresponding to the real object image, this implementation can control the user terminal Display a more realistic result image to improve the display effect of the image.
继续参见图3,图3是根据本实施例的用于处理图像的方法的应 用场景的一个示意图。在图3的应用场景中,服务器301首先获取猫的光照图像302(目标物体光照图像)和足球图像303(目标虚拟物体图像),其中,猫的光照图像302包括猫的图像(物体图像)和猫的影子图像(阴影图像)。然后,服务器301可以将猫的光照图像302输入预先训练的阴影提取模型304,获得包括距离信息的猫的影子图像305(结果阴影图像),其中,距离信息用于表征在猫的光照图像302中,猫的影子图像的像素点与猫的图像对应的像素点的距离。接着,服务器301可以基于包括距离信息的猫的影子图像305,生成猫的光照图像302所对应的光照方向信息306。然后,服务器301可以基于光照方向信息306,生成足球图像304所对应的足球光照图像307(虚拟物体光照图像),其中,足球光照图像307中的足球影子图像(虚拟阴影图像)所对应的光照方向与光照方向信息306所指示的光照方向相匹配。最后,服务器301可以对足球光照图像307和猫的光照图像302进行融合,以将足球光照图像307添加到猫的光照图像302中,获得结果图像308。Continue to refer to Fig. 3, which is a schematic diagram of an application scenario of the method for processing an image according to this embodiment. In the application scenario of FIG. 3, the server 301 first obtains the cat's lighting image 302 (target object lighting image) and the football image 303 (target virtual object image), where the cat lighting image 302 includes the cat's image (object image) and The shadow image of the cat (shadow image). Then, the server 301 can input the cat's light image 302 into the pre-trained shadow extraction model 304 to obtain the cat's shadow image 305 (resulting shadow image) including distance information, where the distance information is used to represent the cat's light image 302 , The distance between the pixel of the cat’s shadow image and the pixel of the cat’s image. Then, the server 301 may generate the light direction information 306 corresponding to the light image 302 of the cat based on the shadow image 305 of the cat including the distance information. Then, the server 301 can generate a football illumination image 307 (virtual object illumination image) corresponding to the football image 304 based on the illumination direction information 306, where the football shadow image (virtual shadow image) in the football illumination image 307 corresponds to the illumination direction It matches the light direction indicated by the light direction information 306. Finally, the server 301 may merge the football lighting image 307 and the cat lighting image 302 to add the football lighting image 307 to the cat lighting image 302 to obtain a result image 308.
目前,对光照场景中的物体进行拍摄时,通常会拍摄到场景中的物体的阴影。而用于添加到真实场景图像中的虚拟物体图像通常不包括阴影图像,此时,将虚拟物体图像添加到真实场景图像中则会降低图像的真实性,影响图像的显示效果。本公开的上述实施例提供的方法可以生成虚拟物体图像所对应的虚拟物体光照图像,以此,可以为虚拟物体图像增添对应的虚拟阴影图像,进而在对虚拟物体光照图像和目标物体光照图像进行融合后,可以提高所生成的结果图像的真实性;此外,本公开可以基于目标物体光照图像中的阴影图像的光照方向来确定虚拟物体图像所对应的虚拟阴影图像的光照方向,以此,可以使虚拟物体图像更好地融合到目标物体光照图像中,进一步提高结果图像的真实性,有助于提高结果图像的显示效果。Currently, when shooting objects in a illuminated scene, the shadows of the objects in the scene are usually shot. The virtual object image used to add to the real scene image usually does not include the shadow image. At this time, adding the virtual object image to the real scene image will reduce the authenticity of the image and affect the display effect of the image. The method provided by the above-mentioned embodiments of the present disclosure can generate the virtual object illumination image corresponding to the virtual object image, so that the corresponding virtual shadow image can be added to the virtual object image, and then the illumination image of the virtual object and the illumination image of the target object can be added. After the fusion, the authenticity of the generated result image can be improved; in addition, the present disclosure can determine the illumination direction of the virtual shadow image corresponding to the virtual object image based on the illumination direction of the shadow image in the target object illumination image. The virtual object image is better integrated into the target object illumination image, and the authenticity of the result image is further improved, which helps to improve the display effect of the result image.
进一步参考图4,其示出了用于处理图像的方法的又一个实施例的流程400。该用于处理图像的方法的流程400,包括以下步骤:With further reference to FIG. 4, it shows a flow 400 of another embodiment of a method for processing an image. The process 400 of the method for processing an image includes the following steps:
步骤401,获取目标物体光照图像和目标虚拟物体图像。Step 401: Obtain a target object illumination image and a target virtual object image.
在本实施例中,用于处理图像的方法的执行主体(例如图1所示的服务器105)可以通过有线连接方式或者无线连接方式从远程或者本地获取目标物体光照图像和目标虚拟物体图像。其中,目标物体光照图像为待对其进行处理的图像。目标物体光照图像包括物体图像和物体图像所对应的阴影图像。目标虚拟物体图像为用于对目标物体光照图像进行处理的图像。目标虚拟物体图像可以为根据虚拟物体的外形预先确定的图像。In this embodiment, the execution subject of the method for processing images (for example, the server 105 shown in FIG. 1) may remotely or locally obtain the target object illumination image and the target virtual object image through a wired connection or a wireless connection. Among them, the illumination image of the target object is the image to be processed. The illumination image of the target object includes the object image and the shadow image corresponding to the object image. The target virtual object image is an image used to process the illumination image of the target object. The target virtual object image may be an image predetermined according to the shape of the virtual object.
步骤402,将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像。Step 402: Input the illumination image of the target object into a pre-trained shadow extraction model, and obtain a resulting shadow image including distance information.
在本实施例中,基于步骤401中得到的目标物体光照图像,上述执行主体可以将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像。其中,结果阴影图像可以为从目标物体光照图像中提取出的、添加了距离信息的阴影图像。距离信息用于表征在目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离。阴影提取模型可以用于表征物体光照图像与结果阴影图像的对应关系。In this embodiment, based on the target object illumination image obtained in step 401, the above-mentioned execution subject may input the target object illumination image into a pre-trained shadow extraction model to obtain a resulting shadow image including distance information. Among them, the resulting shadow image may be a shadow image extracted from the illumination image of the target object and added with distance information. The distance information is used to characterize the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image. The shadow extraction model can be used to characterize the correspondence between the illumination image of the object and the resulting shadow image.
步骤403,将结果阴影图像输入预先训练的光照方向识别模型,获得光照方向信息。Step 403: Input the resulting shadow image into a pre-trained light direction recognition model to obtain light direction information.
在本实施例中,基于步骤402中得到的结果阴影图像,上述执行主体可以将结果阴影图像输入预先训练的光照方向识别模型,获得光照方向信息。其中,光照方向信息可以用于指示光照方向,可以包括但不限于以下至少一项:文字、数字、符号、图像。In this embodiment, based on the result shadow image obtained in step 402, the above-mentioned execution subject may input the result shadow image into a pre-trained light direction recognition model to obtain light direction information. Wherein, the light direction information can be used to indicate the light direction, which can include but is not limited to at least one of the following: text, numbers, symbols, and images.
在本实施例中,光照方向识别模型可以用于表征结果阴影图像与光照方向信息的对应关系。具体的,作为示例,光照方向识别模型可以是技术人员预先基于对大量的结果阴影图像和结果阴影图像所对应的光照方向信息的统计而预先制定的、存储有多个结果阴影图像与对应的光照方向信息的对应关系表;也可以为基于预设的训练样本,利用机器学习方法对初始模型(例如神经网络)进行训练后得到的模型。In this embodiment, the light direction recognition model can be used to characterize the corresponding relationship between the resulting shadow image and light direction information. Specifically, as an example, the illumination direction recognition model may be pre-made by technicians based on statistics of a large number of result shadow images and the illumination direction information corresponding to the result shadow images, and store multiple result shadow images and corresponding illumination. Correspondence table of direction information; it can also be a model obtained after training an initial model (such as a neural network) using a machine learning method based on preset training samples.
步骤404,基于光照方向信息,生成目标虚拟物体图像所对应的虚拟物体光照图像。 Step 404, based on the illumination direction information, generate a virtual object illumination image corresponding to the target virtual object image.
在本实施例中,基于步骤403中获得的光照方向信息,上述执行主体可以生成目标虚拟物体图像所对应的虚拟物体光照图像。其中,虚拟物体光照图像包括上述目标虚拟物体图像和目标虚拟物体图像所对应的虚拟阴影图像。虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与光照方向信息所指示的光照方向相匹配。这里,相匹配指的是虚拟阴影图像所对应的光照方向相对于光照方向信息所指示的光照方向的角度偏差小于等于预设角度。In this embodiment, based on the illumination direction information obtained in step 403, the above-mentioned execution subject may generate the virtual object illumination image corresponding to the target virtual object image. The lighting image of the virtual object includes the above-mentioned target virtual object image and the virtual shadow image corresponding to the target virtual object image. The lighting direction corresponding to the virtual shadow image in the lighting image of the virtual object matches the lighting direction indicated by the lighting direction information. Here, the matching means that the angular deviation of the illumination direction corresponding to the virtual shadow image with respect to the illumination direction indicated by the illumination direction information is less than or equal to the preset angle.
步骤405,对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像。Step 405: Fusion of the lighting image of the virtual object and the lighting image of the target object to add the lighting image of the virtual object to the lighting image of the target object to obtain a result image.
在本实施例中,基于步骤404中得到的虚拟物体光照图像,上述执行主体可以对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像。其中,结果图像为添加了虚拟物体光照图像的目标物体光照图像。In this embodiment, based on the illumination image of the virtual object obtained in step 404, the above-mentioned execution subject may merge the illumination image of the virtual object and the illumination image of the target object to add the illumination image of the virtual object to the illumination image of the target object to obtain the result image. Among them, the result image is the target object illumination image with the virtual object illumination image added.
上述步骤401、步骤402、步骤404、步骤405可以分别采用与前述实施例中的步骤201、步骤202、步骤204和步骤205类似的方式执行,上文针对步骤201、步骤202、步骤204和步骤205的描述也适用于步骤401、步骤402、步骤404和步骤405,此处不再赘述。The above step 401, step 402, step 404, and step 405 can be respectively performed in a manner similar to step 201, step 202, step 204, and step 205 in the foregoing embodiment. The above is for step 201, step 202, step 204, and step 205. The description of 205 is also applicable to step 401, step 402, step 404, and step 405, and will not be repeated here.
从图4中可以看出,与图2对应的实施例相比,本实施例中的用于处理图像的方法的流程400突出了利用光照方向识别模型,生成光照方向信息的步骤。由此,本实施例描述的方案可以更为便捷地确定目标物体光照图像所对应的光照方向,进而可以更为快速地生成结果图像,提高了图像处理的效率。It can be seen from FIG. 4 that, compared with the embodiment corresponding to FIG. 2, the process 400 of the method for processing an image in this embodiment highlights the step of using the light direction recognition model to generate light direction information. Therefore, the solution described in this embodiment can more conveniently determine the illumination direction corresponding to the illumination image of the target object, thereby can generate the result image more quickly, and improve the efficiency of image processing.
进一步参考图5,作为对上述各图所示方法的实现,本公开提供了一种用于处理图像的装置的一个实施例,该装置实施例与图2所示的方法实施例相对应,该装置具体可以应用于各种电子设备中。With further reference to FIG. 5, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for processing images. The device embodiment corresponds to the method embodiment shown in FIG. The device can be specifically applied to various electronic devices.
如图5所示,本实施例的用于处理图像的装置500包括:图像获取单元501、图像输入单元502、信息生成单元503、图像生成单元504和图像融合单元505。其中,图像获取单元501被配置成获取目标物体光照图像和目标虚拟物体图像,其中,目标物体光照图像包括物体 图像和物体图像所对应的阴影图像;图像输入单元502被配置成将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像,其中,距离信息用于表征在目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离;信息生成单元503被配置成基于结果阴影图像,生成目标物体光照图像所对应的光照方向信息;图像生成单元504被配置成基于光照方向信息,生成目标虚拟物体图像所对应的虚拟物体光照图像,其中,虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与光照方向信息所指示的光照方向相匹配;图像融合单元505被配置成对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像。As shown in FIG. 5, the apparatus 500 for processing images in this embodiment includes: an image acquisition unit 501, an image input unit 502, an information generation unit 503, an image generation unit 504, and an image fusion unit 505. The image acquisition unit 501 is configured to acquire a target object illumination image and a target virtual object image, where the target object illumination image includes the object image and a shadow image corresponding to the object image; the image input unit 502 is configured to illuminate the target object image Input the pre-trained shadow extraction model to obtain the resulting shadow image including distance information, where the distance information is used to represent the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image; information generation unit 503 Is configured to generate illumination direction information corresponding to the target object illumination image based on the resulting shadow image; the image generating unit 504 is configured to generate the virtual object illumination image corresponding to the target virtual object image based on the illumination direction information, wherein the virtual object illuminates The illumination direction corresponding to the virtual shadow image in the image matches the illumination direction indicated by the illumination direction information; the image fusion unit 505 is configured to fuse the virtual object illumination image and the target object illumination image to add the virtual object illumination image Into the illumination image of the target object, the result image is obtained.
在本实施例中,用于处理图像的装置500的图像获取单元501可以通过有线连接方式或者无线连接方式从远程或者本地获取目标物体光照图像和目标虚拟物体图像。其中,目标物体光照图像为待对其进行处理的图像。目标物体光照图像包括物体图像和物体图像所对应的阴影图像。目标虚拟物体图像为用于对目标物体光照图像进行处理的图像。目标虚拟物体图像可以为根据虚拟物体的外形预先确定的图像。In this embodiment, the image acquisition unit 501 of the apparatus 500 for processing images may remotely or locally acquire the target object illumination image and the target virtual object image through a wired connection or a wireless connection. Among them, the illumination image of the target object is the image to be processed. The illumination image of the target object includes the object image and the shadow image corresponding to the object image. The target virtual object image is an image used to process the illumination image of the target object. The target virtual object image may be an image predetermined according to the shape of the virtual object.
在本实施例中,基于图像获取单元501得到的目标物体光照图像,图像输入单元502可以将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像。其中,结果阴影图像可以为从目标物体光照图像中提取出的、添加了距离信息的阴影图像。距离信息用于表征在目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离。距离信息可以以各种形式在结果阴影图像中得以体现。阴影提取模型可以用于表征物体光照图像与结果阴影图像的对应关系。In this embodiment, based on the illumination image of the target object obtained by the image acquisition unit 501, the image input unit 502 may input the illumination image of the target object into a pre-trained shadow extraction model to obtain a resulting shadow image including distance information. Among them, the resulting shadow image may be a shadow image extracted from the illumination image of the target object and added with distance information. The distance information is used to characterize the distance between the pixel point of the shadow image and the pixel point corresponding to the object image in the target object illumination image. The distance information can be embodied in the resulting shadow image in various forms. The shadow extraction model can be used to characterize the correspondence between the illumination image of the object and the resulting shadow image.
在本实施例中,基于图像输入单元502得到的结果阴影图像,信息生成单元503可以生成目标物体光照图像所对应的光照方向信息。其中,光照方向信息可以用于指示光照方向,可以包括但不限于以下至少一项:文字、数字、符号、图像。In this embodiment, based on the resulting shadow image obtained by the image input unit 502, the information generating unit 503 may generate light direction information corresponding to the light image of the target object. Wherein, the light direction information can be used to indicate the light direction, which can include but is not limited to at least one of the following: text, numbers, symbols, and images.
在本实施例中,基于信息生成单元503获得的光照方向信息,图 像生成单元504生成目标虚拟物体图像所对应的虚拟物体光照图像。其中,虚拟物体光照图像包括上述目标虚拟物体图像和目标虚拟物体图像所对应的虚拟阴影图像。虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与光照方向信息所指示的光照方向相匹配。这里,相匹配指的是虚拟阴影图像所对应的光照方向相对于光照方向信息所指示的光照方向的角度偏差小于等于预设角度。In this embodiment, based on the lighting direction information obtained by the information generating unit 503, the image generating unit 504 generates a virtual object lighting image corresponding to the target virtual object image. The lighting image of the virtual object includes the above-mentioned target virtual object image and the virtual shadow image corresponding to the target virtual object image. The lighting direction corresponding to the virtual shadow image in the lighting image of the virtual object matches the lighting direction indicated by the lighting direction information. Here, the matching means that the angular deviation of the illumination direction corresponding to the virtual shadow image with respect to the illumination direction indicated by the illumination direction information is less than or equal to the preset angle.
在本实施例中,基于图像生成单元504得到的虚拟物体光照图像,图像融合单元505可以对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像。其中,结果图像为添加了虚拟物体光照图像的目标物体光照图像。In this embodiment, based on the virtual object illumination image obtained by the image generation unit 504, the image fusion unit 505 may fuse the virtual object illumination image and the target object illumination image to add the virtual object illumination image to the target object illumination image. Obtain the resulting image. Among them, the result image is the target object illumination image with the virtual object illumination image added.
在本实施例的一些可选的实现方式中,信息生成单元503可以进一步被配置成:将结果阴影图像输入预先训练的光照方向识别模型,获得光照方向信息。In some optional implementations of this embodiment, the information generating unit 503 may be further configured to input the resulting shadow image into a pre-trained light direction recognition model to obtain light direction information.
在本实施例的一些可选的实现方式中,距离信息为结果阴影图像中的像素点的像素值。In some optional implementations of this embodiment, the distance information is the pixel value of the pixel in the resulting shadow image.
在本实施例的一些可选的实现方式中,阴影提取模型可以通过以下步骤训练得到:获取预置的训练样本集,其中,训练样本包括样本物体光照图像和针对样本物体光照图像预先确定的样本结果阴影图像;获取预先建立的生成式对抗网络,其中,生成式对抗网络包括生成网络和判别网络,生成网络用于对所输入的物体光照图像进行识别并输出结果阴影图像,判别网络用于确定所输入的图像是否为生成网络所输出的图像;基于机器学习方法,将训练样本集中的训练样本包括的样本物体光照图像作为生成网络的输入,将生成网络输出的结果阴影图像和与所输入的样本物体光照图像相对应的样本结果阴影图像作为判别网络的输入,对生成网络和判别网络进行训练,将训练后的生成网络确定为阴影提取模型。In some optional implementations of this embodiment, the shadow extraction model can be obtained by training in the following steps: Obtain a preset training sample set, where the training samples include sample object illumination images and samples predetermined for the sample object illumination images Result shadow image; obtain a pre-established generative confrontation network, where the generative confrontation network includes a generation network and a discriminant network. The generation network is used to identify the input object illumination image and output the resulting shadow image, and the discriminant network is used to determine Whether the input image is the image output by the generation network; based on the machine learning method, the illumination image of the sample object included in the training sample in the training sample set is used as the input of the generation network, and the resulting shadow image output by the generation network is combined with the input The sample result shadow image corresponding to the illumination image of the sample object is used as the input of the discriminant network, the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
在本实施例的一些可选的实现方式中,装置500还可以包括:图像显示单元(图中未示出),被配置成对所获得的结果图像进行显示。In some optional implementation manners of this embodiment, the apparatus 500 may further include: an image display unit (not shown in the figure), configured to display the obtained result image.
在本实施例的一些可选的实现方式中,装置500还可以包括:图 像发送单元(图中未示出),被配置成将所获得的结果图像发送给通信连接的用户终端,以及控制用户终端对结果图像进行显示。In some optional implementation manners of this embodiment, the apparatus 500 may further include: an image sending unit (not shown in the figure) configured to send the obtained result image to the user terminal connected in communication, and to control the user The terminal displays the result image.
可以理解的是,该装置500中记载的诸单元与参考图2描述的方法中的各个步骤相对应。由此,上文针对方法描述的操作、特征以及产生的有益效果同样适用于装置500及其中包含的单元,在此不再赘述。It can be understood that the units recorded in the device 500 correspond to the steps in the method described with reference to FIG. 2. Therefore, the operations, features, and beneficial effects produced by the method described above are also applicable to the device 500 and the units contained therein, and will not be repeated here.
本公开的上述实施例提供的装置500可以生成虚拟物体图像所对应的虚拟物体光照图像,以此,可以为虚拟物体图像增添对应的虚拟阴影图像,进而在对虚拟物体光照图像和目标物体光照图像进行融合后,可以提高所生成的结果图像的真实性;此外,本公开可以基于目标物体光照图像中的阴影图像的光照方向来确定虚拟物体图像所对应的虚拟阴影图像的光照方向,以此,可以使虚拟物体图像更好地融合到目标物体光照图像中,进一步提高结果图像的真实性,有助于提高结果图像的显示效果。The apparatus 500 provided by the above-mentioned embodiment of the present disclosure can generate the virtual object illumination image corresponding to the virtual object image, and thereby can add a corresponding virtual shadow image to the virtual object image, and then illuminate the virtual object illumination image and the target object illumination image After the fusion, the authenticity of the generated result image can be improved; in addition, the present disclosure can determine the illumination direction of the virtual shadow image corresponding to the virtual object image based on the illumination direction of the shadow image in the target object illumination image, so as to: The virtual object image can be better integrated into the target object illumination image, further improving the authenticity of the result image, and helping to improve the display effect of the result image.
下面参考图6,其示出了适于用来实现本公开实施例的电子设备(例如图1中的终端设备或服务器)600的结构示意图。本公开实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图6示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。Next, refer to FIG. 6, which shows a schematic structural diagram of an electronic device (such as the terminal device or the server in FIG. 1) 600 suitable for implementing the embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablets), PMPs (portable multimedia players), vehicle-mounted terminals (e.g. Mobile terminals such as car navigation terminals) and fixed terminals such as digital TVs, desktop computers, etc. The electronic device shown in FIG. 6 is only an example, and should not bring any limitation to the function and use range of the embodiments of the present disclosure.
如图6所示,电子设备600可以包括处理装置(例如中央处理器、图形处理器等)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储装置608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有电子设备600操作所需的各种程序和数据。处理装置601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 6, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processor, etc.) 601, which can be loaded into a random access device according to a program stored in a read-only memory (ROM) 602 or from a storage device 608. The program in the memory (RAM) 603 executes various appropriate actions and processing. The RAM 603 also stores various programs and data required for the operation of the electronic device 600. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to the bus 604.
通常,以下装置可以连接至I/O接口605:包括例如触摸屏、触摸 板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置606;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置607;包括例如磁带、硬盘等的存储装置608;以及通信装置609。通信装置609可以允许电子设备600与其他设备进行无线或有线通信以交换数据。虽然图6示出了具有各种装置的电子设备600,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。Generally, the following devices can be connected to the I/O interface 605: including input devices 606 such as touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, liquid crystal display (LCD), speakers, vibration An output device 607 such as a device; a storage device 608 such as a magnetic tape and a hard disk; and a communication device 609. The communication device 609 may allow the electronic device 600 to perform wireless or wired communication with other devices to exchange data. Although FIG. 6 shows an electronic device 600 having various devices, it should be understood that it is not required to implement or have all the illustrated devices. It may alternatively be implemented or provided with more or fewer devices.
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置609从网络上被下载和安装,或者从存储装置608被安装,或者从ROM 602被安装。在该计算机程序被处理装置601执行时,执行本公开实施例的方法中限定的上述功能。In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
需要说明的是,本公开所述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指 令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium described in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium. The computer-readable signal medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device . The program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wire, optical cable, RF (Radio Frequency), etc., or any suitable combination of the above.
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备:获取目标物体光照图像和目标虚拟物体图像,其中,目标物体光照图像包括物体图像和物体图像所对应的阴影图像;将目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像,其中,距离信息用于表征在目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离;基于结果阴影图像,生成目标物体光照图像所对应的光照方向信息;基于光照方向信息,生成目标虚拟物体图像所对应的虚拟物体光照图像,其中,虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与光照方向信息所指示的光照方向相匹配;对虚拟物体光照图像和目标物体光照图像进行融合,以将虚拟物体光照图像添加到目标物体光照图像中,获得结果图像。The above-mentioned computer-readable medium may be included in the above-mentioned electronic device; or it may exist alone without being assembled into the electronic device. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains the target object illumination image and the target virtual object image, where the target object illumination image includes The object image and the shadow image corresponding to the object image; input the target object illumination image into the pre-trained shadow extraction model to obtain the resulting shadow image including distance information, where the distance information is used to characterize the shadow image in the target object illumination image The distance between the pixel point and the pixel point corresponding to the object image; based on the resulting shadow image, the illumination direction information corresponding to the target object illumination image is generated; based on the illumination direction information, the virtual object illumination image corresponding to the target virtual object image is generated, where the virtual The lighting direction corresponding to the virtual shadow image in the object lighting image matches the lighting direction indicated by the lighting direction information; the virtual object lighting image and the target object lighting image are merged to add the virtual object lighting image to the target object lighting image , Get the result image.
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。The computer program code used to perform the operations of the present disclosure can be written in one or more programming languages or a combination thereof. The programming languages include object-oriented programming languages—such as Java, Smalltalk, C++, and also conventional Procedural programming language-such as "C" language or similar programming language. The program code can be executed entirely on the user's computer, partly on the user's computer, executed as an independent software package, partly on the user's computer and partly executed on a remote computer, or entirely executed on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user’s computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (for example, using an Internet service provider to pass Internet connection).
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码 的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions, and operations of the system, method, and computer program product according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram can represent a module, program segment, or part of code, and the module, program segment, or part of code contains one or more for realizing the specified logical function Executable instructions. It should also be noted that, in some alternative implementations, the functions marked in the block may also occur in a different order from the order marked in the drawings. For example, two blocks shown in succession can actually be executed substantially in parallel, or they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and/or flowchart, and the combination of the blocks in the block diagram and/or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations Or it can be realized by a combination of dedicated hardware and computer instructions.
描述于本公开实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,单元的名称在某种情况下并不构成对该单元本身的限定,例如,图像获取单元还可以被描述为“获取目标物体光照图像和虚拟物体图像的单元”。The units involved in the embodiments described in the present disclosure may be implemented in a software manner, or may be implemented in a hardware manner. Among them, the name of the unit does not constitute a limitation on the unit itself under certain circumstances. For example, the image acquisition unit can also be described as "a unit that acquires the illumination image of the target object and the image of the virtual object".
以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in this disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover the above technical features or technical solutions without departing from the above disclosed concept. Other technical solutions formed by any combination of its equivalent features. For example, the above-mentioned features and the technical features disclosed in the present disclosure (but not limited to) with similar functions are mutually replaced to form a technical solution.

Claims (14)

  1. 一种用于处理图像的方法,包括:A method for processing images, including:
    获取目标物体光照图像和目标虚拟物体图像,其中,所述目标物体光照图像包括物体图像和物体图像所对应的阴影图像;Acquiring a target object illumination image and a target virtual object image, where the target object illumination image includes the object image and the shadow image corresponding to the object image;
    将所述目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像,其中,距离信息用于表征在所述目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离;The illumination image of the target object is input into a pre-trained shadow extraction model to obtain a resulting shadow image including distance information, where the distance information is used to represent the pixel points of the shadow image corresponding to the object image in the illumination image of the target object Pixel distance;
    基于所述结果阴影图像,生成所述目标物体光照图像所对应的光照方向信息;Based on the resulting shadow image, generating light direction information corresponding to the target object light image;
    基于所述光照方向信息,生成所述目标虚拟物体图像所对应的虚拟物体光照图像,其中,所述虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与所述光照方向信息所指示的光照方向相匹配;Based on the illumination direction information, a virtual object illumination image corresponding to the target virtual object image is generated, wherein the illumination direction corresponding to the virtual shadow image in the virtual object illumination image is the same as the illumination indicated by the illumination direction information Match the direction;
    对所述虚拟物体光照图像和所述目标物体光照图像进行融合,以将虚拟物体光照图像添加到所述目标物体光照图像中,获得结果图像。The virtual object illumination image and the target object illumination image are fused to add the virtual object illumination image to the target object illumination image to obtain a result image.
  2. 根据权利要求1所述的方法,其中,所述基于所述结果阴影图像,生成所述目标物体光照图像所对应的光照方向信息包括:The method according to claim 1, wherein said generating the illumination direction information corresponding to the illumination image of the target object based on the resulting shadow image comprises:
    将所述结果阴影图像输入预先训练的光照方向识别模型,获得光照方向信息。The resultant shadow image is input into a pre-trained light direction recognition model to obtain light direction information.
  3. 根据权利要求1所述的方法,其中,所述距离信息为结果阴影图像中的像素点的像素值。The method according to claim 1, wherein the distance information is the pixel value of the pixel in the resulting shadow image.
  4. 根据权利要求1所述的方法,其中,所述阴影提取模型通过以下步骤训练得到:The method according to claim 1, wherein the shadow extraction model is obtained by training in the following steps:
    获取预置的训练样本集,其中,训练样本包括样本物体光照图像和针对样本物体光照图像预先确定的样本结果阴影图像;Acquiring a preset training sample set, where the training sample includes a sample object illumination image and a sample result shadow image predetermined for the sample object illumination image;
    获取预先建立的生成式对抗网络,其中,所述生成式对抗网络包 括生成网络和判别网络,生成网络用于对所输入的物体光照图像进行识别并输出结果阴影图像,判别网络用于确定所输入的图像是否为生成网络所输出的图像;Obtain a pre-established generative confrontation network, where the generative confrontation network includes a generation network and a discrimination network. The generation network is used to recognize the input object illumination image and output the resulting shadow image, and the discrimination network is used to determine the input Whether the image of is the image output by the generation network;
    基于机器学习方法,将所述训练样本集中的训练样本包括的样本物体光照图像作为生成网络的输入,将生成网络输出的结果阴影图像和与所输入的样本物体光照图像相对应的样本结果阴影图像作为所述判别网络的输入,对生成网络和判别网络进行训练,将训练后的生成网络确定为阴影提取模型。Based on the machine learning method, the sample object illumination image included in the training samples in the training sample set is used as the input of the generation network, and the resulting shadow image output by the network and the sample result shadow image corresponding to the input sample object illumination image are generated As the input of the discriminant network, the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
  5. 根据权利要求1-4之一所述的方法,其中,所述方法还包括:The method according to any one of claims 1-4, wherein the method further comprises:
    对所获得的结果图像进行显示。Display the obtained result image.
  6. 根据权利要求1-4之一所述的方法,其中,所述方法还包括:The method according to any one of claims 1-4, wherein the method further comprises:
    将所获得的结果图像发送给通信连接的用户终端,以及控制所述用户终端对所述结果图像进行显示。The obtained result image is sent to a user terminal connected in communication, and the user terminal is controlled to display the result image.
  7. 一种用于处理图像的装置,包括:A device for processing images, including:
    图像获取单元,被配置成获取目标物体光照图像和目标虚拟物体图像,其中,所述目标物体光照图像包括物体图像和物体图像所对应的阴影图像;An image acquisition unit configured to acquire a target object illumination image and a target virtual object image, wherein the target object illumination image includes the object image and the shadow image corresponding to the object image;
    图像输入单元,被配置成将所述目标物体光照图像输入预先训练的阴影提取模型,获得包括距离信息的结果阴影图像,其中,距离信息用于表征在所述目标物体光照图像中,阴影图像的像素点与物体图像对应的像素点的距离;The image input unit is configured to input the target object illumination image into a pre-trained shadow extraction model to obtain a resultant shadow image including distance information, wherein the distance information is used to characterize the shadow image in the target object illumination image The distance between the pixel point and the pixel point corresponding to the object image;
    信息生成单元,被配置成基于所述结果阴影图像,生成所述目标物体光照图像所对应的光照方向信息;An information generating unit configured to generate light direction information corresponding to the target object light image based on the resulting shadow image;
    图像生成单元,被配置成基于所述光照方向信息,生成所述目标虚拟物体图像所对应的虚拟物体光照图像,其中,所述虚拟物体光照图像中的虚拟阴影图像所对应的光照方向与所述光照方向信息所指示的光照方向相匹配;The image generating unit is configured to generate a virtual object lighting image corresponding to the target virtual object image based on the lighting direction information, wherein the lighting direction corresponding to the virtual shadow image in the virtual object lighting image is the same as the Match the light direction indicated by the light direction information;
    图像融合单元,被配置成对所述虚拟物体光照图像和所述目标物体光照图像进行融合,以将虚拟物体光照图像添加到所述目标物体光照图像中,获得结果图像。The image fusion unit is configured to fuse the illumination image of the virtual object and the illumination image of the target object to add the illumination image of the virtual object to the illumination image of the target object to obtain a result image.
  8. 根据权利要求7所述的装置,其中,所述信息生成单元进一步被配置成:The device according to claim 7, wherein the information generating unit is further configured to:
    将所述结果阴影图像输入预先训练的光照方向识别模型,获得光照方向信息。The resultant shadow image is input into a pre-trained light direction recognition model to obtain light direction information.
  9. 根据权利要求7所述的装置,其中,所述距离信息为结果阴影图像中的像素点的像素值。8. The device according to claim 7, wherein the distance information is the pixel value of the pixel in the resulting shadow image.
  10. 根据权利要求7所述的装置,其中,所述阴影提取模型通过以下步骤训练得到:The device according to claim 7, wherein the shadow extraction model is obtained by training in the following steps:
    获取预置的训练样本集,其中,训练样本包括样本物体光照图像和针对样本物体光照图像预先确定的样本结果阴影图像;Acquiring a preset training sample set, where the training sample includes a sample object illumination image and a sample result shadow image predetermined for the sample object illumination image;
    获取预先建立的生成式对抗网络,其中,所述生成式对抗网络包括生成网络和判别网络,生成网络用于对所输入的物体光照图像进行识别并输出结果阴影图像,判别网络用于确定所输入的图像是否为生成网络所输出的图像;Obtain a pre-established generative confrontation network, where the generative confrontation network includes a generation network and a discrimination network. The generation network is used to recognize the input object illumination image and output the resulting shadow image, and the discrimination network is used to determine the input Whether the image of is the image output by the generation network;
    基于机器学习方法,将所述训练样本集中的训练样本包括的样本物体光照图像作为生成网络的输入,将生成网络输出的结果阴影图像和与所输入的样本物体光照图像相对应的样本结果阴影图像作为所述判别网络的输入,对生成网络和判别网络进行训练,将训练后的生成网络确定为阴影提取模型。Based on the machine learning method, the sample object illumination image included in the training samples in the training sample set is used as the input of the generation network, and the resulting shadow image output by the network and the sample result shadow image corresponding to the input sample object illumination image are generated As the input of the discriminant network, the generation network and the discriminant network are trained, and the trained generation network is determined as the shadow extraction model.
  11. 根据权利要求7-10之一所述的装置,其中,所述装置还包括:The device according to any one of claims 7-10, wherein the device further comprises:
    图像显示单元,被配置成对所获得的结果图像进行显示。The image display unit is configured to display the obtained result image.
  12. 根据权利要求7-10之一所述的装置,其中,所述装置还包括:The device according to any one of claims 7-10, wherein the device further comprises:
    图像发送单元,被配置成将所获得的结果图像发送给通信连接的用户终端,以及控制所述用户终端对所述结果图像进行显示。The image sending unit is configured to send the obtained result image to a user terminal connected in communication, and control the user terminal to display the result image.
  13. 一种电子设备,包括:An electronic device including:
    一个或多个处理器;One or more processors;
    存储装置,其上存储有一个或多个程序,A storage device on which one or more programs are stored,
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-6中任一所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-6.
  14. 一种计算机可读介质,其上存储有计算机程序,其中,该程序被处理器执行时实现如权利要求1-6中任一所述的方法。A computer-readable medium having a computer program stored thereon, wherein the program is executed by a processor to implement the method according to any one of claims 1-6.
PCT/CN2020/078582 2019-04-16 2020-03-10 Method and device for processing image WO2020211573A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910302471.0 2019-04-16
CN201910302471.0A CN110033423B (en) 2019-04-16 2019-04-16 Method and apparatus for processing image

Publications (1)

Publication Number Publication Date
WO2020211573A1 true WO2020211573A1 (en) 2020-10-22

Family

ID=67238554

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/078582 WO2020211573A1 (en) 2019-04-16 2020-03-10 Method and device for processing image

Country Status (2)

Country Link
CN (1) CN110033423B (en)
WO (1) WO2020211573A1 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110033423B (en) * 2019-04-16 2020-08-28 北京字节跳动网络技术有限公司 Method and apparatus for processing image
CN111144491B (en) * 2019-12-26 2024-05-24 南京旷云科技有限公司 Image processing method, device and electronic system
CN111292408B (en) * 2020-01-21 2022-02-01 武汉大学 Shadow generation method based on attention mechanism
CN111667420B (en) * 2020-05-21 2023-10-24 维沃移动通信有限公司 Image processing method and device
CN111915642B (en) * 2020-09-14 2024-05-14 北京百度网讯科技有限公司 Image sample generation method, device, equipment and readable storage medium
CN112686988A (en) * 2020-12-31 2021-04-20 北京北信源软件股份有限公司 Three-dimensional modeling method, three-dimensional modeling device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102696057A (en) * 2010-03-25 2012-09-26 比兹摩德莱恩有限公司 Augmented reality systems
CN104913784A (en) * 2015-06-19 2015-09-16 北京理工大学 Method for autonomously extracting navigation characteristic on surface of planet
CN106558090A (en) * 2015-09-21 2017-04-05 三星电子株式会社 3D is rendered and shadow information storage method and equipment
CN107808409A (en) * 2016-09-07 2018-03-16 中兴通讯股份有限公司 The method, device and mobile terminal of illumination render are carried out in a kind of augmented reality
US20190102950A1 (en) * 2017-10-03 2019-04-04 ExtendView Inc. Camera-based object tracking and monitoring
CN110033423A (en) * 2019-04-16 2019-07-19 北京字节跳动网络技术有限公司 Method and apparatus for handling image

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100594519C (en) * 2008-03-03 2010-03-17 北京航空航天大学 Method for real-time generating reinforced reality surroundings by spherical surface panoramic camera
DE102008028945A1 (en) * 2008-06-18 2009-12-31 Siemens Aktiengesellschaft Method and visualization module for visualizing unevennesses of the inner surface of a hollow organ, image processing device and tomography system
CN101520904B (en) * 2009-03-24 2011-12-28 上海水晶石信息技术有限公司 Reality augmenting method with real environment estimation and reality augmenting system
CN102426695A (en) * 2011-09-30 2012-04-25 北京航空航天大学 Virtual-real illumination fusion method of single image scene
CN104766270B (en) * 2015-03-20 2017-10-03 北京理工大学 One kind is based on fish-eye actual situation illumination fusion method
CN108986199B (en) * 2018-06-14 2023-05-16 北京小米移动软件有限公司 Virtual model processing method and device, electronic equipment and storage medium
WO2020056689A1 (en) * 2018-09-20 2020-03-26 太平洋未来科技(深圳)有限公司 Ar imaging method and apparatus and electronic device
CN109523617B (en) * 2018-10-15 2022-10-18 中山大学 Illumination estimation method based on monocular camera

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102696057A (en) * 2010-03-25 2012-09-26 比兹摩德莱恩有限公司 Augmented reality systems
CN104913784A (en) * 2015-06-19 2015-09-16 北京理工大学 Method for autonomously extracting navigation characteristic on surface of planet
CN106558090A (en) * 2015-09-21 2017-04-05 三星电子株式会社 3D is rendered and shadow information storage method and equipment
CN107808409A (en) * 2016-09-07 2018-03-16 中兴通讯股份有限公司 The method, device and mobile terminal of illumination render are carried out in a kind of augmented reality
US20190102950A1 (en) * 2017-10-03 2019-04-04 ExtendView Inc. Camera-based object tracking and monitoring
CN110033423A (en) * 2019-04-16 2019-07-19 北京字节跳动网络技术有限公司 Method and apparatus for handling image

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
NGUYEN, VU ET AL.: "Shadow Detection with Conditional Generative Adversarial Networks", 2017 IEEE INTERNATIONAL CONFERENCE ON COMPUTER VISION (ICCV), 22 October 2017 (2017-10-22), XP033283326, ISSN: 2380-7504, DOI: 20200603162940Y *

Also Published As

Publication number Publication date
CN110033423A (en) 2019-07-19
CN110033423B (en) 2020-08-28

Similar Documents

Publication Publication Date Title
WO2020211573A1 (en) Method and device for processing image
CN109858445B (en) Method and apparatus for generating a model
CN109214343B (en) Method and device for generating face key point detection model
JP7104683B2 (en) How and equipment to generate information
CN111476871B (en) Method and device for generating video
US20200234478A1 (en) Method and Apparatus for Processing Information
US11436863B2 (en) Method and apparatus for outputting data
CN109829432B (en) Method and apparatus for generating information
CN110188719B (en) Target tracking method and device
US10970938B2 (en) Method and apparatus for generating 3D information
CN109754464B (en) Method and apparatus for generating information
CN110059623B (en) Method and apparatus for generating information
CN109800730B (en) Method and device for generating head portrait generation model
CN109981787B (en) Method and device for displaying information
CN111524216B (en) Method and device for generating three-dimensional face data
CN110059624B (en) Method and apparatus for detecting living body
WO2020253716A1 (en) Image generation method and device
WO2023185391A1 (en) Interactive segmentation model training method, labeling data generation method, and device
CN111402122A (en) Image mapping processing method and device, readable medium and electronic equipment
CN108597034B (en) Method and apparatus for generating information
CN115937033A (en) Image generation method and device and electronic equipment
CN109829431B (en) Method and apparatus for generating information
WO2024131630A1 (en) License plate recognition method and apparatus, electronic device, and storage medium
WO2024060708A1 (en) Target detection method and apparatus
CN109816791B (en) Method and apparatus for generating information

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20790905

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 02.02.2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20790905

Country of ref document: EP

Kind code of ref document: A1