Picture processing method and system, electronic equipment and medium
By obtaining pixel depth information and using convolution kernels for calculations, the flickering problem in the visual system is solved, blurring the details of the picture and distinguishing the depth of field, eliminating flickering, reducing computer performance requirements, and avoiding the problem of high resource usage.
Patent Information
- Application Number
- CN202410658492.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-03
AI Technical Summary
In the visual system, the flicker phenomenon is unavoidable. Although existing technologies such as Gaussian blur and MIPMAP technology can reduce flicker, it will lead to a decrease in picture clarity or the need to pre-produce multiple sets of textures and models, which requires high resource usage and high computer performance requirements. And requires a lot of manual drawing.
By obtaining the depth information of each pixel, using the convolution kernel to perform operations, selecting a smoothing or sharpening convolution kernel based on the depth information, and adjusting the convolution kernel parameters until the requirements are met, the details of the picture are blurred and the depth of field is distinguished.
It effectively distinguishes different depths of field in the picture, achieves detail blurring, and eliminates flickering. It eliminates the need to prefabricate multiple sets of models and textures, reduces computer performance requirements, and provides flexible control effects.
Smart Images

Figure CN118587264A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image processing technology, and in particular relates to a picture processing method, system, electronic equipment and medium. Background Art
[0002] In visual systems, flickering is a very difficult problem to avoid and solve. The fundamental reason for its occurrence is that when the visual image is output, the output image must be rasterized, and the continuous image information is gridded into discrete pixels. However, current graphics cards can only output 4k, 2k or even lower resolutions (resolution represents the number of pixels). For tiny objects or lines in the image, if there is an area smaller than one pixel in the image, then when the image is rasterized, there will definitely be a rasterization error in that area, that is, the pixel can only be fully displayed or completely hidden. These pixels are sometimes displayed and sometimes hidden as the viewpoint moves, giving the appearance of flickering. When there are a large number of sharp-edged lines in the image, as the lines increase in distance from the viewpoint, the lines gradually become thinner and smaller, and this phenomenon will recur.
[0003] Currently, the most common solution is to perform Gaussian blur on the rendered image, or use other anti-aliasing algorithms to make the fine lines in the image transition smoothly with the surrounding pixels, thereby reducing the flickering phenomenon. However, this method directly operates on the pixels of the image and cannot distinguish between the foreground and background, which can easily cause the overall clarity of the image to decrease. Another type of method, such as computer graphics MIPMAP technology, multi-level of detail LOD technology, etc., is based on the basic principle of pre-making a variety of models or textures with different precisions. When the distance to the viewpoint is close, high-precision models and textures are used. At this time, due to the close distance to the viewpoint, the lines on the model and texture require multiple pixels to describe, so there is no obvious flickering phenomenon; when the distance to the viewpoint becomes farther and farther, low-precision models and textures are loaded. These low-precision models and textures do not have too many details, but only have outlines of pieces, which also need to be drawn with multiple pixels to avoid flickering. Since the blur is set according to the distance from the viewpoint, it can better preserve close details. However, the effectiveness of this method depends on the number of model accuracy levels. The finer the level division, the better the effect. This often requires pre-production of multiple sets of textures and models, which not only consumes a lot of resources and has high requirements on computer performance, but also requires a lot of manual work to draw textures and models of various precisions. Summary of the Invention
[0004] In order to overcome the problems existing in the prior art, the present invention provides a picture processing method, system, electronic device and medium, which are used to overcome the current defects.
[0005] A picture processing method, comprising the steps of:
[0006] S1. Get the depth information of each pixel in the picture;
[0007] S2. Set the convolution kernel of the image;
[0008] S3. Multiplying the depth information by the convolution kernel to perform a convolution operation;
[0009] S4. Judge the operation result. If it does not meet the preset requirements, return to S2 to adjust the convolution kernel and repeat the operation until the requirements are met.
[0010] According to the above aspects and any possible implementation, an implementation is further provided, wherein the convolution kernel includes a smoothing convolution kernel and a sharpening convolution kernel.
[0011] According to the above aspects and any possible implementation, an implementation is further provided, wherein the depth information is obtained by cyclically tracking the distance between the eye point and all pixels in the screen image and the intersecting objects in the scene.
[0012] According to the aspects and any possible implementations described above, an implementation is further provided, wherein S3 includes: comparing the depth information of a certain pixel with the depth information of its adjacent pixels, and selecting a smoothing convolution kernel or a sharpening convolution kernel according to the comparison result.
[0013] According to the aspects and any possible implementation methods described above, an implementation method is further provided, wherein the method further includes: when the correlation between the depth information of a certain pixel and the depth information of its adjacent pixels is less than or equal to a set constant, convolving the depth information of the certain pixel with a smoothing convolution kernel.
[0014] According to the aspects and any possible implementation methods described above, an implementation method is further provided, wherein the method further includes: when the correlation between the depth information of a certain pixel and the depth information of its adjacent pixels is greater than a set constant, the depth information of the certain pixel is convolved with a sharpening convolution kernel.
[0015] As described above, in any possible implementation, a further implementation is provided, wherein the smoothing convolution kernel is obtained by performing Gaussian filtering on the image, that is, taking a weighted average of a pixel and surrounding pixels.
[0016] The present invention also provides a picture processing system, which implements the method described above and includes the following modules:
[0017] The acquisition module is used to obtain the depth information of each pixel in the picture;
[0018] Setting module, used to set the convolution kernel of the picture;
[0019] An operation module, configured to perform a convolution operation by multiplying the depth information by a convolution kernel;
[0020] The adjustment module is used to judge the operation results. If they do not meet the preset requirements, the convolution kernel is adjusted and the operation is repeated until the requirements are met.
[0021] The present invention further provides an electronic device, comprising:
[0022] a memory storing executable instructions;
[0023] A processor is configured to execute the executable instructions in the memory to implement the method.
[0024] The present invention also provides a computer storage medium, on which a computer program is stored. The computer program is executed by a processor to implement the method described above.
[0025] Beneficial effects of the present invention
[0026] Compared with the existing technology, the present invention has the following beneficial effects: by obtaining the depth information of each pixel during rendering, the distance between the pixel and the eye point is calculated; each pixel is convolved with the surrounding pixels, and the convolution kernel set during convolution is related to the depth information of the adjacent pixels, that is, when the depth information of adjacent pixels is consistent, a smooth convolution kernel is used, so that objects with the same depth of field are smoothed with each other; although the pixels are adjacent, but the depth of field is inconsistent, a sharpened convolution kernel is used, so that the foreground and background are more clearly distinguished, thereby improving the clarity of the picture. The advantages of the present invention are:
[0027] 1) Compared to global image blurring, this method can better distinguish different depths of field in the image, thereby achieving detail blurring results similar to MIPMAP and LOD. This method blurs the distant depth of field while preserving the details of the near image, achieving the purpose of eliminating image flicker.
[0028] 2) Compared to MIPMAP and LOD, which require prefabricated models and textures, this method can directly process the image online, eliminating the need for manual rendering of multiple layers of textures and models. Furthermore, by controlling the convolution kernel parameters, effects such as sharpening, blurring, and contrast can be quickly adjusted, providing flexible control over the effects.
[0029] 3) Relying on the parallel computing of the graphics card, this method has very little impact on scene rendering performance, does not require additional memory resources, and reduces the overall performance requirements of the computer. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1Schematic diagram of the relationship between the eye point (camera) position and image pixels and spatial objects of the present invention;
[0031] Figure 2 Schematic diagram of the area representation of any pixel in an image within a 3*3 convolution kernel of the present invention;
[0032] Figure 3 Schematic diagram of convolution calculation of the present invention;
[0033] Figure 4 This is a schematic diagram of the results obtained by convolving an image with different convolution kernels in the present invention;
[0034] Figure 5 Schematic diagram of the parameters adjustment of the smoothing convolution kernel and the sharpening convolution kernel of the present invention. DETAILED DESCRIPTION
[0035] To better understand the technical solutions of the present invention, the present invention includes but is not limited to the specific embodiments described below. Similar technologies and methods should be considered within the scope of protection of the present invention. To further clarify the technical problems, technical solutions, and advantages to be solved by the present invention, the following detailed description is provided in conjunction with the accompanying drawings and specific embodiments.
[0036] It should be understood that the embodiments described herein are only a portion of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0037] The image processing method of the present invention comprises the steps of:
[0038] S1. Get the depth information of each pixel in the picture;
[0039] S2. Set the convolution kernel of the image;
[0040] S3. Multiplying the depth information by the convolution kernel to perform a convolution operation;
[0041] S4. Judge the operation result. If it does not meet the preset requirements, return to S2 to adjust the convolution kernel and repeat the operation until the requirements are met.
[0042] Preferably, the convolution kernel includes a smoothing convolution kernel and a sharpening convolution kernel.
[0043] Preferably, the depth information is obtained by cyclically tracking the distance between the eye point and all pixels in the screen image and intersecting objects in the scene.
[0044] Preferably, the S3 includes: comparing the depth information of a certain pixel with the depth information of its adjacent pixels, and selecting a smoothing convolution kernel or a sharpening convolution kernel for operation according to the comparison result.
[0045] Preferably, the method further comprises: when the correlation between the depth information of a certain pixel and the depth information of its adjacent pixels is less than or equal to a set constant, performing a convolution operation on the depth information of the certain pixel and a smoothing convolution kernel.
[0046] Preferably, the method further comprises: when the correlation between the depth information of a certain pixel and the depth information of its adjacent pixels is greater than a set constant, performing a convolution operation on the depth information of the certain pixel and a sharpening convolution kernel.
[0047] Preferably, the smoothing convolution kernel is obtained by performing Gaussian filtering on the image, that is, taking the weighted average of a pixel and surrounding pixels.
[0048] Specifically, the process of the present invention is as follows:
[0049] Step 1: Get pixel depth information
[0050] The overall goal of rendering geometry is to ensure that the final rendered image is representative of a given scene. At the highest level, this means that objects must appear correctly occluded by closer objects and not be occluded by more distant objects. This process is called visible surface determination (VSD), and there are many very different ways to accomplish it. These methods all involve comparing the depth of surfaces at one level of granularity or another, and rendering them in such a way that the object with the smallest depth at a given pixel (i.e. the closest object) is the one rendered to the screen.
[0051] The pixel depth information is the distance from the visible object to the eye point (camera). For example, a ray is traced through a pixel in the image and the distance between the eye point and any object that intersects the ray is found, which is represented by t. t is the depth information of this pixel. Figure 1 As shown in . The depth information of all pixels in the image is obtained by tracing the intersecting objects in the scene through the eye point and all pixels in the image. Figure 1 Set the coordinate of the eye point in the scene to O (x,y,z) , the fragment position represented by the pixel is but
[0052]
[0053] Where x, y, z are the coordinates of the eye point, and x, y, z are the coordinates of the fragment position.
[0054] Step 2: Set the smoothing convolution kernel and sharpening convolution kernel parameters
[0055] The convolution kernel is a data matrix, and different convolution kernels are obtained by changing the data in the matrix. Step 1 obtains the original data convolved by the convolution kernel, such as pixel position and depth information.
[0056] Both smoothing and sharpening an image can enhance and improve the image quality. Sharpening reduces blurry details in an image by enhancing high-frequency information, namely, texture edges. However, this also introduces image noise when enhancing texture. Smoothing, in contrast to sharpening, filters out high-frequency components, which can reduce image noise but may make the image blurrier. To this end, the present invention uses a convolution method that combines information such as pixel position, depth, color, and brightness in the original data to sharpen edges with a larger depth of field and smooth areas with a closer depth of field.
[0057] Convolution can be viewed as a weighted summation process. Convolution is represented by a very small matrix whose size is an odd number and is the same as the size of the area being used. This matrix is called a convolution kernel. Each pixel in the area is multiplied by each element in the convolution kernel. The sum of all products is the new value of the center pixel of the area. For example, if you want to smooth Figure 2 Middle a u,v Pixel point, then take out a in the pixel matrix u,v The point and the 8 surrounding points form a u,v The pixel matrix f is convolved with the convolution kernel g, and the calculation result (that is, the new value) is filled back, that is, the calculation result is replaced by Figure 2 Middle pixel a u,v The original value is used as the new value. For the specific calculation method, refer to Figure 3 As shown. After convolution processing, the central pixel a of the area u,v It is expressed as follows:
[0058]
[0059]
[0060] a u,v The surrounding 8 pixel values plus pixel a u,v There are a total of 9 pixel values and the convolution coefficient in the convolution kernel g are calculated, and the result is a new pixel a u,v value.
[0061] Each element in the convolution kernel is the convolution coefficient b -1,-1 , b -1,0 , b -1,1 ,…,b 1,1The size, direction, and order of the convolution coefficients in the convolution kernel determine the image processing effect of convolution. In addition to the convolution coefficients, the number of rows and columns in the convolution kernel also affects the level of image processing refinement. The area kernel used is typically 3*3, but can also be 5*5, 7*7, etc. Larger coefficients indicate a larger area involved in the calculation, resulting in finer image processing. To preserve the original pixel characteristics as much as possible, the g matrix is often a normally distributed matrix.
[0062] Similarly, the following are the results of convolving the image with different convolution kernels, namely edge detection convolution kernel, sharpening convolution kernel and Gaussian blur (smoothing) convolution kernel, as shown in the figure. Figure 4 shown.
[0063] Step 3: Image convolution operation
[0064] The original data obtained from step 1 includes pixel depth information. The depth information matrix T corresponding to the matrix f is taken out. The sharpening and smoothing convolution kernels set in step 2 can be used to 1 represents the sharpening convolution kernel, g 2 represents the smoothing convolution kernel, which is obtained by changing the convolution coefficient of the convolution kernel g initially set in step 2; the depth information matrix T is the original convolved matrix, which is obtained in step 1. The calculation result can be expressed as follows according to formula 2:
[0065] f(u, v)*g=a u-1,v-1 b 1,1 +a u-1,v b 1,0 +a u-1,v+1 b 1,-1 +a v,v-1 b 0,1 +a u,v b 0,0 +a u,v+1 b 0,-1 +a u+1,v- 1b -1,1 +a u+1,v b -1,0 +a u+1,v+1 b -1,-1 Formula 3
[0066] The depth information matrix T is:
[0067]
[0068] set up
[0069] Sharpening convolution kernel
[0070] Smoothing convolution kernel
[0071] The pixel matrix of the convolution area in the picture is If the depth information of adjacent pixels is compared, for example, there are 9 pixels in the T matrix, that is, there are 9 pixels in the convolution area, and the middle pixel a u,v Compare the depth information values with the surrounding 8 pixels. If the difference is less than d, d is a constant, and d is the distance difference between the objects represented by the two adjacent pixels. For example, assuming d = 50 meters, and the two adjacent pixels represent a house and a tree respectively, the depth information of the house and the tree can be obtained respectively by the above step 1, that is, their distances from the eye point respectively. The difference between these two distances can be used to obtain the distance between the house and the tree. In this case, d is set to 50 meters. If the distance between the house and the tree is greater than the set 50 meters, a sharpening convolution kernel is used between the two pixels to make the house in the near distance clear and the tree in the far distance blurred. If the distance between the house and the tree is less than or equal to the set 50 meters, a smoothing convolution is used between the two pixels to make the clarity of the house and the tree similar, and to smooth the relationship between the house and the tree. The relationship is as follows:
[0072]
[0073] like Figure 3 As shown above, the convolution of a single pixel is an example. The distance d can be adjusted as needed. 1 and g 2 It can also be adjusted so that the convolution of the entire image can be processed by the general convolution formula, as follows:
[0074] f(u,v)*g(m,n)=∑f(u,v)g(mu,nv) Equation 5
[0075] f(u, v) is the input image, g(m, n) is the convolution kernel, and (u, v) is the pixel coordinate on the original image. To achieve a more refined picture effect, the convolution area can be increased horizontally. In this example, a 3*3 convolution kernel is used. Vertically, the levels between smoothing and sharpening can be subdivided according to the pixel depth information, that is, multiple convolution kernels are calculated according to different depths of field.
[0076] Step 4: Adjust the parameters of the smoothing convolution kernel and the sharpening convolution kernel
[0077] In the above step 2, the convolution kernel is set and the preliminary convolution coefficient is set. In step 3, the convolution calculation is performed with the preliminary set convolution coefficient and the convolution result is obtained. Therefore, when the result is not satisfactory in this step, the parameters of the smoothing convolution kernel and the sharpening convolution kernel must be adjusted. Before adjusting the convolution coefficient in the convolution kernel, we must first understand the nature of smoothing and sharpening. Sharpening makes objects close to the eye point clearer and Gaussian blurs distant objects; smoothing is Gaussian filtering of the image to make two objects at close distances have similar clarity and a more natural transition of pixel values; Gaussian filtering is to take the weighted average of a pixel point and the surrounding pixels, so that the pixel value of each pixel point will be affected by the surrounding pixel values, and there will be no particularly abrupt pixels, so that noise can be eliminated, and sharpening is just the opposite. By adjusting the matrix parameters of the convolution kernel, the weighted range value can be adjusted, that is, the value of the convolution kernel can be controlled to obtain the required filtering effect, such as Figure 5 shown.
[0078] As an embodiment disclosed in the present invention, the present invention further discloses a picture processing system, which implements the method described above and includes the following modules:
[0079] The acquisition module is used to obtain the depth information of each pixel in the picture;
[0080] Setting module, used to set the convolution kernel of the picture;
[0081] An operation module, configured to perform a convolution operation by multiplying the depth information by a convolution kernel;
[0082] The adjustment module is used to judge the operation results. If they do not meet the preset requirements, the convolution kernel is adjusted and the operation is repeated.
[0083] As an embodiment disclosed in the present invention, the present invention further discloses an electronic device, comprising:
[0084] a memory storing executable instructions;
[0085] A processor runs the executable instructions in the memory to implement the method described in the present invention.
[0086] As an embodiment disclosed in the present invention, the present invention further discloses a computer storage medium, on which a computer program is stored. The computer program is executed by a processor to implement the method described in the present invention.
[0087] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The singular forms "a", "an", "the" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise.
[0088] The foregoing description shows and describes several preferred embodiments of the present invention. However, as previously mentioned, it should be understood that the present invention is not limited to the disclosed form and should not be construed as excluding other embodiments. Instead, the present invention can be used in various other combinations, modifications, and environments and can be modified within the scope of the present invention through the above teachings or through techniques or knowledge in the relevant field. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention are intended to be protected by the appended claims.
Claims
1. A picture processing method, It is characterized in that The method comprises the steps of: S1. Obtain the depth information of each pixel in the picture; S2. Set the convolution kernel of the image; S3. multiplying the depth information by the convolution kernel to perform a convolution operation; S4. The operation result is judged. If it does not meet the preset requirements, return to S2 to adjust the convolution kernel and repeat the operation until the requirements are met.
2. The image processing method according to claim 1, It is characterized in that The convolution kernel includes a smoothing convolution kernel and a sharpening convolution kernel.
3. The image processing method according to claim 2, It is characterized in that The depth information is obtained by cyclically tracking the distance between the eye point and all pixels in the screen image and the intersecting objects in the scene.
4. The image processing method according to claim 2, It is characterized in that The S3 includes: comparing the depth information of a certain pixel with the depth information of its adjacent pixels, and selecting a smoothing convolution kernel or a sharpening convolution kernel according to the comparison result.
5. The image processing method according to claim 4, It is characterized in that The method further includes: when the correlation between the depth information of a certain pixel and the depth information of its adjacent pixels is less than or equal to a set constant, performing a convolution operation on the depth information of the certain pixel and a smoothing convolution kernel.
6. The image processing method according to claim 5, It is characterized in that The method further includes: when the correlation between the depth information of a certain pixel and the depth information of its adjacent pixels is greater than a set constant, performing a convolution operation on the depth information of the certain pixel and a sharpening convolution kernel.
7. The image processing method according to claim 4, It is characterized in that The smoothing convolution kernel is obtained by performing Gaussian filtering on the image, that is, taking the weighted average of a pixel and surrounding pixels.
8. A picture processing system, It is characterized in that The system implements the method described in any one of claims 1 to 7, and includes the following modules: An acquisition module is used to obtain the depth information of each pixel in the picture; The setting module is used to set the convolution kernel of the picture; A calculation module, used for performing a convolution operation by multiplying the depth information with a convolution kernel; The adjustment module is used to judge the operation result. If it does not meet the preset requirements, the convolution kernel is adjusted and the operation is repeated until the requirements are met.
9. An electronic device, It is characterized in that The electronic device comprises: A memory storing executable instructions; A processor, wherein the processor runs the executable instructions in the memory to implement the method according to any one of claims 1 to 7.
10. A computer storage medium, It is characterized in that The medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 7.
