Image processing method and device based on bilateral filtering, equipment and storage medium
By combining the low-pass filtering results of the current frame and the previous frame, the bilateral filtering coefficients and sampling processing are optimized, solving the balance problem between filtering effect and power consumption in the bilateral filtering algorithm, and achieving more efficient image processing.
Patent Information
- Application Number
- CN202310122878.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-15
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2043-02-15
AI Technical Summary
Existing bilateral filtering algorithms struggle to balance filtering effectiveness and power consumption, resulting in time constraints and high resource consumption.
By combining the low-pass filtering results of the current frame and the previous frame, the Gaussian range and spatial coefficients of the bilateral filter are obtained, the filter value of each pixel is calculated, and the filtering process is optimized through sampling processing to reduce power consumption and improve the filtering effect.
While reducing power consumption, the effect of bilateral filtering is improved, saving resources and enhancing the quality of image processing.
Smart Images

Figure CN116128772B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and particularly relates to an image processing method and device based on bilateral filtering, equipment and a storage medium. BACKGROUND
[0002] Bilateral filtering is a kind of non-linear filtering method, which is a compromise processing combining the spatial proximity and pixel value similarity of an image, simultaneously considering the spatial information and gray similarity, and achieving the purpose of edge-preserving denoising. Bilateral filtering has the characteristics of simplicity, non-iteration and locality. Bilateral filtering has the advantage of edge-preserving, but the power consumption of bilateral filtering is large due to the combination of value domain integration, and the timing is tight. Therefore, it is urgent to provide a fast bilateral filtering algorithm with good filtering effect, small power consumption and resource saving. SUMMARY
[0003] In order to solve the above technical problems, the embodiments of the present application provide an image processing method and device based on bilateral filtering, equipment and a storage medium.
[0004] In a first aspect, the embodiments of the present application provide an image processing method based on bilateral filtering, which comprises:
[0005] According to the low-pass filtering result of the current frame original image, a bilateral filtering Gaussian value domain coefficient is obtained, and a bilateral filtering Gaussian spatial domain coefficient is set;
[0006] According to the bilateral filtering Gaussian value domain coefficient and the bilateral filtering Gaussian spatial domain coefficient, a first spatial domain filtering value of a current pixel point of the current frame original image is obtained, and a first value domain filtering value of the current pixel point of the current frame original image is determined according to the first spatial domain filtering value;
[0007] The last frame original image is sampled and processed to obtain a sampling image;
[0008] According to the current pixel point of the current frame original image, a current pixel point of the sampling image is determined;
[0009] According to the bilateral filtering Gaussian value domain coefficient and the bilateral filtering Gaussian spatial domain coefficient, a second spatial domain filtering value of the current pixel point of the sampling image is obtained, and a second value domain filtering value of the current pixel point of the sampling image is determined according to the second spatial domain filtering value;
[0010] According to the first value domain filtering value, the second value domain filtering value, the first spatial domain filtering value and the second spatial domain filtering value, a filtering output result is determined.
[0011] In an embodiment, the bilateral filtering Gaussian value domain coefficient comprises:
[0012] performing low-pass filtering on the first preset range image region of the current frame original image to obtain a low-pass filtering result;
[0013] obtaining a brightness adaptive coefficient according to the low-pass filtering result;
[0014] determining the bilateral filtering Gaussian value range coefficient according to the bilateral filtering value range coefficient and the brightness adaptive coefficient.
[0015] In an embodiment, the step of obtaining the brightness adaptive coefficient according to the low-pass filtering result comprises:
[0016] setting a low brightness threshold, a high brightness threshold, a high brightness adaptive coefficient, a low brightness adaptive coefficient and an interpolation slope coefficient;
[0017] if the low-pass filtering result is less than the low brightness threshold, determining the high brightness adaptive coefficient as the brightness adaptive coefficient;
[0018] if the low-pass filtering result is greater than the low brightness threshold, determining the low brightness adaptive coefficient as the brightness adaptive coefficient;
[0019] if the low-pass filtering result is greater than the low brightness threshold and the low-pass filtering result is less than the high brightness threshold, calculating an adaptive output result according to the low-pass filtering result, the low brightness threshold and the interpolation slope coefficient, and determining the adaptive output result as the brightness adaptive coefficient.
[0020] In an embodiment, the step of obtaining the first spatial domain filtering value of the current pixel point of the current frame original image according to the bilateral filtering Gaussian value range coefficient and the bilateral filtering Gaussian spatial domain coefficient comprises:
[0021] taking the current pixel point of the current frame original image as a first center pixel point, and determining a first target pixel point within a circle with the first center pixel point as the center and a preset radius;
[0022] calculating a spatial domain weight of the current pixel point of the current frame original image according to each first target pixel point and the bilateral filtering Gaussian spatial domain coefficient;
[0023] calculating a value domain weight of the current pixel point of the current frame original image according to a first pixel value of each first target pixel point, a second pixel value of the first center pixel point and the bilateral filtering Gaussian value range coefficient;
[0024] adding the spatial domain weight of the current pixel point of the current frame original image and the value domain weight of the current pixel point of the current frame original image to obtain a first index weight;
[0025] obtaining the first spatial filter value according to the first index weight lookup table;
[0026] The first value domain filter value of the current pixel point of the original image of the current frame is determined according to the first spatial filter value, and the first value domain filter value is determined according to the first spatial filter value and the pixel value of the current pixel point of the original image.
[0027] The first value domain filter value is determined according to the first spatial filter value and the pixel value of the current pixel point of the original image.
[0028] In an embodiment, the spatial weight of the current pixel point of the original image of the current frame is calculated according to each first target pixel point and the bilateral filter Gaussian spatial coefficient, and the spatial weight of the current pixel point of the original image of the current frame is calculated according to each first target pixel point and the bilateral filter Gaussian spatial coefficient.
[0029] The first distance from each first target pixel point to the first center pixel point is calculated.
[0030] The spatial weight of each first target pixel point is calculated according to each first distance and the bilateral filter Gaussian spatial coefficient.
[0031] The sum of the spatial weights of each first target pixel point is determined as the spatial weight of the current pixel point of the original image.
[0032] The value domain weight of the current pixel point of the original image of the current frame is calculated according to the first pixel value of each first target pixel point, the second pixel value of the first center pixel point and the bilateral filter Gaussian value domain coefficient, and the value domain weight of the current pixel point of the original image of the current frame is calculated according to the first pixel value of each first target pixel point, the second pixel value of the first center pixel point and the bilateral filter Gaussian value domain coefficient.
[0033] The value domain difference between the second pixel value of each first target pixel point and the first pixel value of the center pixel point is calculated.
[0034] The value domain weight of each first target pixel point is calculated according to each value domain difference and the bilateral filter Gaussian value domain coefficient.
[0035] The sum of the value domain weights of each first target pixel point is determined as the value domain weight of the current pixel point of the original image of the current frame.
[0036] In an embodiment, the second spatial filter value of the current pixel point of the sampling image is obtained according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial coefficient, and the second spatial filter value of the current pixel point of the sampling image is obtained according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial coefficient.
[0037] The current pixel point of the sampling image is taken as a second center pixel point.
[0038] Second target pixel points in a circular ring with the second center pixel point as the center, a first preset length as the inner radius and a second preset length as the outer radius are determined.
[0039] According to the second target pixel point, the bilateral filtering Gaussian spatial coefficient calculates the spatial weight of the current pixel point of the sampling image;
[0040] According to the first pixel value of each second target pixel point, the second pixel value of the first center pixel point and the bilateral filtering Gaussian value domain coefficient, the value domain weight of the current pixel point of the sampling image is calculated;
[0041] The spatial weight of the current pixel point of the sampling image and the value domain weight of the current pixel point of the sampling image are added to obtain a second index weight;
[0042] According to the second index weight, a mapping table is searched to obtain the second spatial filtering value;
[0043] The second value domain filtering value of the current pixel point of the sampling image is determined according to the second spatial filtering value, comprising:
[0044] The second value domain filtering value of the current pixel point of the sampling image is determined according to the second spatial filtering value and the pixel value of the current pixel point of the sampling image.
[0045] In an embodiment, the sampling processing of the previous frame original image comprises:
[0046] The down-sampling processing is performed on the previous frame original image to obtain a down-sampling image;
[0047] The second preset range image region of the down-sampling image is up-sampled to obtain the sampling image.
[0048] Secondly, the embodiments of the present application provide an image processing device based on bilateral filtering, the device comprises:
[0049] The processing module is used for acquiring a bilateral filtering Gaussian value domain coefficient and setting a bilateral filtering Gaussian spatial coefficient;
[0050] The first acquisition module is used for acquiring a first spatial filtering value of a current pixel point of the current frame original image according to the bilateral filtering Gaussian value domain coefficient and the bilateral filtering Gaussian spatial coefficient, and determining a first value domain filtering value of the current pixel point of the current frame original image according to the first spatial filtering value;
[0051] The sampling module is used for sampling processing of a previous frame original image to obtain a sampling image;
[0052] The first determination module is used for determining the current pixel point of the sampling image according to the current pixel point of the current frame original image;
[0053] The second acquisition module is configured to acquire a second spatial domain filter value of a current pixel point of the sample image according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and determine a second value domain filter value of the current pixel point of the sample image according to the second spatial domain filter value.
[0054] The second determination module is configured to determine a filter output result according to the first value domain filter value, the second value domain filter value, the first spatial domain filter value and the second spatial domain filter value.
[0055] In a third aspect, an electronic device is provided, including a memory and a processor, the memory is configured to store a computer program, and the computer program is configured to execute the image processing method based on bilateral filtering provided in the first aspect when the processor runs.
[0056] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program, and the computer program is configured to execute the image processing method based on bilateral filtering provided in the first aspect when a processor runs.
[0057] The image processing method, device, electronic device and storage medium based on bilateral filtering provided in the present application are as follows: a bilateral filter Gaussian value domain coefficient is acquired according to a low-pass filter result of a current frame original image, and a bilateral filter Gaussian spatial domain coefficient is set; a first spatial domain filter value of a current pixel point of the current frame original image is acquired according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and a first value domain filter value of the current pixel point of the current frame original image is determined according to the first spatial domain filter value; a last frame original image is sampled to obtain a sample image; a current pixel point of the sample image is determined according to the current pixel point of the current frame original image; a second spatial domain filter value of the current pixel point of the sample image is acquired according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and a second value domain filter value of the current pixel point of the sample image is determined according to the second spatial domain filter value; and a filter output result is determined according to the first value domain filter value, the second value domain filter value, the first spatial domain filter value and the second spatial domain filter value. In this way, bilateral filtering is performed on the current frame original image and the sample image of the last frame original image, so that the effect of bilateral filtering can be improved on the basis of reducing power consumption as much as possible. BRIEF DESCRIPTION OF DRAWINGS
[0058] In order to more clearly illustrate the technical solutions of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the protection scope of the present application. In the various drawings, similar components are denoted by similar reference numerals.
[0059] Figure 1 Fig. 1 shows one of the flow diagrams of the image processing method based on bilateral filtering provided by the embodiments of the present application;
[0060] Figure 2 Fig. 2 shows one of the schematic diagrams of the in-circle points provided by the embodiments of the present application;
[0061] Figure 3 Fig. 3 shows one of the schematic diagrams of the down-sampled images provided by the embodiments of the present application;
[0062] Figure 4 Fig. 4 shows one of the schematic diagrams of the in-ring points provided by the embodiments of the present application;
[0063] Figure 5 Fig. 5 shows another one of the flow diagrams of the image processing method based on bilateral filtering provided by the embodiments of the present application;
[0064] Figure 6 Fig. 6 shows another one of the flow diagrams of the image processing method based on bilateral filtering provided by the embodiments of the present application
[0065] Figure 7 Fig. 7 shows one of the structural schematic diagrams of the image processing apparatus based on bilateral filtering provided by the embodiments of the present application.
[0066] Fig. 1 shows one of the flow diagrams of the image processing method based on bilateral filtering provided by the embodiments of the present application; Fig. 2 shows one of the schematic diagrams of the in-circle points provided by the embodiments of the present application; Fig. 3 shows one of the schematic diagrams of the down-sampled images provided by the embodiments of the present application; Fig. 4 shows one of the schematic diagrams of the in-ring points provided by the embodiments of the present application; Fig. 5 shows another one of the flow diagrams of the image processing method based on bilateral filtering provided by the embodiments of the present application; Fig. 6 shows another one of the flow diagrams of the image processing method based on bilateral filtering provided by the embodiments of the present application; Fig. 7 shows one of the structural schematic diagrams of the image processing apparatus based on bilateral filtering provided by the embodiments of the present application. DETAILED DESCRIPTION
[0067] The technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application.
[0068] The components of the embodiments of the present application generally described and illustrated in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of the present application.
[0069] Hereinafter, the terms "include", "have", and their conjugations, used in the various embodiments of the present application, merely indicate the presence of certain features, numbers, steps, operations, elements, components, or combinations thereof, and do not exclude the possibility of the presence or addition of one or more other features, numbers, steps, operations, elements, components, or combinations thereof.
[0070] Also, the terms "first", "second", "third", and the like are used only to distinguish descriptions, and cannot be understood as indicating or implying a relative importance.
[0071] Unless defined otherwise, all terms used herein (including technical terms and scientific terms) have the same meanings as those generally understood by those having ordinary knowledge in the field to which the various embodiments of the present application belong. Such terms, as defined in generally used dictionaries, will be interpreted to have the same meanings as those in the context of relevant technology and will not be interpreted to have ideal or excessively formal meanings unless clearly defined in the various embodiments of the present application.
[0072] Embodiment 1
[0073] The embodiments of the present application provide a bilateral filtering-based image processing method, which has good filtering effect, low power consumption, and saves resources.
[0074] Referring to Figure 1 The bilateral filtering-based image processing method includes steps S101-S106, and each step is described below.
[0075] In step S101, a bilateral filtering Gaussian spatial coefficient is obtained according to a low-pass filtering result of a current frame original image, and the bilateral filtering Gaussian spatial coefficient is set.
[0076] In the embodiment, the original image can be a camera captured image, the current frame original image is an image at a current time point, a previous image relative to the current frame original image is referred to as a previous frame image, and a next image relative to the current frame original image is referred to as a next frame image. The bilateral filtering Gaussian spatial coefficient sgaussianSCoeffmul can be set according to experience in advance.
[0077] In the embodiment, the step S101 of obtaining the bilateral filtering Gaussian spatial coefficient according to the low-pass filtering result of the current frame original image includes:
[0078] The first preset range image region of the current frame original image is subjected to low-pass filtering processing to obtain the low-pass filtering result.
[0079] According to the low-pass filtering result, a brightness adaptive coefficient is obtained;
[0080] According to the bilateral filtering value range coefficient and the brightness adaptive coefficient, the bilateral filtering Gaussian value range coefficient is determined.
[0081] In a specific embodiment, the first preset range image region can be a pixel point AxA range of the original image of the current frame, A can be a reasonable value, for example, 5, 6, 7, etc. In an implementation, AxA can be taken as 5x5 range, the pixel point AxA range of the original image of the current frame is obtained for low-pass filtering, and the pixel points in the AxA range are weighted and averaged to obtain a low-pass filtering result.
[0082] For example, it is assumed that the current pixel point of the current frame image is P(x,y), and the low-pass filtering result of the current pixel point is luma_lowpass. N
[0083] luma_lowpass
[0084] = ((P(x-2,y-2)+P(x-2,y+2)+P(x+2,y)+P(x+2,y+2))*1 N N N N
[0085] + (P(x-2,y-1)+P(x-2,y+1)+P(x-1,y+2)+P(x+1,y+2)+ N N N N
[0086] + P(x+2,y-1)+P(x+2,y+1)+P(x+1,y-2)+P(x+1,y-2))*4 N N N N
[0087] + (P(x-2,y)+P(x,y+2)+P(x+2,y)+P(x,y-2))*6 N N N N
[0088] + (P(x-1,y-1)+P(x-1,y+1)+P(x+1,y-1)+P(x+1,y+1))*16 N N N N
[0089] + P N (x-1,y) + P N (x,y+1) + P N (x+1,y) + P N (x,y-1) * 24
[0090] + P N (x,y) * 36) » 8
[0091] In an embodiment, the obtaining the luma adaptive coefficient according to the low-pass filtering result comprises:
[0092] setting a low luma threshold, a high luma threshold, a high luma adaptive coefficient, a low luma adaptive coefficient and an interpolation slope coefficient;
[0093] if the low-pass filtering result is less than the low luma threshold, determining the high luma adaptive coefficient as the luma adaptive coefficient;
[0094] if the low-pass filtering result is greater than the low luma threshold, determining the low luma adaptive coefficient as the luma adaptive coefficient;
[0095] if the low-pass filtering result is greater than the low luma threshold and the low-pass filtering result is less than the high luma threshold, calculating an adaptive output result according to the low-pass filtering result, the low luma threshold and the interpolation slope coefficient, and determining the adaptive output result as the luma adaptive coefficient.
[0096] For example, setting a low luma threshold LUMA TH1 and a high luma threshold LUMA TH2, a high luma adaptive coefficient aotoRRate1 and a low luma adaptive coefficient aotoRRate2, and an interpolation slope coefficient autoRRateslo, the luma adaptive coefficient can be determined according to the following formula:
[0097]
[0098] wherein autoRRte_cout
[0099] = ((luma_lowpass-LUMA TH1) * autoRRateslo)
[0100] >> 10 + autoRRate1
[0101] Setting a bilateral filter value range coefficient SIGMA R, the bilateral filter Gaussian value range coefficient can be determined according to the following formula:
[0102]
[0103] gaussianRCoeffmul represents a bilateral filtering Gaussian value domain coefficient.
[0104] In this way, the original image is low-pass filtered, and the Gaussian coefficient of the bilateral filtering median filtering is determined according to the low-pass filtering result, so that the value domain filtering effect can be effectively improved.
[0105] In step S102, a first spatial domain filtering value of the current pixel point of the original image of the current frame is obtained according to the bilateral filtering Gaussian value domain coefficient and the bilateral filtering Gaussian spatial domain coefficient, and a first value domain filtering value of the current pixel point of the original image of the current frame is determined according to the first spatial domain filtering value.
[0106] Referring to Figure 5 , the step S102 includes:
[0107] In step S1021, the current pixel point of the original image of the current frame is taken as a first center pixel point, and a first target pixel point in a circle with the first center pixel point as the center and a preset radius is determined.
[0108] In specific embodiments, the preset radius can be a reasonable numerical value r1, for example, the preset radius r1 can be 3, and the current pixel point P N (x,y) of the original image of the current frame is taken as the first center pixel point P N (x,y), it is determined whether the points in the Bx B range are in the circle with PN(x,y) as the center and r1 as the radius, and the first target pixel point P7x7(n,m) in the circle is determined. Among them, B is a reasonable numerical value, which can be 7, 8, 9, etc. For example, the Bx B range can be a 7x7 range.
[0109] In step S1022, the spatial domain weight of the current pixel point of the original image of the current frame is calculated according to each first target pixel point and the bilateral filtering Gaussian spatial domain coefficient.
[0110] In an embodiment, step S1022 includes:
[0111] The first distance of each first target pixel point to the first center pixel point is calculated.
[0112] The spatial domain weight of each first target pixel point is calculated according to each first distance and the bilateral filtering Gaussian spatial domain coefficient.
[0113] The sum of the spatial domain weights of each first target pixel point is determined as the spatial domain weight of the current pixel point of the original image.
[0114] For example, referring toFigure 3 The current pixel point of the current frame original image is taken as the center to perform bilateral filtering on the pixel points in the BxB range, and the points beyond the image boundary are discarded. If the current pixel point traversed is P N (x,y), and other points in the BxB range except the current pixel point are P N (a,b), the coordinates of the current pixel point and other pixel points satisfy the following formula:
[0115] (x-r1<a<x+r1);
[0116] (y-r1<b<y+r1)
[0117] The distance tmpSquare_BxB of other points in the BxB range to P N (x,y) is calculated according to the following formula:
[0118] tmpSquare_BxB(a,b);
[0119] =(x-a)*(x-a)+(y-b)*(y-b)
[0120] The first target pixel point in the BxB range in the circle with P N (x,y) as the center and r1 as the radius is selected, the first target pixel point in the circle is P BxB (n,m); the distance of the first target pixel point P BxB (n,m) to the current pixel point P N (x,y) is taken to calculate the point spatial domain weight indexSweight_BxB of the current pixel point. Exemplarily, the spatial domain weight indexSweight_BxB of each first target pixel point can be calculated according to the following formula:
[0121] indexSweight_BxB(n,m);
[0122] =(tmpSquare_BxB(n,m)*gaussianSCoeffmul)>>18
[0123] The spatial domain weight of the current pixel point of the original image is calculated according to the following formula:
[0124] indexSweight_BxB;
[0125] =∑ n,m indexSweight_BxB(n,m)
[0126] Wherein, indexSweight_BxB represents the spatial domain weight of the current pixel point of the current frame original image.
[0127] Step S1023: Calculate the value range weight of the current pixel in the original image of the current frame based on the first pixel value of each first target pixel, the second pixel value of the first center pixel, and the bilateral filter Gaussian value range coefficients.
[0128] In one embodiment, calculating the value range weight of the current pixel in the original image of the current frame based on the first pixel value of each first target pixel, the second pixel value of the first center pixel, and the bilateral filter Gaussian value range coefficients includes:
[0129] Calculate the range difference between the second pixel value of each first target pixel and the first pixel value of the center pixel;
[0130] The value range weight of each first target pixel is calculated based on the difference between each value range and the Gaussian value range coefficients of the bilateral filter.
[0131] The sum of the value range weights of each first target pixel is determined as the value range weight of the current pixel in the original image of the current frame.
[0132] As an example, let the pixel value of the current pixel in the original image of the current frame be pixel_P. N (x,y), the pixel value of the first target pixel within the B×B neighborhood of the circle is pixel_P. BxB (n,m) Calculate the pixel value of the first target pixel within the range B×B using the following formula: pixel_P BxB (n,m) and the pixel value of the current pixel point (pixel_P) N The range difference pixel_dif_B×B between (x, y) can be calculated using the following formula:
[0133] pixel_dif_BxB(n,m);
[0134] =pixel_p BxB (n,m)-pixel_p N (x,y)
[0135] Where pixel_dif_B×B represents the pixel value of the first target pixel, pixel_P. BxB (n,m) and the pixel value of the current pixel point (pixel_P) N The difference in the range of (x,y).
[0136] The value range weight indexRweight_BxB of each first target pixel is calculated using the following formula:
[0137] indexRweight_BxB(n,m);
[0138] = ((pixel_dif(n, m) 2 >> 8) * gaussianRCoeffmul
[0139] wherein, indexRweight_BxB represents the value range weight of the first target pixel point.
[0140] The value range weight of the current pixel point of the current frame original image is calculated according to the following formula:
[0141] indexRweight_BxB;
[0142] = ∑ n,m indexRweight_BxB(n, m)
[0143] wherein, indexRweight_BxB represents the value range weight of the current pixel point of the original image.
[0144] Step S1024, adding the spatial weight of the current pixel point of the current frame original image and the value range weight of the current pixel point of the current frame original image to obtain the first index weight.
[0145] Exemplarily, the first index weight can be calculated according to the following formula:
[0146] indexweight_BxB;
[0147] = Σ n,m indexRweight_BxB(n, m) + indexSweight_BxB(n, m)
[0148] wherein, indexweight_BxB is the first index weight.
[0149] Step S1025, searching the mapping table according to the first index weight to obtain the first spatial filter value.
[0150] In the embodiment, the mapping table can be pre-stored in a storage medium, and the first spatial filter value can be searched according to the following relationship.
[0151] weight_sum_BxB = ReciprocalExp(indexweight_BxB);
[0152] wherein, ReciprocalExp represents a table lookup calculation filter weight.
[0153] Low table address: indexLowOfIut = indexweight_BxB >> B;
[0154] High lookup table address: indexHighOf_flt = indexLowOf_flt + 1;
[0155] Lookup weight: indexFrac;
[0156] =indexweight_BxB-(indexLowOfflut< <B)
[0157] After looking up the table, calculate weight_sum_B×B using the following formula:
[0158] weight_sum_BxB;
[0159] =lut(indexL owOfflut)+((lut(index xHighOfflut)
[0160] -lut(indexL owOf))*indexFrac)
[0161] >>B
[0162] When weight_sum_B×B equals weight_sum_7×7, the formula is as follows:
[0163] weight_sum_7x7
[0164] =lut(indexLowOfflut)+((lut(indexHighOfflut)-lut(undexLowOf))*indexFrac)>>7
[0165] It should be noted that the first spatial filtering value is a constant with a depth of 64, and the mapping table LUT example is as follows:
[0166] Lut
[64] ={1024,903,797,703,621,584,483,426,376,332,293,258,228,201,177,157,138,122,107,95,84,74,65 ,57,50,44,39,35,30,27,24,21,18,16,14,12,11,10,8,7,6,6,5,4,4,3,3,2,2,2,1,1,1,1,1,1,0,0,0,0,0,0,0,0}
[0167] In one embodiment, the step S102 of determining the first domain filter value of the current pixel of the original image of the current frame based on the first spatial domain filter value includes:
[0168] The first value domain filter value is determined according to the first spatial domain filter value and a pixel value of a current pixel point of the original image.
[0169] In the embodiment, the first value domain filter value can be determined according to the first spatial domain filter value and a pixel value of a current pixel point of the current frame original image. For example, the first filter value is calculated according to the following formula:
[0170] pixel_sum_BxB=weight_sum_BxB*pixel_p N (x, y);
[0171] wherein, pixel_sum_BxB represents the first value domain filter value, pixel_p N (x, y) represents a pixel value of a current pixel point of the current frame original image, and weight_sum_BxB represents the first spatial domain filter value.
[0172] In step S103, the previous frame original image is sampled to obtain a sample image.
[0173] In the embodiment, the size of the sample image can be the same as or different from the size of the current frame original image.
[0174] In an embodiment, step S103 comprises:
[0175] down-sampling the previous frame original image to obtain a down-sampled image;
[0176] up-sampling a second preset range image region of the down-sampled image to obtain the sample image.
[0177] For example, the original image is down-sampled by 16 times to obtain a down-sampled image, as shown in FIG. 2. Figure 3 , Figure 3 The second preset range image region can be a CxC range, and C can be a reasonable value. For example, the CxC range can be a 6x6 range. The points in the CxC range of the down-sampled image are up-sampled to the sample image of the original image size.
[0178] In step S104, a current pixel point of the sample image is determined according to a current pixel point of the current frame original image.
[0179] For example, if the size of the sampling image can be the same as that of the current frame original image, the current pixel point of the sampling image is determined as P(x, y). If the size of the sampling image can be different from that of the current frame original image, the size of the sampling image can be in a proportional relationship with that of the current frame original image, and the P(x1, y1) pixel point of the sampling image is calculated as the current pixel point based on the proportional relationship and the current pixel point P(x, y) of the current frame original image.
[0180] In step S105, a second spatial domain filter value of the current pixel point of the sampling image is obtained according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and a second value domain filter value of the current pixel point of the sampling image is determined according to the second spatial domain filter value.
[0181] Please refer to Figure 6 In step S105, the second spatial domain filter value of the current pixel point of the sampling image is obtained according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and the second value domain filter value of the current pixel point of the sampling image is determined according to the second spatial domain filter value.
[0182] In step S1051, the current pixel point of the sampling image is taken as a second center pixel point.
[0183] In step S1052, a second target pixel point in a circular ring with the second center pixel point as the center, a first preset length as the inner radius and a second preset length as the outer radius is determined.
[0184] In step S1053, a spatial domain weight of the current pixel point of the sampling image is calculated according to each second target pixel point and the bilateral filter Gaussian spatial domain coefficient.
[0185] In step S1054, a value domain weight of the current pixel point of the sampling image is calculated according to the first pixel value of each second target pixel point, the second pixel value of the first center pixel point and the bilateral filter Gaussian value domain coefficient.
[0186] In step S1055, the spatial domain weight of the current pixel point of the sampling image and the value domain weight of the current pixel point of the sampling image are added to obtain a second index weight.
[0187] In step S1056, the second index weight is used to search a mapping table to obtain the second spatial domain filter value.
[0188] For example, the current pixel point of the sampling image is P(x, y), and the C of the sampling image C×C range can be a reasonable value, for example, 6×6 range. In the 6×6 range, the current pixel point is P(x, y), and the first target pixel point is P(x-1, y-1). N N Other pixel points of (x, y) are P 6x6 If (a, b) satisfies the following relationship:
[0189] (x-16*3<a<x+16*3);
[0190] (y-16*3<b<y+16*3)
[0191] According to the following formula, the distance of other pixel points in the CxC range to the current pixel point P N (x, y) is tmpSquare_CxC:
[0192] tmpSquare_CxC(a, b);
[0193] =(x-a)*(x-a)+(y-b)*(y-b)
[0194] Wherein, tmpSquare_CxC represents the distance of other pixel points in the CxC range to the current pixel point P N (x, y).
[0195] In this embodiment, the first preset length can be 3, and the second preset length can be 3*16. It is judged whether the pixel points in the CxC range are the second target pixel points in the circular ring with P N (x, y) as the center, 3 as the inner diameter of the circular ring, and 3*16 as the outer diameter of the circular ring. It is assumed that the points in the circular ring are P CxC (n, m).
[0196] Referring to the schematic diagram of the points in the circular ring shown in Figure 4 , Figure 4 , the spatial domain weight of each second target pixel point in the circular ring is calculated according to the following formula.
[0197] indexSweig ht_CxC(n,m);
[0198] =(tmpSquare_CxC(n,m)*gaussianRCoeffmul)>>18
[0199] Wherein, indexSweight_CxC(n, m) represents the spatial domain weight of each second target pixel point.
[0200] The spatial domain weight of the current pixel point of the sampling image is calculated according to the following formula:
[0201]
[0202] Wherein, indexSweight_CxC represents the spatial domain weight of the current pixel point of the sampling image.
[0203] pixel_P CxC (n,m) ; the value range difference between the pixel value of each second target pixel in the CxC range and the pixel value of the current pixel point is calculated according to the following formula:
[0204] pixel_dif_CxC(n,m) = pixel_p CxC (n,m) - pixel_p N (x,y) ;
[0205] wherein, pixel_dif_CxC(n,m) represents the value range difference between the pixel value of each second target pixel and the pixel value of the current pixel point.
[0206] In the embodiment, the value range weight of each second target pixel point is calculated according to the following formula:
[0207] indexRweight_CxC(n,m) ;
[0208] = ((pixel_dif_CxC(n,m)) 2 >> 8) * gaussianRCoeffmul
[0209] indexRweight_CxC represents the value range weight of each second target pixel point;
[0210] The value range weight of the current pixel point of the sampling image is calculated according to the following formula:
[0211]
[0212] wherein, indexRweight_CxC represents the value range weight of the current pixel point of the sampling image.
[0213] The sum of all spatial weights and value range weights of the CxC range in the annulus obtains the second index weight, that is, the second index weight is calculated according to the following formula:
[0214]
[0215] wherein, indexweight_CxC represents the second index weight.
[0216] The second spatial filter value is obtained by table lookup calculation according to the second index weight indexweight_CxC. The second spatial filter value weight_sum_CxC is obtained by table lookup according to the following relationship:
[0217] weight_sum_CxC ;
[0218] = Reciprocal Exp(index weight_CxC)
[0219] wherein, weight_sum_CxC represents the second spatial filter value.
[0220] In an embodiment, the determining the second value domain filter value of the current pixel of the sample image according to the second spatial filter value in step S105 comprises:
[0221] determining the second value domain filter value of the current pixel of the sample image according to the second spatial filter value and the pixel value of the current pixel of the sample image.
[0222] Exemplarily, the second value domain filter value pixel_sum_CxC can be calculated according to the following formula:
[0223] pixel_sum_CxC;
[0224] = weight_sum_CxC*pixel_p N (x,y)
[0225] wherein, pixel_sum_CxC represents the second value domain filter value.
[0226] Step S106, determining the filter output result according to the first value domain filter value, the second value domain filter value, the first spatial filter value and the second spatial filter value.
[0227] Exemplarily, the filter output result can be calculated according to the following formula.
[0228]
[0229] wherein, P out (x,y) represents the filter output result, pixel_sum_BxB represents the first value domain filter value, pixel_sum_CxC represents the second value domain filter value, weight_sum_BxB represents the first spatial filter value, and weight_sum_CxC represents the second spatial filter value.
[0230] It should be noted that the output filter result of the current pixel of the current frame original image can be calculated through the foregoing steps S101-S106, if the pixel points of the current frame original image are sequentially traversed, and the traversed pixel point is taken as the current pixel to perform steps S101-S106, then the output filter result of each pixel of the current frame original image can be calculated, and the filter image of the current frame original image can be produced according to the output filter result of each pixel of the current frame original image.
[0231] In this embodiment, the lookup table is used to replace the value range filtering integral, so as to reduce the power consumption. The low-pass filtering result is used to adjust the value range filtering Gaussian coefficient, so as to improve the filtering effect. The current frame original image and the sampling image of the last frame original image are combined for the bilateral filtering processing, so as to improve the bilateral filtering quality while effectively reducing the bandwidth and memory consumption.
[0232] The image processing method based on the bilateral filtering provided in this embodiment comprises the following steps: acquiring a bilateral filtering Gaussian value range coefficient and setting a bilateral filtering Gaussian space domain coefficient according to a low-pass filtering result of a current frame original image; acquiring a first space domain filtering value of a current pixel point of the current frame original image according to the bilateral filtering Gaussian value range coefficient and the bilateral filtering Gaussian space domain coefficient, and determining a first value range filtering value of the current pixel point of the current frame original image according to the first space domain filtering value; performing sampling processing on a last frame original image to obtain a sampling image; determining a current pixel point of the sampling image according to the current pixel point of the current frame original image; acquiring a second space domain filtering value of the current pixel point of the sampling image according to the bilateral filtering Gaussian value range coefficient and the bilateral filtering Gaussian space domain coefficient, and determining a second value range filtering value of the current pixel point of the sampling image according to the second space domain filtering value; and determining a filtering output result according to the first value range filtering value, the second value range filtering value, the first space domain filtering value and the second space domain filtering value. In this way, the current frame original image and the sampling image of the last frame original image are combined for the bilateral filtering, so as to improve the effect of the bilateral filtering while reducing the power consumption as much as possible.
[0233] Embodiment 2
[0234] In addition, the embodiment of the present application provides an image processing device based on bilateral filtering.
[0235] Referring to Figure 7 As Figure 7 shown, the image processing device based on bilateral filtering 700 comprises:
[0236] The processing module 701 is configured to acquire a bilateral filtering Gaussian value range coefficient and set a bilateral filtering Gaussian space domain coefficient.
[0237] The first acquisition module 702 is configured to acquire a first space domain filtering value of a current pixel point of the current frame original image according to the bilateral filtering Gaussian value range coefficient and the bilateral filtering Gaussian space domain coefficient, and determine a first value range filtering value of the current pixel point of the current frame original image according to the first space domain filtering value.
[0238] The sampling module 703 is configured to perform sampling processing on a last frame original image to obtain a sampling image.
[0239] The first determination module 704 is configured to determine a current pixel point of the sample image according to a current pixel point of the current frame original image.
[0240] The second acquisition module 705 is configured to acquire a second spatial domain filter value of the current pixel point of the sample image according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and determine a second value domain filter value of the current pixel point of the sample image according to the second spatial domain filter value.
[0241] The second determination module 706 is configured to determine a filter output result according to the first value domain filter value, the second value domain filter value, the first spatial domain filter value and the second spatial domain filter value.
[0242] The image processing apparatus based on bilateral filtering provided in this embodiment can implement the image processing method based on bilateral filtering provided in Embodiment 1, and details are not repeated here.
[0243] The image processing apparatus based on bilateral filtering provided in this embodiment acquires a bilateral filter Gaussian value domain coefficient according to a low-pass filter result of a current frame original image, and sets a bilateral filter Gaussian spatial domain coefficient; acquires a first spatial domain filter value of a current pixel point of the current frame original image according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and determines a first value domain filter value of the current pixel point of the current frame original image according to the first spatial domain filter value; performs sample processing on a previous frame original image to obtain a sample image; determines a current pixel point of the sample image according to a current pixel point of the current frame original image; acquires a second spatial domain filter value of the current pixel point of the sample image according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and determines a second value domain filter value of the current pixel point of the sample image according to the second spatial domain filter value; and determines a filter output result according to the first value domain filter value, the second value domain filter value, the first spatial domain filter value and the second spatial domain filter value. In this way, bilateral filtering is performed on the sample image of the previous frame original image in combination with the current frame original image, which can improve the effect of bilateral filtering on the basis of minimizing power consumption.
[0244] Embodiment 3
[0245] In addition, an electronic device is provided in this embodiment, which includes a memory and a processor, the memory stores a computer program, and the computer program performs the image processing method based on bilateral filtering provided in Embodiment 1 when running on the processor.
[0246] The electronic device provided in this embodiment can implement the image processing method based on bilateral filtering provided in Embodiment 1, and details are not repeated here.
[0247] Embodiment 4
[0248] The application further provides a computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and the computer program is executed by a processor to implement the bilateral filtering based image processing method in the embodiment 1.
[0249] In the embodiment, the computer readable storage medium can be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, etc.
[0250] The computer readable storage medium provided in the embodiment can implement the bilateral filtering based image processing method in the embodiment 1, and details are not described herein again to avoid repetition.
[0251] It should be noted that, in the present document, the term “comprising” or “including” or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article or terminal. Without more limitations, the element defined by the statement “including a…” does not exclude the presence of another identical element in the process, method, article or terminal including the element.
[0252] From the above description of the embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment method can be realized by means of software and necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for making a terminal (which can be a mobile phone, computer, server, air conditioner or network device, etc.) execute the methods described in various embodiments of the present application.
[0253] The embodiments of the present application are described above in combination with the drawings, but the present application is not limited to the above specific embodiments, and the above specific embodiments are only illustrative, not restrictive. Those skilled in the art can make many forms under the inspiration of the present application without departing from the scope of the present application and the protection scope of the claims, and all forms belong to the protection scope of the present application.
Claims
1. A bilateral filtering based image processing method, characterized in that, The method comprises: obtaining a bilateral filtering Gaussian value domain coefficient according to a low-pass filtering result of a current frame original image, and setting a bilateral filtering Gaussian space domain coefficient; obtaining a first space domain filtering value of a current pixel point of the current frame original image according to the bilateral filtering Gaussian value domain coefficient and the bilateral filtering Gaussian space domain coefficient, and determining a first value domain filtering value of the current pixel point of the current frame original image according to the first space domain filtering value; sampling a previous frame original image to obtain a sampling image; determining a current pixel point of the sampling image according to a current pixel point of the current frame original image; obtaining a second space domain filtering value of the current pixel point of the sampling image according to the bilateral filtering Gaussian value domain coefficient and the bilateral filtering Gaussian space domain coefficient, and determining a second value domain filtering value of the current pixel point of the sampling image according to the second space domain filtering value; determining a filtering output result according to the first value domain filtering value, the second value domain filtering value, the first space domain filtering value and the second space domain filtering value; the method comprises: obtaining a low-pass filtering result of a first preset range image region of the current frame original image to obtain the low-pass filtering result; obtaining a luminance adaptive coefficient according to the low-pass filtering result; 2. The method of claim 1, wherein, determining the bilateral filtering Gaussian value domain coefficient according to the bilateral filtering value domain coefficient and the luminance adaptive coefficient. the method comprises: obtaining a low-pass filtering result of a first preset range image region of the current frame original image to obtain the low-pass filtering result; obtaining a luminance adaptive coefficient according to the low-pass filtering result; 3. The method of claim 2, wherein, determining the bilateral filtering Gaussian value domain coefficient according to the bilateral filtering value domain coefficient and the luminance adaptive coefficient. the method comprises: setting a low luminance threshold, a high luminance threshold, a high luminance adaptive coefficient, a low luminance adaptive coefficient and an interpolation slope coefficient; if the low-pass filtering result is less than the low luminance threshold, the high luminance adaptive coefficient is determined as the luminance adaptive coefficient; if the low-pass filtering result is greater than the low luminance threshold, the low luminance adaptive coefficient is determined as the luminance adaptive coefficient; 4. The method of claim 1, wherein, if the low-pass filtering result is greater than the low luminance threshold and the low-pass filtering result is less than the high luminance threshold, an adaptive output result is calculated according to the low-pass filtering result, the low luminance threshold and the interpolation slope coefficient, and the adaptive output result is determined as the luminance adaptive coefficient. the method comprises: taking the current pixel point of the current frame original image as a first center pixel point, and determining a first target pixel point in a circle with the first center pixel point as the center and a preset radius; calculating a space domain weight of the current pixel point of the current frame original image according to each first target pixel point and the bilateral filtering Gaussian space domain coefficient; According to the first pixel value of each first target pixel point, the second pixel value of the first center pixel point and the bilateral filter Gauss value domain coefficient, a value domain weight of the current pixel point of the current frame original image is calculated; The value domain weight of the current pixel point of the current frame original image and the value domain weight of the current pixel point of the current frame original image are added to obtain a first index weight; According to the first index weight, a mapping table is looked up to obtain the first spatial domain filter value; The first value domain filter value of the current pixel point of the current frame original image is determined according to the first spatial domain filter value, and the first value domain filter value of the current pixel point of the current frame original image is determined according to the first spatial domain filter value and the pixel value of the current pixel point of the original image. The first value domain filter value is determined according to the first spatial domain filter value and the pixel value of the current pixel point of the original image.
5. The method of claim 4, wherein, According to each first target pixel point, the bilateral filter Gauss spatial domain coefficient, the spatial domain weight of the current pixel point of the current frame original image is calculated, including: The first distance of each first target pixel point to the first center pixel point is calculated; According to each first distance and the bilateral filter Gauss spatial domain coefficient, the spatial domain weight of each first target pixel point is calculated; The sum of the spatial domain weights of each first target pixel point is determined as the spatial domain weight of the current pixel point of the current frame original image; According to the first pixel value of each first target pixel point, the second pixel value of the first center pixel point and the bilateral filter Gauss value domain coefficient, a value domain weight of the current pixel point of the current frame original image is calculated, including: The value domain difference between the second pixel value of each first target pixel point and the first pixel value of the center pixel point is calculated; According to each value domain difference and the bilateral filter Gauss value domain coefficient, the value domain weight of each first target pixel point is calculated; The sum of the value domain weights of each first target pixel point is determined as the value domain weight of the current pixel point of the current frame original image.
6. The method of claim 4, wherein, According to the bilateral filter Gauss value domain coefficient and the bilateral filter Gauss spatial domain coefficient, the second spatial domain filter value of the current pixel point of the sampling image is obtained, including: The current pixel point of the sampling image is taken as a second center pixel point; Second target pixel points in a circular ring with the second center pixel point as the center, a first preset length as the inner radius and a second preset length as the outer radius are determined; According to each second target pixel point, the bilateral filter Gauss spatial domain coefficient, the spatial domain weight of the current pixel point of the sampling image is calculated; According to the first pixel value of each second target pixel point, the second pixel value of the first center pixel point and the bilateral filter Gauss value domain coefficient, a value domain weight of the current pixel point of the sampling image is calculated; The value domain weight of the current pixel point of the sampling image and the value domain weight of the current pixel point of the sampling image are added to obtain a second index weight; According to the second index weight, a mapping table is looked up to obtain the second spatial domain filter value; The second value domain filter value of the current pixel point of the sampling image is determined according to the second spatial domain filter value, and the second value domain filter value of the current pixel point of the sampling image is determined according to the second spatial domain filter value and the pixel value of the current pixel point of the sampling image. The sampling processing on the last frame original image includes:
7. The method of claim 1, wherein, Down-sample the original image to obtain a down-sampled image; Up-sample a second pre-set range image region of the down-sampled image to obtain the sampling image.
8. An apparatus for image processing based on bilateral filtering, characterized by The device comprises: The processing module is configured to obtain a bilateral filter Gaussian value domain coefficient according to a low-pass filter result of a current frame original image, and set a bilateral filter Gaussian spatial domain coefficient; The first obtaining module is configured to obtain a first spatial domain filter value of a current pixel point of the current frame original image according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and determine a first value domain filter value of the current pixel point of the current frame original image according to the first spatial domain filter value; The sampling module is configured to sample a previous frame original image to obtain a sampling image; The first determining module is configured to determine a current pixel point of the sampling image according to a current pixel point of the current frame original image; The second obtaining module is configured to obtain a second spatial domain filter value of the current pixel point of the sampling image according to the bilateral filter Gaussian value domain coefficient and the bilateral filter Gaussian spatial domain coefficient, and determine a second value domain filter value of the current pixel point of the sampling image according to the second spatial domain filter value; The second determining module is configured to determine a filter output result according to the first value domain filter value, the second value domain filter value, the first spatial domain filter value and the second spatial domain filter value. The bilateral filter Gaussian value domain coefficient is obtained according to a low-pass filter result of a current frame original image, which comprises: performing low-pass filter processing on a first pre-set range image region of the current frame original image to obtain the low-pass filter result; The luminance adaptive coefficient is obtained according to the low-pass filter result; The bilateral filter Gaussian value domain coefficient is determined according to the bilateral filter value domain coefficient and the luminance adaptive coefficient.
9. An electronic device, comprising: The device comprises a memory and a processor, the memory stores a computer program, and the computer program executes the bilateral filter-based image processing method in any one of claims 1 to 7 when running on the processor.
10. A computer-readable storage medium, characterized in that, The device stores a computer program, and the computer program executes the bilateral filter-based image processing method in any one of claims 1 to 7 when running on the processor.
Citation Information
Patent Citations
Systems and methods for reducing noise in video streams
CN104685538A
Video image 3D noise reduction method, computer device and computer readable storage medium
CN109743473A