Image filtering method and device
By calculating the depth contribution weight of the sample point pixels, filtering out the key pixel points and setting their filter weight to 0, the problem of edge information loss in the joint bilateral filtering method is solved, and the edge details of long-distance scene pictures are retained during the noise reduction process.
Patent Information
- Application Number
- CN202111165525.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2041-09-30
AI Technical Summary
When the existing joint bilateral filtering method filters geometric structures with little difference in normal but great depth, edge information cannot be retained well, resulting in loss of details.
By calculating the depth contribution weight of the pixel to be rendered by sampling point, judging the depth gap, and setting the filter weight of the pixel to be rendered to 0 when the depth gap is large, performing joint bilateral filtering, filtering out key pixel points for details protection, and avoiding weighted average processing.
While keeping the noise reduction effect unchanged, keep the edges of the long-distance scene picture content not lost, avoiding details and grid phenomena.
Smart Images

Figure CN115908208B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer software, and in particular to an image filtering method and device. Background Art
[0002] Currently, real-time rendering engine systems on the market are increasingly using real-time ray tracing technology to achieve rendering effects and physical accuracy. However, if you want to use ray tracing to render a noise-free image, each pixel in the image requires data information of approximately 200 rays. In real-time rendering, to maintain the frame rate, existing hardware (home PCs) can only provide data information of about 0.5 rays per pixel, which will generate a lot of noise. Therefore, denoising the ray tracing information is necessary.
[0003] Joint bilateral filtering is a denoising method where the weights depend not only on the Euclidean distance of the pixels, but also on the radiometric differences (e.g., range differences such as color intensity, depth distance, etc.). This allows for the preservation of sharp edges.
[0004] When rendering the skylight stage with real-time ray tracing enabled, the existing joint bilateral filtering algorithm performs poorly for geometric structures with small normal differences but large depth differences. Edge information cannot be well preserved, resulting in loss of details. Summary of the Invention
[0005] In view of this, an embodiment of the present invention provides an image filtering method and device to solve the problem in the prior art that the edge information cannot be well preserved when filtering geometric structures with small normal differences but large depth differences, resulting in loss of details.
[0006] According to a first aspect, an embodiment of the present invention provides an image filtering method, comprising:
[0007] Obtaining a pixel to be rendered in a target image and a sampling point pixel in a filter kernel corresponding to the pixel to be rendered, wherein the pixel to be rendered is a center pixel of the filter kernel;
[0008] Calculating the depth contribution weight of the sampling point pixel to the pixel to be rendered;
[0009] Determine whether the depth contribution weight is 0;
[0010] When the contribution weight is 0, the filtering weight corresponding to the pixel to be rendered is set to 0, and joint bilateral filtering is performed on the pixel to be rendered.
[0011] Optionally, calculating the depth contribution weight of the sampling point pixel and the pixel to be rendered includes:
[0012] Obtaining a first depth coordinate corresponding to the current sampling point pixel and a second depth coordinate corresponding to the pixel to be rendered;
[0013] Calculate a depth vector from the pixel to be rendered to the current sampling point pixel based on the first depth coordinate and the second depth coordinate;
[0014] A depth contribution weight of the current sampling point pixel to the pixel to be rendered is calculated based on the depth vector and a preset maximum blur distance.
[0015] Optionally, before calculating the depth contribution weights of the sampling point pixel and the pixel to be rendered, the method further includes:
[0016] Determine whether the distance between the pixel to be rendered and the corresponding acquisition point of the target image is greater than a preset distance;
[0017] When the distance between the pixel to be rendered and the acquisition device corresponding to the target image is greater than a preset distance, a depth contribution weight of the sampling point pixel and the pixel to be rendered is calculated.
[0018] Optionally, when the depth contribution weight is not 0, the method further includes:
[0019] Determining whether the depth contribution weight is greater than a preset depth contribution weight threshold;
[0020] When the depth contribution weight is not greater than a preset depth contribution weight threshold, the filtering weight corresponding to the pixel to be rendered is set to 0.
[0021] Optionally, before setting the filter weight value corresponding to the pixel to be rendered to 0, the method further includes:
[0022] Determine whether the pixel to be rendered is a pixel point facing the acquisition device corresponding to the target image;
[0023] When the pixel to be rendered is not a pixel point facing the acquisition device corresponding to the target image, determining whether the pixel to be rendered is a pixel point perpendicular to the vertical axis or parallel to the vertical axis in the world space coordinate system;
[0024] When the pixel to be rendered is not a pixel point perpendicular to the vertical axis and not parallel to the vertical axis in the world space coordinate system, the filtering weight value corresponding to the pixel to be rendered is set to 0.
[0025] Optionally, when the pixel to be rendered is a pixel point facing the acquisition device corresponding to the target image, or when the pixel to be rendered is a pixel point parallel to the vertical axis in the world space coordinate system, obtaining a calculation result of a filtering weight value corresponding to the pixel to be rendered;
[0026] The calculation result of the filtering weight value is updated based on the preset coefficient, and the joint bilateral filtering process is performed on the pixel to be rendered based on the updated filtering weight value.
[0027] Optionally, determining whether the pixel to be rendered is a pixel facing the acquisition device corresponding to the target image includes:
[0028] Obtaining a pixel normal of the pixel to be rendered and a forward vector of the acquisition device in the target image acquisition direction;
[0029] Calculating a dot product of the pixel normal and the forward vector;
[0030] Determining whether the dot product is less than a preset dot product value;
[0031] When the dot product is less than a preset dot product value, determining that the pixel to be rendered is a pixel point facing the acquisition device corresponding to the target image;
[0032] When the dot product is not less than a preset dot product value, it is determined that the pixel to be rendered is a pixel point facing sideways toward the acquisition device corresponding to the target image.
[0033] Optionally, determining whether the pixel to be rendered is a pixel point perpendicular to a vertical axis or parallel to the vertical axis in a world space coordinate system includes:
[0034] Obtaining the space normal corresponding to the pixel to be rendered in the world space coordinate system;
[0035] Determining whether the space normal is parallel or perpendicular to the vertical axis;
[0036] When the space normal is parallel to the vertical axis, determining that the pixel to be rendered is a pixel point parallel to the vertical axis in the world space coordinate system;
[0037] When the space normal is perpendicular to the vertical axis, it is determined that the pixel to be rendered is a pixel point perpendicular to the vertical axis in the world space coordinate system.
[0038] According to a second aspect, an embodiment of the present invention provides an image filtering device, comprising:
[0039] An acquisition module, configured to acquire a pixel to be rendered in a target image and a sampling point pixel in a filter kernel corresponding to the pixel to be rendered, wherein the pixel to be rendered is a center pixel of the filter kernel;
[0040] A first processing module, configured to calculate a depth contribution weight of a sampling point pixel to the pixel to be rendered;
[0041] A second processing module is used to determine whether the depth contribution weight is 0;
[0042] The third processing module is configured to, when the contribution weight is 0, set the filtering weight corresponding to the pixel to be rendered to 0, and perform joint bilateral filtering on the pixel to be rendered.
[0043] According to a third aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a processor, they implement the method described in the first aspect of the present invention and any optional method thereof.
[0044] According to the fourth aspect, an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method described in the first aspect of the present invention and any optional method thereof by executing the computer instructions.
[0045] The technical solution of the present invention has the following advantages:
[0046] An embodiment of the present invention provides an image filtering method and apparatus, which obtains a pixel to be rendered in a target image and a sampling point pixel within a filter kernel corresponding to the pixel to be rendered, wherein the pixel to be rendered is the center pixel of the filter kernel; calculates the depth contribution weight of the sampling point pixel to the pixel to be rendered; determines whether the depth contribution weight is 0; and when the contribution weight is 0, sets the filter weight corresponding to the pixel to be rendered to 0, and performs joint bilateral filtering on the pixel to be rendered. Thus, by calculating the depth contribution weight of the sampling point pixel to the pixel to be rendered, the depth difference between the sampling point and the center point is determined, and when the depth difference between the two is large, the filter weight corresponding to the pixel to be rendered is set to 0. This method, by screening out key pixels with lost details, performs detail protection, avoids weighted averaging of the sampling point pixel and the pixel to be rendered, and prevents blurring of the pixel, thereby achieving the goal of maintaining the edge of distant scene content without loss while ensuring the noise reduction effect remains unchanged. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0048] Figure 1 is a flow chart of an image filtering method according to an embodiment of the present invention;
[0049] Figure 2 Schematic diagram of the structure of an image filtering device according to an embodiment of the present invention;
[0050] Figure 3 Schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0052] In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0053] Joint bilateral filtering is a denoising method where the weights depend not only on the Euclidean distance of the pixels, but also on the radiometric differences (e.g., range differences such as color intensity, depth distance, etc.). This allows for the preservation of sharp edges.
[0054] When rendering the skylight stage with real-time ray tracing enabled, the existing joint bilateral filtering algorithm performs poorly for geometric structures with small normal differences but large depth differences. Edge information cannot be well preserved, resulting in loss of details.
[0055] Based on the above problems, an embodiment of the present invention provides an image filtering method, such as Figure 1 As shown, the image filtering method specifically includes the following steps:
[0056] Step S101: obtaining pixels to be rendered in a target image and sampling point pixels in a filter kernel corresponding to the pixels to be rendered.
[0057] The filter kernel is a pre-designed filter kernel for the joint bilateral filtering algorithm before running. Its size can be flexibly set based on the filtering accuracy and efficiency requirements, but the present invention is not limited thereto. The pixel to be rendered is the center pixel of the filter kernel, and the sampling pixels are the pixels other than the center pixel within the area covered by the filter kernel on the target image. Specifically, when filtering the target image, the position and size of the filter kernel are first set accordingly on the target image, and then the filter kernels are processed one by one.
[0058] Step S102: Calculate the depth contribution weight of the sampling point pixel to the pixel to be rendered.
[0059] Step S103: Determine whether the depth contribution weight is 0.
[0060] Step S104: when the contribution weight is 0, the filtering weight corresponding to the pixel to be rendered is set to 0, and a joint bilateral filtering process is performed on the pixel to be rendered.
[0061] Specifically, if the depth contribution weight of the sampling point pixel to the pixel to be rendered is 0, it means that the depth difference between the two is very large. The pixel to be rendered is an edge detail point. In order to avoid it being blurred during the filtering calculation, the corresponding wave weight value is set to 0 and then a joint bilateral filtering process is performed to complete the filtering operation of the filter kernel, and then the above steps are repeated until the target image is filtered.
[0062] By executing the above steps, the image filtering method provided by the embodiment of the present invention determines the depth difference between the sampling point and the center point by calculating the depth contribution weight of the sampling point pixel to the pixel to be rendered. When the depth difference between the two is large, the filtering weight corresponding to the pixel to be rendered is set to 0. In this way, key pixels with lost details are screened out to protect details, avoiding weighted averaging of the sampling point pixel and the pixel to be rendered, so that the pixel is not blurred. This ensures that the edges of the distant scene content are not lost while ensuring the noise reduction effect remains unchanged.
[0063] Specifically, in one embodiment, the above step S102 specifically includes the following steps:
[0064] Step S201: obtaining a first depth coordinate corresponding to a pixel at a current sampling point and a second depth coordinate corresponding to a pixel to be rendered.
[0065] Step S202: Calculating a depth vector from the pixel to be rendered to the current sampling point pixel based on the first depth coordinate and the second depth coordinate.
[0066] Step S203: Calculate the depth contribution weight of the current sampling point pixel to the pixel to be rendered based on the depth vector and a preset maximum blur distance, wherein the preset maximum blur distance is a default setting value of the engine.
[0067] Specifically, within a single filter kernel, the depth coordinates of the sampling point pixel are subtracted from the depth coordinates of the center point pixel to obtain the depth vector from the center point to the sampling point. The result of the vector multiplication is divided by the square of the engine's preset maximum blur distance, and then the result is subtracted from 1. The final result is normalized to the interval [0, 1], because the farther the depth distance between the two points is, the smaller the contribution weight of the sampling point to the center point in the depth dimension should be. Finally, the depth contribution of the sampling point to the center point is obtained. Therefore, by judging whether the contribution weight is 0, the depth difference between the two is judged. If it is 0, it means that the depth difference between the sampling point and the center point is large, and the pixel point is an edge detail point and needs to be retained.
[0068] Specifically, in one embodiment, before executing the above step S102, the image filtering method provided by the embodiment of the present invention further includes the following steps:
[0069] Step S105: determining whether the distance between the pixel to be rendered and the corresponding acquisition point of the target image is greater than a preset distance.
[0070] Among them, the preset distance is flexibly set according to the actual distance between the camera and the shooting object. For example, when the shooting target is in the distance, the preset distance is adjusted larger, otherwise it is adjusted smaller. For example, when shooting a tall building in the distance, the preset distance can be 100m, etc., but the present invention is not limited to this.
[0071] Step S106: If the distance between the pixel to be rendered and the acquisition device corresponding to the target image is greater than the preset distance, step S102 is executed. If the distance between the pixel to be rendered and the acquisition device corresponding to the target image is not greater than the preset distance, the default filter weight calculation method is used for calculation. These non-critical pixels, such as those not representing outline edges, can be subjected to conventional noise reduction and do not require special processing.
[0072] Specifically, by judging whether the pixels to be rendered are far enough, the pixels to be rendered are divided into two parts, near and far. In an embodiment of the present invention, the three-dimensional space position of the pixel is within a certain distance from the acquisition device such as a camera as one part, and the part beyond that is another part. The near part of the pixels continues to use the engine's default bilateral joint filtering algorithm to calculate the noise reduction result, and the far part is calculated using the method provided by the embodiment of the present invention. Because the closer the scene is to the camera, the smaller the geometric area in the three-dimensional space represented by the unit pixel, and conversely, the more pixel representations are obtained for the geometric area in the unit three-dimensional space, the more corresponding real-time ray tracing data, the less noise points, and the more correct information. The probability of detail loss and grid is small. Therefore, it is only necessary to process pixels beyond a certain distance to avoid detail loss and grid.
[0073] Specifically, in one embodiment, when the depth contribution weight is not 0, the method further includes the following steps:
[0074] Step S107: Determine whether the depth contribution weight is greater than the preset depth contribution weight threshold; when the depth contribution weight is not greater than the preset depth contribution weight threshold, set the filter weight value corresponding to the pixel to be rendered to 0. When the depth contribution weight is greater than the preset depth contribution weight threshold, the filter weight value can be calculated according to the engine's default joint bilateral filtering algorithm. These pixels are also non-critical pixels, such as those that do not have contour edges, and can be denoised conventionally without special processing. Among them, the preset depth contribution weight threshold is pre-set, and usually a small decimal is selected between 0 and 0.5. For example, in an embodiment of the present invention, the preset depth contribution weight threshold is the fourth power of 0.618. It is considered that pixels with a weight of (0, 0.618^4] are pixels that contribute less to the center point in depth.
[0075] Specifically, by re-judging the filtered pixels, these pixels are used as a transition pixel group to realize the transition from the filter weight value calculation provided by the embodiment of the present invention to the engine default weight calculation. When the depth is considered for weight calculation, when the calculated weight is 0, the calculation result of the transition domain weight calculation method is the same as the filter weight value provided by the embodiment of the present invention; when the depth is considered for weight calculation, when the calculated weight is (0, 0.618^4], the transition domain weight calculation method is the same as the calculation result of the engine default filter calculation formula. This is to avoid sudden changes in the filtering results.
[0076] Specifically, in one embodiment, before executing step S104 to set the filter weight value corresponding to the pixel to be rendered to 0, the method further includes the following steps:
[0077] Step S108: Determine whether the pixel to be rendered is a pixel point facing the acquisition device corresponding to the target image.
[0078] Specifically, the pixel normal of the pixel to be rendered and the forward vector of the acquisition device in the target image acquisition direction are obtained; the dot product of the pixel normal and the forward vector is calculated; and it is determined whether the dot product is less than a preset dot product value. When the dot product is less than the preset dot product value, the pixel to be rendered is determined to be a pixel point facing the acquisition device corresponding to the target image from the front; when the dot product is not less than the preset dot product value, the pixel to be rendered is determined to be a pixel point facing the acquisition device corresponding to the target image from the side. The dot product value is a number between 0 and 1. The closer it is to 1, the closer the pixel is to facing the camera from the front, and the closer it is to 0, the pixel is at a certain angle to the camera or even nearly perpendicular to the camera's forward vector. The preset dot product value can be flexibly set according to the accuracy requirements. In the embodiment of the present invention, the preset dot product value is set to 0.95, taking into account certain measurement deviations. This is only an example and is not limited to this.
[0079] Step S109: When the pixel to be rendered is not a pixel point facing the acquisition device corresponding to the target image, determine whether the pixel to be rendered is a pixel point perpendicular to the vertical axis or parallel to the vertical axis in the world space coordinate system; when the pixel to be rendered is neither perpendicular to the vertical axis nor parallel to the vertical axis in the world space coordinate system, set the filtering weight value corresponding to the pixel to be rendered to 0.
[0080] Specifically, the system obtains the spatial normal corresponding to the pixel to be rendered in the world space coordinate system; determines whether the spatial normal is parallel or perpendicular to the vertical axis; if the spatial normal is parallel to the vertical axis, determines whether the pixel to be rendered is parallel to the vertical axis in the world space coordinate system; if the spatial normal is perpendicular to the vertical axis, determines whether the pixel to be rendered is perpendicular to the vertical axis in the world space coordinate system. This allows the system to distinguish between horizontal and vertical planes within the scene and process them separately to avoid gridding.
[0081] The pixels filtered out in step S109 correspond to the key contour lines and are key pixels for detail loss. The final sampling point's contribution to the center point's color should be zero. Since the sampling point has no contribution to the center point, the weighted average of the two will not be used. Without weighted averaging, blurring will not occur. Thus, the key contour lines are preserved.
[0082] Step S110: When the pixel to be rendered is a pixel point facing the acquisition device corresponding to the target image, or when the pixel to be rendered is a pixel point parallel to the vertical axis in the world space coordinate system, obtain the calculation result of the filtering weight value corresponding to the pixel to be rendered.
[0083] The filter weight calculation result is the weight calculation result obtained by the engine default weight calculation method.
[0084] Step S111: updating the calculation result of the filtering weight value based on the preset coefficient, and performing joint bilateral filtering on the pixels to be rendered based on the updated filtering weight value.
[0085] The preset coefficient is used to adjust the calculated filter weight value and is typically set between 0 and 0.5. In the embodiment of the present invention, 0.1 is used as an example, but the present invention is not limited to this. By setting a smaller weight coefficient, the filter weight value of the pixel is reduced, thereby reducing noise while preserving details.
[0086] This completes the filtering process. The entire filtering process uses various criteria to identify pixels with lost detail. Once found, the filtering weight is set to zero. This includes adding a transition region and special processing for squares and vertical surfaces facing the screen. Ultimately, this approach achieves the goal of preserving key contours, preventing detail loss, and effectively handling noise.
[0087] By performing the above steps, the image filtering method provided by the embodiment of the present invention determines the depth difference between the sampling point and the center point by calculating the depth contribution weight of the sampling point pixel to the pixel to be rendered, and sets the filtering weight corresponding to the pixel to be rendered to 0 when the depth difference between the two is large. This protects the details by screening out key pixels where details are lost, avoiding weighted averaging of the sampling point pixels and the pixels to be rendered, so that the pixels are not blurred, thereby achieving the goal of maintaining the edges of the distant scene image content without losing them while ensuring the noise reduction effect remains unchanged. The joint bilateral filtering method provided by the embodiment of the present invention comprehensively considers factors in multiple dimensions such as scene distance, normal direction, pixel depth, normal direction and camera angle, and calculates the influence intensity of the pixels in the filter kernel on the center pixel, i.e., the weight. While ensuring the noise reduction effect remains unchanged, the edges of the distant scene image content are maintained without losing them, and the grid phenomenon is weakened. After applying the filtering method of the present invention, in typical scenes, in the absence of noise, the details are better preserved than the original algorithm, and the grid is weaker.
[0088] The embodiment of the present invention also provides an image filtering device, such as Figure 2 As shown, the image filtering device specifically includes:
[0089] The acquisition module 101 is used to acquire the pixel to be rendered in the target image and the sampling point pixel in the filter kernel corresponding to the pixel to be rendered. The pixel to be rendered is the center pixel of the filter kernel. For details, please refer to the relevant description of step S101 in the above method embodiment, which will not be repeated here.
[0090] The first processing module 102 is used to calculate the depth contribution weight of the sampling point pixel to the pixel to be rendered. For details, please refer to the relevant description of step S102 in the above method embodiment, which will not be repeated here.
[0091] The second processing module 103 is used to determine whether the depth contribution weight is 0. For details, please refer to the relevant description of step S103 in the above method embodiment, which will not be repeated here.
[0092] The third processing module 104 is configured to set the filter weight corresponding to the pixel to be rendered to 0 when the contribution weight is 0, and perform joint bilateral filtering on the pixel to be rendered. For details, please refer to the description of step S104 in the above method embodiment, which will not be repeated here.
[0093] The further functional description of each of the above modules is the same as that of the above corresponding method embodiments and will not be repeated here.
[0094] Through the collaborative cooperation of the above-mentioned components, the image filtering device provided by the embodiment of the present invention determines the depth difference between the sampling point and the center point by calculating the depth contribution weight of the sampling point pixel to the pixel to be rendered. When the depth difference between the two is large, the filtering weight corresponding to the pixel to be rendered is set to 0. In this way, key pixels with lost details are screened out to protect details, avoiding weighted averaging of the sampling point pixel and the pixel to be rendered, so that the pixel is not blurred, thereby achieving the goal of maintaining the edges of the content of the distant scene image without losing while ensuring the noise reduction effect remains unchanged.
[0095] The embodiment of the present invention further provides an electronic device, such as Figure 3 As shown, the electronic device may include a processor 901 and a memory 902, wherein the processor 901 and the memory 902 may be connected via a bus or other means. Figure 3 The bus connection is taken as an example.
[0096] The processor 901 may be a central processing unit (CPU). The processor 901 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0097] Memory 902, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as the program instructions / modules corresponding to the methods in the embodiments of the present invention. Processor 901 executes the non-transitory software programs, instructions, and modules stored in memory 902 to perform various processor functions and data processing, thereby implementing the aforementioned methods.
[0098] The memory 902 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created by the processor 901, etc. In addition, the memory 902 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 902 may optionally include a memory remotely located relative to the processor 901, and these remote memories may be connected to the processor 901 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0099] One or more modules are stored in the memory 902 and, when executed by the processor 901 , perform the above method.
[0100] The specific details of the above electronic device can be understood by referring to the corresponding descriptions and effects in the above method embodiments, and will not be repeated here.
[0101] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD). The storage medium can also include a combination of the above-mentioned types of memory.
[0102] The above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be included in the scope of the claims of the present invention.
Claims
1. An image filtering method, characterized in that: include: Obtaining a pixel to be rendered in a target image and a sampling point pixel in a filter kernel corresponding to the pixel to be rendered, wherein the pixel to be rendered is a center pixel of the filter kernel; Calculating the depth contribution weight of the sampling point pixel to the pixel to be rendered; Determine whether the depth contribution weight is 0; When the contribution weight is 0, the filtering weight corresponding to the pixel to be rendered is set to 0, and a joint bilateral filtering process is performed on the pixel to be rendered; The calculating of the depth contribution weights of the sampling point pixel and the pixel to be rendered includes: Obtaining a first depth coordinate corresponding to the current sampling point pixel and a second depth coordinate corresponding to the pixel to be rendered; Calculate a depth vector from the pixel to be rendered to the current sampling point pixel based on the first depth coordinate and the second depth coordinate; A depth contribution weight of the current sampling point pixel to the pixel to be rendered is calculated based on the depth vector and a preset maximum blur distance.
2. The method according to claim 1, characterized in that Before calculating the depth contribution weights of the sampling point pixel and the pixel to be rendered, the method further includes: Determine whether the distance between the pixel to be rendered and the corresponding acquisition point of the target image is greater than a preset distance; When the distance between the pixel to be rendered and the acquisition device corresponding to the target image is greater than a preset distance, a depth contribution weight of the sampling point pixel and the pixel to be rendered is calculated.
3. The method according to claim 1, characterized in that When the depth contribution weight is not 0, the method further includes: Determining whether the depth contribution weight is greater than a preset depth contribution weight threshold; When the depth contribution weight is not greater than a preset depth contribution weight threshold, the filtering weight corresponding to the pixel to be rendered is set to 0.
4. The method according to claim 1, wherein Before setting the filter weight value corresponding to the pixel to be rendered to 0, the method further includes: Determine whether the pixel to be rendered is a pixel point facing the acquisition device corresponding to the target image; When the pixel to be rendered is not a pixel point facing the acquisition device corresponding to the target image, determining whether the pixel to be rendered is a pixel point perpendicular to the vertical axis or parallel to the vertical axis in the world space coordinate system; When the pixel to be rendered is not a pixel point perpendicular to the vertical axis and not parallel to the vertical axis in the world space coordinate system, the filtering weight value corresponding to the pixel to be rendered is set to 0.
5. The method according to claim 4, characterized in that When the pixel to be rendered is a pixel point facing the acquisition device corresponding to the target image, or when the pixel to be rendered is a pixel point parallel to the vertical axis in the world space coordinate system, obtaining a calculation result of a filtering weight value corresponding to the pixel to be rendered; The calculation result of the filtering weight value is updated based on the preset coefficient, and the joint bilateral filtering process is performed on the pixel to be rendered based on the updated filtering weight value.
6. The method according to claim 4, characterized in that The determining whether the pixel to be rendered is a pixel point facing the acquisition device corresponding to the target image includes: Obtaining a pixel normal of the pixel to be rendered and a forward vector of the acquisition device in the target image acquisition direction; Calculating a dot product of the pixel normal and the forward vector; Determining whether the dot product is less than a preset dot product value; When the dot product is less than a preset dot product value, determining that the pixel to be rendered is a pixel point facing the acquisition device corresponding to the target image; When the dot product is not less than a preset dot product value, it is determined that the pixel to be rendered is a pixel point facing sideways toward the acquisition device corresponding to the target image.
7. The method according to claim 4, characterized in that The determining whether the pixel to be rendered is a pixel point perpendicular to the vertical axis or parallel to the vertical axis in the world space coordinate system includes: Obtaining the space normal corresponding to the pixel to be rendered in the world space coordinate system; Determining whether the space normal is parallel or perpendicular to the vertical axis; When the space normal is parallel to the vertical axis, determining that the pixel to be rendered is a pixel point parallel to the vertical axis in the world space coordinate system; When the space normal is perpendicular to the vertical axis, it is determined that the pixel to be rendered is a pixel point perpendicular to the vertical axis in the world space coordinate system.
8. An image filtering device, characterized in that: include: An acquisition module, configured to acquire a pixel to be rendered in a target image and a sampling point pixel in a filter kernel corresponding to the pixel to be rendered, wherein the pixel to be rendered is a center pixel of the filter kernel; A first processing module, configured to calculate a depth contribution weight of a sampling point pixel to the pixel to be rendered; The calculating of the depth contribution weight of the sampling point pixel and the pixel to be rendered includes: obtaining a first depth coordinate corresponding to the current sampling point pixel and a second depth coordinate corresponding to the pixel to be rendered; calculating a depth vector from the pixel to be rendered to the current sampling point pixel based on the first depth coordinate and the second depth coordinate; and calculating a depth contribution weight of the current sampling point pixel to the pixel to be rendered based on the depth vector and a preset maximum blur distance. A second processing module is used to determine whether the depth contribution weight is 0; The third processing module is configured to, when the contribution weight is 0, set the filtering weight corresponding to the pixel to be rendered to 0, and perform joint bilateral filtering on the pixel to be rendered.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, which, when executed by a processor, implement the method according to any one of claims 1 to 7.
10. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method according to any one of claims 1 to 7 by executing the computer instructions.
Citation Information
Patent Citations
Remote drawing method based on depth information and action stream information
CN103561280A
Volume cloud processing method and device, electronic equipment and storage medium
CN112465941A