Method, device, equipment and medium for generating three-dimensional effects for two-dimensional images
By generating coefficient information and processing target pixel points based on pixel values and weighting coefficients, the visual tomography problem when converting two-dimensional images into three-dimensional effects is solved, and the smoothness and visual effects of the image are improved.
Patent Information
- Application Number
- CN202110172749.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-08
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-02-08
AI Technical Summary
When converting a two-dimensional image into a three-dimensional effect, the pixel point positions are discontinuous by rounding the pixel displacement, and visual tomography occurs.
By acquiring pixel displacement information of a two-dimensional image, coefficient information is generated, and based on the pixel values and weighting coefficients of the target pixel point and its adjacent pixel points, the pixel values of the target pixel point in the target image are determined, and the smoothing process is performed.
It reduces the visual tomography caused by discontinuity of pixel point positions and improves the smoothness and visual effect of image content.
Smart Images

Figure CN113592990B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, device, equipment and medium for generating three-dimensional effects for two-dimensional images. Background Art
[0002] Currently, 3D videos are displayed as two slightly different images, one for the left and one for the right eye. The human brain automatically calculates the depth based on the difference between the left and right eye images, thus creating a sense of three-dimensionality.
[0003] In related technologies, when converting a two-dimensional image into a three-dimensional effect, a computer device can simulate the left and right eyes as two cameras, assuming that the two-dimensional image is located right between the two eyes. Furthermore, based on the depth information in the two-dimensional image, the pixel displacement matrix of the left and right eye images is determined, and based on the original pixel matrix of the two-dimensional image, the pixel displacement matrix is rounded to an integer to generate a target image. The target image is used to generate a three-dimensional effect of the two-dimensional image.
[0004] However, in the above-mentioned related technologies, in the process of converting a two-dimensional image into a target image for generating a three-dimensional effect, the pixel displacement information is rounded off to obtain the pixel displacement amount, and then the pixel points in the two-dimensional image are moved according to the displacement amount obtained after rounding off to generate the target image. This method will cause pixel points with the same or similar pixel values to be discontinuous in position due to different displacement amounts, resulting in a visual discontinuity phenomenon. Summary of the Invention
[0005] The embodiments of the present application provide a method, apparatus, device, and medium for generating a three-dimensional effect for a two-dimensional image, which can smooth the pixel values of target pixels to improve the smoothness and visual effect of the image content. The technical solution is as follows:
[0006] According to one aspect of an embodiment of the present application, a method for generating a three-dimensional effect for a two-dimensional image is provided, the method comprising:
[0007] Obtaining pixel displacement information corresponding to a two-dimensional image, the pixel displacement information including a planned displacement of each pixel point in the two-dimensional image in a target image; wherein the target image is used to generate a three-dimensional effect of the two-dimensional image;
[0008] generating coefficient information based on the planned displacement amount in the pixel displacement information, the coefficient information including a weighting coefficient for each pixel point in the two-dimensional image;
[0009] For a target pixel point in the two-dimensional image, a pixel value of the target pixel point in the target image is determined based on the pixel values of the target pixel point and its adjacent pixel points and a weighting coefficient.
[0010] According to one aspect of an embodiment of the present application, a method for displaying a three-dimensional effect on a two-dimensional image is provided, the method comprising:
[0011] Acquire a target image corresponding to the two-dimensional image, wherein the target image is used to generate a three-dimensional effect of the two-dimensional image;
[0012] displaying the target image;
[0013] Among them, the pixel value of the target pixel point in the two-dimensional image in the target image is determined based on the pixel values and weighting coefficients of the target pixel point and its adjacent pixel points, and the weighting coefficient of the target pixel point is determined based on the planned displacement of the target pixel point in the target image.
[0014] According to one aspect of an embodiment of the present application, a device for generating a three-dimensional effect for a two-dimensional image is provided, the device comprising:
[0015] a displacement acquisition module, configured to acquire pixel displacement information corresponding to a two-dimensional image, wherein the pixel displacement information includes a planned displacement of each pixel point in the two-dimensional image in a target image; wherein the target image is used to generate a three-dimensional effect of the two-dimensional image;
[0016] a coefficient generating module, configured to generate coefficient information based on the planned displacement amount in the pixel displacement information, wherein the coefficient information includes a weighting coefficient for each pixel point in the two-dimensional image;
[0017] The pixel determination module is used to determine the pixel value of the target pixel point in the target image based on the pixel values of the target pixel point and its adjacent pixel points and the weighting coefficient.
[0018] According to one aspect of an embodiment of the present application, a three-dimensional effect display device for a two-dimensional image is provided, the device comprising:
[0019] An image acquisition module, configured to acquire a target image corresponding to a two-dimensional image, wherein the target image is used to generate a three-dimensional effect of the two-dimensional image;
[0020] A target display module is used to display the target image; wherein the pixel value of the target pixel point in the two-dimensional image in the target image is determined based on the pixel value and weighting coefficient of the target pixel point and its adjacent pixel points, and the weighting coefficient of the target pixel point is determined based on the planned displacement of the target pixel point in the target image.
[0021] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set, or an instruction set, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the above-mentioned three-dimensional effect generation method for a two-dimensional image, or to implement the above-mentioned three-dimensional effect display method for a two-dimensional image.
[0022] Optionally, the computer device is a terminal or a server.
[0023] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer-readable storage medium, wherein the readable storage medium stores at least one instruction, at least one program, a code set, or an instruction set, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the above-mentioned three-dimensional effect generation method for a two-dimensional image, or to implement the above-mentioned three-dimensional effect display method for a two-dimensional image.
[0024] According to one aspect of an embodiment of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described method for generating a three-dimensional effect for a two-dimensional image or the above-described method for displaying a three-dimensional effect for a two-dimensional image.
[0025] The technical solutions provided in the embodiments of the present application can bring the following beneficial effects:
[0026] Coefficient information is generated through the pixel displacement information of the two-dimensional image, and when determining the target image corresponding to the two-dimensional image, the pixel values and weighting coefficients of the target pixel point and its adjacent pixel points are used to determine the target image, wherein the weighting coefficient is included in the coefficient information. That is, when determining the target image for displaying the three-dimensional effect of the two-dimensional image, the pixel value of the target pixel point in the target image is determined through the pixel values and weighting coefficients of the target pixel point and its adjacent pixel points, and the pixel value of the target pixel point is smoothed to ensure the accuracy of the target image generation, reduce the visual fault phenomenon caused by the discontinuous position of pixels (with the same or similar pixel values), and improve the smoothness and visual effect of the image content. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0028] Figure 1 is a schematic diagram of a three-dimensional effect generation system provided by an embodiment of the present application;
[0029] Figure 2 This is a flowchart of a method for generating a three-dimensional effect for a two-dimensional image provided by an embodiment of the present application;
[0030] Figure 3 A schematic diagram exemplarily shows a method for generating a three-dimensional effect for a two-dimensional image;
[0031] Figure 4 is a flowchart of a method for generating a three-dimensional effect for a two-dimensional image provided by another embodiment of the present application;
[0032] Figure 5 This is a flowchart of a method for generating a three-dimensional effect for a two-dimensional image provided by another embodiment of the present application;
[0033] Figure 6 and Figure 7 A schematic diagram exemplarily showing pixel locations of a left-eye image and a right-eye image;
[0034] Figure 8 This is a flowchart of a method for displaying a three-dimensional effect on a two-dimensional image provided by an embodiment of the present application;
[0035] Figure 9 A schematic diagram exemplarily illustrates a comparison between the related art and the present application;
[0036] Figure 10 This is a block diagram of a device for generating a three-dimensional effect for a two-dimensional image provided by one embodiment of the present application;
[0037] Figure 11 is a block diagram of a device for generating a three-dimensional effect for a two-dimensional image provided by another embodiment of the present application;
[0038] Figure 12 This is a block diagram of a three-dimensional effect display device for a two-dimensional image provided by an embodiment of the present application;
[0039] Figure 13 This is a structural block diagram of a server provided by an embodiment of the present application;
[0040] Figure 14This is a structural block diagram of a terminal provided by an embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0042] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also involves studying the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.
[0043] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0044] Computer vision (CV) is the science of making machines "see." Specifically, it refers to using cameras and computers to replace the human eye in identifying, tracking, and measuring objects. It also performs further image processing, transforming the computer's image into an image more suitable for human observation or transmission to instrumentation. As a scientific discipline, computer vision studies related theories and technologies, attempting to build artificial intelligence systems capable of extracting information from images or multidimensional data. Computer vision technologies typically include image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping, and common biometric recognition technologies such as facial recognition and fingerprint recognition.
[0045] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, autonomous driving, drones, robots, smart medical care, smart customer service, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0046] The solution provided by the embodiments of the present application involves technologies such as artificial intelligence computer vision, and uses image processing technology to obtain depth information in a two-dimensional image, and based on this depth information, obtains pixel displacement information, and then generates coefficient information based on this pixel displacement information. When determining the pixel value of a target pixel point in a target image, based on the pixel value of the target pixel point in the two-dimensional image, the weighted coefficient of the target pixel point and its adjacent pixels is obtained from the coefficient information, and the pixel value of the target pixel point in the target image is determined by the pixel value of the target pixel point and the weighted coefficient of the target pixel point and its adjacent pixels. Wherein, the target image is used to generate a three-dimensional effect of the two-dimensional image.
[0047] Please refer to Figure 1 , which shows a schematic diagram of a 3D effect generation system provided by an embodiment of the present application. The 3D effect generation system may include: a terminal 10 and a server 20.
[0048] The terminal 10 may be an electronic device such as a mobile phone, tablet computer, game console, e-book reader, multimedia player, wearable device, PC (Personal Computer), smart TV, smart car terminal, etc. An application client may be installed in the terminal 10. The application may be any application with a three-dimensional display function, such as a video application, game application, shopping application, image application, etc. Optionally, the application may be an application that requires downloading and installation, or an application that is click-to-use, which is not limited in the present embodiment.
[0049] Server 20 is used to provide background services for the client of the application in terminal 10. For example, server 20 can be the background server of the above-mentioned application. Server 20 can be a single server, a server cluster consisting of multiple servers, or a cloud computing service center. Optionally, server 20 provides background services for multiple clients simultaneously.
[0050] Optionally, the terminal 10 and the server 20 may communicate with each other via a network.
[0051] Below, the technical solution of this application will be described in detail with reference to several embodiments.
[0052] Please refer to Figure 2 , which shows a flow chart of a method for generating a three-dimensional effect for a two-dimensional image provided by an embodiment of the present application. The method can be applied to a computer device, such as the execution subject of each step can be Figure 1The server 20 or terminal 10 in the 3D effect generation system shown in FIG. The method may include the following steps (201 to 203):
[0053] Step 201: Obtain pixel displacement information corresponding to a two-dimensional image.
[0054] The pixel displacement information includes the planned displacement of each pixel point in the two-dimensional image in the target image. The planned displacement refers to the displacement distance of a single pixel point in the two-dimensional image, and the displacement distance is a floating point number (decimal). Optionally, when generating the above-mentioned target image, the server can obtain the two-dimensional image to be processed, and perform image processing on the two-dimensional image to determine the pixel displacement information corresponding to the two-dimensional image, and then shift each pixel value in the two-dimensional image according to the pixel displacement information to generate the target image corresponding to the above-mentioned two-dimensional image. It should be noted that the above-mentioned planned displacement has a one-to-one correspondence with the pixel points in the two-dimensional image.
[0055] The target image is used to generate a three-dimensional effect on a two-dimensional image. This three-dimensional effect is also known as a stereoscopic effect. That is, the target image can visually give the two-dimensional image a stereoscopic effect. Optionally, when generating the three-dimensional effect corresponding to the two-dimensional image, the server can determine a corresponding target image based on pixel displacement information corresponding to the two-dimensional image, and then use this target image to generate the three-dimensional effect for the two-dimensional image. In this case, the target image can be displayed on the terminal, allowing the user to directly view the three-dimensional effect of the two-dimensional image.
[0056] In the embodiment of the present application, when determining to generate a 3D effect for a 2D image, the server obtains the 2D image and obtains pixel displacement information corresponding to the 2D image. The 2D image may be an image sent to the server by a terminal or an image pre-stored in the server, and this embodiment of the present application is not limited thereto.
[0057] It should be noted that, in the embodiment of the present application, the acquisition of the above pixel displacement information is related to the depth information. The depth information is used to indicate the distance between each pixel point in the two-dimensional image and the shooting position. Optionally, the above step 201 includes the following steps:
[0058] 1. Obtain the depth information corresponding to the two-dimensional image.
[0059] The depth information includes a depth value of each pixel in the two-dimensional image. Optionally, the depth value can be used to indicate the distance between each pixel in the two-dimensional image and the shooting position.
[0060] In an embodiment of the present application, when determining to obtain pixel displacement information corresponding to a two-dimensional image, the server obtains the depth information corresponding to the two-dimensional image, that is, obtains the depth value corresponding to each pixel point in the two-dimensional image. In one possible implementation, the above-mentioned depth information is obtained by image processing. Optionally, after obtaining the above-mentioned two-dimensional image, the server performs image processing on the two-dimensional image, obtains the depth value corresponding to each pixel point in the two-dimensional image, and then determines the depth information corresponding to the two-dimensional image. In another possible implementation, the above-mentioned depth information is the attribute information of the two-dimensional image itself. Optionally, after obtaining the above-mentioned two-dimensional image, the server obtains the depth information corresponding to the two-dimensional image from the attribute information of the two-dimensional image itself.
[0061] 2. Based on the depth information, determine the pixel displacement information corresponding to the two-dimensional image.
[0062] In an embodiment of the present application, after obtaining the depth information, the server determines pixel displacement information corresponding to the two-dimensional image based on the depth information. The planned displacement amount in the pixel displacement information is negatively correlated with the depth value in the depth information. That is, for a target pixel in the two-dimensional image, the larger the depth value of the target pixel, the smaller the planned displacement amount, and conversely, the smaller the depth value of the target pixel, the larger the planned displacement amount.
[0063] Optionally, in an embodiment of the present application, when obtaining the above-mentioned pixel displacement information, the server may obtain the above-mentioned pixel displacement information based on the depth information and the shooting parameters of the two-dimensional image. The shooting parameters include a horizontal focal length parameter and a horizontal displacement parameter, which may be fixed parameters obtained by the shooting environment and the shooting camera of the two-dimensional image. When obtaining the planned displacement of the target pixel point on the two-dimensional image, the server may multiply the horizontal focal length parameter and the horizontal displacement parameter, and divide the result by the depth value of the target pixel point to determine the planned displacement of the target pixel point.
[0064] Step 202: Generate coefficient information based on the planned displacement amount in the pixel displacement information.
[0065] The coefficient information includes a weighted coefficient for each pixel in the two-dimensional image, and the weighted coefficient can be used to indicate the influence parameter for each pixel. Optionally, when generating a three-dimensional effect of a two-dimensional image, the server can determine the influence parameter of each pixel on a certain pixel from the coefficient information, and then generate a target image corresponding to the two-dimensional image based on the coefficient information and the pixel value of the two-dimensional image, and use the target image to make the two-dimensional image have a three-dimensional effect. Of course, in actual use, the server can also only determine the influence parameters of the adjacent pixels and its own pixels on a certain pixel from the coefficient information, and then generate a target image corresponding to the two-dimensional image based on the coefficient information and the pixel value of the two-dimensional image, and the embodiment of the present application is not limited to this. Among them, the number of the above-mentioned adjacent pixels can be any value, such as 1, 2, 3, etc., and the embodiment of the present application is not limited to this. Optionally, when determining the adjacent pixels corresponding to the target pixel, the server can use the pixels in the same depth area as the target pixel as the adjacent pixels.
[0066] In an embodiment of the present application, after obtaining the pixel displacement information, the server generates coefficient information based on the pixel displacement information. Optionally, when generating the coefficient information, the server determines a planned displacement amount for each pixel from the pixel displacement information, and based on the planned displacement amount, determines an influence parameter of each pixel with respect to a particular pixel. In this manner, the server traverses each pixel in the two-dimensional image to generate the coefficient information.
[0067] In a possible embodiment, after obtaining the above-mentioned pixel displacement information, the server determines the target position and the planned position of the target pixel point in the target image based on the planned displacement amount of the target pixel point, and then determines the weighting coefficient of the target pixel point based on the distance between the target position and the planned position. At this time, the weighting coefficient of the target pixel point refers to the weighting coefficient of the target pixel point for itself. Among them, the target position is obtained by displacing the target pixel point according to the rounded result of the planned displacement amount, and the planned position is obtained by displacing the target pixel point according to the planned displacement amount. Similarly, when obtaining the weighting coefficient of the adjacent pixel point for the target pixel point, the server determines the target position of the target pixel point in the target image based on the planned displacement amount of the target pixel point, determines the planned position of the adjacent pixel point in the target image based on the planned displacement amount of the adjacent pixel point, and then determines the weighting coefficient of the adjacent pixel point for the target pixel point based on the distance between the target position of the target pixel point and the planned position of the adjacent pixel point.
[0068] In another possible embodiment, after obtaining the above-mentioned pixel displacement information, the server rounds the planned displacement of the target pixel point based on the planned displacement of the target pixel point to obtain the target displacement of the target pixel point, and then determines the weighting coefficient of the target pixel point based on the absolute value of the difference between the planned displacement and the target displacement. In this case, the weighting coefficient of the target pixel point refers to the weighting coefficient of the target pixel point for itself. In this case, when obtaining the weighting coefficient of the adjacent pixel point for the target pixel point, the server determines the target position of the target pixel point in the target image based on the planned displacement of the target pixel point, determines the planned position of the adjacent pixel point in the target image based on the planned displacement of the adjacent pixel point, and then determines the weighting coefficient of the adjacent pixel point for the target pixel point based on the distance between the target position of the target pixel point and the planned position of the adjacent pixel point.
[0069] Among them, the above-mentioned target pixel point can be any pixel point in the two-dimensional image, and the embodiment of the present application is not limited to this.
[0070] Step 203 : For a target pixel point in the two-dimensional image, determine the pixel value of the target pixel point in the target image based on the pixel values of the target pixel point and its adjacent pixels and weighting coefficients.
[0071] In an embodiment of the present application, after obtaining the above-mentioned coefficient information, the server determines the pixel value of each pixel in the target image based on the pixel value of each pixel in the two-dimensional image, combined with the weighting coefficient in the coefficient information, and then determines the target image corresponding to the two-dimensional image. Taking a certain pixel as an example, for the target pixel in the two-dimensional image, after obtaining the above-mentioned coefficient information, the server determines the pixel value of the target pixel in the target image based on the pixel value and weighting coefficient of the target pixel and its adjacent pixels. Furthermore, the server traverses each pixel in the two-dimensional image using the above-mentioned method to obtain the target image corresponding to the above-mentioned two-dimensional image.
[0072] Among them, the pixel values of the above-mentioned target pixel point and its adjacent pixel points refer to the pixel values of the target pixel point in the two-dimensional image, and the pixel values of the adjacent pixel points in the two-dimensional image; the weighting coefficients of the above-mentioned target pixel point and its adjacent pixel points refer to the weighting coefficients of the target pixel point for itself, and the weighting coefficients of the adjacent pixel points for the target pixel point. Optionally, the above-mentioned adjacent pixel points can be pixel points distributed in the area around the target pixel point, or pixel points in the same depth area as the target pixel point, or pixel points distributed in the area around the target pixel point and in the same depth area as the target pixel point. The embodiments of the present application do not limit this.
[0073] To summarize, in the technical solution provided in the embodiments of the present application, coefficient information is generated through the pixel displacement information of the two-dimensional image, and when determining the target image corresponding to the two-dimensional image, the pixel value and weighting coefficient of the target pixel point and its adjacent pixel points are used to determine the target image, wherein the weighting coefficient is included in the coefficient information. That is, when determining the target image for displaying the three-dimensional effect of the two-dimensional image, the pixel value of the target pixel point in the target image is determined through the pixel value and weighting coefficient of the target pixel point and its adjacent pixel points, and the pixel value of the target pixel point is smoothed to ensure the accuracy of the target image generation, reduce the visual fault phenomenon caused by the discontinuous position of pixels (with the same or similar pixel values), and improve the smoothness and visual effect of the image content.
[0074] In addition, when determining the weighting coefficient of the target pixel point, the weighting coefficient is determined by the distance between the planned position and the target position of the target pixel point in the target image, and the target position is obtained by displacing the target pixel point according to the rounding result of the planned displacement amount, and the planned position is obtained by displacing the target pixel point according to the planned displacement amount. Taking into account the problem of inaccurate target image caused by rounding of pixel displacement information, the distance between the target position and the planned position after rounding is used as the weighting coefficient of the target pixel point, which ensures the accuracy of subsequent target image generation and effectively improves the authenticity of the three-dimensional effect of the two-dimensional image.
[0075] Optionally, in an embodiment of the present application, the server may determine a specific weighting method when obtaining the pixel value of the target image based on the positional relationship between the target position and the planned position. Below, taking the target pixel point as an example, the method for determining the pixel value of the target pixel point in the target image is introduced.
[0076] In one possible implementation, the planned position of the target pixel is located in a first direction of the target position. In this case, if the planned position of the target pixel in the target image is located in the first direction of the target position, the server determines the pixel value of the target pixel in the target image based on the pixel values of the target pixel and its neighboring pixels in the second direction and the weighting coefficient.
[0077] Optionally, in an embodiment of the present application, when the server determines that the planned position of the above-mentioned target pixel point is located in the first direction of the target position, the server multiplies the pixel value of the target pixel point with the weighting coefficient of the adjacent pixel points in the second direction to obtain a first value; multiplies the pixel value of the adjacent pixel points in the second direction with the weighting coefficient of the target pixel point to obtain a second value; and divides the sum of the first value and the second value by the weighting coefficient of the target pixel point and the sum of the weighting coefficients of the adjacent pixel points in the second direction to obtain the pixel value of the target pixel point in the target image.
[0078] In another possible implementation, the planned position of the target pixel is located in a second direction from the target position. In this case, if the planned position of the target pixel in the target image is located in the second direction from the target position, the server determines the pixel value of the target pixel in the target image based on the pixel values of the target pixel and its neighboring pixels in the first direction and the weighting coefficient.
[0079] Optionally, in an embodiment of the present application, when the server determines that the planned position of the above-mentioned target pixel point is located in the second direction of the second position, the server multiplies the pixel value of the target pixel point with the weighting coefficient of the adjacent pixel points in the first direction to obtain a third value; multiplies the pixel value of the adjacent pixel points in the first direction with the weighting coefficient of the target pixel point to obtain a fourth value; and divides the sum of the third and fourth values by the weighting coefficient of the target pixel point and the sum of the weighting coefficients of the adjacent pixel points in the first direction to obtain the pixel value of the target pixel point in the target image.
[0080] The target position is obtained by displacing the target pixel point according to the rounded result of the planned displacement amount, and the planned position is obtained by displacing the target pixel point according to the planned displacement amount.
[0081] It should be noted that the first direction and the second direction are opposite directions. For example, if the first direction is the left direction, the second direction is the right direction; if the first direction is the right direction, the second direction is the left direction. The pixel value of the target pixel refers to the pixel value of the target pixel in the two-dimensional image. The pixel value of the adjacent pixel refers to the pixel value of the adjacent pixel in the two-dimensional image. The weighting coefficient of the target pixel refers to the weighting coefficient of the target pixel for itself. The weighting coefficient of the adjacent pixel refers to the weighting coefficient of the adjacent pixel for the target pixel.
[0082] For example, in conjunction with reference Figure 3This application provides a complete introduction to the method for determining pixel values in the target image. First, after acquiring a two-dimensional image, the server determines the pixel displacement information corresponding to the two-dimensional image based on the depth information of the two-dimensional image. Furthermore, based on the pixel displacement information, the server determines the distance between the planned position and the target position of each pixel, generating coefficient information. The planned position is obtained by displacing the target pixel according to the planned displacement amount in the pixel position information, and the target position is obtained by displacing the target pixel according to the rounded result of the planned displacement amount. The server then determines a weighting method for the pixel based on the positional relationship between the planned position and the target position. If the planned position of the pixel is located in a first direction from the target position, the pixel value in the target image is determined based on the weighting coefficients of the pixel and its neighboring pixels in the second direction, combined with the pixel values of the pixel and its neighboring pixels in the second direction in the two-dimensional image. If the planned position of the pixel is located in a second direction from the target position, the pixel value in the target image is determined based on the weighting coefficients of the pixel and its neighboring pixels in the first direction, combined with the pixel values of the pixel and its neighboring pixels in the first direction in the two-dimensional image. The first and second directions are opposite directions.
[0083] Optionally, in an embodiment of the present application, the adjacent pixel points corresponding to the target pixel point may include adjacent pixel points in the same depth region as the target pixel point, and adjacent pixel points in different depth regions from the target pixel point. In this case, if the target pixel point and the adjacent pixel points belong to the same depth region, the server may perform the above-mentioned step of determining the pixel value of the target pixel point in the target image based on the pixel value and weighting coefficient of the target pixel point in the two-dimensional image; if the target pixel point and the adjacent pixel points do not belong to the same depth region, the server may determine the pixel value of the target pixel point in the two-dimensional image as the pixel value of the target pixel point in the target image.
[0084] Please refer to Figure 4 , which shows a flow chart of a method for generating a three-dimensional effect for a two-dimensional image provided by another embodiment of the present application. The method can be applied to a computer device, such as the execution subject of each step can be Figure 1 The server 20 or terminal 10 in the 3D effect generation system shown in FIG. The method may include the following steps (401 to 404):
[0085] Step 401: Obtain pixel displacement information corresponding to a two-dimensional image.
[0086] Step 402: Generate coefficient information based on the planned displacement amount in the pixel displacement information.
[0087] Step 403, when the target pixel point and the adjacent pixel points belong to the same depth region, for the target pixel point in the two-dimensional image, based on the pixel values and weighting coefficients of the target pixel point and its adjacent pixel points, determine the pixel value of the target pixel point in the target image.
[0088] Step 404 : When the target pixel and the adjacent pixels do not belong to the same depth region, the pixel value of the target pixel in the two-dimensional image is determined as the pixel value of the target pixel in the target image.
[0089] Optionally, in an embodiment of the present application, the target image includes a left-eye image and a right-eye image. The server can use the left-eye and right-eye images to induce a visual error in the user, thereby allowing the user to experience a three-dimensional effect of a two-dimensional image. The left-eye image refers to an image acquired based on the left eye, and the right-eye image refers to an image acquired based on the right eye. The following describes how the left-eye and right-eye images are generated.
[0090] Please refer to Figure 5 , which shows a flow chart of a method for generating a three-dimensional effect for a two-dimensional image provided by another embodiment of the present application. The method can be applied to a computer device, such as the execution subject of each step can be Figure 1 The server 20 or terminal 10 in the 3D effect generation system shown in the figure is used as an example to illustrate the method executed by the server. The method may include the following steps (501-503):
[0091] Step 501: Obtain left-eye pixel displacement information and right-eye pixel displacement information corresponding to a two-dimensional image.
[0092] The left-eye pixel displacement information includes the planned displacement amount of each pixel point in the two-dimensional image in the left-eye image. The right-eye pixel displacement information includes the planned displacement amount of each pixel point in the two-dimensional image in the right-eye image.
[0093] In an embodiment of the present application, when determining to generate a three-dimensional effect for a two-dimensional image, the server obtains the two-dimensional image and obtains the left-eye pixel displacement information and right-eye pixel displacement information corresponding to the two-dimensional image. Optionally, the server may obtain the left-eye pixel displacement information and right-eye pixel displacement information based on the depth information of the two-dimensional image and the shooting parameters of the two-dimensional image. Due to the symmetry between the left eye and the right eye, the planned displacement amounts in the left-eye pixel displacement information and the right-eye pixel displacement information are the same, but the displacement directions of the planned displacement amounts are opposite.
[0094] For example, assuming that the horizontal focal length parameter of the shooting parameter is f x , the horizontal displacement parameter in the shooting parameters is t x, then the planned displacement of point x in the left (right) eye pixel displacement information is dx_float x , the planned displacement of point x-1 dx_float x-1 , the planned displacement of point x+1 dx_float x+1 They are:
[0095]
[0096]
[0097]
[0098] Among them, z x Indicates the depth value of point x, z x-1 Indicates the depth value of point x-1, z x+1 Indicates the depth value of point x+1, where point x-1 is to the left of point x and point x+1 is to the right of point x.
[0099] One thing that needs to be explained is that the pixel displacement information mentioned in this application refers to the horizontal displacement information of the pixel points. In actual application, the server needs to determine the horizontal coordinates of the pixel points through the horizontal displacement information, and combine the vertical coordinates of the pixel points to determine the position of the pixel points on the target image. In this application, the vertical coordinates of the pixel points on the target image (left eye image and right eye image) are the same as the vertical coordinates on the two-dimensional image.
[0100] Step 502 : Generate left-eye coefficient information based on the planned displacement amount in the left-eye pixel displacement information, and generate right-eye coefficient information based on the planned displacement amount in the right-eye pixel displacement information.
[0101] The left-eye coefficient information includes the left-eye weighting coefficient of each pixel in the two-dimensional image. The right-eye coefficient information includes the right-eye weighting coefficient of each pixel in the two-dimensional image.
[0102] In an embodiment of the present application, after obtaining the above-mentioned left-eye pixel displacement information and the above-mentioned right-eye displacement information, the server generates left-eye coefficient information based on the left-eye pixel displacement information, and generates right-eye coefficient information based on the right-eye pixel displacement information.
[0103] For the above-mentioned left-eye displacement information, optionally, after obtaining the left-eye pixel displacement information, the server determines the target position and the planned position of the target pixel point in the left-eye image based on the planned displacement amount of the target pixel point in the left-eye image, and then determines the weighting coefficient of the target pixel point based on the distance between the target position and the planned position. At this time, the weighting coefficient of the target pixel point refers to the weighting coefficient of the target pixel point for itself in the left-eye image. Similarly, when obtaining the weighting coefficient of the adjacent pixel points for the target pixel point in the left-eye image, the server determines the target position of the target pixel point in the left-eye image based on the planned displacement amount of the target pixel point in the left-eye image, determines the planned position of the adjacent pixel point in the left-eye image based on the planned displacement amount of the adjacent pixel point in the left-eye image, and then determines the weighting coefficient of the adjacent pixel point for the target pixel point in the left-eye image based on the distance between the target position of the target pixel point in the left-eye image and the planned position of the adjacent pixel point in the left-eye image.
[0104] For example, assuming that the planned displacement of point x in the left eye pixel displacement information is dx_float x , the planned displacement of point x-1 is dx_float x-1 , the planned displacement of point x+1 is dx_float x+1 , then the planned position of point x in the left eye image is x+dx_float x , the target position is x+dx x , dx x is through dx_float x The planned position of point x-1 in the left eye image is obtained by rounding; x-1+dx_float x-1 , the target position is x-1+dx x-1 , dx x-1 is through dx_float x-1 The planned position of point x+1 in the left eye image is obtained by rounding; x+1+ dx_float x+1 , the target position is x+1+dx x+1 , dx x+1 is through dx_float x+1 At this time, the weighted coefficient coe of the target pixel in the left eye image is x , the weighting coefficient coe_l of the left adjacent pixel x-1 for the target pixel in the left eye image x-1 , the weighting coefficient coe_l of the right adjacent pixel x+1 for the target pixel in the left eye image x+1 They are:
[0105] coe x =|dx x-dx_float x |;
[0106] coe_l x-1 =|dx_float x-1 -dx x -1|;
[0107] coe_l x+1 =|dx_float x+1 -dx x +1|.
[0108] For the above-mentioned right-eye displacement information, optionally, after obtaining the right-eye pixel displacement information, the server determines the target position and the planned position of the target pixel point in the right-eye image based on the planned displacement amount of the target pixel point in the right-eye image, and then determines the weighting coefficient of the target pixel point based on the distance between the target position and the planned position. At this time, the weighting coefficient of the target pixel point refers to the weighting coefficient of the target pixel point for itself in the right-eye image. Similarly, when obtaining the weighting coefficient of the adjacent pixel point for the target pixel point in the right-eye image, the server determines the target position of the target pixel point in the right-eye image based on the planned displacement amount of the target pixel point in the right-eye image, determines the planned position of the adjacent pixel point in the right-eye image based on the planned displacement amount of the adjacent pixel point in the right-eye image, and then determines the weighting coefficient of the adjacent pixel point for the target pixel point in the right-eye image based on the distance between the target position of the target pixel point in the right-eye image and the planned position of the adjacent pixel point in the right-eye image.
[0109] For example, assuming that the planned displacement of point x in the right eye pixel displacement information is dx_float x , the planned displacement of point x-1 is dx_float x-1 , the planned displacement of point x+1 is dx_float x+1 , then the planned position of point x in the right eye image is x-dx_float x , the target position is x-dx x , dx x is through dx_float x The planned position of point x-1 in the right eye image is obtained by rounding; x-1-dx_float x-1 , the target position is x-1-dx x-1 , dx x-1 is through dx_float x-1 The planned position of point x+1 in the right eye image is obtained by rounding; x+1-dx_float x+1 , the target position is x+1-dx x+1 , dx x+1is through dx_float x+1 At this time, the weighted coefficient coe of the target pixel in the right eye image is x , the weighted coefficient coe_r of the left adjacent pixel x-1 for the target pixel in the right eye image x-1 , the weighted coefficient coe_r of the right adjacent pixel x+1 for the target pixel in the right eye image x+1 They are:
[0110] coe x =|dx x -dx_float x |;
[0111] coe_r x-1 =|dx x -dx_float x-1 -1|;
[0112] coe_r x+1 =|dx x -dx_float x+1 +1|.
[0113] Step 503: For a target pixel point in a two-dimensional image, the pixel value of the target pixel point in the left-eye image is determined based on the pixel values of the target pixel point and its adjacent pixel points and the left-eye weighting coefficient; and, for a target pixel point in a two-dimensional image, the pixel value of the target pixel point in the right-eye image is determined based on the pixel values of the target pixel point and its adjacent pixel points and the right-eye weighting coefficient.
[0114] In an embodiment of the present application, after obtaining the above-mentioned left-eye coefficient information and the above-mentioned right-eye coefficient information, the server determines the pixel value of each pixel point in the left-eye image based on the pixel value of each pixel point in the two-dimensional image and combines the left-eye weighting coefficient in the left-eye coefficient information, and determines the pixel value of each pixel point in the right-eye image based on the right-eye weighting coefficient in the right-eye coefficient information.
[0115] Taking a specific pixel as an example, for a target pixel in a two-dimensional image, after obtaining the above-mentioned left-eye coefficient information and the above-mentioned right-eye coefficient information, the server determines the pixel value of the target pixel in the left-eye image based on the pixel values of the target pixel and its adjacent pixels and the left-eye weighting coefficient, and determines the pixel value of the target pixel in the right-eye image based on the pixel values of the target pixel and its adjacent pixels and the right-eye weighting coefficient. Furthermore, the server traverses each pixel in the two-dimensional image using the above-mentioned method to obtain the left-eye image and right-eye image corresponding to the above-mentioned two-dimensional image.
[0116] Among them, the pixel values of the above-mentioned target pixel point and its adjacent pixel points refer to the pixel values of the target pixel point in the two-dimensional image, and the pixel values of the adjacent pixel points in the two-dimensional image; the left-eye weighting coefficient of the above-mentioned target pixel point and its adjacent pixel points refers to the left-eye weighting coefficient of the target pixel point for itself, and the left-eye weighting coefficient of the adjacent pixel points for the target pixel point; the right-eye weighting coefficient of the above-mentioned target pixel point and its adjacent pixel points refers to the right-eye weighting coefficient of the target pixel point for itself, and the right-eye weighting coefficient of the adjacent pixel points for the target pixel point.
[0117] Optionally, in an embodiment of the present application, the server may determine a specific weighting method when obtaining the pixel value of the left eye image based on the positional relationship between the target position and the planned position of the target pixel point in the left eye image.
[0118] For example, Figure 6 As shown, in the left eye image, if dx_float x >dx x , the planned position of point x in the left eye image is to the right of the target position. At this time, the server determines the pixel value img_l of point x in the left eye image based on the pixel value of point x and its left adjacent pixel point x-1 and the left eye weighting coefficient. x for:
[0119]
[0120] If dx_float x <dx x , the planned position of point x in the left eye image is to the left of the target position. At this time, the server determines the pixel value img_l of point x in the left eye image based on the pixel value of point x and its right adjacent pixel point x-1 and the left eye weighting coefficient. x for:
[0121]
[0122] Among them, org x Represents the pixel value of point x in the two-dimensional image, org x-1 Represents the pixel value of point x-1 in the two-dimensional image, org x+1 Represents the pixel value of point x+1 in the two-dimensional image.
[0123] For example, Figure 7 As shown, in the right eye image, if dx_float x >dx x , the planned position of point x in the right eye image is to the left of the target position. At this time, the server determines the pixel value img_r of point x in the right eye image based on the pixel value of point x and its right adjacent pixel point x+1 and the right eye weighting coefficient.x for:
[0124]
[0125] If dx_float x <d x , the planned position of point x in the right eye image is to the right of the target position. At this time, the server determines the pixel value img_r of point x in the right eye image based on the pixel value of point x and its left adjacent pixel point x-1 and the right eye weighting coefficient. x for:
[0126]
[0127] Among them, org x Represents the pixel value of point x in the two-dimensional image, org x-1 Represents the pixel value of point x-1 in the two-dimensional image, org x+1 Represents the pixel value of point x+1 in the two-dimensional image.
[0128] To summarize, in the technical solution provided in the embodiments of the present application, left-eye (right-eye) coefficient information is generated by the pixel displacement information of the two-dimensional image, and when determining the left-eye (right-eye) image corresponding to the two-dimensional image, the pixel values of the target pixel point and its adjacent pixel points and the left-eye (right-eye) weighting coefficient are used to determine the left-eye (right-eye) image, wherein the left-eye (right-eye) weighting coefficient is included in the left-eye (right-eye) coefficient information. That is, when determining the left-eye (right-eye) image for displaying the three-dimensional effect of the two-dimensional image, the pixel value of the target pixel point in the left-eye (right-eye) image is determined by the pixel value of the target pixel point and its adjacent pixel points and the left-eye (right-eye) weighting coefficient, and the pixel value of the target pixel point is smoothed to ensure the accuracy of the left-eye (right-eye) image generation, reduce the visual fault phenomenon caused by the discontinuous position of pixels (with the same or similar pixel values), and improve the smoothness and visual effect of the left-eye (right-eye) image content.
[0129] Please refer to Figure 8 , which shows a flow chart of a method for displaying a three-dimensional effect of a two-dimensional image provided by an embodiment of the present application. The method can be applied to a computer device, such as the execution subject of each step can be Figure 1 The terminal 10 in the 3D effect generation system shown in FIG. The method may include the following steps (801-802):
[0130] Step 801, obtaining a target image corresponding to a two-dimensional image;
[0131] Step 802: Display the target image.
[0132] The target image is used to generate a three-dimensional effect of a two-dimensional image. Optionally, the terminal can display the target image in an interface to achieve a three-dimensional effect of the two-dimensional image.
[0133] In an embodiment of the present application, when determining the three-dimensional effect of displaying a two-dimensional image, the terminal obtains a target image corresponding to the two-dimensional image and then displays the target image in the interface. The pixel value of the target pixel in the two-dimensional image is determined based on the pixel values and weighting coefficients of the target pixel and its adjacent pixels. The weighting coefficients of the target pixel and its adjacent pixels are determined based on the planned displacement of the target pixel and its adjacent pixels in the target image. The details are as described above and are not repeated here.
[0134] Optionally, the target image includes a left-eye image and a right-eye image. The terminal may simultaneously display the left-eye image and the right-eye image to cause a visual error in the user, so that the user may perceive a three-dimensional effect on the two-dimensional image based on the visual error.
[0135] To sum up, in the technical solution provided in the embodiment of the present application, coefficient information is generated by using the pixel displacement information of the two-dimensional image, and when determining the target image corresponding to the two-dimensional image, the pixel values and weighting coefficients of the target pixel point and its adjacent pixel points are used to determine the target image, and the pixel values of the target pixel points are smoothed to ensure the accuracy of the target image generation, reduce the visual fault phenomenon caused by the discontinuous position of pixels (with the same or similar pixel values), and improve the smoothness and visual effect of the image content.
[0136] For example, in conjunction with reference Figure 9 , a comparison is made between the three-dimensional effect generation method for two-dimensional images in the related art and the three-dimensional effect generation method for two-dimensional images in the present application.
[0137] In related art, after obtaining pixel displacement information 91, the server rounds the pixel displacement information to obtain rounded pixel displacement information 92. At this time, the row of pixels with a planned displacement of 8.4990 is adjacent to the row of pixels with a planned displacement of 8.5010. They should be mapped to adjacent positions in the target image, but the upper row of pixels is shifted by 8 pixels due to rounding, and the lower row of pixels is shifted by 9 pixels due to rounding. This 1-pixel displacement difference causes stripe distortion in the final left and right eye images, resulting in the final effect shown in the effect diagram ( Figure 9 Visual discontinuity 94 in 93).
[0138] In the technical solution provided by the present application, when determining the target image for displaying the three-dimensional effect of a two-dimensional image, the server determines the pixel value of the target pixel in the target image by using the pixel values and weighting coefficients of the target pixel and its adjacent pixel points, and when determining the weighting coefficient of the target pixel, the weighting coefficient of the target pixel is determined by using the distance between the planned position of the target pixel in the target image and the target position. The target position is obtained by displacing the target pixel according to the rounding result of the planned displacement amount, and the planned position is obtained by displacing the target pixel according to the planned displacement amount. Taking into account the problem of inaccurate target image caused by rounding of pixel displacement information, the distance between the target position and the planned position after rounding is used as the weighting coefficient of the target pixel, and the pixel value of the target pixel is weightedly adjusted in combination with the adjacent pixel points, and the pixel value of the target pixel is smoothed to ensure the accuracy of target image generation, reduce the visual fault phenomenon caused by the discontinuity of the position of pixels (with the same or similar pixel values), improve the smoothness and visual effect of the image content, and finally present the effect as shown in the effect diagram ( Figure 9 As shown in Figure 95), there is no visual discontinuity.
[0139] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0140] Please refer to Figure 10 , which shows a block diagram of a device for generating a 3D effect for a 2D image, provided in one embodiment of the present application. This device implements the aforementioned method for generating a 3D effect for a 2D image. The device 1000 may include a displacement acquisition module 1010, a coefficient generation module 1020, and a pixel determination module 1030.
[0141] The displacement acquisition module 1010 is used to obtain pixel displacement information corresponding to a two-dimensional image, wherein the pixel displacement information includes the planned displacement of each pixel point in the two-dimensional image in a target image; wherein the target image is used to generate a three-dimensional effect of the two-dimensional image.
[0142] The coefficient generating module 1020 is configured to generate coefficient information based on the planned displacement amount in the pixel displacement information, where the coefficient information includes a weighting coefficient for each pixel point in the two-dimensional image.
[0143] The pixel determination module 1030 is configured to determine, for a target pixel in the two-dimensional image, a pixel value of the target pixel in the target image based on the pixel values of the target pixel and its adjacent pixels and a weighting coefficient.
[0144] In an exemplary embodiment, the coefficient generation module 1020 is used to determine the target position and the planned position of the target pixel point in the target image based on the planned displacement amount of the target pixel point; wherein the target position is obtained by displacing the target pixel point according to the rounded result of the planned displacement amount, and the planned position is obtained by displacing the target pixel point according to the planned displacement amount; based on the distance between the target position and the planned position, the weighting coefficient of the target pixel point is determined.
[0145] In an exemplary embodiment, as Figure 11 As shown, the pixel determination module 1030 includes: a first determination unit 1031 and a second determination unit 1032.
[0146] The first determination unit 1031 is used to determine the pixel value of the target pixel point in the target image based on the pixel values and weighting coefficients of the target pixel point and its adjacent pixel points in the second direction if the planned position of the target pixel point in the target image is located in the first direction of the target position.
[0147] The second determination unit 1032 is used to determine the pixel value of the target pixel point in the target image based on the pixel values and weighting coefficients of the target pixel point and its adjacent pixel points in the first direction if the planned position of the target pixel point in the target image is located in the second direction of the target position.
[0148] The target position is obtained by displacing the target pixel point according to the rounded result of the planned displacement amount, and the planned position is obtained by displacing the target pixel point according to the planned displacement amount.
[0149] In an exemplary embodiment, the first determination unit 1031 is used to multiply the pixel value of the target pixel point by the weighting coefficient of the adjacent pixel points in the second direction to obtain a first value; multiply the pixel value of the adjacent pixel points in the second direction by the weighting coefficient of the target pixel point to obtain a second value; and divide the sum of the first value and the second value by the weighting coefficient of the target pixel point and the sum of the weighting coefficients of the adjacent pixel points in the second direction to obtain the pixel value of the target pixel point in the target image.
[0150] In an exemplary embodiment, the second determination unit 1032 is used to multiply the pixel value of the target pixel point by the weighting coefficient of the adjacent pixel points in the first direction to obtain a third value; multiply the pixel value of the adjacent pixel points in the first direction by the weighting coefficient of the target pixel point to obtain a fourth value; and divide the sum of the third value and the fourth value by the sum of the weighting coefficient of the target pixel point and the weighting coefficient of the adjacent pixel points in the first direction to obtain the pixel value of the target pixel point in the target image.
[0151] In an exemplary embodiment, the displacement acquisition module 1010 is used to obtain depth information corresponding to the two-dimensional image, where the depth information includes the depth value of each pixel in the two-dimensional image; based on the depth information, the pixel displacement information corresponding to the two-dimensional image is determined; wherein the planned displacement amount is negatively correlated with the depth value.
[0152] In an exemplary embodiment, the pixel determination module 1030 is also used to, when the target pixel point and the adjacent pixel point belong to the same depth area, execute the step of determining the pixel value of the target pixel point in the target image based on the pixel value and weighting coefficient of the target pixel point and its adjacent pixel points for the target pixel point in the two-dimensional image; and when the target pixel point and the adjacent pixel point do not belong to the same depth area, determine the pixel value of the target pixel point in the two-dimensional image as the pixel value of the target pixel point in the target image.
[0153] In an exemplary embodiment, the target image includes a left-eye image and a right-eye image.
[0154] The displacement acquisition module 1010 is further used to obtain left-eye pixel displacement information and right-eye pixel displacement information corresponding to the two-dimensional image; wherein the left-eye pixel displacement information includes the planned displacement amount of each pixel point in the two-dimensional image in the left-eye image, and the right-eye pixel displacement information includes the planned displacement amount of each pixel point in the two-dimensional image in the right-eye image.
[0155] The coefficient generation module 1020 is further used to generate left-eye coefficient information based on the planned displacement amount in the left-eye pixel displacement information, and to generate right-eye coefficient information based on the planned displacement amount in the right-eye pixel displacement information; wherein the left-eye coefficient information includes the left-eye weighting coefficient of each pixel point in the two-dimensional image, and the right-eye coefficient information includes the right-eye weighting coefficient of each pixel point in the two-dimensional image.
[0156] The pixel determination module 1030 is also used to determine, for a target pixel point in the two-dimensional image, the pixel value of the target pixel point in the left eye image based on the pixel values of the target pixel point and its adjacent pixel points and the left eye weighting coefficient; and, for a target pixel point in the two-dimensional image, determine, based on the pixel values of the target pixel point and its adjacent pixel points and the right eye weighting coefficient, the pixel value of the target pixel point in the right eye image.
[0157] To summarize, in the technical solution provided in the embodiments of the present application, coefficient information is generated through the pixel displacement information of the two-dimensional image, and when determining the target image corresponding to the two-dimensional image, the pixel value and weighting coefficient of the target pixel point and its adjacent pixel points are used to determine the target image, wherein the weighting coefficient is included in the coefficient information. That is, when determining the target image for displaying the three-dimensional effect of the two-dimensional image, the pixel value of the target pixel point in the target image is determined through the pixel value and weighting coefficient of the target pixel point and its adjacent pixel points, and the pixel value of the target pixel point is smoothed to ensure the accuracy of the target image generation, reduce the visual fault phenomenon caused by the discontinuous position of pixels (with the same or similar pixel values), and improve the smoothness and visual effect of the image content.
[0158] Please refer to Figure 12 , which shows a block diagram of a device for displaying a three-dimensional effect of a two-dimensional image according to an embodiment of the present application. The device 1200 may include: an image acquisition module 1210 and a target display module 1220.
[0159] The image acquisition module 1210 is configured to acquire a target image corresponding to a two-dimensional image, where the target image is used to generate a three-dimensional effect of the two-dimensional image.
[0160] The target display module 1220 is used to display the target image; wherein, the pixel value of the target pixel point in the two-dimensional image in the target image is determined based on the pixel value and weighting coefficient of the target pixel point and its adjacent pixel points, and the weighting coefficient of the target pixel point is determined based on the planned displacement of the target pixel point in the target image.
[0161] To sum up, in the technical solution provided in the embodiment of the present application, coefficient information is generated by using the pixel displacement information of the two-dimensional image, and when determining the target image corresponding to the two-dimensional image, the pixel values and weighting coefficients of the target pixel point and its adjacent pixel points are used to determine the target image, and the pixel values of the target pixel points are smoothed to ensure the accuracy of the target image generation, reduce the visual fault phenomenon caused by the discontinuous position of pixels (with the same or similar pixel values), and improve the smoothness and visual effect of the image content.
[0162] It should be noted that the apparatus provided in the above embodiments, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0163] Please refer to Figure 13 , which shows a structural block diagram of a server provided by an embodiment of the present application. The server can be used to implement the functions of the above-mentioned method for generating a three-dimensional effect for a two-dimensional image. The server can be Figure 1 The server 20 in the 3D effect generation system shown is shown. Specifically:
[0164] Server 1300 includes a central processing unit (CPU) 1301, a system memory 1304 including a random access memory (RAM) 1302 and a read-only memory (ROM) 1303, and a system bus 1305 connecting system memory 1304 and CPU 1301. Optionally, server 1300 also includes a basic input / output system (I / O system) 1306 for facilitating information transfer between various components within the computer, and a mass storage device 1307 for storing an operating system 1313, application programs 1314, and other program modules 1315.
[0165] The basic input / output system 1306 may include a display 1308 (e.g., an external display) for displaying information and an input device 1309, such as a mouse or keyboard, for user input. Both the display 1308 and the input device 1309 may be connected to the central processing unit 1301 via an input / output controller 1310 connected to the system bus 1305. The basic input / output system 1306 may also include an input / output controller 1310 for receiving and processing input from a variety of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1310 also provides output to a display screen, printer, or other types of output devices.
[0166] The mass storage device 1307 is connected to the central processing unit 1301 via a mass storage controller (not shown) connected to the system bus 1305. The mass storage device 1307 and its associated computer-readable media provide non-volatile storage for the server 1300. In other words, the mass storage device 1307 may include computer-readable media (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.
[0167] Without loss of generality, computer-readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory), flash memory or other solid-state storage technologies, CD-ROM, DVD (Digital Video Disc) or other optical storage, tape cassettes, magnetic tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media are not limited to the above-mentioned ones. The above-mentioned system memory 1304 and mass storage device 1307 can be collectively referred to as memory.
[0168] According to various embodiments of the present application, the server 1300 may also be connected to a remote computer on a network such as the Internet for operation. That is, the server 1300 may be connected to the network 1312 via a network interface unit 1311 connected to the system bus 1305. Alternatively, the network interface unit 1311 may be used to connect to other types of networks or remote computer systems (not shown).
[0169] The memory further includes a computer program, which is stored in the memory and configured to be executed by one or more processors to implement the above-mentioned method for generating a three-dimensional effect for a two-dimensional image.
[0170] Those skilled in the art will understand that Figure 13 The structure shown in the figure does not constitute a limitation on the server 1300, and the server 1300 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0171] Please refer to Figure 14 , which shows a block diagram of the structure of a terminal 1400 provided in one embodiment of the present application. The terminal is used to implement the three-dimensional effect display method for a two-dimensional image provided in the above embodiment, or the terminal is used to implement the three-dimensional effect generation method for a two-dimensional image provided in the above embodiment. The terminal can be Figure 1 The terminal 10 in the three-dimensional effect generation system shown is shown. Specifically:
[0172] Typically, the terminal 1400 includes a processor 1401 and a memory 1402 .
[0173] The processor 1401 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1401 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1401 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1401 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1401 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0174] The memory 1402 may include one or more computer-readable storage media, which may be non-transitory. The memory 1402 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1402 is used to store at least one instruction, at least one program, code set or instruction set, and is configured to be executed by one or more processors to implement the above-mentioned three-dimensional effect display method for two-dimensional images, or to implement the above-mentioned three-dimensional effect generation method for two-dimensional images.
[0175] In some embodiments, terminal 1400 may optionally include a peripheral device interface 1403 and at least one peripheral device. Processor 1401, memory 1402, and peripheral device interface 1403 may be connected via a bus or signal lines. Each peripheral device may be connected to peripheral device interface 1403 via a bus, signal lines, or circuit boards. Specifically, the peripheral device may include at least one of a radio frequency circuit 1404, a display screen 1405, a camera assembly 1406, an audio circuit 1407, a positioning assembly 1408, and a power supply 1409.
[0176] Those skilled in the art will understand that Figure 14 The structure shown in the figure does not constitute a limitation on the terminal 1400, and the terminal 1400 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.
[0177] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one instruction, at least one program, a code set or an instruction set is stored. When the at least one instruction, the at least one program, the code set or the instruction set is executed by a processor, it implements the above-mentioned method for generating a three-dimensional effect for a two-dimensional image, or implements the above-mentioned method for displaying a three-dimensional effect for a two-dimensional image.
[0178] Optionally, the computer-readable storage medium may include: ROM (Read Only Memory), RAM (Random Access Memory), SSD (Solid State Drives), or an optical disk, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).
[0179] In an exemplary embodiment, a computer program product or computer program is also provided. The computer program product or computer program includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described method for generating a 3D effect for a 2D image or the above-described method for displaying a 3D effect for a 2D image.
[0180] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application do not limit this.
[0181] The above description is merely an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for generating a three-dimensional effect for a two-dimensional image, characterized in that: The method comprises: Obtaining pixel displacement information corresponding to a two-dimensional image, the pixel displacement information including a planned displacement of each pixel point in the two-dimensional image in a target image; wherein the target image is used to generate a three-dimensional effect of the two-dimensional image; generating coefficient information based on the planned displacement amount in the pixel displacement information, the coefficient information including a weighting coefficient for each pixel point in the two-dimensional image; If the planned position of a target pixel point in the two-dimensional image in the target image is located in a first direction of the target position, determining a pixel value of the target pixel point in the target image based on the pixel values of the target pixel point and its adjacent pixels in a second direction and a weighting coefficient; If the planned position of the target pixel point in the target image is located in the second direction of the target position, determining the pixel value of the target pixel point in the target image based on the pixel values of the target pixel point and its adjacent pixels in the first direction and the weighting coefficient; The target position is obtained by displacing the target pixel point according to the rounded result of the planned displacement amount, and the planned position is obtained by displacing the target pixel point according to the planned displacement amount.
2. The method according to claim 1, characterized in that The generating coefficient information based on the planned displacement amount in the pixel displacement information includes: Determining a target position and a planned position of the target pixel point in the target image based on the planned displacement amount of the target pixel point; wherein the target position is obtained by displacing the target pixel point according to a rounded result of the planned displacement amount, and the planned position is obtained by displacing the target pixel point according to the planned displacement amount; A weighting coefficient of the target pixel point is determined based on the distance between the target position and the planned position.
3. The method according to claim 1, characterized in that The determining, based on the pixel values of the target pixel and the pixel values of the adjacent pixel points in the second direction and the weighting coefficient, of the target pixel in the target image includes: Multiplying the pixel value of the target pixel by the weighted coefficient of the adjacent pixel points in the second direction to obtain a first value; Multiplying the pixel values of the adjacent pixels in the second direction by the weighting coefficient of the target pixel to obtain a second value; The sum of the first value and the second value is divided by the sum of the weighting coefficient of the target pixel point and the weighting coefficients of the adjacent pixels in the second direction to obtain the pixel value of the target pixel point in the target image.
4. The method according to claim 1, wherein The determining, based on the pixel values of the target pixel and the pixel values of the adjacent pixel points in the first direction and the weighting coefficient, of the target pixel in the target image includes: Multiplying the pixel value of the target pixel by the weighted coefficients of the adjacent pixels in the first direction to obtain a third value; Multiplying the pixel values of the adjacent pixels in the first direction by the weighting coefficient of the target pixel to obtain a fourth value; The sum of the third value and the fourth value is divided by the sum of the weighting coefficient of the target pixel point and the weighting coefficients of the adjacent pixel points in the first direction to obtain the pixel value of the target pixel point in the target image.
5. The method according to claim 1, wherein The obtaining of pixel displacement information corresponding to the two-dimensional image includes: Acquire depth information corresponding to the two-dimensional image, where the depth information includes a depth value of each pixel in the two-dimensional image; Based on the depth information, the pixel displacement information corresponding to the two-dimensional image is determined; wherein the planned displacement amount is negatively correlated with the depth value.
6. The method according to claim 1, characterized in that The method further comprises: In the case where the target pixel point and the adjacent pixel points belong to the same depth area, performing the steps of determining the pixel value of the target pixel point in the target image based on the pixel values of the target pixel point and the adjacent pixel points in the second direction and the weighting coefficient if the planned position of the target pixel point in the target image is located in the first direction of the target position; and determining the pixel value of the target pixel point in the target image based on the pixel values of the target pixel point and the adjacent pixel points in the first direction and the weighting coefficient if the planned position of the target pixel point in the target image is located in the second direction of the target position; In a case where the target pixel point and the adjacent pixel points do not belong to the same depth region, the pixel value of the target pixel point in the two-dimensional image is determined as the pixel value of the target pixel point in the target image.
7. The method according to any one of claims 1 to 6, characterized in that The target image includes a left-eye image and a right-eye image; The obtaining of pixel displacement information corresponding to the two-dimensional image includes: Obtain left-eye pixel displacement information and right-eye pixel displacement information corresponding to the two-dimensional image; wherein the left-eye pixel displacement information includes the planned displacement amount of each pixel point in the two-dimensional image in the left-eye image, and the right-eye pixel displacement information includes the planned displacement amount of each pixel point in the two-dimensional image in the right-eye image.
8. The method according to claim 7, characterized in that The generating coefficient information based on the planned displacement amount in the pixel displacement information includes: Left-eye coefficient information is generated based on the planned displacement amount in the left-eye pixel displacement information, and right-eye coefficient information is generated based on the planned displacement amount in the right-eye pixel displacement information; wherein the left-eye coefficient information includes the left-eye weighting coefficient of each pixel point in the two-dimensional image, and the right-eye coefficient information includes the right-eye weighting coefficient of each pixel point in the two-dimensional image.
9. The method according to claim 7, characterized in that The pixel value of the target pixel in the left-eye image is determined based on the pixel values of the target pixel and its adjacent pixels and a left-eye weighting coefficient; The pixel value of the target pixel in the right-eye image is determined based on the pixel values of the target pixel and its adjacent pixels and a right-eye weighting coefficient.
10. A method for displaying a three-dimensional effect on a two-dimensional image, characterized in that: The method comprises: Acquire a target image corresponding to the two-dimensional image, wherein the target image is used to generate a three-dimensional effect of the two-dimensional image; displaying the target image; Among them, if the planned position of the target pixel point in the two-dimensional image in the target image is located in the first direction of the target position, then the pixel value of the target pixel point in the target image is determined based on the pixel values of the target pixel point and its adjacent pixels in the second direction and the weighting coefficient; if the planned position of the target pixel point in the target image is located in the second direction of the target position, then the pixel value of the target pixel point in the target image is determined based on the pixel values of the target pixel point and its adjacent pixels in the first direction and the weighting coefficient; the weighting coefficient of the target pixel point is determined based on the planned displacement amount of the target pixel point in the target image; the target position is obtained by displacing the target pixel point according to the rounding result of the planned displacement amount; and the planned position is obtained by displacing the target pixel point according to the planned displacement amount.
11. A device for generating a three-dimensional effect for a two-dimensional image, characterized in that: The device comprises: a displacement acquisition module, configured to acquire pixel displacement information corresponding to a two-dimensional image, wherein the pixel displacement information includes a planned displacement of each pixel point in the two-dimensional image in a target image; wherein the target image is used to generate a three-dimensional effect of the two-dimensional image; a coefficient generating module, configured to generate coefficient information based on the planned displacement amount in the pixel displacement information, wherein the coefficient information includes a weighting coefficient for each pixel point in the two-dimensional image; a pixel determination module configured to determine, if the planned position of a target pixel point in the two-dimensional image in the target image is located in a first direction of the target position, a pixel value of the target pixel point in the target image based on the pixel values of the target pixel point and its adjacent pixels in a second direction and a weighting coefficient; The pixel determination module is further configured to determine a pixel value of the target pixel in the target image based on the pixel values of the target pixel and its adjacent pixels in the first direction and a weighting coefficient if the planned position of the target pixel in the target image is located in the second direction of the target position; The target position is obtained by displacing the target pixel point according to the rounded result of the planned displacement amount, and the planned position is obtained by displacing the target pixel point according to the planned displacement amount.
12. A three-dimensional effect display device for a two-dimensional image, characterized in that: The device comprises: An image acquisition module, configured to acquire a target image corresponding to a two-dimensional image, wherein the target image is used to generate a three-dimensional effect of the two-dimensional image; A target display module is used to display the target image; wherein, if the planned position of the target pixel point in the two-dimensional image in the target image is located in the first direction of the target position, the pixel value of the target pixel point in the target image is determined based on the pixel values of the target pixel point and its adjacent pixels in the second direction and a weighting coefficient; if the planned position of the target pixel point in the target image is located in the second direction of the target position, the pixel value of the target pixel point in the target image is determined based on the pixel values of the target pixel point and its adjacent pixels in the first direction and a weighting coefficient; the weighting coefficient of the target pixel point is determined based on the planned displacement amount of the target pixel point in the target image; the target position is obtained by displacing the target pixel point according to the rounding result of the planned displacement amount; and the planned position is obtained by displacing the target pixel point according to the planned displacement amount.
13. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one program, and the at least one program is loaded and executed by the processor to implement the three-dimensional effect generating method for a two-dimensional image as described in any one of claims 1 to 9, or to implement the three-dimensional effect display method for a two-dimensional image as described in claim 10.
14. A computer-readable storage medium, characterized in that The storage medium stores at least one program, which is loaded and executed by the processor to implement the three-dimensional effect generation method for a two-dimensional image as described in any one of claims 1 to 9, or to implement the three-dimensional effect display method for a two-dimensional image as described in claim 10.
15. A computer program product, characterized in that The computer program product includes computer instructions, which are executed by a processor to implement the three-dimensional effect generating method for a two-dimensional image as described in any one of claims 1 to 9, or the three-dimensional effect display method for a two-dimensional image as described in claim 10.
Citation Information
Patent Citations
Three-dimensional method and device for two-dimensional image, equipment and computer readable storage medium
CN111970503A