Depth-of-field image rendering method and apparatus, electronic device, computer readable storage medium, and computer program product
By performing pixel block and classification processing on depth-of-field images, the problems of unsatisfactory depth-of-field image rendering effects and high performance consumption in the existing technology are solved, and efficient depth-of-field image rendering effects are achieved.
Patent Information
- Application Number
- PCT/CN2023/132283
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-23
- Filing Date
- 2023-11-17
- Publication Date
- 2024-10-03
AI Technical Summary
The existing technology requires multiple adjustments of non-physical parameters when rendering depth-of-field images, resulting in unsatisfactory rendering effects, high performance consumption and low efficiency in the rendering process.
By dividing the depth image of the image to be rendered into pixel blocks, the depth of field parameters of each pixel block are obtained, classified and blurred, and the corresponding rendering process is performed according to the category to generate a depth of field image.
It improves the efficiency and effect of depth-of-field image rendering, reduces the rendering process, reduces performance consumption, and achieves efficient image processing.
Smart Images

Figure CN2023132283_03102024_PF_FP_ABST
Abstract
Description
Depth-of-field image rendering method, device, electronic device, computer-readable storage medium, and computer program product
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] The embodiments of this application are based on the Chinese patent application with application number 202310201486.4 and application date February 23, 2023, and claim the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into the embodiments of this application as a reference. Technical Field
[0003] The present application relates to the field of computer technology, and in particular to a method, device, electronic device, computer-readable storage medium, and computer program product for rendering a depth of field image. Background Art
[0004] When using related technologies to render depth of field images, if you want to reduce the rendering process, you need to use many non-physical adjustment parameters. This means that every time the user focuses on the picture, they need to repeatedly adjust parameters such as the transition area and the degree of transition blur, resulting in a very unsatisfactory rendering effect. If you want to achieve an ideal rendering effect based on fewer adjustment parameters, more rendering processes are required, which not only has extremely high performance overhead, but also has low efficiency when rendering depth of field images.
[0005] Summary of the Invention
[0006] Embodiments of the present application provide a method, apparatus, electronic device, computer-readable storage medium, and computer program product for rendering a depth-of-field image, which can improve the efficiency and rendering effect of rendering a depth-of-field image.
[0007] The technical solution of the embodiment of the present application is implemented as follows:
[0008] An embodiment of the present application provides a method for rendering a depth of field image, the method comprising:
[0009] Obtaining a depth image of the image to be rendered, and dividing the depth image into pixel blocks to obtain at least two pixel blocks;
[0010] Obtaining a depth of field parameter of each pixel block, and classifying the at least two pixel blocks based on the depth of field parameter to obtain a category to which each pixel block belongs;
[0011] For each pixel block of the category, based on the position of each pixel block in the category in the depth image, determining a pixel area of the pixel block of the category in the image to be rendered, and blurring the pixel area based on a blurring processing method corresponding to the category to obtain a blurred image;
[0012] Based on the image to be rendered and the blurred image, a depth of field image corresponding to the image to be rendered is obtained.
[0013] An embodiment of the present application provides a device for rendering a depth of field image, the device comprising:
[0014] A first acquisition module is configured to acquire a depth image of an image to be rendered, and perform pixel blocking on the depth image to obtain at least two pixel blocks;
[0015] a second acquisition module configured to acquire a depth of field parameter of each pixel block, and classify the at least two pixel blocks based on the depth of field parameter to obtain a category to which each pixel block belongs;
[0016] a blur processing module configured to determine, for each pixel block of the category, a pixel area of the pixel block in the image to be rendered based on a position of each pixel block in the category in the depth image, and perform blur processing on the pixel area based on a blur processing method corresponding to the category to obtain a blurred image;
[0017] The rendering module is configured to obtain a depth of field image corresponding to the image to be rendered based on the image to be rendered and the blurred image.
[0018] An embodiment of the present application provides an electronic device, including:
[0019] a memory configured to store computer-executable instructions;
[0020] The processor is configured to implement the depth of field image rendering method provided in the embodiment of the present application when executing the computer executable instructions stored in the memory.
[0021] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are executed by a processor, the processor will execute the depth-of-field image rendering method provided by the embodiment of the present application.
[0022] Embodiments of the present application provide a computer program product, which includes a computer program or computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the electronic device to perform the depth-of-field image rendering method provided in embodiments of the present application.
[0023] The embodiments of the present application have the following beneficial effects:
[0024] First, the depth image of the image to be rendered is pixel-blocked to obtain at least two pixel blocks, and based on the depth of field parameters corresponding to each pixel block, the at least two pixel blocks are classified to obtain the category to which each pixel block belongs. Then, according to the different categories to which each pixel block belongs, the pixel area corresponding to the pixel block in the image to be rendered is blurred according to the blurring method corresponding to the category to obtain a blurred image. Finally, based on the image to be rendered and the blurred image, a depth of field image corresponding to the image to be rendered is obtained. In this way, the pixel blocks are classified according to the rendering parameters corresponding to different pixel blocks during the rendering process and the complexity of the rendering process, so that the rendering process corresponding to the category is executed for pixel blocks of different categories to obtain the final depth of field image. In this way, not only the rendering effect when rendering the depth of field image is improved, but also the rendering process when rendering the depth of field image is reduced, thereby reducing performance consumption and improving the efficiency of image processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] FIG1 is a schematic diagram of the architecture of a depth-of-field image rendering system 100 provided in an embodiment of the present application;
[0026] FIG2 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;
[0027] FIG3 is a schematic diagram of a flow chart of a method for rendering a depth-of-field image according to an embodiment of the present application;
[0028] FIG4 is a schematic diagram of an image to be rendered and a depth image corresponding to the image to be rendered provided by an embodiment of the present application;
[0029] FIG5 is a schematic diagram of a process of pixel segmentation of a depth image provided by an embodiment of the present application;
[0030] FIG6 is a schematic diagram of performing expansion processing on each pixel block according to an embodiment of the present application;
[0031] FIG7 is a schematic diagram of blurring a pixel area based on different blurring methods according to an embodiment of the present application;
[0032] FIG8 is a schematic diagram of a blurred image and a regional transition image provided by an embodiment of the present application;
[0033] FIG9 is a schematic diagram of a region division image and a pre-blurred image provided in an embodiment of the present application;
[0034] FIG10 is a schematic diagram of a pre-blurred image and a regional transition image provided in an embodiment of the present application;
[0035] FIG11 is a schematic diagram of performing image rendering based on an image to be rendered and a blurred image to obtain a depth of field image corresponding to the image to be rendered, provided by an embodiment of the present application;
[0036] FIG12 is a schematic diagram of the effect of post-processing depth of field rendering based on block rendering provided by an embodiment of the present application;
[0037] FIG13 is a technical architecture diagram of post-processing depth of field rendering based on block rendering provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting the embodiments of the present application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the embodiments of the present application.
[0039] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0040] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0041] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art in the art of the present application. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0042] Before describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0043] 1) Client, also known as user end, refers to the program corresponding to the server that provides local services to users. Except for some applications that can only run locally, it is generally installed on an ordinary client and needs to cooperate with the server to run. That is, there must be corresponding servers and service programs in the network to provide corresponding services. In this way, a specific communication connection needs to be established between the client and the server to ensure the normal operation of the application.
[0044] 2) Render Target (RT), the video memory buffer used to render pixels, that is, the memory area. There can be multiple such memory areas at the same time, that is, there can be multiple render targets at the same time.
[0045] 3) Circle of Confusion (COC), also known as the blur circle, is used to indicate that when an object point is imaged, due to aberrations, its imaging light beam cannot converge at a point, forming a diffuse circular projection on the imaging plane. That is, before and after the focus, the light goes from convergence to diffusion, and the image of the point goes from a circle to the focus, and then diffuses to a circle again. The circles in front of and behind the focus are called the circles of confusion.
[0046] 4) Up sampling, also known as image interpolation, is used to enlarge the image and improve the resolution, such as using interpolation methods to improve the resolution.
[0047] 5) Pixel depth refers to the number of bits used to store each pixel. It is also used to measure the color resolution of an image and to determine the number of possible colors for each pixel in a color image.
[0048] 6) Depth image. Depth refers to the Z coordinate of the pixel in the camera coordinate system of the view. It is a unit of space. A depth map can be obtained for any image. The depth map refers to a two-dimensional image that stores the depth values of all pixels in a single view. It is a spatial unit, such as millimeters. The significance of the depth map is to express the three-dimensional results of image matching in an orderly manner with less storage space.
[0049] 7) Unreal Engine (UE), a suite of engine tools for developing real-time technologies, is currently widely used in 3D modeling, rendering, and game development. Its comprehensive tool suite and simple workflow allow developers to quickly modify or review their work, with minimal reliance on code.
[0050] 8) Depth of field (DOF) is used to describe the distance range in space where a clear image can be formed.
[0051] Referring to FIG1 , FIG1 is a schematic diagram of the architecture of a depth-of-field image rendering system 100 provided in an embodiment of the present application. In order to realize an application scenario of rendering a depth-of-field image (for example, the application scenario of rendering a depth-of-field image may be that when rendering an image to be rendered, first, pixel blocks are formed on the depth image of the image to be rendered to obtain at least two pixel blocks, and then, based on the maximum and minimum values of the diffusion circle of each pixel block, the at least two pixel blocks are classified to obtain a category of an image region to which each pixel block belongs, which is used to indicate the image region to which the corresponding pixel block belongs in the image to be rendered, and the image region is the image region of the image to be rendered). One of the focus area, foreground area, background area and boundary area, and then rendering the image to be rendered based on the rendering processing method corresponding to the category to obtain a depth of field image corresponding to the image to be rendered), the terminal (terminal 400 is shown as an example) is connected to the server 200 through the network 300, the network 300 can be a wide area network or a local area network, or a combination of the two, the terminal 400 is configured for the user to use the client 401, and is displayed on the display interface (display interface 401-1 is shown as an example), and the terminal 400 and the server 200 are connected to each other via a wired or wireless network.
[0052] The server 200 is configured to obtain a depth image of the image to be rendered, and perform pixel segmentation on the depth image to obtain at least two pixel blocks; obtain a depth parameter of each pixel block, and classify the at least two pixel blocks based on the depth parameter to obtain a category to which each pixel block belongs; for each category of pixel blocks, based on the position of each pixel block in the category in the depth image, determine a pixel area of the pixel blocks of the category in the image to be rendered, and perform blur processing on the pixel area based on a blur processing method corresponding to the category to obtain a blurred image; obtain a depth image corresponding to the image to be rendered based on the image to be rendered and the blurred image; and send the depth image corresponding to the image to be rendered to the terminal 400;
[0053] The terminal 400 is further configured to receive a depth of field image corresponding to the image to be rendered, and display the depth of field image based on a display interface.
[0054] In some embodiments, the server 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The terminal 400 can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a set-top box, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and a mobile device (for example, a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable gaming device, a smart speaker, and a smart watch), etc., but is not limited thereto. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.
[0055] Referring to Figure 2, Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. In actual applications, the electronic device may be the server 200 or the terminal 400 shown in Figure 1. Referring to Figure 2, the electronic device shown in Figure 2 includes: at least one processor 410, a memory 450, at least one network interface 420 and a user interface 430. The various components in the terminal 400 are coupled together through a bus system 440. It can be understood that the bus system 440 is configured to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, various buses are labeled as bus system 440 in Figure 2.
[0056] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0057] The user interface 430 includes one or more output devices 431 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0058] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard drives, optical drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 410.
[0059] The memory 450 includes volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.
[0060] In some embodiments, the memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplified below.
[0061] Operating system 451, including system programs configured to handle various basic system services and perform hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., configured to implement various basic services and handle hardware-based tasks;
[0062] A network communication module 452 is configured to reach other electronic devices via one or more (wired or wireless) network interfaces 420 , exemplary network interfaces 420 including Bluetooth, Wireless LAN (WiFi), and Universal Serial Bus (USB);
[0063] a presentation module 453 configured to enable presentation of information via one or more output devices 431 (e.g., a display screen, a speaker, etc.) associated with the user interface 430 (e.g., a user interface configured to operate peripheral devices and display content and information);
[0064] The input processing module 454 is configured to detect user input or interaction from one or more input devices 432 and to translate the detected input or interaction.
[0065] In some embodiments, the device provided by the embodiment of the present application can be implemented in software. FIG2 shows a rendering device 455 for a depth of field image stored in a memory 450, which can be software in the form of a program and a plug-in, including the following software modules: a first acquisition module 4551, a second acquisition module 4552, a blur processing module 4553, and a rendering module 4554. These modules are logical and can be arbitrarily combined or combined according to the functions implemented.
[0066] The functions of each module will be described below.
[0067] In other embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the depth of field image rendering device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the depth of field image rendering method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs) or other electronic components.
[0068] In some embodiments, the terminal or server can implement the depth of field image rendering method provided by the embodiments of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a native application (APP), that is, a program that needs to be installed in the operating system to run, such as an instant messaging APP or a web browser APP; it can also be a small program, that is, a program that can be run only by downloading it into a browser environment; it can also be a small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0069] Based on the above description of the depth of field image rendering system and electronic device provided in the embodiment of the present application, the depth of field image rendering method provided in the embodiment of the present application is described below. In actual implementation, the depth of field image rendering method provided in the embodiment of the present application can be implemented separately by the terminal or the server, or by the terminal and the server in collaboration. The server 200 in Figure 1 alone executes the depth of field image rendering method provided in the embodiment of the present application as an example for description. Referring to Figure 3, Figure 3 is a flow chart of the depth of field image rendering method provided in the embodiment of the present application. The steps shown will be described below in conjunction with Figure 3.
[0070] In step 101 , the server obtains a depth image of an image to be rendered, and divides the depth image into pixel blocks to obtain at least two pixel blocks.
[0071] In actual implementation, the image to be rendered can be pre-stored locally, or obtained from the outside world (such as the Internet), or can be collected in real time, for example, collected in real time by a shooting device. Here, after the server obtains the image to be rendered, the depth image corresponding to the image to be rendered is obtained based on the image to be rendered, wherein the image to be rendered is obtained, and a spatial coordinate system corresponding to the image to be rendered is constructed; based on the image to be rendered, the height value of each pixel in the image to be rendered in the spatial coordinate system is determined; based on the height value, the depth image corresponding to the image to be rendered is generated. For example, referring to Figure 4, Figure 4 is a schematic diagram of the image to be rendered and the depth image corresponding to the image to be rendered provided in an embodiment of the present application. Based on Figure 4, 401 is the image to be rendered, and 402 is the depth image corresponding to the image to be rendered. First, the image to be rendered as shown in 401 is obtained, and a spatial coordinate system corresponding to the image to be rendered is constructed, and based on the image to be rendered, the height value of each pixel in the image to be rendered in the spatial coordinate system is determined, thereby generating a depth image corresponding to the image to be rendered as shown in 402 based on the height value.
[0072] In actual implementation, the process of pixel-blocking a depth image to obtain at least two pixel blocks may include obtaining a preset pixel block size; dividing the multiple pixel points included in the depth image based on the size of the pixel block to obtain at least two pixel blocks, and the number of pixel points included in each pixel block is the same. It should be noted that the size of the pixel block here is preset, such as 16*16 or 10*10, so that the multiple pixel points included in the depth image are divided based on the preset pixel block size to obtain at least two pixel blocks of size 16*16 or 10*10. For example, referring to Figure 5, Figure 5 is a schematic diagram of the process of pixel-blocking a depth image provided by an embodiment of the present application. Based on Figure 5, 501 shows a depth image, and 502 shows at least two pixel blocks. Here, when the preset pixel block size is 16*16, the full-resolution depth image as shown in 501 is pixel-blocked to obtain at least two pixel blocks of size 16*16 as shown in 502.
[0073] Step 102: Obtain a depth parameter of each pixel block, and classify at least two pixel blocks based on the depth parameter to obtain a category to which each pixel block belongs.
[0074] It should be noted that different categories of pixel blocks correspond to different blur processing methods, and the depth of field parameter is used to indicate the change of the circle of confusion corresponding to the pixel block, including the maximum and minimum values of the circle of confusion of the pixel block. Therefore, based on the depth of field parameter, at least two pixel blocks are classified to obtain the category to which each pixel block belongs. The process may include, for each pixel block, taking the difference between the maximum and minimum values of the circle of confusion of the pixel block to obtain the change value of the circle of confusion of the pixel block; based on the change value and maximum value of the circle of confusion of each pixel block, at least two pixel blocks are classified to obtain the category to which each pixel block belongs.
[0075] In actual implementation, the process of obtaining the depth of field parameters corresponding to each pixel block, that is, obtaining the maximum and minimum values of the circle of confusion for each pixel block, is to obtain the value of the circle of confusion corresponding to each pixel point in the pixel block, that is, the radius of the circle of confusion, and then select the maximum and minimum values from the values of the circle of confusion corresponding to each pixel point as the maximum and minimum values of the circle of confusion corresponding to the pixel block. Here, the process of obtaining the value of the circle of confusion corresponding to each pixel point in the pixel block can be to obtain the diffusion parameters corresponding to the pixel point, wherein the diffusion parameters include at least the aperture diameter of the lens, the focal length of the lens, the focus position, the object distance, etc., and then determine the value of the circle of confusion corresponding to the pixel point, that is, the radius of the circle of confusion, based on the diffusion parameters, that is:
[0076] Among them, COC is the radius of the circle of confusion, A is the aperture diameter, F is the focal length, P is the focus position, and D represents the object distance.
[0077] It should be noted that the lens here is used to indicate the shooting lens of the shooting device for the image to be rendered. After the position of the lens and the imaging plane is determined, there is a position in front of the lens that can be focused on the imaging plane, so the distance between this position and the center of the lens is the focusing position, and the object distance is used to indicate the distance between the object and the lens, that is, the distance between the point on the object corresponding to the pixel point and the lens.
[0078] In actual implementation, after determining the change value and the maximum value of the circle of confusion of each pixel block, the process of classifying at least two pixel blocks based on the change value and the maximum value of the circle of confusion of each pixel block to obtain the category to which each pixel block belongs may include performing the following processing on each pixel block: when the maximum value of the circle of confusion of the pixel block is less than a target threshold, determining the category to which the pixel block belongs as a first category, and the first category is used to indicate that the pixel block belongs to the in-focus area in the image to be rendered; when the change value of the circle of confusion of the pixel block is less than the target threshold, determining the category to which the pixel block belongs as a second category, and the second category is used to indicate that the pixel block belongs to the foreground area or the background area in the image to be rendered; when the change value of the circle of confusion of the pixel block is not less than the target threshold, determining the category to which the pixel block belongs as a third category, and the third category is used to indicate that the pixel block belongs to the boundary area between the foreground area and the background area in the image to be rendered.
[0079] It should be noted that the target threshold here can be pre-set, such as 1. When the maximum value of the circle of confusion of a pixel block is less than 1, the pixel block is considered to be in the focus area of the image to be rendered, and the category to which the pixel block belongs is determined to be the first category; when the difference between the maximum and minimum values of the circle of confusion of a pixel block is less than 1, the pixel block is considered to be in an area of the image to be rendered where the circle of confusion does not change much, such as the foreground area or the background area of the image to be rendered, and the category to which the pixel block belongs is determined to be the second category; and for other cases except the above two cases, that is, when the difference between the maximum and minimum values of the circle of confusion of a pixel block is greater than or equal to 1, the pixel block is considered to be in an area of the image to be rendered where the circle of confusion changes greatly, such as the boundary area between the foreground area and the background area of the image to be rendered, and the category to which the pixel block belongs is determined to be the third category.
[0080] In some embodiments, at least two pixel blocks are classified based on the depth of field parameters to obtain the category to which each pixel block belongs. Alternatively, the image to be rendered may be divided into regions to obtain the focus area, foreground area, background area, and boundary area between the foreground area and the background area of the image to be rendered; for each pixel block, the image area to which the pixel block belongs in the image to be rendered is determined based on the depth of field parameters, the image area being one of the focus area, foreground area, background area, and boundary area; and the category to which the pixel block belongs is determined based on the image area to which the pixel block belongs.
[0081] It should be noted that the process of determining the image region to which a pixel block belongs in the image to be rendered based on the depth of field parameter is similar to the process of classifying at least two pixel blocks based on the depth of field parameter to obtain the category to which each pixel block belongs. For each pixel block, the maximum and minimum values of the circle of confusion of the pixel block are subtracted to obtain a change value of the circle of confusion of the pixel block; and the image region to which the pixel block belongs in the image to be rendered is determined based on the change value and the maximum value of the circle of confusion of each pixel block. Here, the process of determining the image region to which the pixel block belongs in the image to be rendered based on the change value and the maximum value of the circle of confusion of each pixel block may be performing the following processing on each pixel block: when the maximum value of the circle of confusion of the pixel block is less than a target threshold, determining that the pixel block belongs to the in-focus region of the image to be rendered; when the change value of the circle of confusion of the pixel block is less than the target threshold, determining that the pixel block belongs to the foreground region or the background region of the image to be rendered; and when the change value of the circle of confusion of the pixel block is not less than the target threshold, determining that the pixel block belongs to the boundary region between the foreground region and the background region of the image to be rendered. Thus, based on the image area to which the pixel block belongs, the category to which the pixel block belongs is determined. When the pixel block belongs to the focus area in the image to be rendered, the category to which the pixel block belongs is determined to be the first category; when the pixel block belongs to the foreground area or the background area in the image to be rendered, the category to which the pixel block belongs is determined to be the second category; when the pixel block belongs to the boundary area between the foreground area and the background area in the image to be rendered, the category to which the pixel block belongs is determined to be the third category.
[0082] In some embodiments, after pixel-blocking the depth image to obtain at least two pixel blocks, each pixel block may be dilated to obtain a dilated pixel block. Thus, the process of obtaining depth parameters corresponding to each pixel block may include obtaining depth parameters corresponding to each dilated pixel block. Based on the depth parameters corresponding to each dilated pixel block, the at least two dilated pixel blocks are classified to obtain the category to which each dilated pixel block belongs. For example, referring to FIG. 6 , FIG. 6 is a schematic diagram of dilating each pixel block according to an embodiment of the present application. Based on FIG. 6 , FIG. 6 shows an image corresponding to an undilated pixel block, and FIG. 6 shows an image corresponding to an dilated pixel block obtained after dilation. After pixel-blocking the depth image to obtain images corresponding to at least two pixel blocks, as shown in FIG. 6 , each pixel block in the image shown in FIG. 6 is dilated to obtain an image corresponding to the dilated pixel block, as shown in FIG. 6 , thereby obtaining depth parameters corresponding to each dilated pixel block. Based on the depth parameters corresponding to each dilated pixel block, the at least two dilated pixel blocks are classified to obtain the category to which each dilated pixel block belongs.
[0083] It should be noted that dilation is a mathematical morphological transformation. Through dilation, the pixel regions of previously detected clear object edges (such as those of people) are enlarged and connected into a single, integrated whole. In other words, through dilation, the pixel regions of clear object edges, originally composed of points or lines, are transformed into pixel regions composed of surfaces. This expands the clear points or lines, connecting them into a single surface. This facilitates segmentation of the original image's clear portions, such as those of people, from the blurred portions, thereby successfully extracting the clear objects, such as people, within each image—the areas that can be captured clearly within the current depth of field of the lens.
[0084] In step 103, for each category of pixel blocks, based on the position of each pixel block in the depth image, the pixel area of the corresponding category of pixel blocks in the image to be rendered is determined, and the pixel area is blurred based on the blur processing method corresponding to the corresponding category to obtain a blurred image.
[0085] In actual implementation, the image to be rendered includes a focus area, a foreground area, a background area, and a boundary area between the foreground area and the background area. For a process of blurring the pixel area based on a blurring processing method corresponding to the category to obtain a blurred image, when the pixel blocks belong to different categories, that is, belong to different areas, based on the category of the pixel blocks corresponding to the pixel area, a blurring processing method corresponding to the category is obtained; based on the blurring processing method, the pixel area is blurred to obtain a blur value of each pixel point in the pixel area; for each pixel area, a blurred image is generated based on the blurred pixel value of each pixel point in the pixel area.
[0086] It should be noted that when pixel blocks belong to different categories, that is, different areas, the blurring methods for blurring the pixel areas are different. Thus, based on the blurring methods, the process of blurring the pixel areas and obtaining the blur values of each pixel point in the pixel areas is also different. Next, when the pixel blocks belong to different categories, the process of blurring the pixel areas based on the blurring methods corresponding to the categories and obtaining the blur values of each pixel point in the pixel areas is explained.
[0087] In some embodiments, when the category of the pixel block indicates that the pixel block belongs to the focus area, the pixel area is not blurred, that is, the pixel value of each pixel in the pixel area is directly determined as the blurred pixel value of the corresponding pixel.
[0088] In other embodiments, when the category of a pixel block indicates that the pixel block belongs to a foreground area or a background area, for each pixel point in the pixel area, the first sampling area to which the pixel point belongs and the area weight of the corresponding pixel point are determined, and based on the area weight, the blurred pixel value of the pixel point in the first sampling area is determined.
[0089] In actual implementation, in the process of determining the first sampling area to which a pixel point belongs and the area weight corresponding to the pixel point, the sampling radius for the pixel point is first calculated, that is:
[0090] Where COC is the radius of the circle of confusion, A is the aperture diameter, and K is the image resolution of the image to be rendered.
[0091] Then, according to the sampling radius, a first sampling area for the pixel point is determined, and for each sampling point in the first sampling area, the value of the diffusion circle, the foreground factor or the background factor of the sampling point is obtained, wherein the foreground factor is used to indicate the degree of influence of the pixel point on the sampling points in the surrounding sampling area when the pixel point is in the foreground area, and the background factor is used to indicate the degree of influence of the pixel point on the sampling points in the surrounding sampling area when the pixel point is in the background area, thereby determining the regional weight of the sampling point based on the value of the diffusion circle of the sampling point, the foreground factor and the background factor, wherein the regional weight includes the foreground weight and the background weight, wherein the foreground weight is used to indicate the degree of influence of the color value of the pixel point, that is, the pixel value, on the blurred pixel value when the sampling point is in the foreground area, and the background weight is used to indicate the degree of influence of the color value of the pixel point, that is, the pixel value, on the blurred pixel value when the sampling point is in the background area.
[0092] Based on this, the process of determining the regional weight of the sampling point based on the value of the diffusion circle of the sampling point, the foreground factor, and the background factor can be as follows: obtaining a pre-set first mapping relationship, where the first mapping relationship is used to indicate the correspondence between the value of the diffusion circle of the sampling point and the weight parameter of the sampling point; determining the weight parameter of the sampling point based on the first mapping relationship and the value of the diffusion circle of the sampling point; when the sampling point is in the foreground area, multiplying the value of the weight parameter of the sampling point by the foreground factor of the sampling point to obtain the regional weight of the sampling point, i.e., the foreground weight; when the sampling point is in the background area, multiplying the value of the weight parameter of the sampling point by the background factor of the sampling point to obtain the regional weight of the sampling point, i.e., the background weight.
[0093] Finally, for the process of determining the blurred pixel value of the pixel based on the regional weight, the region where the pixel is located and each sampling point in the first sampling region for the pixel are determined, and then the color value of the sampling point and the regional weight corresponding to the region where the sampling point is located are determined for each sampling point in the first sampling region of the pixel. Thus, based on the regional weight of the sampling point and the color value of the sampling point, the blurred pixel value for the pixel is determined, that is:
[0094] Among them, S is the number of pixels in the sampling area around the pixel point, FilteredForegroundColor is used to indicate the blurred pixel value when the area where the pixel point is located is the foreground area, FilteredBackgroundColor is used to indicate the blurred pixel value when the area where the pixel point is located is the background area, ForegroundWeight i Used to indicate the foreground weight of the i-th pixel in the sampling area around the pixel, BackgroundWeight i Used to indicate the background weight of the i-th pixel in the sampling area around the pixel, Color i Used to indicate the color value of the i-th pixel in the sampling area around the pixel.
[0095] It should be noted that, since the sampling area includes the pixel point, the sampling point here may also include the pixel point. This embodiment of the present application does not limit this.
[0096] In other embodiments, when the category of the pixel block indicates that the pixel block belongs to the boundary area, for each pixel point in the pixel area, the second sampling area corresponding to the pixel point and the area weight of each sampling point in the second sampling area are determined, and the blurred pixel value of the pixel point is determined based on the area weight.
[0097] It should be noted that, when the category of the pixel block indicates that the pixel block belongs to the boundary area, the process of determining, for each pixel point in the pixel area, the second sampling area to which the pixel point belongs and the area weight of each sampling point in the second sampling area, and determining the blurred pixel value of the pixel point based on the area weight is similar to the above-mentioned process of determining, for each pixel point in the pixel area, the first sampling area corresponding to the pixel point and the area weight of each sampling point in the first sampling area, and determining the blurred pixel value of the pixel point based on the area weight when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, except that the number of pixels included in the first sampling area is different from the number of pixels included in the second sampling area, and the number of pixels included in the second sampling area is greater than the number of pixels included in the first sampling area.
[0098] For example, referring to FIG7, FIG7 is a schematic diagram of blurring a pixel area based on different blurring methods provided by an embodiment of the present application. Based on FIG7, 701 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area and the corresponding pixel area is blurred. 702 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area and when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, and 703 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area and when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area. The foreground area or the background area, when the category of the pixel block indicates that the pixel block belongs to the boundary area, the image obtained when the corresponding pixel area is blurred. Here, when the category of the pixel block indicates that the pixel block belongs to the focus area, the corresponding pixel area is blurred to obtain the image shown in 701, and then based on the image shown in 701, the pixel area corresponding to the pixel block belonging to the foreground area or the background area is blurred accordingly to obtain the image shown in 702, and then based on the image shown in 702, the pixel area corresponding to the pixel block belonging to the boundary area is blurred accordingly to obtain the image shown in 703, which is a blurred image.
[0099] In some embodiments, in addition to generating a blurred image based on the blurred pixel values of each pixel point in the pixel area, a transition coefficient from the foreground area to the background area can also be generated, so as to generate a regional transition image corresponding to the image to be rendered based on the transition coefficient. Here, the regional transition image is used to indicate the degree of mixing between the foreground area and the background area in the image to be rendered. The transition coefficient includes a first transition coefficient, a second transition coefficient and a third transition coefficient. When the category of the pixel block indicates that the pixel block belongs to the focus area, the first transition coefficient is obtained; when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, the second transition coefficient is obtained; when the category of the pixel block indicates that the pixel block belongs to the boundary area, the third transition coefficient is obtained; based on the first transition coefficient, the second transition coefficient and the third transition coefficient, the regional transition image corresponding to the image to be rendered is generated.
[0100] For example, referring to FIG8 , FIG8 is a schematic diagram corresponding to a blurred image and a regional transition image provided in an embodiment of the present application. Based on FIG8 , 801 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area and the corresponding pixel area is blurred. 802 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area and when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area. 803 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area, when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, and when the category of the pixel block indicates that the pixel block belongs to the boundary area and the corresponding pixel area is blurred, that is, a blurred image. 804 shows an image corresponding to the first transition coefficient obtained when the category of the pixel block indicates that the pixel block belongs to the focus area. 805 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area and When the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, the images corresponding to the first transition coefficient and the second transition coefficient are obtained. 806 shows the images corresponding to the first transition coefficient, the second transition coefficient and the third transition coefficient obtained when the category of the pixel block indicates that the pixel block belongs to the focus area, when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, and when the category of the pixel block indicates that the pixel block belongs to the junction area, that is, the regional transition image. Here, when the category of the pixel block indicates that the pixel block belongs to the focus area, the regional transition image corresponding to the first transition coefficient as shown in 804 is obtained, and then based on the pixel block belonging to the foreground area or the background area, the second transition coefficient is obtained, and based on the second transition coefficient and the first transition coefficient, the image shown in 805 is determined. Finally, based on the pixel block belonging to the junction area, the third transition coefficient is obtained, and based on the first transition coefficient, the second transition coefficient and the third transition coefficient, the image shown in 806, that is, the regional transition image, is determined.
[0101] In some embodiments, after determining the pixel area of the pixel block in the image to be rendered based on the position of each pixel block in the category in the depth image, the pixel area can be pre-blurred to obtain a pre-blurred image, and then the pre-blurred image can be blurred to obtain a blurred image. The process of pre-blurring the pixel area to obtain the pre-blurred image can be, based on the category of the pixel block corresponding to the pixel area, obtaining a pre-blurring method corresponding to the category; based on the pre-blurring method, pre-blurring the pixel area to obtain a pre-blur value of each pixel in the pixel area, and generating a pre-blurred image based on the pre-blurring value; then, based on the position of the pixel area in the image to be rendered, determining the pre-blurred area corresponding to the pixel area in the pre-blurred image, and then, based on the blurring method corresponding to the category, blurring the pixel area to obtain a blurred image can be, based on the blurring method corresponding to the category, blurring the pre-blurred area corresponding to the pixel area to obtain a blurred image.
[0102] It should be noted that there are multiple categories of pixel blocks corresponding to pixel areas. When pixel blocks belong to different categories, that is, to different areas, the pre-blur processing methods corresponding to the categories are obtained. Therefore, based on the pre-blur processing methods, the pixel area is pre-blurred to obtain the pre-blur value of each pixel point in the pixel area. The process is also different. Next, when the pixel blocks corresponding to the pixel area belong to different categories, the pixel area is pre-blurred based on the pre-blur processing methods corresponding to the categories, and the process of obtaining the pre-blur value of each pixel point in the pixel area is explained.
[0103] In some embodiments, when the category of the pixel block indicates that the pixel block belongs to the focus area, no pre-blurring process is performed on the pixel area, that is, the pixel value of each pixel in the pixel area is directly determined as the pre-blurred pixel value of the corresponding pixel.
[0104] In other embodiments, when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, for each pixel point in the pixel area, a first sampling area corresponding to the pixel point and multiple sampling points corresponding to the pixel point in the first sampling area are determined; the depth difference between each sampling point and the pixel point is obtained respectively, and based on the depth difference, the pre-blurred pixel value of the pixel point is determined.
[0105] In actual implementation, for the process of determining the first sampling area corresponding to the pixel point and the multiple sampling points corresponding to the pixel point in the first sampling area, first, as shown in formula (2), the sampling radius of the pixel point is calculated, and then the first sampling area for the pixel point is determined based on the sampling radius, and the multiple sampling points corresponding to the pixel point in the first sampling area are determined; then, the depth difference between each sampling point and the pixel point is obtained respectively, so that the process of determining the pre-blurred pixel value of the pixel point in the first sampling area based on the depth difference can be, for each sampling point, based on the depth difference, obtaining the first color of the pixel point The first color value and the first weight of the corresponding pixel point, as well as the second color value of the sampling point and the second weight of the corresponding sampling point are weightedly summed based on the first color value, the first weight, the second color value and the second weight to obtain a weighted color value for the sampling point, where the sum of the first weight and the second weight is 1. Then, the weighted color values of the sampling points are accumulated and summed to obtain the sum of the weighted color values, and the ratio of the sum of the weighted color values to the number of the plurality of sampling points in the first sampling area is obtained to obtain a target color value for the pixel point, and the target color value is used as the pre-blurred pixel value corresponding to the pixel point.
[0106] It should be noted that if the depth of the sampling point is close to the depth of the current pixel (that is, the pixel), the color weight of the sampling point is large, otherwise the color weight is small. For the depth difference between each sampling point and the pixel, for each sampling point, when the depth difference is large, the color weight of the sampling point is small, and when the depth difference is small, the color weight of the sampling point is large. At the same time, the sum of the color weight of the sampling point and the color weight of the current pixel is 1. Therefore, based on the depth difference, the first weight of the corresponding pixel, that is, the color weight of the corresponding pixel, and the second weight of the corresponding sampling point, that is, the color weight of the corresponding sampling point, are obtained.
[0107] It should be noted that, unlike the process of determining the blurred pixel value described above, the sampling points here cannot include the pixel point. At the same time, for each pixel point, there is a corresponding pre-set second mapping relationship, which is used to indicate the correspondence between the depth difference between the sampling point corresponding to the pixel point and the pixel point, and the color weight of the sampling point. Therefore, for each sampling point, based on the depth difference, the process of obtaining the first color value of the pixel point and the first weight of the corresponding pixel point, as well as the second color value of the sampling point and the second weight of the corresponding sampling point can be, for example, obtaining the pre-set second mapping relationship, and for each sampling point, determining the second weight corresponding to the sampling point based on the depth difference and the second mapping relationship; performing a subtraction process on the target parameter, i.e., 1, and the second weight to obtain the first weight of the pixel point.
[0108] In other embodiments, when the category of the pixel block indicates that the pixel block belongs to the boundary area, for each pixel point in the pixel area, a second sampling area corresponding to the pixel point and multiple sampling points corresponding to the pixel point in the second sampling area are determined; the depth difference between each sampling point and the pixel point is obtained, and based on the depth difference, the pre-blurred pixel value of the pixel point is determined.
[0109] It should be noted that when the category of the pixel block indicates that the pixel block belongs to the boundary area, determining, for each pixel in the pixel area, the second sampling area to which the pixel belongs and multiple sampling points corresponding to the pixel in the second sampling area, then obtaining a depth difference between each sampling point and the pixel, and determining the pre-blurred pixel value for the pixel based on the depth difference is similar to the above-mentioned process of determining, for each pixel in the pixel area, the first sampling area to which the pixel belongs and multiple sampling points corresponding to the pixel in the first sampling area, then obtaining a depth difference between each sampling point and the pixel, and determining the pre-blurred pixel value for the pixel based on the depth difference when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, except that the number of pixels included in the first sampling area is different from the number of pixels included in the second sampling area, and the number of pixels included in the second sampling area is greater than the number of pixels included in the first sampling area.
[0110] In some embodiments, in addition to pre-blurring the pixel area to obtain a pre-blurred image, a region division image corresponding to the image to be rendered may be generated. This may be done by determining the focus area in the image to be rendered when the category of the pixel block indicates that the pixel block belongs to the focus area; determining the foreground area and background area in the image to be rendered when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area; and determining the boundary area between the foreground area and the background area in the image to be rendered when the category of the pixel block indicates that the pixel block belongs to the boundary area. Thus, based on the focus area, foreground area, background area, and boundary area, a region division image corresponding to the image to be rendered is generated. In the subsequent process, based on the region division image and the blurring method corresponding to the category corresponding to each area in the region division image, the corresponding pixel area in the pre-blurred image is blurred to obtain a blurred image.
[0111] For example, referring to FIG9, FIG9 is a schematic diagram of a region division image and a pre-blurred image provided by an embodiment of the present application. Based on FIG9, 907 shows an image to be rendered, 904 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area and the corresponding pixel area is pre-blurred, 905 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area and when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, the corresponding pixel area is pre-blurred, and 906 shows an image obtained when the category of the pixel block indicates that the pixel block belongs to the focus area. , when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, and when the category of the pixel block indicates that the pixel block belongs to the boundary area, the image obtained when the corresponding pixel area is pre-blurred, 901 shows an image including the focus area when the category of the pixel block indicates that the pixel block belongs to the focus area, 902 shows an image including the focus area, the foreground area and the background area when the category of the pixel block indicates that the pixel block belongs to the focus area, and when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, 903 shows an image including the focus area, the foreground area and the background area when the category of the pixel block indicates that the pixel block belongs to the When the pixel block belongs to the focus area, when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, and when the category of the pixel block indicates that the pixel block belongs to the boundary area, an image including the focus area, the foreground area, the background area and the boundary area is determined. Here, when the category of the pixel block indicates that the pixel block belongs to the focus area, a pre-blur processing is performed on the corresponding pixel area in the rendered image to obtain an image as shown in 904, and after obtaining the image including the focus area as shown in 901, based on the image shown in 904, a corresponding pre-blur processing is performed on the pixel area corresponding to the pixel block belonging to the foreground area or the background area , an image as shown in 905 is obtained, and based on the pixel blocks belonging to the foreground area or the background area, and the image shown in 901, an image as shown in 902 including the focus area, the foreground area and the background area is determined. Then, based on the image shown in 905, the pixel area corresponding to the pixel blocks belonging to the boundary area is pre-blurred to obtain an image as shown in 906, which is also a pre-blurred image. Based on the pixel blocks belonging to the junction area, and the image shown in 902, an image as shown in 903, which is also a region division image, is determined including the focus area, the foreground area, the background area and the boundary area.
[0112] In some embodiments, after dilating each pixel block to obtain a dilated pixel block, and classifying at least two dilated pixel blocks based on the depth of field parameters corresponding to each dilated pixel block to obtain the category to which each dilated pixel block belongs, a pre-blurring processing method corresponding to the category may be obtained based on the category of the dilated pixel block corresponding to the pixel region; pre-blurring the pixel region based on the pre-blurring processing method to obtain a pre-blur value for each pixel in the pixel region; and generating a pre-blurred image based on the pre-blurring value. Thus, based on the region division image and the blurring processing method corresponding to the category of the pixel blocks included in each region, blurring the corresponding pixel region in the pre-blurred image to obtain a blurred image may be performed by obtaining a region division image corresponding to the image to be rendered; then, based on the category of the dilated pixel block corresponding to the pixel region, obtaining a blurring processing method corresponding to the category; then, based on the region division image and the blurring processing method corresponding to the category corresponding to each region in the region division image, blurring the corresponding pixel region in the pre-blurred image to obtain a blurred image; and obtaining a region transition image corresponding to the image to be rendered. In a subsequent process, a depth of field image corresponding to the image to be rendered is obtained based on the region transition image and the blurred image.
[0113] For example, referring to FIG10, FIG10 is a schematic diagram of a pre-blurred image and a regional transition image provided by an embodiment of the present application. Based on FIG10, 1001 shows an image obtained when the category of the expanded pixel block indicates that the expanded pixel block belongs to the focus area, and when the category of the expanded pixel block indicates that the expanded pixel block belongs to the foreground area or the background area, the image obtained when the corresponding pixel area in the pre-blurred image is blurred. 1003 shows an image obtained when the category of the expanded pixel block indicates that the expanded pixel block belongs to the focus area, and when the category of the expanded pixel block indicates that the expanded pixel block belongs to the foreground area or the background area, and when the category of the expanded pixel block indicates that the expanded pixel block belongs to the boundary area, the image obtained when the corresponding pixel area in the pre-blurred image is blurred, that is, the blurred image; 1004 shows the first transition coefficient corresponding to the first transition coefficient obtained when the category of the expanded pixel block indicates that the expanded pixel block belongs to the focus area. 1005 shows an image corresponding to the first transition coefficient and the second transition coefficient when the dilated pixel block category indicates that the dilated pixel block belongs to the focus area, and when the dilated pixel block category indicates that the dilated pixel block belongs to the foreground area or the background area. 1006 shows an image corresponding to the first transition coefficient, the second transition coefficient, and the third transition coefficient when the dilated pixel block category indicates that the dilated pixel block belongs to the focus area, when the dilated pixel block category indicates that the dilated pixel block belongs to the foreground area or the background area, and when the dilated pixel block category indicates that the dilated pixel block belongs to the boundary area, i.e., a regional transition image. 1007 shows an image corresponding to the dilated pixel block obtained by performing the dilation process. 1008 shows a region division image. 1009 shows a pre-blurred image. Based on the region division image shown in 1008, the pre-blurred image shown in 1009, and the image corresponding to the dilated pixel block obtained by performing the dilation process shown in 1007, the blurred image shown in 1003 and the regional transition image shown in 1006 are determined.
[0114] Step 104 : obtaining a depth of field image corresponding to the image to be rendered based on the image to be rendered and the blurred image.
[0115] In actual implementation, the process of performing image rendering based on the image to be rendered and the blurred image to obtain the depth of field image corresponding to the image to be rendered can be: upsampling the blurred image to obtain the upsampled blurred image; performing image fusion on the image to be rendered and the upsampled blurred image to obtain a fused image; and performing image rendering on the fused image to obtain the depth of field image corresponding to the image to be rendered.
[0116] In some embodiments, a depth of field image corresponding to the image to be rendered can also be obtained based on the regional transition image and the blurred image. Here, first, based on the regional transition image and the depth image of the image to be rendered, the image to be rendered and the blurred image are rendered to obtain a depth of field image corresponding to the image to be rendered, wherein the regional transition image corresponding to the image to be rendered is obtained, and the regional transition image is used to indicate the degree of mixing of the foreground area and the background area in the image to be rendered; the regional transition image is upsampled to obtain an upsampled regional transition image; thus, the process of performing image rendering based on the image to be rendered and the blurred image to obtain the depth of field image corresponding to the image to be rendered can be: upsampling the blurred image to obtain an upsampled blurred image; performing image fusion on the image to be rendered and the upsampled blurred image based on the depth image and the upsampled regional transition image to obtain a fused image; and performing image rendering on the fused image to obtain a depth of field image corresponding to the image to be rendered.
[0117] Exemplarily, refer to Figure 11, which is a schematic diagram of an embodiment of the present application, providing an image rendering based on the image to be rendered and the blurred image to obtain a depth of field image corresponding to the image to be rendered. Based on Figure 11, 1101 is shown as the image to be rendered, 1102 is shown as the depth image corresponding to the image to be rendered, 1103 is shown as the blurred image, 1104 is shown as the regional transition image, and 1105 is shown as the depth of field image corresponding to the image to be rendered. Here, the regional transition image shown in 1104 is upsampled to obtain an upsampled regional transition image, and then the blurred image shown in 1103 is upsampled to obtain an upsampled blurred image; thus, based on the depth image shown in 1102 and the upsampled regional transition image, the image to be rendered shown in 1101 and the upsampled blurred image are image fused to obtain a fused image; the fused image is image rendered to obtain a depth of field image corresponding to the image to be rendered shown in 1105.
[0118] In some embodiments, the blurred image includes multiple image blocks, so after blurring the pixel area based on the blur processing method corresponding to the category to obtain the blurred image, the following processing can also be performed on each pixel point in the blurred image: determine the image block to which the pixel point belongs; take the median value from the pixel values of the multiple pixel points included in the image block, and determine the median value as the target pixel value of the pixel point; generate a target blurred image based on the target pixel value of each pixel point in the blurred image; thus, the process of obtaining the depth of field image corresponding to the image to be rendered based on the image to be rendered and the blurred image can be, based on the image to be rendered and the target blurred image, obtaining the depth of field image corresponding to the image to be rendered.
[0119] By applying the above embodiment, for each pixel in the blurred image, the image block to which the pixel belongs is determined, and the median value is taken from the pixel values of the multiple pixels included in the image block, and the median value is determined as the target pixel value of the pixel to achieve filtering of the blurred image, thereby effectively removing highlight noise in the picture.
[0120] In some embodiments, the regional transition image includes multiple image blocks, so that after blurring the pixel area based on the blurring processing method corresponding to the category to obtain a blurred image, the following processing can also be performed on each pixel point in the regional transition image: determine the image block to which the pixel point belongs; take the middle value from the pixel values of the multiple pixel points included in the image block, and determine the middle value as the target pixel value of the pixel point; generate a target regional transition image based on the target pixel value of each pixel point in the regional transition image; thus, based on the regional transition image and the depth image, the process of obtaining a depth of field image corresponding to the image to be rendered and the target blurred image can be, based on the target regional transition image and the depth image, obtaining a depth of field image corresponding to the image to be rendered and the target blurred image.
[0121] In practical applications, for each pixel point in the regional transition image, the image block to which the pixel point belongs is determined, and the median value is taken from the pixel values of multiple pixels included in the image block, and the median value is determined as the target pixel value of the pixel point to filter the regional transition image, thereby effectively removing the highlight noise in the picture.
[0122] It should be noted that the size of the image blocks in the blurred image and the regional transition image is pre-set, such as the image block can be a pixel area including 9*9 pixels; the process of obtaining the depth of field image corresponding to the image to be rendered based on the image to be rendered and the target blurred image is similar to the process of obtaining the depth of field image corresponding to the image to be rendered based on the image to be rendered and the blurred image in the previous text. At the same time, the process of performing image rendering on the image to be rendered and the target blurred image based on the target regional transition image and the depth image to obtain the depth of field image corresponding to the image to be rendered is similar to the process of performing image rendering on the image to be rendered and the blurred image based on the regional transition image and the depth image to obtain the depth of field image corresponding to the image to be rendered. This will not be elaborated in the embodiments of the present application.
[0123] Applying the above-mentioned embodiment of the present application, the depth image of the image to be rendered is first pixel-blocked to obtain at least two pixel blocks, and based on the depth of field parameters corresponding to each pixel block, the at least two pixel blocks are classified to obtain the category to which each pixel block belongs. Then, according to the different categories to which each pixel block belongs, the pixel area corresponding to the pixel block in the image to be rendered is blurred according to the blurring method corresponding to the category to obtain a blurred image. Finally, based on the image to be rendered and the blurred image, a depth of field image corresponding to the image to be rendered is obtained. In this way, the pixel blocks are classified according to the rendering parameters corresponding to different pixel blocks in the rendering process and the complexity of the rendering process, so that the rendering process corresponding to the category is executed for pixel blocks of different categories to obtain the final depth of field image. In this way, not only the rendering effect when rendering the depth of field image is improved, but also the rendering process when rendering the depth of field image is reduced, thereby reducing performance consumption and improving the efficiency of image processing.
[0124] The following describes an exemplary application of the embodiments of the present application in a practical application scenario.
[0125] The inventors have discovered that for the rendering process of the depth of field image, that is, the rendering process of the depth of field of the image, related technologies such as UE4 provide two depth of field implementation methods on the mobile platform, namely FastBlur Dof (fast blurred depth of field) and Gaussian Dof (Gaussian depth of field). The implementation methods of the two are roughly the same. The basic principle is to achieve the depth of field effect by specifying parameters such as the focal region (Focal Region), the foreground transition region (Near Transition), the background transition region (Far Transition), and the camera focal length (Focal Distance). In addition to the above two mobile-side depth of field implementations, UE4 provides a more complex depth of field implementation method on the PC side (computer side), namely Diaphragm Dof (aperture depth of field), which performs close to the result of real optical simulation. However, compared to using a camera in real life, the user only needs to control the aperture size, camera focal length, and focus distance to freely control the degree of blur of the depth of field. The two mobile-side depths of field of UE4 bring many non-physical parameters. Every time the user focuses on the picture, he needs to repeatedly adjust parameters such as the transition area and transition blur degree, which results in a very unsatisfactory blur effect. At the same time, the higher-quality Gaussian Dof on the mobile terminal uses Gaussian blur to separate the foreground and background, and then superimposes it with the original clear image. In areas where the COC changes greatly (such as the boundary between the focus and the background), the blur effect of the depth of field image is reduced;
[0126] As for Diaphragm Dof, a method of rendering depth of field images based on purely physical geometric optics formulas, users only need to adjust the three parameters of aperture size, camera focal length, and focus distance to achieve a nearly perfect depth of field effect. However, even the lowest quality Diaphragm Dof requires an astonishing 17 passes, which brings about bandwidth consumption and time consumption that mobile devices cannot bear. Bandwidth consumption will directly affect the heating of the phone, and time consumption will affect the frame rate of the game. In addition, for the Diaphragm Dof method, when executing an if operation in the Shader (shader), if the if contains a dynamic variable, it depends on whether all threads in the warp pass or do not pass the if branch, otherwise an empty wait operation of the thread will be generated. If the Shader is too complex, it may also cause problems such as register overflow, which are all operations that increase rendering time.
[0127] Based on this, the embodiment of the present application provides a post-processing depth of field implementation method based on block rendering. Compared with the related technology that originally used the execution of if branches in the Shader to implement the depth of field rendering process, through the technical solution of the embodiment of the present application, the depth of field rendering can be simply represented by the circle of confusion (COC), and different operations are performed on pixels with different COCs. Among them, the pixel area with a smaller COC can be considered as the focus area (Early Exit), and the current clear pixel is directly returned; the pixel area with a larger COC but smaller change can be considered as a cheap area (Cheap) because the Shader calculation amount is small; the area with a larger COC and larger change can be considered as an expensive area (Expensive). In this way, through the above classification method, the input pixels can be divided into blocks in advance, and then only different Shader calls need to be executed on different pixel blocks, thereby performing a series of steps including pre-filtering, main filtering, post-filtering, upsampling, etc. In this way, it is possible to effectively avoid executing if operations in an extremely complex Shader, which not only improves the rendering effect when rendering the depth of field image, but also reduces the rendering process when rendering the depth of field image, reduces performance consumption, and improves the efficiency of image processing.
[0128] It should be noted that, referring to Figure 12, Figure 12 is a schematic diagram of the effect of post-processing depth of field rendering based on block rendering provided in an embodiment of the present application. Based on Figure 12, the post-processing depth of field effect based on block rendering of this application is shown in Figure 12. It can be determined that the effect shown in Figure 12 is very close to the Diaphragm Dof effect provided by the UE4 PC end in the related technology, but the bandwidth and time consumption are greatly reduced.
[0129] Next, the solution of post-processing depth of field rendering based on block rendering provided by the embodiment of the present application is explained from the technical perspective. Referring to Figure 13, Figure 13 is a technical architecture diagram of post-processing depth of field rendering based on block rendering provided by the embodiment of the present application. Based on Figure 13, the method of post-processing depth of field rendering based on block rendering provided by the embodiment of the present application is implemented through the six steps of Tiling Pass (blocking), TileDilate Pass (block expansion), Prefilter Pass (pre-filtering), MainFilter Pass (main blurring), PostFilter Pass (post-filtering) and Upsample Pass (upsampling).
[0130] For the blocking (pixel blocking) process, as shown in Figure 5, the full-resolution depth map is first input, and then a 16×16 pixel area is used as a Tile (pixel block), and the rendering target used to indicate the minimum depth (TileMinDepth), maximum COC (TileMaxCOC), and minimum COC (TileMinCOC) of the pixels in the Tile is output.
[0131] For the block expansion process, as shown in Figure 6, the Tiling The output rendering target of Pass is expanded. Here, only after the expansion process can the pixel area with obvious COC changes (such as the pixels around the edge of the character) be processed more effectively, and the rendering target after the expansion process (expanded pixel block) is recorded as NeighborTileMinDepthMaxCOC; at the same time, during the block expansion process, each tile is also classified into EarlyExitQueue (first category), CheapQueue (second category), and ExpensiveQueue (third category), among which the maximum radius MaxCOC (maximum value of the circle of confusion) and the minimum radius MinCOC (minimum value of the circle of confusion) corresponding to each pixel block are determined. If MaxCOC is less than 1, the tile is considered to be in the focus area, and the tile is classified as EarlyExitQueue; if MaxCOC-MinCOC<1, the tile is considered to be in the area where the COC changes little, and the tile is classified as CheapQueue; for tiles in other cases, the corresponding tiles are classified as ExpensiveQueue.
[0132] It should be noted that this process can also output the first 12 bytes to record the number of different types of tiles, and the last 36 bytes are used as the Indirect Buffer for the result of Indirect Dispatch, so that the task scheduling module can record the number of Groups for each type of tile to be Indirect Dispatched (indirectly distributed) based on the result.
[0133] For the pre-filtering (pre-blurring) process, as shown in Figure 9, it is first necessary to distinguish different areas in the image to be rendered, such as the foreground area, background area, focus area, and the boundary area between the foreground area and the background area, and then perform pre-filtering. Here, if pre-filtering is not performed, the subsequent MainFilter Pass will directly sample the original image (image to be rendered). Since the sampling is performed in a circular manner and the number of sampling is limited, it will cause undersampling problems, thereby reducing the effect of blurring.
[0134] In actual implementation, the pre-filtering process mainly outputs two rendering targets, namely Presort (region division image) and Prefilter (pre-blurred image). The resolution of these two rendering targets is half of the input image (image to be rendered); among them, Presort stores three values, namely the COC of the current pixel, background factor (Background Factor), and foreground factor (Foreground Factor), while Prefilter stores the filtered half-resolution image. Here, Presort and Prefilter are obtained by three consecutive Indirect Dispatches. The three Indirect Dispatches can be executed in sequence or in parallel to reduce rendering time. This is not limited in the embodiments of the present application.
[0135] Next, the execution process of three Indirect Dispatches is explained. When the pixel block is in the EarlyExitQueue (when the pixel block is in the focus area), the current pixel is returned directly (the pixel value of the current pixel is used as the pre-blurred pixel value); when the pixel block is in the CheapQueue (when the pixel block is in the background area or the foreground area), the sampling radius is first calculated, and then based on the sampling radius, the points around the current pixel are sampled and the colors are accumulated. Here, the strategy of color accumulation is that if the depth of the sampling point is close to the depth of the current point (current pixel), the weight of the sampling point is large, otherwise the weight is small. Based on the depth difference, the first color value of the current point and the first weight corresponding to the current point, as well as the second color value of the sampling point and the second weight corresponding to the sampling point are obtained, thereby performing weighted summation based on the first color value, the first weight, the second color value and the second weight to obtain the color value for the current point. The weighted color value of the sampling point, where the sum of the first weight and the second weight is 1, is then accumulated and summed to obtain the sum of the weighted color values, and the ratio of the sum of the weighted color values to the number of sampling points is obtained to obtain the pre-blurred pixel value corresponding to the current point; when the pixel block is in the ExpensiveQueue (when the pixel block is in the boundary area between the background area and the foreground area), the process of determining the pre-blurred pixel value of the current point is the same as the process of determining the pre-blurred pixel value of the current point when the pixel block is in the CheapQueue, except that the sampling radius determined by the two processes is different, and therefore, the number of sampling points is also different. The number of sampling points corresponding to the pixel block in the ExpensiveQueue is greater than the number of sampling points corresponding to the pixel block in the CheapQueue.
[0136] As shown in Figure 10, the main blur (blur processing) process uses NeighborTileMinDepthMaxCOC, Prefilter, and Presort as inputs, and this pass performs the actual blur operation. The Mainfilter Pass also calls Indirect Dispatch three times to perform different ring sampling operations on different types of tiles. For example, when the pixel block is in the EarlyExitQueue, the current pixel is directly returned, while when the pixel block is in the CheapQueue and ExpensiveQueue, different ring sampling strategies are implemented according to MaxCOC. Among them, the number of samples performed when the pixel block is in the ExpensiveQueue is the largest. During ring sampling, the cumulative values of the background color and foreground color are calculated based on the foreground factor and background factor in Presort.
[0137] Next, the execution process of three Indirect Dispatch is explained. When the pixel block is in the EarlyExitQueue (when the pixel block is in the focus area), the current pixel is directly returned (the pre-blurred pixel value of the current pixel is used as the blurred pixel value); when the pixel block is in the CheapQueue (when the pixel block is in the background area or foreground area), the COC, background factor, and foreground factor of the current pixel in the Presort are first obtained, and then the background weight and foreground weight for the current point are obtained based on the COC, background factor, and foreground factor of the current point. weight), then calculate the sampling radius for the current point, and then determine the sampling area corresponding to the current point based on the sampling radius. Thus, based on the sampling area and whether the area corresponding to the current point is the foreground area or the background area, the color value (fuzzy value) of the current point is determined by formula (3) and formula (4); when the pixel block is in the ExpensiveQueue (when the pixel block is in the boundary area between the background area and the foreground area), the process of determining the fuzzy pixel value of the current point is the same as the process of determining the fuzzy pixel value of the current point when the pixel block is in the CheapQueue, except that the sampling radius determined by the two processes is different, so the number of sampling points is also different. The number of sampling points corresponding to the pixel block in the ExpensiveQueue is greater than the number of sampling points corresponding to the pixel block in the CheapQueue.
[0138] For the post-filtering process, median filtering is required after the MainFilter Pass to remove noise. By sampling the two textures of MainFilter (blurred image) and Alpha (region transition image), median filtering is performed on the 9×9 pixels around each pixel, which can effectively remove the highlight noise in the picture.
[0139] For the upsampling process, as shown in Figure 11, the process takes full-resolution SceneColor (image to be rendered) and SceneDepth (depth image), half-resolution PostFilter (target blurred image) and PostFilterAlpha (target area division image) as input, and then fuses SceneColor and PostFilter based on SceneDepth and PostFilterAlpha, and finally outputs a depth of field image comparable to Diaphragm Dof.
[0140] It should be noted that different rendering grading configurations can also be set, among which Tiling Pass, Tile Dilate Pass, MainFilter Pass, and Upsample Pass are the passes that must be executed, that is, by executing the four processes of Tiling Pass, Tile Dilate Pass, MainFilter Pass, and Upsample Pass, the lowest quality depth of field image is output; or by executing the five processes of Tiling Pass, Tile Dilate Pass, Prefilter Pass, MainFilter Pass, and Upsample Pass, the intermediate quality depth of field image is output; or by executing the six processes of Tiling Pass, Tile Dilate Pass, Prefilter Pass, MainFilter Pass, PostFilter Pass, and Upsample Pass, the highest quality depth of field image is output.
[0141] In this way, this application achieves an effect similar to UE4's Dipahragm DoF on PC with fewer rendering times and less bandwidth, while ensuring that it can provide high-quality depth of field on mobile devices. In addition, this application has also been tested on mobile devices. By adjusting parameters such as aperture and focal length, different parameters will lead to different blur strategies and shader complexity, which can also achieve the effect of greatly reducing bandwidth and time consumption.
[0142] Applying the above-mentioned embodiment of the present application, the depth image of the image to be rendered is first pixel-blocked to obtain at least two pixel blocks, and based on the depth of field parameters corresponding to each pixel block, the at least two pixel blocks are classified to obtain the category to which each pixel block belongs. Then, according to the different categories to which each pixel block belongs, the pixel area corresponding to the pixel block in the image to be rendered is blurred according to the blurring method corresponding to the category to obtain a blurred image. Finally, based on the image to be rendered and the blurred image, a depth of field image corresponding to the image to be rendered is obtained. In this way, the pixel blocks are classified according to the rendering parameters corresponding to different pixel blocks in the rendering process and the complexity of the rendering process, so that the rendering process corresponding to the category is executed for pixel blocks of different categories to obtain the final depth of field image. In this way, not only the rendering effect when rendering the depth of field image is improved, but also the rendering process when rendering the depth of field image is reduced, thereby reducing performance consumption and improving the efficiency of image processing.
[0143] The following further describes an exemplary structure of a depth-of-field image rendering device 455 provided in an embodiment of the present application implemented as a software module. In some embodiments, as shown in FIG2 , the software module stored in the depth-of-field image rendering device 455 in the memory 450 may include:
[0144] A first acquisition module 4551 is configured to acquire a depth image of an image to be rendered, and perform pixel blocking on the depth image to obtain at least two pixel blocks;
[0145] a second acquisition module 4552 configured to acquire a depth of field parameter of each pixel block, and classify the at least two pixel blocks based on the depth of field parameter to obtain a category to which each pixel block belongs;
[0146] a blur processing module 4553 configured to determine, for each pixel block of the category, a pixel region of the pixel block of the category in the image to be rendered based on a position of each pixel block in the category in the depth image, and perform blur processing on the pixel region based on a blur processing method corresponding to the category to obtain a blurred image;
[0147] The rendering module 4554 is configured to obtain a depth of field image corresponding to the image to be rendered based on the image to be rendered and the blurred image.
[0148] In some embodiments, the first acquisition module 4551 is further configured to acquire the image to be rendered and construct a spatial coordinate system corresponding to the image to be rendered; based on the image to be rendered, determine the height value of each pixel point in the image to be rendered in the spatial coordinate system; and based on the height value, generate a depth image of the image to be rendered.
[0149] In some embodiments, the second acquisition module 4552 is further configured to obtain the size of a preset pixel block; based on the size of the pixel block, the multiple pixel points included in the depth image are divided to obtain at least two pixel blocks, and the number of pixel points included in each pixel block is the same.
[0150] In some embodiments, the apparatus further includes a dilation module configured to dilate each pixel block to obtain an expanded pixel block; the second acquisition module 4552 is further configured to obtain a depth of field parameter of each expanded pixel block.
[0151] In some embodiments, the depth of field parameters include the maximum and minimum values of the circle of confusion of the pixel block, and the second acquisition module 4552 is further configured to, for each pixel block, subtract the maximum and minimum values of the circle of confusion of the pixel block to obtain a change value of the circle of confusion of the pixel block; based on the change value and the maximum value of the circle of confusion of each pixel block, classify the at least two pixel blocks to obtain the category to which each pixel block belongs.
[0152] In some embodiments, the second acquisition module 4552 is further configured to perform the following processing on each of the pixel blocks: when the maximum value of the circle of confusion of the pixel block is less than the target threshold, the category to which the pixel block belongs is determined to be the first category, and the first category is used to indicate that the pixel block belongs to the in-focus area in the image to be rendered; when the change value of the circle of confusion of the pixel block is less than the target threshold, the category to which the pixel block belongs is determined to be the second category, and the second category is used to indicate that the pixel block belongs to the foreground area or the background area in the image to be rendered; when the change value of the circle of confusion of the pixel block is not less than the target threshold, the category to which the pixel block belongs is determined to be the third category, and the third category is used to indicate that the pixel block belongs to the boundary area between the foreground area and the background area in the image to be rendered.
[0153] In some embodiments, the second acquisition module 4552 is further configured to divide the image to be rendered into regions to obtain the focus area, foreground area, background area, and the boundary area between the foreground area and the background area of the image to be rendered; for each pixel block, based on the depth of field parameter, determine the image area to which the pixel block belongs in the image to be rendered, and the image area is one of the focus area, the foreground area, the background area and the boundary area; based on the image area to which the pixel block belongs, determine the category to which the pixel block belongs.
[0154] In some embodiments, the image to be rendered includes a focus area, a foreground area, a background area, and a boundary area between the foreground area and the background area. The blur processing module 4553 is further configured to, when the category of the pixel block indicates that the pixel block belongs to the focus area, determine the pixel value of each pixel in the pixel area as the blurred pixel value of the corresponding pixel; when the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, determine, for each pixel in the pixel area, a first sampling area corresponding to the pixel point and a region weight of each sampling point in the first sampling area, and determine the blurred pixel value of the pixel point based on the region weight; when the category of the pixel block indicates that the pixel block belongs to the boundary area, determine, for each pixel in the pixel area, a second sampling area corresponding to the pixel point and a region weight of each sampling point in the second sampling area, and determine the blurred pixel value of the pixel point based on the region weight; wherein the number of pixels included in the first sampling area is different from the number of pixels included in the second sampling area; and generate the blurred image for each pixel area based on the blurred pixel value of each pixel in the pixel area.
[0155] In some embodiments, the device also includes a pre-blur processing module, which is configured to obtain a pre-blur processing method corresponding to the category of the pixel block corresponding to the pixel area based on the category; based on the pre-blur processing method, pre-blur processing is performed on the pixel area to obtain a pre-blur value of each pixel point in the pixel area, and a pre-blurred image is generated based on the pre-blur value; based on the position of the pixel area in the image to be rendered, a pre-blurred area corresponding to the pixel area in the pre-blurred image is determined; the blur processing module 4553 is also configured to blur the pre-blurred area corresponding to the pixel area based on the blur processing method corresponding to the category to obtain a blurred image.
[0156] In some embodiments, the blurred image includes multiple image blocks, and the device also includes a median filtering module, which is configured to perform the following processing on each pixel point in the blurred image: determine the image block to which the pixel point belongs; take the median value from the pixel values of the multiple pixel points included in the image block, and determine the median value as the target pixel value of the pixel point; generate a target blurred image based on the target pixel value of each pixel point in the blurred image; the rendering module 4554 is also configured to perform image rendering based on the image to be rendered and the target blurred image to obtain a depth of field image corresponding to the image to be rendered.
[0157] In some embodiments, the device also includes a third acquisition module, which is configured to acquire a regional transition image corresponding to the image to be rendered, and the regional transition image is used to indicate the degree of mixing between the foreground area and the background area in the image to be rendered; upsampling the regional transition image to obtain an upsampled regional transition image; the rendering module 4554 is also configured to upsample the blurred image to obtain an upsampled blurred image; based on the depth image and the upsampled regional transition image, the image to be rendered and the upsampled blurred image are image-fused to obtain a fused image; image rendering is performed on the fused image to obtain a depth of field image corresponding to the image to be rendered.
[0158] The present invention provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the depth-of-field image rendering method described in the present invention, such as the depth-of-field image rendering method shown in FIG3 .
[0159] An embodiment of the present application provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor will execute the depth of field image rendering method provided by the embodiment of the present application, for example, the depth of field image rendering method shown in Figure 3.
[0160] In some embodiments, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disk, or a CD-ROM; or various devices including one or any combination of the above memories.
[0161] In some embodiments, executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0162] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, e.g., in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinating files (e.g., files storing one or more modules, subroutines, or code portions).
[0163] As an example, executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed across multiple sites and interconnected by a communication network.
[0164] It should be noted that in the embodiments of the present application, related data such as images to be rendered are involved. When the embodiments of the present application are applied to specific products or technologies, corresponding licenses or consents need to be obtained, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0165] In summary, the embodiments of the present application have the following beneficial effects:
[0166] (1) According to the rendering parameters corresponding to different pixel blocks in the rendering process and the complexity of the rendering process, the pixel blocks are classified, so that the rendering process corresponding to the category is executed for the pixel blocks of different categories to obtain the final depth of field image. In this way, not only the rendering effect when rendering the depth of field image is improved, but also the rendering process when rendering the depth of field image is reduced, the performance consumption is reduced, and the efficiency of image processing is improved.
[0167] (2) Using fewer rendering times and less bandwidth, we achieve an effect similar to UE4's Dipahragm DoF on PC, while ensuring that it can provide high-quality depth of field on mobile devices. In addition, this application was also tested on mobile devices. By adjusting parameters such as aperture and focal length, different parameters will lead to different blur strategies and shader complexity, which can also achieve the effect of greatly reducing bandwidth and time consumption.
[0168] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the embodiments of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the embodiments of the present application are included in the scope of protection of the embodiments of the present application.
Claims
1. A method for rendering a depth of field image, the method being performed by an electronic device, the method comprising: Obtaining a depth image of the image to be rendered, and dividing the depth image into pixel blocks to obtain at least two pixel blocks; Acquiring a depth of field parameter of each of the pixel blocks, and classifying the at least two pixel blocks based on the depth of field parameter to obtain a category to which each of the pixel blocks belongs; For each of the categories of pixel blocks, based on the position of each pixel block in the category in the depth image, determine the pixel area of the pixel block in the category in the image to be rendered, and perform blur processing on the pixel area based on a blur processing method corresponding to the category to obtain a blurred image; Based on the image to be rendered and the blurred image, a depth of field image corresponding to the image to be rendered is obtained.
2. The method of claim 1, wherein: The step of obtaining a depth image of an image to be rendered includes: Acquire an image to be rendered, and construct a spatial coordinate system corresponding to the image to be rendered; Based on the image to be rendered, determining a height value of each pixel point in the image to be rendered in a spatial coordinate system; Based on the height value, a depth image of the image to be rendered is generated.
3. The method according to any one of claims 1 to 2, wherein: The pixel-blocking of the depth image to obtain at least two pixel blocks includes: Get the size of the preset pixel block; Based on the size of the pixel block, a plurality of pixel points included in the depth image are divided to obtain at least two pixel blocks, and the number of pixel points included in each pixel block is the same.
4. The method according to any one of claims 1 to 3, wherein: After dividing the depth image into pixels and obtaining at least two pixel blocks, the method further includes: Performing expansion processing on each of the pixel blocks to obtain an expanded pixel block; The obtaining of the depth of field parameter of each pixel block includes: The depth of field parameter of each of the dilated pixel blocks is obtained.
5. The method according to any one of claims 1 to 4, wherein: The depth of field parameter includes a maximum value and a minimum value of the circle of confusion of the pixel block, and the at least two pixel blocks are classified based on the depth of field parameter to obtain the category to which each pixel block belongs, including: For each pixel block, subtract the maximum value and the minimum value of the circle of confusion of the pixel block to obtain a change value of the circle of confusion of the pixel block; Based on the change value and the maximum value of the circle of confusion of each pixel block, the at least two pixel blocks are classified to obtain the category to which each pixel block belongs.
6. The method of claim 5, wherein: The classifying the at least two pixel blocks based on the change value and the maximum value of the circle of confusion of each pixel block to obtain the category to which each pixel block belongs includes: The following processing is performed for each pixel block: When the maximum value of the circle of confusion of the pixel block is less than a target threshold, determining the category to which the pixel block belongs to be a first category, where the first category is used to indicate that the pixel block belongs to a focus area in the image to be rendered; When the change value of the circle of confusion of the pixel block is less than a target threshold, determining the category to which the pixel block belongs to be a second category, where the second category is used to indicate that the pixel block belongs to a foreground area or a background area in the image to be rendered; When the change value of the circle of confusion of the pixel block is not less than the target threshold, the category to which the pixel block belongs is determined to be a third category, and the third category is used to indicate that the pixel block belongs to a boundary area between a foreground area and a background area in the image to be rendered.
7. The method according to any one of claims 1 to 6, wherein: The classifying the at least two pixel blocks based on the depth of field parameter to obtain the category to which each of the pixel blocks belongs includes: Dividing the image to be rendered into regions to obtain a focus region, a foreground region, a background region, and a boundary region between the foreground region and the background region of the image to be rendered; For each of the pixel blocks, based on the depth of field parameter, determine the image area to which the pixel block belongs in the image to be rendered, the image area being one of the focus area, the foreground area, the background area and the boundary area; based on the image area to which the pixel block belongs, determine the category to which the pixel block belongs.
8. The method according to any one of claims 1 to 7, wherein: The image to be rendered includes a focus area, a foreground area, a background area, and a boundary area between the foreground area and the background area. Based on a blur processing method corresponding to the category, blur processing is performed on the pixel area to obtain a blurred image, including: When the category of the pixel block indicates that the pixel block belongs to the focus area, determining the pixel value of each pixel point in the pixel area as the blurred pixel value of the corresponding pixel point; When the category of the pixel block indicates that the pixel block belongs to the foreground area or the background area, determining, for each pixel point of the pixel area, a first sampling area corresponding to the pixel point and an area weight of each sampling point in the first sampling area, and determining a blurred pixel value of the pixel point based on the area weight; When the category of the pixel block indicates that the pixel block belongs to the boundary area, determining, for each pixel point in the pixel area, a second sampling area corresponding to the pixel point and an area weight of each sampling point in the second sampling area, and determining a fuzzy pixel value of the pixel point based on the area weight; The number of pixels included in the first sampling area is different from the number of pixels included in the second sampling area; For each of the pixel regions, the blurred image is generated based on the blurred pixel value of each of the pixel points in the pixel region.
9. The method according to any one of claims 1 to 8, wherein: After determining the pixel blocks of the category in the pixel area in the image to be rendered based on the position of each pixel block in the category in the depth image, the method further includes: Based on the category of the pixel block corresponding to the pixel area, obtaining a pre-blur processing method corresponding to the category; Based on the pre-blur processing method, pre-blur processing is performed on the pixel area to obtain a pre-blur value of each pixel in the pixel area, and a pre-blurred image is generated based on the pre-blur value; Determine, based on the position of the pixel area in the image to be rendered, a pre-blurred area in the pre-blurred image corresponding to the pixel area; The step of performing blur processing on the pixel region based on the blur processing method corresponding to the category to obtain a blurred image includes: Based on the blur processing method corresponding to the category, blur processing is performed on the pre-blurred area corresponding to the pixel area to obtain a blurred image.
10. The method according to any one of claims 1 to 9, wherein: The blurred image includes a plurality of image blocks. After the blurred image is obtained by performing the blur processing on the pixel area based on the blur processing method corresponding to the category, the method further includes: The following processing is performed for each pixel in the blurred image: determining the image block to which the pixel belongs; taking a middle value from the pixel values of a plurality of pixels included in the image block, and determining the middle value as the target pixel value of the pixel; Generate a target blurred image based on the target pixel value of each pixel in the blurred image; The obtaining, based on the image to be rendered and the blurred image, a depth of field image corresponding to the image to be rendered comprises: Image rendering is performed based on the image to be rendered and the target blurred image to obtain a depth of field image corresponding to the image to be rendered.
11. The method according to any one of claims 1 to 10, wherein: The method further comprises: Acquire a regional transition image corresponding to the image to be rendered, wherein the regional transition image is used to indicate a degree of mixing between a foreground area and a background area in the image to be rendered; Performing upsampling processing on the regional transition image to obtain an upsampled regional transition image; The obtaining, based on the image to be rendered and the blurred image, a depth of field image corresponding to the image to be rendered comprises: Performing upsampling processing on the blurred image to obtain an upsampled blurred image; Based on the depth image and the up-sampled region transition image, performing image fusion on the image to be rendered and the up-sampled blurred image to obtain a fused image; The fused image is rendered to obtain a depth of field image corresponding to the image to be rendered.
12. A device for rendering a depth of field image, the device comprising: A first acquisition module is configured to acquire a depth image of an image to be rendered, and perform pixel block division on the depth image to obtain at least two pixel blocks; A second acquisition module is configured to acquire a depth of field parameter of each of the pixel blocks, and classify the at least two pixel blocks based on the depth of field parameter to obtain a category to which each of the pixel blocks belongs; a blur processing module configured to determine, for each of the categories of pixel blocks, a pixel area of the pixel blocks of the category in the image to be rendered based on a position of each pixel block in the category in the depth image, and perform blur processing on the pixel area based on a blur processing method corresponding to the category to obtain a blurred image; The rendering module is configured to obtain a depth of field image corresponding to the image to be rendered based on the image to be rendered and the blurred image.
13. An electronic device comprising: a memory configured to store computer executable instructions; The processor is configured to implement the method for rendering a depth of field image as described in any one of claims 1 to 11 when executing the computer executable instructions stored in the memory.
14. A computer-readable storage medium storing computer-executable instructions for causing a processor to execute the method for rendering a depth of field image according to any one of claims 1 to 11.
15. A computer program product, comprising a computer program or a computer executable instruction, wherein when the computer program or the computer executable instruction is executed by a processor, the method for rendering a depth of field image according to any one of claims 1 to 11 is implemented.
