Image filtering method, image filtering device, storage medium and electronic equipment
By obtaining the preset sampling distribution and calculating the sampling coordinates during image filtering, and determining the filtering results based on the sampled pixel values, the problems of low filtering efficiency and inaccurate results in the existing technology are solved, and efficient and accurate image filtering processing is achieved.
Patent Information
- Application Number
- CN202310221843.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-08
- Publication Date
- 2024-09-10
AI Technical Summary
The weighted filtering method in the prior art has low processing efficiency, increases the power consumption of the terminal, and there are differences between the sampling results and the Gaussian filtering results, resulting in inaccurate filtering results.
By obtaining the preset sampling distribution of the image to be processed and the sampling coordinates of the sampling points, the filtering results are determined based on the sampling pixel values at the sampling coordinates. The sampling coordinates are calculated based on the weight of the filter kernel, reducing the number of readings of pixel values and improving filtering efficiency. and accuracy.
It improves the efficiency of image filtering, reduces power consumption, ensures that the sampling filtering results are consistent with the filtering kernel filtering results, enhances the accuracy of filtering, and provides flexible sampling distribution settings.
Smart Images

Figure CN118628359A
Abstract
Description
Background Art
[0002] Weighted filtering is widely used in image processing. For example, it may be used in scenes such as portrait beautification and portrait blur.
[0003] However, the processing efficiency of the weighted filtering method in the related art is low, which increases the power consumption of the terminal.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The purpose of the present disclosure is to provide an image filtering method, an image filtering device, a computer-readable medium and an electronic device, thereby improving the efficiency of image filtering at least to a certain extent and reducing the power consumption of the terminal by the filtering process.
[0006] According to a first aspect of the present disclosure, there is provided an image filtering method, comprising: obtaining a preset sampling distribution of a current pixel point to be processed of an image to be processed; for each sampling point in the preset sampling distribution, determining a sampling coordinate of the sampling point according to a weight corresponding to a pixel point in the image to be processed on which the sampling point depends in a filter kernel; obtaining a sampling pixel value at the sampling coordinate, and determining a filtering result of the pixel point to be processed based on the sampling pixel value at each sampling coordinate.
[0007] According to a second aspect of the present disclosure, another image filtering method is provided, comprising: obtaining, for a current pixel point to be processed of an image to be processed, preset reference coordinates of a sampling point of a filter kernel and preset offset coordinates of the sampling point based on the preset reference coordinates; determining the sampling coordinates of the sampling point according to the preset reference coordinates and the preset offset coordinates; obtaining sampling pixel values at the sampling coordinates, and determining a filtering result of the pixel point to be processed based on the sampling pixel values at each sampling coordinate; wherein the preset offset coordinates are predetermined according to the weights corresponding to the pixel points in the filter kernel on which the sampling point depends in the image to be processed.
[0008] According to a third aspect of the present disclosure, there is provided an image filtering device, comprising: a preset sampling distribution acquisition module, configured to acquire a preset sampling distribution of a current pixel point to be processed of an image to be processed; a first sampling coordinate determination module, configured to determine, for each sampling point in the preset sampling distribution, the sampling coordinates of the sampling point according to the weight corresponding to the pixel point in the filter kernel on which the sampling point depends in the image to be processed; and a filtering result determination module, configured to acquire the sampling pixel value at the sampling coordinate, and determine the filtering result of the pixel point to be processed based on the sampling pixel value at each sampling coordinate.
[0009] According to a fourth aspect of the present disclosure, another image filtering device is provided, comprising: a preset offset coordinate acquisition module, configured to acquire, for a current pixel point to be processed of an image to be processed, preset reference coordinates of a sampling point of a filter kernel and preset offset coordinates of the sampling point based on the preset reference coordinates; a second sampling coordinate determination module, configured to determine the sampling coordinates of the sampling point according to the preset reference coordinates and the preset offset coordinates; a filtering processing module, configured to acquire sampling pixel values at the sampling coordinates, and determine a filtering result of the pixel point to be processed based on the sampling pixel values at each sampling coordinate; wherein the preset offset coordinates are predetermined according to the weights corresponding to the pixel points on which the sampling point depends in the image to be processed in the filter kernel.
[0010] According to a fifth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the image filtering method described in the first aspect and / or the second aspect is implemented.
[0011] According to the sixth aspect of the present disclosure, an electronic device is provided, characterized in that it includes: one or more processors; and a memory for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the image filtering method described in the first aspect and / or the second aspect above.
[0012] According to a seventh aspect of the present disclosure, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the steps of the image filtering method as described in the first aspect and / or the second aspect.
[0013] The technical solution disclosed in this disclosure has the following beneficial effects:
[0014] Based on the technical solution disclosed in the present invention, on the one hand, filtering is performed through sampling, which can reduce the number of times the pixel value is read during the filtering process, thereby improving the filtering efficiency and reducing the power consumption of the terminal device during the filtering process; on the other hand, the sampling coordinates in the present invention are calculated based on the weight of the filter kernel, so that the sampling filtering result is consistent with the filter kernel filtering result, thereby improving the accuracy of the filtering; on the other hand, the preset sampling distribution in the present invention can be customized according to user needs, so as to determine the pixel points that the sampling point depends on in the image to be processed according to the preset sampling distribution, and determine the sampling coordinates of the sampling point, thereby improving the flexibility of sampling to adapt to different sampling needs.
[0015] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0017] Figure 1 A schematic diagram showing a filter kernel in an exemplary embodiment of the present disclosure;
[0018] Figure 2 A schematic diagram showing pixel representation in an exemplary embodiment of the present disclosure;
[0019] Figure 3 A schematic diagram showing a system architecture to which exemplary embodiments of the present disclosure may be applied;
[0020] Figure 4 A schematic diagram showing a flow chart of an image filtering method in an exemplary embodiment of the present disclosure;
[0021] Figure 5 A schematic diagram showing the distribution of preset sampling points in an exemplary embodiment of the present disclosure;
[0022] Figure 6 A schematic flow chart showing a method for determining sampling coordinates in an exemplary embodiment of the present disclosure;
[0023] Figure 7 A schematic diagram showing another filter kernel in an exemplary embodiment of the present disclosure;
[0024] Figure 8 A schematic flow chart showing another image filtering method in an exemplary embodiment of the present disclosure;
[0025] Fig. 9 A schematic structural diagram of an image filtering device in an exemplary embodiment of the present disclosure is shown;
[0026] Fig.10 A schematic structural diagram showing another image filtering device in an exemplary embodiment of the present disclosure;
[0027] Fig.11 A schematic diagram showing an electronic device to which the exemplary embodiments of the present disclosure can be applied. DETAILED DESCRIPTION
[0028] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0029] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0030] Weighted filtering is widely used in image processing, such as portrait beautification and portrait blur. Weighted filtering is an image smoothing technology that replaces the pixel value of the center pixel in the local window with the weighted value of all pixel points in the local window of the filter kernel size.
[0031] In a related technique, the filter kernel is used as Figure 1 Taking the 3×3 filter kernel as an example, when filtering, each pixel to be processed corresponds to a GPU (Graphics process unit, graphics processor) thread, reads the pixel values of the 9 pixels within the filter kernel range corresponding to the current pixel to be processed, multiplies the read 9 pixel values by the weight value corresponding to each pixel in the filter kernel to obtain the product value, and then accumulates each product value to obtain the filtering result of the current pixel to be processed. Figure 2 As shown in the example, Figure 2P5 in is the current pixel to be processed, then the filtering result of P5 is P5=W1*P1+W2*P2+W3*P3+W4*P4+W5*P5+W6*P6+W7*P7+W8*P8+W9*P9, where the symbol "*" represents multiplication. That is, in the related art, 9 pixel value readings, 9 multiplications and 8 addition operations are required to calculate the filtering value of each pixel. Obviously, this filtering method is inefficient and will increase the power consumption of the terminal.
[0032] In another related technology, the Gaussian filtering result is obtained according to the average value of multiple pixels corresponding to the target pixel point. Although it can improve the filtering efficiency to a certain extent, it is sampled at fixed coordinates and has poor flexibility. In addition, there is a difference between the sampling result and the Gaussian filtering result, resulting in inaccurate filtering results.
[0033] In view of the above problems, exemplary embodiments of the present disclosure provide an image filtering method and apparatus to improve or overcome the deficiencies in the above related technologies to a certain extent.
[0034] Next, combine Figure 3 The system architecture of the operating environment of this exemplary embodiment is exemplarily described.
[0035] Figure 3 The schematic diagram of the system architecture is shown, and the system architecture 300 may include a terminal 310 and a server 320. The terminal 310 may be a terminal device such as a smart phone, a smart wearable electronic device (such as a smart watch), a tablet computer, a desktop computer, a laptop computer, etc. The server 320 generally refers to a background system that provides related services of the image filtering method in this exemplary embodiment, and may be a server or a cluster formed by multiple servers. The terminal 310 and the server 320 may be connected via a wired or wireless communication link to perform data exchange.
[0036] In an exemplary implementation, the above method may be performed by the server 320. For example, after the user captures the image to be processed through the terminal device 310, the image to be processed may be uploaded to the server 320, and the server 320 may perform the image filtering method in the present disclosure to obtain the filtering result of each pixel in the image to be processed, thereby implementing filtering processing on the image to be processed.
[0037] In another exemplary implementation, the above method may also be executed by the terminal 310. For example, the image filtering method of the present disclosure may be configured in advance in the terminal device 310, and after the terminal device 310 captures the image to be processed, the terminal device 310 may execute the image filtering method of the present disclosure to filter the captured image to be processed, thereby displaying the filtered image in the terminal device 310.
[0038] As can be seen from the above, the execution subject of the image filtering method in this exemplary embodiment may be the terminal 310 or the server 320, and the present disclosure does not limit this.
[0039] Combine the following Figure 4 The image filtering method in this exemplary embodiment is described. Figure 4 An exemplary process of the image filtering method is shown, which may include:
[0040] Step S410, obtaining a preset sampling distribution of a current pixel point to be processed of the image to be processed;
[0041] Step S420, for each sampling point in the preset sampling distribution, determining the sampling coordinates of the sampling point according to the weight corresponding to the pixel point in the filter kernel on which the sampling point depends in the image to be processed;
[0042] Step S430, obtaining the sampling pixel value at the sampling coordinate, and determining the filtering result of the pixel point to be processed based on the sampling pixel value at each sampling coordinate.
[0043] Based on the image filtering method in the present disclosure, on the one hand, filtering processing is performed through sampling, which can reduce the number of times the pixel value is read during the filtering process, thereby improving the filtering efficiency and reducing the power consumption of the terminal device during the filtering process; on the other hand, the sampling coordinates in the present disclosure are calculated based on the weight of the filter kernel, so that the sampling filtering result and the filter kernel filtering result are consistent, thereby improving the accuracy of the filtering; on the other hand, the preset sampling distribution in the present disclosure can be customized according to user needs, so as to determine the pixel points that the sampling point depends on in the image to be processed according to the preset sampling distribution, and determine the sampling coordinates of the sampling point, thereby improving the flexibility of sampling to adapt to different sampling needs.
[0044] Below Figure 4 Each step in the illustrated embodiment is described in detail.
[0045] In step S410, a preset sampling distribution of a current pixel point to be processed of the image to be processed is obtained.
[0046] For example, a preset sampling distribution of the image to be processed can be predetermined, and the preset sampling distribution can be used to indicate how to sample the pixel points covered by the filter kernel, so as to filter the pixel points at the center of the filter kernel based on the pixel values of all the pixel points covered by the filter kernel. The preset sampling distribution can be customized according to user needs, and this exemplary embodiment does not specifically limit this.
[0047] In an exemplary embodiment, the method for determining the preset sampling distribution includes: based on the minimum number of graphics processor sampling times, non-repetitive coverage of all pixel points in the image to be processed required when filtering the current pixel to be processed according to the filter core, so as to determine the preset sampling distribution.
[0048] In other words, the preset sampling distribution can be determined based on the principle of obtaining the pixel values of all the pixels covered by the filter core without duplication based on the minimum number of graphics processor sampling times. The preset sampling distribution determined based on this principle can make the number of sampling points less than the number of pixels covered by the filter core.
[0049] One of the outstanding features of GPU is its texture sampling unit, which can conveniently and efficiently perform bilinear interpolation on images. Each bilinear interpolation involves the values of 4 surrounding pixels, that is, the GPU can obtain the values of up to 4 pixels at a time.
[0050] Taking the GPU as an example, the maximum value of 4 pixels is obtained at one time. For a 3×3 filter kernel, the corresponding preset sampling point distribution can be as follows: Figure 5 As shown, it is necessary to perform at least 4 times to obtain all the pixels covered by the filter kernel. Figure 5 In the example shown, there are no repeated dependent pixels between the four samples. Figure 5 , the pixel value of sampling point a depends on pixel points 1, 2, 4, and 5 in the image to be processed, the pixel value of sampling point b depends on pixel points 3 and 6 in the image to be processed, the pixel value of sampling point c depends on pixel points 7 and 8 in the image to be processed, and the pixel value of sampling point d is the pixel value of pixel point 9 in the image to be processed.
[0051] Of course, the preset sampling distribution can also be set according to one's own needs, such as sampling point a depends on pixel points 1 and 4, sampling point b depends on pixel points 2, 3, 5, 6, sampling point c depends on pixel point 7, sampling point d depends on pixel points 8 and 9, etc. This exemplary embodiment does not make any special limitations on this.
[0052] As mentioned above, the preset sampling distribution can be determined based on the size of the filter kernel and the sampling capacity of the texture sampler of the graphics processor GPU, with the principle of obtaining the pixel values of all pixels covered by the filter kernel with the minimum number of samplings and without duplication. After the preset sampling distribution is determined in advance, any pixel to be processed in the image to be processed can be filtered according to the sampling points in the preset sampling distribution. Of course, different preset sampling distributions can also be used for filtering some special pixels to be processed, that is, the preset sampling distribution of each pixel to be processed can be the same or different, and this exemplary embodiment does not make any special limitation on this.
[0053] It should be noted that the preset sampling distribution only determines the pixel points that each sampling point depends on, but does not give the specific coordinates of the sampling points. Figure 5 For sampling point b, the preset sampling distribution only determines that it can be between pixel point 3 and pixel point 6, but whether it is closer to pixel point 3 or pixel point 6, the preset sampling distribution is not clear, so the sampling coordinates of each sampling point can be determined based on the subsequent step S420.
[0054] Continue to refer Figure 4 In step S420, for each sampling point in the preset sampling distribution, the sampling coordinates of the sampling point are determined according to the weight corresponding to the pixel point in the filter kernel on which the sampling point depends in the image to be processed.
[0055] For example, after obtaining the preset sampling distribution of the current pixel points to be processed of the image to be processed in step S410, the pixel points that each sampling point depends on in the image to be processed can be determined according to the preset sampling distribution.
[0056] For example, Figure 6 A schematic flow chart of a method for determining sampling coordinates in an exemplary embodiment of the present disclosure is shown. Figure 6 , the method may include steps S610 to S630.
[0057] In step S610, for each sampling point in the preset sampling distribution, a first sampling value expression of the sampling point is determined according to the sampling method of the texture sampling unit of the graphics processor, the pixel points on which the sampling point depends in the image to be processed, and the bias coordinates to be solved of the sampling point.
[0058] The sampling method of the GPU texture sampling unit is bilinear interpolation based on the sampling point coordinates. Figure 5The sampling point a in the image has a coordinate of pixel 1 offset by (x, y), that is, the offset coordinate to be solved is (x, y), where x is greater than or equal to 0, and y is less than or equal to 1, that is, the sampling coordinate C of the sampling point a. a C a =C1+(x,y), where C1 represents the coordinates of pixel 1. For example, the sampling result of sampling point a is based on the bilinear interpolation result of pixel points 1, 2, 4, and 5. Then, according to the principle of bilinear interpolation, the sampling value I of sampling point a is a , that is, the first sampling value expression of sampling point a can be expressed as follows (1)
[0059] I a =(1.0-x)(1.0-y)I1+x(1.0-y)I2+(1.0-x)yI4+xyI5 (1)
[0060] In formula (1), I1 is the pixel value of pixel point 1, I2 is the pixel value of pixel point 2, I4 is the pixel value of pixel point 4, and I5 is the pixel value of pixel point 5.
[0061] In other words, in the first sampling value expression of the sampling point a, the coefficient of the pixel value of the pixel point on which the sampling point a depends in the image to be processed is related to the sampling coordinates of the sampling point a.
[0062] In step S620, based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel, the value of the to-be-solved offset coordinate of the sampling point is determined.
[0063] In an exemplary embodiment, the filter kernel in the present disclosure can be customized according to user needs. It can be a Gaussian filter kernel or other filter kernels, a two-dimensional filter kernel or a one-dimensional filter kernel. This exemplary embodiment does not make any special limitations on this.
[0064] Exemplarily, a specific implementation of step S620 may include: determining the value of the bias coordinate to be solved of the sampling point so that the ratio of the coefficients of the pixel points in the first sampling value expression is the same as the ratio of the weights corresponding to the pixel points in the filter kernel.
[0065] As mentioned above, the coefficients of the pixel values of the pixels in the first sampling value expression of the sampling point are all related to the sampling coordinates of the sampling point. Based on this, the coefficient ratio of the pixel points that the sampling point depends on in the first sampling value expression can be made consistent with the weights corresponding to the pixel points in the filter kernel, thereby solving the sampling coordinates of the sampling point. In this way, the filtering result after sampling can be consistent with the original filtering result of the filter kernel, thereby improving the accuracy of filtering.
[0066] The sampling point is Figure 5 The sampling point a and the filter kernel are Figure 7 Taking the 3×3 filter kernel in as an example, the filter weight corresponding to the pixel 1 on which the sampling point a depends is 0.0625, the filter weight of the pixel 2 on which the sampling point a depends is 0.125, the filter weight of the pixel 4 on which the sampling point a depends is 0.125, and the filter weight of the pixel 5 on which the sampling point a depends is 0.25. When the ratio of the coefficients of the pixel points in the first sampling value expression is the same as the ratio of the weights corresponding to the pixel points in the filter kernel, the following equations (2), (3), and (4) can be obtained:
[0067]
[0068]
[0069]
[0070] By using the above equations (2), (3) and (4), we can solve x=2 / 3 and y=2 / 3, thus obtaining the value of the bias coordinate of the sampling point to be solved.
[0071] In step S630, the sampling coordinates of the sampling point are determined according to the preset reference coordinates of the sampling point and the values of the offset coordinates to be solved.
[0072] In an exemplary embodiment, the preset reference coordinates of the sampling points can be predetermined based on the preset sampling distribution of the filter kernel. Figure 5 1 to 9 pixels shown in the figure are taken as examples, that is, for any pixel to be processed, when filtering, the preset reference coordinate of sampling point a can be any one of the 4 pixels in the upper left corner on which it depends, such as the first pixel in the upper left corner is the preset reference coordinate of sampling point a. In this way, when processing any pixel to be processed, the preset reference coordinate of sampling point a is the first pixel in the upper left corner covered by the filter kernel; for any pixel to be processed, the preset reference coordinate of the second sampling point b can be the coordinate of the last pixel in the first row of pixels currently covered by the filter kernel, that is, Figure 5 For any pixel to be processed, the preset reference coordinates of the third sampling point c can be the coordinates of the first pixel in the third row of the first column of all pixels covered by the filter kernel, that is, Figure 5 for any pixel to be processed, the preset reference coordinates of the fourth sampling point d can be the coordinates of the third pixel in the third row and the third column of the pixel currently covered by the filter kernel.
[0073] Continue with Figure 5 For example, the coordinates of sampling point a are obtained by offsetting the coordinates of pixel point 1 by (x, y). In other words, pixel point 1 is the reference coordinate of sampling point a. Then the coordinates of sampling point a are C a C a =C1+(2 / 3,2 / 3). In this way, the coordinates of sampling point a can be determined by the value of the offset coordinate to be solved and the reference coordinates of sampling point a (ie, the coordinates of pixel point 1).
[0074] In other words, when determining the coordinates of the sampling point, a preset reference coordinate can be determined in advance based on the pixel points that the sampling point depends on in the image to be processed, such as Figure 5 For the sampling point a in, its reference coordinates can be the coordinates of pixel point 1, and of course, can also be the coordinates of any pixel point among pixel points 2, 4, and 5. Then, it is assumed that the coordinates of the sampling point are offset by a to-be-solved offset coordinate on the basis of the preset reference coordinates, such as the above-mentioned (x, y), and then the value of the to-be-solved offset coordinate is obtained according to the above-mentioned steps S610 to S620. Finally, the sampling coordinates of the sampling point can be determined according to the preset reference coordinates and the values of the to-be-solved offset coordinates.
[0075] It should be noted that, for the value of the offset coordinate to be solved, it can be determined based on the first pixel to be processed or any pixel to be processed in the image to be processed through the above steps S610 to S620. After the determination, for all other pixels to be processed in the image to be processed, the value of the offset coordinate to be solved of the sampling point is the same, that is, when processing other pixels, the value of the offset coordinate to be solved is directly obtained, and then based on the current preset reference coordinate, the current sampling point coordinate can be obtained. In this way, the filtering efficiency can be further improved.
[0076] Continue to refer Figure 4 In step S430, the sampling pixel value at the sampling coordinate is obtained, and the filtering result of the pixel point to be processed is determined based on the sampling pixel value at each sampling coordinate.
[0077] In an exemplary implementation, after the sampling coordinates of each sampling point are determined, the pixel value at the sampling coordinates can be directly obtained through the GPU, and then the pixel values at the sampling coordinates are summed to obtain the filtering result of the pixel to be processed. Figure 5 For example, by summing the sampling results of sampling points a, b, c, and d, the filtering result of the pixel point 5 to be processed can be obtained, that is, the pixel value of the pixel point 5 to be processed is adjusted to the filtering result.
[0078] Exemplarily, in the present disclosure, for each sampling point in the preset sampling distribution, the fusion weight of the sampling point can be determined according to the weight in the filter kernel corresponding to the pixel point on which the sampling point depends in the image to be processed. Based on this, another specific implementation of step S430 may include: obtaining the sampling pixel value at the sampling coordinate, and determining the filtering result of the pixel point to be processed based on the sampling pixel value at each sampling coordinate and the fusion weight of each sampling point.
[0079] Exemplarily, for each sampling point in the preset sampling distribution, the fusion weight of the sampling point is determined according to the weight corresponding to the pixel point on which the sampling point depends in the image to be processed and in the filter kernel, including: for each sampling point in the preset sampling distribution, according to the sampling mode of the texture sampling unit of the graphics processor, the pixel point on which the sampling point depends in the image to be processed and the bias coordinate to be solved of the sampling point, a first sampling value expression of the sampling point is determined; based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel, the value of the bias coordinate to be solved of the sampling point is determined; according to the value of the bias coordinate to be solved of the sampling point, the coefficient value of the pixel point on which the sampling point depends in the first sampling value expression in the image to be processed is determined; and the fusion weight of the sampling point is determined so that the coefficient value of at least one pixel point in the first sampling value expression is the same as the weight corresponding to the pixel point in the filter kernel.
[0080] For example, according to the above steps S610 to S620, the value of the bias coordinate to be solved of the sampling point can be determined, and the coefficient value of each pixel point in the first sampling value expression can be determined based on the value of the bias coordinate to be solved of the sampling point. Figure 5 Taking the sampling point a in as an example, after solving x=2 / 3, y=2 / 3 according to the above equations (2), (3), and (4), x=2 / 3, y=2 / 3 can be substituted into the first sampling value expression, that is, the above equation (1), and the following expression (5) can be obtained:
[0081] I a =(1.0 / 9)I1+(2.0 / 9)I2+(2.0 / 9)I4+(4.0 / 9)I5(5)
[0082] That is, the coefficient value of pixel 1 is 1.0 / 9, the coefficient value of pixel 2 is 2.0 / 9, the coefficient value of pixel 4 is 2.0 / 9, and the coefficient value of pixel 5 is 4.0 / 9. Through the above steps S610 to S630, the value of the sampling point can be made to have the same ratio of the filter weights corresponding to the pixels 1, 2, 4, and 5 on which it depends, such as the ratio of the coefficient of pixel 1 to the coefficient of pixel 2 and the ratio of the filter weight of pixel 1 to the filter weight of pixel 2. However, the coefficient of the pixel on which the sampling point depends in the value of the sampling point is still different from the filter weight of the pixel in the filter kernel. For example, in formula (5), the coefficient of pixel 1 is 1.0 / 9, and the filter weight corresponding to pixel 1 is 0.0625, which are different. Based on this, the fusion weight of the sampling point can be determined by making the coefficient value of at least one pixel in the first sampling value expression the same as its filter weight in the filter kernel. In this way, the difference between the value obtained by sampling at the sampling point a and the value after weighting by the filter kernel can be made smaller, thereby ensuring the accuracy of filtering.
[0083] Taking the above formula (5) as an example, the coefficient of each sampling point is multiplied by In the case of , the coefficient value of each pixel can be made the same as its filter weight in the filter kernel, that is, we can get In other words, multiply the sample value at sampling point a by This makes the coefficient value of each pixel point (1, 2, 4, 5) on which the sampling value of sampling point a depends the same as the filtering weight of the pixel point in the filter kernel. Then, the fusion weight F of sampling point a is a equal
[0084] Thus, the coordinate C of the sampling point a a =C1+(2.0 / 3,2.0 / 3), and multiply the pixel value of sampling point a obtained by the GPU based on the sampling coordinates of sampling point a by The accumulated values of pixels 1, 2, 4, and 5 corresponding to the filter kernel weights can be obtained.
[0085] It should be noted that, in the case of a preset sampling distribution response for each pixel point, the fusion weight of the sampling point is the same as the value of the bias coordinate to be solved for the sampling point, and can also be determined based on the first pixel point to be processed or any pixel point to be processed in the image to be processed through the above steps S610 to S620. After the determination, the fusion weight of the sampling point is the same for all other pixels to be processed in the image to be processed, that is, when processing other pixels, the fusion weight of the corresponding sampling point is directly obtained to perform filtering based on the fusion weight and the sampled pixel value. In this way, the filtering efficiency can be further improved.
[0086] Exemplarily, the obtaining of the sampled pixel values at the sampling coordinates and determining the filtering result of the pixel to be processed based on the sampled pixel values at each sampling coordinate and the fusion weight of each sampling point include: obtaining the sampled pixel values at the sampling coordinates; calculating the product of the sampled pixel values at each sampling coordinate and the fusion weight of each sampling point; and determining the filtering result of the pixel to be processed according to the sum of the products of the sampled pixel values at the sampling coordinates of each sampling point and the fusion weight of the sampling point.
[0087] For example, based on the method of determining the sampling coordinates of the sampling points and the fusion weights of the sampling points in the present disclosure, it is possible to determine Figure 5 The sampling coordinates and fusion weights of the sampling points b, c, and d in are: C d =C9, Among them, C b , C c , C d Respectively represent the sampling coordinates of b, c, and d, and F b 、F c 、F d Respectively represent the fusion weights of b, c, and d. Based on this, we can get Figure 5 The filtering result of the pixel 5 to be processed in is:
[0088] That is to say, through the image filtering method disclosed in the present invention, for a filter kernel of size 3×3, it is only necessary to obtain the pixel values of sampling points a, b, c, and d, and then respectively multiply the sampling values of sampling points a, b, c, and d by the fusion weights of the sampling points, and then add the results of the multiplication of each sampling point to obtain the filtering result. That is, only 4 samplings, 4 multiplications, and 3 additions are required to obtain the filtering result. Compared with 9 samplings, 9 multiplications, and 8 additions in the related art, the number of samplings, the number of multiplication operations, and the number of addition operations are reduced, so the filtering efficiency can be greatly improved. And by determining the fusion weights and sampling coordinates, while improving the filtering efficiency, it can ensure that the results of the sampling filtering are the same as the results of the direct filtering of the filter kernel, that is, the accuracy of the filtering is guaranteed.
[0089] For example, Figure 8 FIG. 1 is a flow chart showing another image filtering method in an exemplary embodiment of the present disclosure. Figure 8 , the image filtering method may include steps S810 to S830, wherein:
[0090] In step S810, for a current pixel to be processed of the image to be processed, a preset reference coordinate of a sampling point of a filter kernel and a preset offset coordinate of the sampling point based on the preset reference coordinate are obtained.
[0091] The method for determining the preset reference coordinates may refer to the description of the relevant contents in the above-mentioned step S630, which will not be described in detail here.
[0092] In an exemplary embodiment, the preset offset coordinates are predetermined according to weights corresponding to pixel points in the filter kernel on which the sampling point depends in the image to be processed.
[0093] Exemplarily, the preset bias coordinates are predetermined based on the weights corresponding to the pixel points in the filter kernel on which the sampling point depends in the image to be processed, including: for each preset sampling point, determining a first sampling value expression for the sampling point based on the sampling method of the texture sampling unit of the graphics processor, the pixel points on which the sampling point depends in the image to be processed, and the bias coordinates to be solved; predetermining the value of the bias coordinates to be solved for the sampling point based on the coefficients of the pixel points in the first sampling value expression and the weights corresponding to the pixel points in the filter kernel, and determining the preset bias coordinates based on the value of the bias coordinates to be solved.
[0094] In an exemplary embodiment, based on the coefficients of the pixel points in the first sampling value expression and the weights corresponding to the pixel points in the filter kernel, the values of the bias coordinates to be solved of the sampling points are pre-determined, including: pre-determining the values of the bias coordinates to be solved of the sampling points so that the ratio of the coefficients of the pixel points in the first sampling value expression is the same as the ratio of the weights corresponding to the pixel points in the filter kernel.
[0095] The specific implementation of the method for determining the value of the offset coordinate to be determined can refer to the above-mentioned steps S610 to S620, which will not be described in detail here. After the value of the offset coordinate to be determined for the preset sampling point is determined in advance, the value of the offset coordinate to be determined can be determined as the preset offset coordinate of the sampling point. That is, the corresponding preset offset coordinate can be pre-configured for each sampling point in the filtering algorithm.
[0096] In step S820, the sampling coordinates of the sampling points are determined according to the preset reference coordinates and the preset offset coordinates.
[0097] For example, for each sampling point, a preset offset coordinate may be added to the preset reference coordinate of the sampling point to obtain the sampling coordinate of the sampling point.
[0098] In step S830, the sampling pixel value at the sampling coordinate is obtained, and the filtering result of the pixel point to be processed is determined based on the sampling pixel value at each sampling coordinate.
[0099] Exemplarily, a specific implementation of step S830 may include: after determining the sampling coordinates of each sampling point, the pixel value at the sampling coordinates can be directly obtained through the GPU, and then the pixel values at the sampling coordinates are summed to obtain the filtering result of the pixel point to be processed.
[0100] Exemplarily, another specific implementation of step S830 may include: obtaining a preset fusion weight for each sampling point, and determining a filtering result for the pixel point to be processed based on the preset fusion weight for each sampling point and a sampled pixel value at a sampling coordinate of the sampling point.
[0101] In an exemplary embodiment, the preset fusion weight is predetermined in the following manner: for each sampling point in a preset sampling distribution, a first sampling value expression of the sampling point is determined according to the sampling method of the texture sampling unit of the graphics processor, the pixel point on which the sampling point depends in the image to be processed, and the bias coordinate to be solved of the sampling point; based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel, the value of the bias coordinate to be solved of the sampling point is determined; according to the value of the bias coordinate to be solved of the sampling point, the coefficient value of the pixel point on which the sampling point depends in the first sampling value expression in the image to be processed is determined; and the fusion weight of the sampling point is determined so that the coefficient value of at least one pixel point in the first sampling value expression is the same as the weight corresponding to the pixel point in the filter kernel.
[0102] The specific implementation of presetting the fusion weight may refer to the specific implementation of determining the fusion weight of each sampling point mentioned above, which will not be described in detail here.
[0103] In other words, in the present disclosure, the sampling coordinates and fusion weights of the sampling points can be calculated when processing the image to be processed. In this way, even if the sampling coordinates and fusion weights need to be calculated during processing, this part of the calculation can still save processing time compared to the sampling, multiplication and addition calculations during filtering. In addition, when the preset sampling distribution of each pixel point to be processed is the same, only the fusion weights and bias coordinates need to be calculated once, and all the pixels can be shared, which can also improve the filtering efficiency. Of course, the bias coordinates and fusion weights can also be determined in advance according to the preset sampling distribution, so that when filtering, they can be directly obtained, which further improves the filtering efficiency.
[0104] The present invention makes full use of the capabilities of the GPU and can determine appropriate image sampling coordinates based on the requirements of the filtering weights of the filtering kernel, thereby meeting the original weight filtering requirements with fewer sampling times and fewer calculations, thereby reducing the processing time and power consumption of the terminal algorithm.
[0105] In summary, based on the technical solution disclosed in the present invention, on the one hand, filtering is performed through sampling, which can reduce the number of times the pixel value is read during the filtering process, thereby improving the filtering efficiency and reducing the power consumption of the terminal device during the filtering process; on the other hand, the sampling coordinates in the present invention are calculated according to the weight of the filter kernel, so that the sampling filtering result is consistent with the filtering result of the filter kernel, thereby improving the accuracy of the filtering; on the other hand, the preset sampling distribution in the present invention can be customized according to user needs, so as to determine the pixel points that the sampling point depends on in the image to be processed according to the preset sampling distribution, and determine the sampling coordinates of the sampling point, thereby improving the flexibility of sampling to adapt to different sampling needs.
[0106] It should be noted that the above figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0107] For further reference, Fig. 9 As shown, in the embodiment of this example, an image filtering device 900 is also provided, referring to Fig. 9 The image filtering device 900 may include a preset sampling distribution acquisition module 910, a first sampling coordinate determination module 920 and a filtering result determination module 930, wherein: the preset sampling distribution acquisition module 910 is configured to acquire the preset sampling distribution of the current pixel point to be processed of the image to be processed; the first sampling coordinate determination module 920 is configured to determine the sampling coordinates of each sampling point in the preset sampling distribution according to the corresponding weight of the pixel point in the filtering kernel on which the sampling point depends in the image to be processed; the filtering result determination module 930 is configured to acquire the sampling pixel value at the sampling coordinate, and determine the filtering result of the pixel point to be processed based on the sampling pixel value at each sampling coordinate.
[0108] In an exemplary embodiment, based on the foregoing embodiment, the first sampling coordinate determination module 920 may also be specifically configured as follows: for each sampling point in a preset sampling distribution, according to the sampling method of the texture sampling unit of the graphics processor, the pixel point on which the sampling point depends in the image to be processed, and the bias coordinate to be solved of the sampling point, determine the first sampling value expression of the sampling point; based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel, determine the value of the bias coordinate to be solved of the sampling point; determine the sampling coordinate of the sampling point according to the preset reference coordinate of the sampling point and the value of the bias coordinate to be solved.
[0109] In an exemplary embodiment, based on the aforementioned embodiment, determining the value of the bias coordinate to be solved of the sampling point based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel includes: determining the value of the bias coordinate to be solved of the sampling point so that the ratio of the coefficients of the pixel point in the first sampling value expression is the same as the ratio of the weight corresponding to the pixel point in the filter kernel.
[0110] In an exemplary embodiment, based on the foregoing embodiment, the device 900 may further include a fusion weight determination module, and the fusion weight determination module is configured to: for each sampling point in the preset sampling distribution, determine the fusion weight of the sampling point according to the corresponding weight of the pixel point in the filter kernel on which the sampling point depends in the image to be processed; based on this, the filtering result determination module 930 may be configured to: obtain the sampling pixel value at the sampling coordinate, and determine the filtering result of the pixel point to be processed based on the sampling pixel value at each sampling coordinate and the fusion weight of each sampling point.
[0111] In an exemplary embodiment, based on the foregoing embodiment, for each sampling point in the preset sampling distribution, the fusion weight of the sampling point is determined according to the weight corresponding to the pixel point in the filter kernel on which the sampling point depends in the image to be processed, including: for each sampling point in the preset sampling distribution, according to the sampling mode of the texture sampling unit of the graphics processor, the pixel point on which the sampling point depends in the image to be processed, and the bias coordinate to be solved of the sampling point, a first sampling value expression of the sampling point is determined; based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel, the value of the bias coordinate to be solved of the sampling point is determined; according to the value of the bias coordinate to be solved of the sampling point, the coefficient value of the pixel point on which the sampling point depends in the first sampling value expression in the image to be processed is determined; and the fusion weight of the sampling point is determined so that the coefficient value of at least one pixel point in the first sampling value expression is the same as the weight corresponding to the pixel point in the filter kernel.
[0112] In an exemplary embodiment, based on the foregoing embodiment, the acquiring the sampled pixel value at the sampling coordinate, and determining the filtering result of the pixel to be processed based on the sampled pixel value at each sampling coordinate and the fusion weight of each sampling point, includes: acquiring the sampled pixel value at the sampling coordinate; calculating the product of the sampled pixel value at each sampling coordinate and the fusion weight of each sampling point; and determining the filtering result of the pixel to be processed according to the sum of the products of the sampled pixel values at the sampling coordinates of each sampling point and the fusion weight of the sampling point.
[0113] For example, Fig.10 Another image filtering device 1000 in an exemplary embodiment of the present disclosure is shown, referring to Fig.10 , the image filtering device 1000 may include: a preset offset coordinate acquisition module 1010, a second sampling coordinate determination module 1020 and a filtering processing module 1030. Wherein: the preset offset coordinate acquisition module 1010 is configured to acquire the preset reference coordinates of the sampling point of the filter kernel and the preset offset coordinates of the sampling point based on the preset reference coordinates for the current pixel point to be processed of the image to be processed; the second sampling coordinate determination module 1020 is configured to determine the sampling coordinates of the sampling point according to the preset reference coordinates and the preset offset coordinates; the filtering processing module 1030 is configured to acquire the sampling pixel values at the sampling coordinates, and determine the filtering result of the pixel point to be processed based on the sampling pixel values at each sampling coordinate; wherein the preset offset coordinates are predetermined according to the weights corresponding to the pixel points in the filtering kernel on which the sampling point depends in the image to be processed.
[0114] In an exemplary embodiment, based on the foregoing embodiment, the preset offset coordinates are predetermined according to the weights corresponding to the pixel points on which the sampling point in the image to be processed depends in the filter kernel, including: for each preset sampling point, according to the sampling method of the texture sampling unit of the graphics processor, the pixel points on which the sampling point in the image to be processed depends and the offset coordinates to be solved, determining the first sampling value expression of the sampling point; based on the coefficients of the pixel points in the first sampling value expression and the weights corresponding to the pixel points in the filter kernel, predetermining the value of the offset coordinates to be solved of the sampling point, and determining the preset offset coordinates according to the value of the offset coordinates to be solved.
[0115] In an exemplary embodiment, based on the foregoing embodiment, the value of the bias coordinate to be solved of the sampling point is pre-determined based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel, including: pre-determining the value of the bias coordinate to be solved of the sampling point so that the ratio of the coefficients of the pixel point in the first sampling value expression is the same as the ratio of the weight corresponding to the pixel point in the filter kernel.
[0116] In an exemplary implementation, based on the foregoing embodiments, the filtering processing module 1030 may be specifically configured to: obtain a preset fusion weight for each sampling point, and determine a filtering result for the pixel to be processed based on the preset fusion weight for each sampling point and the sampled pixel value at the sampling coordinate of the sampling point; wherein the preset fusion weight is predetermined in the following manner: for each sampling point in a preset sampling distribution, determine a first sampling value expression for the sampling point according to a sampling method of a texture sampling unit of a graphics processor, a pixel on which the sampling point depends in the image to be processed, and a bias coordinate to be solved for the sampling point; determine a value of the bias coordinate to be solved for the sampling point based on a coefficient of the pixel in the first sampling value expression and a weight corresponding to the pixel in the filter kernel; determine a coefficient value of the pixel on which the sampling point depends in the first sampling value expression according to the value of the bias coordinate to be solved for the sampling point; and determine the fusion weight of the sampling point so that a coefficient value of at least one pixel in the first sampling value expression is the same as a weight corresponding to the pixel in the filter kernel.
[0117] The specific details of each module in the above device have been described in detail in the implementation method of the method part. The undisclosed details can be found in the implementation method of the method part, so they will not be repeated here.
[0118] The exemplary embodiment of the present disclosure also provides an electronic device for executing the image filtering method, which may be the above-mentioned terminal 310. Generally, the electronic device may include a processor and a memory, the memory is used to store executable instructions of the processor, and the processor is configured to execute the above-mentioned image filtering method by executing the executable instructions.
[0119] The memory may also be used to store information of preset reference coordinates of the sampling points, preset bias coordinates of each preset sampling point, and a fusion weight of each preset sampling point.
[0120] Below Fig.11 Taking the mobile terminal 1100 in FIG. 1 as an example, the structure of the electronic device is exemplarily described. It should be understood by those skilled in the art that, in addition to the components specifically used for mobile purposes, Fig.11 The construction in can also be applied to fixed type equipment.
[0121] like Fig.11 As shown, the mobile terminal 1100 may specifically include: a processor 1101, a memory 1102, a bus 1103, a mobile communication module 1104, an antenna 1, a wireless communication module 1105, an antenna 2, a display screen 1106, a camera module 1107, an audio module 1108, a power module 1109 and a sensor module 1110.
[0122] The processor 1101 may include one or more processing units, for example, the processor 1101 may include an AP (Application Processor), a modem processor, a GPU (Graphics Processing Unit), an ISP (Image Signal Processor), a controller, an encoder, a decoder, a DSP (Digital Signal Processor), a baseband processor and / or an NPU (Neural-Network Processing Unit), etc. For example, in the present disclosure, image filtering processing may be performed by a GPU.
[0123] The processor 1101 may be connected to the memory 1102 or other components via a bus 1103 .
[0124] The memory 1102 may be used to store computer executable program codes, which include instructions. The processor 1101 executes various functional applications and data processing of the mobile terminal 1100 by running the instructions stored in the memory 1102. The memory 1102 may also store application data, such as images, videos and other files, and the memory 1102 may also store the first model, the second model, the third model and the fourth model mentioned above.
[0125] The communication function of the mobile terminal 1100 can be implemented by the mobile communication module 1104, antenna 1, wireless communication module 1105, antenna 2, modem processor and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. The mobile communication module 1104 can provide 2G, 3G, 4G, 5G and other mobile communication solutions applied to the mobile terminal 1100. The wireless communication module 1105 can provide wireless communication solutions such as wireless LAN, Bluetooth, near field communication, etc. applied to the mobile terminal 1100.
[0126] The display screen 1106 is used to implement display functions, such as displaying a user interface, displaying images and videos processed according to the image filtering method of the present disclosure, etc. The camera module 1107 is used to implement shooting functions, such as shooting images and videos, etc. The audio module 1108 is used to implement audio functions, such as playing audio, collecting voice, etc. The power module 1109 is used to implement power management functions, such as charging the battery, powering the device, monitoring the battery status, etc. The sensor module 1110 may include a depth sensor 11101, a pressure sensor 11102, a gyroscope sensor 11103, an air pressure sensor 11104, etc., to implement corresponding sensing detection functions.
[0127] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0128] The exemplary embodiments of the present disclosure also provide a computer-readable storage medium on which a program product capable of implementing the above-mentioned method of the present specification is stored. In some possible implementations, various aspects of the present disclosure can also be implemented in the form of a program product, which includes program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present disclosure described in the above-mentioned "Exemplary Method" section of the present specification, for example, it can execute Figure 4 , Figure 6 , Figure 8 Any one or more steps in .
[0129] The computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0130] In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0131] In addition, program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0132] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0133] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image filtering method, characterized in that: include: Obtaining the preset sampling distribution of the current pixel points to be processed of the image to be processed; For each sampling point in the preset sampling distribution, the sampling coordinates of the sampling point are determined according to the weights corresponding to the pixel points in the to-be-processed image on which the sampling point depends in the filter kernel; The sampling pixel value at the sampling coordinate is obtained, and the filtering result of the pixel point to be processed is determined based on the sampling pixel value at each sampling coordinate.
2. The image filtering method according to claim 1, characterized in that: For each sampling point in the preset sampling distribution, the sampling coordinates of the sampling point are determined according to the weights of the pixels in the filter kernel on which the sampling point depends in the image to be processed, including: For each sampling point in the preset sampling distribution, a first sampling value expression of the sampling point is determined according to a sampling mode of a texture sampling unit of a graphics processor, a pixel point on which the sampling point depends in the image to be processed, and a bias coordinate to be solved of the sampling point; Determine the value of the to-be-solved offset coordinate of the sampling point based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel; The sampling coordinates of the sampling point are determined according to the preset reference coordinates of the sampling point and the values of the offset coordinates to be solved.
3. The image filtering method according to claim 2, characterized in that: Determining the value of the to-be-solved offset coordinate of the sampling point based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel includes: The value of the to-be-solved offset coordinate of the sampling point is determined so that the ratio of the coefficients of the pixel points in the first sampling value expression is the same as the ratio of the weights corresponding to the pixel points in the filter kernel.
4. The image filtering method according to claim 1, characterized in that: The method further comprises: For each sampling point in the preset sampling distribution, determining a fusion weight of the sampling point according to a weight corresponding to a pixel point in the filter kernel on which the sampling point depends in the image to be processed; The acquiring the sampled pixel value at the sampling coordinate, and determining the filtering result of the pixel point to be processed based on the sampled pixel value at each sampling coordinate, comprises: The sampling pixel value at the sampling coordinate is obtained, and based on the sampling pixel value at each sampling coordinate and the fusion weight of each sampling point, the filtering result of the pixel point to be processed is determined.
5. The image filtering method according to claim 4, characterized in that: The step of determining, for each sampling point in the preset sampling distribution, a fusion weight of the sampling point according to a weight corresponding to a pixel point in the image to be processed that the sampling point depends on in the filter kernel, includes: For each sampling point in the preset sampling distribution, a first sampling value expression of the sampling point is determined according to a sampling mode of a texture sampling unit of a graphics processor, a pixel point on which the sampling point depends in the image to be processed, and a bias coordinate to be solved of the sampling point; Determine the value of the to-be-solved offset coordinate of the sampling point based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel; Determine, according to the value of the to-be-solved offset coordinate of the sampling point, the coefficient value of the pixel point on which the sampling point in the to-be-processed image depends in the first sampling value expression; The fusion weight of the sampling point is determined so that the coefficient value of at least one pixel point in the first sampling value expression is the same as the weight corresponding to the pixel point in the filter kernel.
6. The image filtering method according to claim 4, characterized in that: The acquiring the sampled pixel value at the sampling coordinate, and determining the filtering result of the pixel point to be processed based on the sampled pixel value at each sampling coordinate and the fusion weight of each sampling point, comprises: Obtaining a sampled pixel value at the sampling coordinate; Calculate the product of the sampled pixel value at each sampling coordinate and the fusion weight of each sampling point; The filtering result of the pixel point to be processed is determined according to the sum of the product of the sampled pixel value at the sampling coordinate of each sampling point and the fusion weight of the sampling point.
7. An image filtering method, characterized in that: include: For a current pixel point to be processed of the image to be processed, obtaining a preset reference coordinate of a sampling point of the filter kernel and a preset offset coordinate of the sampling point based on the preset reference coordinate; Determining the sampling coordinates of the sampling point according to the preset reference coordinates and the preset offset coordinates; Acquire the sampling pixel value at the sampling coordinate, and determine the filtering result of the pixel point to be processed based on the sampling pixel value at each sampling coordinate; The preset offset coordinates are predetermined according to the weights corresponding to the pixel points in the filter kernel on which the sampling point depends in the image to be processed.
8. The image filtering method according to claim 7, characterized in that: The preset offset coordinates are predetermined according to the weights corresponding to the pixel points in the filter kernel to which the sampling point depends in the image to be processed, including: For each preset sampling point, a first sampling value expression of the sampling point is determined according to a sampling mode of a texture sampling unit of a graphics processor, a pixel point on which the sampling point depends in the image to be processed, and a bias coordinate to be solved; Based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel, the value of the bias coordinate to be solved of the sampling point is determined in advance, The preset offset coordinates are determined according to the values of the offset coordinates to be solved.
9. The image filtering method according to claim 8, characterized in that: Based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel, the value of the bias coordinate to be solved of the sampling point is pre-determined, including: The value of the to-be-solved offset coordinate of the sampling point is predetermined so that the ratio of the coefficients of the pixel points in the first sampling value expression is the same as the ratio of the weights corresponding to the pixel points in the filter kernel.
10. The image filtering method according to claim 7, characterized in that: The acquiring the sampled pixel value at the sampling coordinate, and determining the filtering result of the pixel point to be processed based on the sampled pixel value at each sampling coordinate, comprises: Obtaining a preset fusion weight for each sampling point, and determining a filtering result for the pixel point to be processed based on the preset fusion weight for each sampling point and a sampled pixel value at a sampling coordinate of the sampling point; The preset fusion weight is predetermined in the following manner: For each sampling point in the preset sampling distribution, a first sampling value expression of the sampling point is determined according to a sampling mode of a texture sampling unit of a graphics processor, a pixel point on which the sampling point depends in the image to be processed, and a bias coordinate to be solved of the sampling point; Determine the value of the to-be-solved offset coordinate of the sampling point based on the coefficient of the pixel point in the first sampling value expression and the weight corresponding to the pixel point in the filter kernel; Determine, according to the value of the to-be-solved offset coordinate of the sampling point, the coefficient value of the pixel point on which the sampling point in the to-be-processed image depends in the first sampling value expression; The fusion weight of the sampling point is determined so that the coefficient value of at least one pixel point in the first sampling value expression is the same as the weight corresponding to the pixel point in the filter kernel.
11. An image filtering device, characterized in that: include: A preset sampling distribution condition acquisition module is configured to acquire a preset sampling distribution condition of a current pixel point to be processed of the image to be processed; A first sampling coordinate determination module is configured to determine, for each sampling point in the preset sampling distribution, a sampling coordinate of the sampling point according to a weight corresponding to a pixel point in the filter kernel on which the sampling point depends in the image to be processed; The filtering result determination module is configured to obtain the sampling pixel value at the sampling coordinate, and determine the filtering result of the pixel point to be processed based on the sampling pixel value at each sampling coordinate.
12. An image filtering device, characterized in that: include: A preset offset coordinate acquisition module is configured to acquire, for a current pixel point to be processed of the image to be processed, a preset reference coordinate of a sampling point of the filter kernel and a preset offset coordinate of the sampling point based on the preset reference coordinate; A second sampling coordinate determination module is configured to determine the sampling coordinates of the sampling point according to the preset reference coordinates and the preset offset coordinates; A filtering processing module is configured to obtain the sampled pixel value at the sampling coordinate, and determine the filtering result of the pixel point to be processed based on the sampled pixel value at each sampling coordinate; The preset offset coordinates are predetermined according to the weights corresponding to the pixel points in the filter kernel on which the sampling point depends in the image to be processed.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
14. An electronic device, characterized in that: include: one or more processors; as well as A memory for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to implement the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Image denoising method and device, electronic equipment and storage medium
CN113284075A
Image filtering method and device, controller and readable storage medium
CN115619805A
Graphic processing unit (GPU) with configurable filtering module and operation method thereof
US20110292048A1
