Image sharpness enhancement method and device, computer device and readable storage medium
By filtering and calculating the weight values of neighboring pixels of the target pixel in image processing, the problem of excessively long real-time image filtering time is solved, improving image clarity and reducing latency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TCL TECHNOLOGY GROUP CORPORATION
- Filing Date
- 2022-04-25
- Publication Date
- 2026-05-29
AI Technical Summary
In existing technologies, the filtering time is relatively long during real-time image filtering, resulting in a delay in the displayed image.
By selecting target pixels from the initial pixels, calculating the weight values of the target pixels and their neighboring pixels, expanding the weight values, and calculating the brightness weighted sum, the image clarity is enhanced.
It reduces computational load, improves image filtering efficiency, addresses issues of long filtering times and display delays, and enhances image clarity.
Smart Images

Figure CN116993594B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, specifically to image sharpness enhancement methods, apparatus, computer equipment, and readable storage media. Background Technology
[0002] In existing technologies, in order to make the image displayed on the screen clearer, real-time filtering is often performed while the screen is displaying the image.
[0003] However, when using filters to perform real-time filtering on images, the large amount of computation often results in long filtering times and display delays. Summary of the Invention
[0004] This application provides an image sharpness enhancement method, apparatus, computer device, and readable storage medium, which can improve the problems of long filtering time and display delay in the real-time filtering process of images in the prior art.
[0005] This application provides an image sharpness enhancement method for enhancing the sharpness of a target image, the target image including a first number of initial pixels. The method includes: selecting a second number of target pixels from the first number of initial pixels; for each target pixel, calculating a first weight value between the target pixel and a first neighboring pixel, wherein the first neighboring pixel is a pixel within the neighborhood of the target pixel; expanding the first weight value corresponding to each target pixel to obtain a second weight value corresponding to each initial pixel, wherein the second weight value is the sum of the weight values of the initial pixel and the second neighboring pixel. The weight value of a pixel, the second neighboring pixel is the pixel in the neighborhood of the initial pixel, the second neighboring pixel has a first number of groups, the second neighboring pixel in the first number of groups corresponds one-to-one with the first number of initial pixels; for each initial pixel, according to the second weight value corresponding to the initial pixel and the brightness value of the initial pixel and the second neighboring pixel, the brightness weighted sum of the initial pixel and the second neighboring pixel is calculated; the target image is enhanced in sharpness according to the brightness weighted sum of each initial pixel to obtain a result image, wherein the sharpness of the result image is stronger than that of the target image.
[0006] In the above implementation, a second number of target pixels can be selected from a first number of initial pixels, and the weight value of each target pixel and its neighboring pixels can be calculated. These weight values are then expanded to obtain the weight value of each initial pixel and its neighboring pixels. Next, the brightness weighted sum of each initial pixel and its neighboring pixels is calculated. Finally, the image with enhanced sharpness is obtained based on the brightness weighted sum. In the above implementation, the calculation of the weight values of the initial pixels and their neighboring pixels is achieved by calculating the weight values of the target pixel and its neighboring pixels, and then expanding these weight values. Compared to directly calculating the brightness weighted sum of each initial pixel and its neighboring pixels, this method reduces the computational load, thus effectively improving the problems of long filtering time and display delay that occur when using filters to perform real-time image filtering.
[0007] Optionally, in one embodiment, the step of selecting a second number of target pixels from the first number of initial pixels includes: obtaining pixels with target properties from the first number of initial pixels, and determining the pixels with target properties as target pixels.
[0008] In the above implementation, when filtering target pixels, the filtering of target pixels can be achieved by determining whether there are any pixels with target properties among the initial pixels. After filtering out the target pixels, the amount of computation can be reduced and the processing efficiency can be improved in subsequent processing.
[0009] Optionally, in one embodiment, calculating the first weight value between the target pixel and the first neighboring pixels for each target pixel includes: calculating the brightness difference between the target pixel and the first neighboring pixels for each target pixel; and calculating the first weight value between the target pixel and the first neighboring pixels based on the brightness difference between the target pixel and the first neighboring pixels, the attenuation degree of the spatial proximity factor, and the attenuation degree of the brightness similarity factor.
[0010] In the above implementation, the weight value of each target pixel and its neighboring pixels can be calculated by first calculating the brightness difference between the target pixel and its neighboring pixels, and then calculating the weight value of the target pixel and its neighboring pixels based on the brightness difference, the attenuation of the spatial proximity factor, and the attenuation of the brightness similarity factor. Since this method only needs to calculate and expand the first weight value of the target pixel and the first neighboring pixel to obtain the second weight value of each initial pixel and the second neighboring pixel, instead of calculating the weight value of each initial pixel and its neighboring pixels one by one, it can save computation and improve computational efficiency.
[0011] Optionally, in one embodiment, expanding the first weight value corresponding to each of the target pixels to obtain the second weight value corresponding to each of the initial pixels includes: expanding the first weight value corresponding to each of the target pixels using a bilinear interpolation algorithm to obtain the second weight value corresponding to each of the initial pixels.
[0012] In the above embodiments, bilinear interpolation can be used to extend the weight value from the first weight value of the target pixel and its corresponding first neighboring pixels to the second weight value of the initial pixel and its corresponding second neighboring pixels. Other interpolation algorithms can also be used to achieve this extension; the specific type of interpolation algorithm should not be construed as a limitation of this application.
[0013] Optionally, in one embodiment, the step of enhancing the sharpness of the target image based on the luminance weighted sum of each initial pixel to obtain a result image includes: performing normalization processing on each initial pixel based on the luminance weighted sum corresponding to the initial pixel and the initial pixel to obtain an initial filtering result; and enhancing the sharpness of the target image based on the initial filtering result to obtain a result image.
[0014] In the above implementation, the initial filtering result can be obtained by first normalizing the brightness weighted sum corresponding to the initial pixel and the initial pixel. Then, the sharpness of the target image can be enhanced according to the initial filtering result to obtain the result image.
[0015] Optionally, in one embodiment, the step of normalizing the weighted sum of the brightness of each initial pixel and its neighboring pixels to obtain an initial filtering result includes: obtaining a normalization parameter; for each initial pixel, calculating the quotient of the weighted sum of the brightness of the initial pixel and the normalization parameter, and determining the quotient as the initial filtering result.
[0016] In the above implementation, the normalization parameter can be calculated first, and then the initial filtering result can be obtained by dividing the weighted sum of the brightness of the initial pixel and its neighboring pixels by the normalization parameter.
[0017] Optionally, in one implementation, obtaining the normalized parameters includes:
[0018] Calculate the sum of the target weight values corresponding to each target pixel in all target pixels to obtain the target weight sum, wherein the target weight value of the target pixel is the weight value of the target pixel and its corresponding first neighboring pixel;
[0019] The normalized parameter is obtained by expanding the sum of the target weight values, wherein the normalized parameter is the sum of the target weight values corresponding to each initial pixel in all initial pixels, and the target weight value of each initial pixel is the weight value of the initial pixel and its corresponding second neighboring pixel. In the above embodiment, the normalized parameter can be obtained by calculating the sum of the target weight values corresponding to each target pixel and expanding the sum.
[0020] Optionally, in one embodiment, the step of enhancing the sharpness of the target image based on the initial filtering result to obtain a result image includes: calculating the difference between the brightness value of the initial pixel in the target image and the initial filtering result, determining the difference as a secondary filtering result, wherein the secondary filtering result is a filtering result with more high-frequency details than a second threshold; and calculating the result image based on a preset coefficient and the secondary filtering result.
[0021] In the above implementation, an initial filtering result with fewer high-frequency details can be obtained first. Then, the difference between the brightness value of the initial pixel in the target image and the initial filtering result is calculated to obtain a secondary filtering result with more high-frequency details. Subsequently, the result image is calculated using preset coefficients and the secondary filtering result. Since the target image is enhanced with the secondary filtering result having more high-frequency details, the result image retains more high-frequency details while improving clarity, thus increasing the visual appeal of the image.
[0022] According to one aspect of this application, embodiments of this application also provide an image sharpness enhancement apparatus for enhancing the sharpness of a target image, the target image comprising a first number of initial pixels, the apparatus comprising:
[0023] A pixel filtering unit is used to filter out a second number of target pixels from the first number of initial pixels;
[0024] The weight value calculation unit is used to calculate a first weight value between the target pixel and the first neighboring pixels for each target pixel, wherein the first neighboring pixels are the pixels in the neighborhood of the target pixel;
[0025] The weight value expansion unit is used to expand the first weight value corresponding to each target pixel to obtain the second weight value corresponding to each initial pixel. The second weight value is the weight value between the corresponding initial pixel and the second neighboring pixel. The second neighboring pixel is the pixel in the neighborhood of the initial pixel. The second neighboring pixel has a first number of groups, and the first number of second neighboring pixels corresponds one-to-one with the first number of initial pixels.
[0026] The weighted sum calculation unit is used to calculate, for each initial pixel, a weighted sum of the brightness of the initial pixel and the second neighboring pixels based on the second weight value corresponding to the initial pixel and the brightness values of the initial pixel and the second neighboring pixels;
[0027] A sharpness enhancement unit is configured to enhance the sharpness of the target image based on the brightness weighted sum of each initial pixel to obtain a result image, wherein the sharpness of the result image is stronger than that of the target image.
[0028] Optionally, in one embodiment, the pixel filtering unit is specifically used to obtain pixels with target properties from the first number of initial pixels, and determine the pixels with target properties as target pixels.
[0029] Optionally, in one embodiment, the weight value calculation unit includes:
[0030] A brightness difference calculation subunit is used to calculate the brightness difference between the target pixel and the first neighboring pixel for each target pixel.
[0031] The weight value calculation subunit is used to calculate the first weight value between the target pixel and the first neighboring pixel based on the brightness difference between the target pixel and the first neighboring pixel, the attenuation degree of the spatial proximity factor, and the attenuation degree of the brightness similarity factor.
[0032] Optionally, in one embodiment, the weight value expansion unit is specifically used to expand the first weight value corresponding to each of the target pixels using a bilinear interpolation algorithm to obtain the second weight value corresponding to each initial pixel.
[0033] Optionally, in one embodiment, the sharpness enhancement unit includes:
[0034] The normalization subunit is used to perform normalization processing on each initial pixel based on the brightness weighted sum corresponding to the initial pixel and the initial pixel itself, to obtain the initial filtering result;
[0035] The result enhancement subunit is used to enhance the sharpness of the target image based on the initial filtering result to obtain a result image. Optionally, in one embodiment, the normalization subunit includes:
[0036] The normalization parameter sub-unit is used to obtain the normalization parameter;
[0037] The quotient operation subunit is used to calculate the quotient value of the luminance weighted sum corresponding to each initial pixel and the normalization parameter for each initial pixel, and to determine the quotient value as the initial filtering result.
[0038] Optionally, in one embodiment, the normalized parameter subunit includes:
[0039] The target pixel calculation sub-unit is used to calculate the sum of the target weight values corresponding to each target pixel in all target pixels to obtain the target weight sum, wherein the target weight value of the target pixel is the weight value of the target pixel and the corresponding first neighboring pixel.
[0040] The weight expansion sub-unit is used to expand the sum of the target weight values to obtain the normalization parameter, wherein the normalization parameter is the sum of the target weight values corresponding to each initial pixel in all initial pixels, and the target weight value of the initial pixel is the weight value of the initial pixel and the corresponding second neighboring pixel.
[0041] Optionally, in one implementation, the result enhancement subunit includes:
[0042] The secondary filtering result subunit is used to calculate the difference between the brightness value of the initial pixel in the target image and the initial filtering result, and to determine the difference as the secondary filtering result, wherein the secondary filtering result is a filtering result with more high-frequency details than the second threshold.
[0043] The result image calculation subunit is used to calculate the result image based on preset coefficients and the secondary filtering result.
[0044] This application also provides a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to perform steps implementing the method described above. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This is a schematic flowchart of the image sharpness enhancement method provided in the embodiments of this application;
[0047] Figure 2a This is an application scenario diagram that expands the weight values of the target pixel and its neighboring pixels;
[0048] Figure 2b This is an application scenario diagram that expands upon the sum of the target weights;
[0049] Figure 3 This is a schematic diagram of a structure of the image sharpness enhancement device provided in an embodiment of this application;
[0050] Figure 4 This is a schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation
[0051] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0052] This application provides an image sharpness enhancement method, apparatus, computer device, and readable storage medium.
[0053] Specifically, the image sharpness enhancement device can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet, smart Bluetooth device, laptop, or personal computer (PC); the server can be a single server or a server cluster consisting of multiple servers.
[0054] In some embodiments, the image sharpness enhancement device may also be integrated into multiple electronic devices.
[0055] In some embodiments, the server may also be implemented as a terminal.
[0056] An embodiment of this application provides an image sharpness enhancement method that performs the following steps: selecting a second number of target pixels from a first number of initial pixels; for each target pixel, calculating a first weight value between the target pixel and its first neighboring pixels, wherein the first neighboring pixels are pixels within the neighborhood of the target pixel; expanding the first weight value corresponding to each target pixel to obtain a second weight value corresponding to each initial pixel, wherein the second weight value is the weight value between the corresponding initial pixel and its second neighboring pixels, and the second neighboring pixels... The domain pixel is the pixel in the neighborhood of the initial pixel. The second neighborhood pixel has a first number of groups, and the second neighborhood pixel in the first number of groups corresponds one-to-one with the first number of initial pixels. For each initial pixel, a weighted sum of brightness of the initial pixel and the second neighborhood pixel is calculated based on the second weight value corresponding to the initial pixel and the brightness values of the initial pixel and the second neighborhood pixel. The target image is enhanced in sharpness based on the weighted sum of brightness of each initial pixel to obtain a result image, wherein the sharpness of the result image is stronger than that of the target image.
[0057] The following sections provide detailed descriptions of each example. It should be noted that the sequence numbers of the following embodiments are not intended to limit the preferred order of the embodiments.
[0058] In this embodiment, an image sharpness enhancement method is provided, such as... Figure 1 As shown, the specific process of this image sharpness enhancement method can be described as follows (110 to 160):
[0059] 110. Select a second number of target pixels from the first number of initial pixels.
[0060] The first number of initial pixels constitutes all the pixels that make up the target image. It should be understood that the specific value of the first number should not be construed as a limitation of this application.
[0061] For example, let's assume the target image is a resolution of 3840*2160. Then the target image has 3840*2160 initial pixels, with 2160 rows of initial pixels and 3840 columns in each row.
[0062] The second quantity is a specific value less than the first quantity, and this specific value should not be construed as a limitation on this application.
[0063] Optionally, in one embodiment, step 110 may specifically include the following steps:
[0064] From the first number of initial pixels, obtain pixels that have the target properties, and determine the pixels with the target properties as target pixels.
[0065] The target property is the filtering condition for selecting target pixels from the initial pixels. The target property can be the parity (odd or even) of the row or column of the initial pixels in the pixel matrix of the target image. For example, initial pixels located in odd-numbered rows and columns can be selected from the pixel matrix of the target image and used as target pixels; alternatively, initial pixels located in even-numbered rows and columns can be selected from the pixel matrix of the target image and used as target pixels.
[0066] For ease of description, let's take the example of the initial pixel located in an odd-numbered row and column of the pixel matrix being the target pixel. We can then denote the brightness value of the initial pixel as I(x,y) and the brightness value of the target pixel as I... S (x', y'), where 0 ≤ x ≤ X, 0 ≤ y ≤ Y. X is the upper limit of the rows in the target image, and Y is the upper limit of the columns in the target image.
[0067] 120. For each target pixel, calculate a first weight value between the target pixel and a first neighboring pixel, wherein the first neighboring pixel is a pixel in the neighborhood of the target pixel.
[0068] The first neighboring pixel can be a pixel whose row distance from the target pixel is no greater than m and whose column distance from the target pixel is no greater than n, where m and n are both positive integers. Without loss of generality, let the first neighboring pixel be denoted as (i,j), then -m≤i≤m, -n≤j≤n.
[0069] It can be understood that the target pixel has multiple first neighbor pixels, and the number of first neighbor pixels depends on the values of m and n: the number of first neighbor pixels is (2m+1)*(2n+1). Let's assume m and n are both 2, then each target pixel has (2*2+1)*(2*2+1) = 25 first neighbor pixels.
[0070] Since there are multiple first neighboring pixels of the target pixel, there are also multiple weight values between the target pixel and the first neighboring pixels, and the number of weight values is the same as the number of neighboring pixels.
[0071] Optionally, in one embodiment, step 120 may specifically include the following steps 121 to 122:
[0072] 121. For each target pixel, calculate the brightness difference between the target pixel and the first neighboring pixel.
[0073] According to the formula Calculate the brightness difference In this context, each of the target pixel and its corresponding first neighboring pixels has a brightness difference value. That is, for each target pixel, the number of brightness differences is the same as the number of first neighboring pixels.
[0074] 122. Calculate the first weight value of the target pixel and the first neighboring pixel based on the brightness difference between the target pixel and the first neighboring pixel, the attenuation degree of the spatial proximity factor, and the attenuation degree of the brightness similarity factor.
[0075] After calculating the brightness difference between the target pixel and its corresponding first neighboring pixels, the following formula is used: Calculate the first weight value P(x',y',i,j); where σ d σ represents the attenuation of the spatial proximity factor. c This represents the attenuation rate of the brightness similarity factor.
[0076] It should be understood that for any target pixel among multiple target pixels, there are multiple corresponding first neighbor pixels. Each of these first neighbor pixels has a weight value. Therefore, the number of P(x',y',i,j) is related to the number of first neighbor pixels, which in turn depends on the values of m and n: -m≤i≤m, -n≤j≤n. Therefore, the first weight value corresponding to each first neighbor pixel of the target pixel can be obtained through steps 121 to 122.
[0077] 130. Expand the first weight value corresponding to each target pixel to obtain the second weight value corresponding to each initial pixel.
[0078] Wherein, the second weight value is the weight value of the corresponding initial pixel and the second neighboring pixel, the second neighboring pixel is the pixel in the neighborhood of the initial pixel, the second neighboring pixel has the first number of groups, and the second neighboring pixel in the first number of groups corresponds one-to-one with the first number of initial pixels.
[0079] Optionally, in one specific implementation, step 130 can be implemented using a bilinear interpolation algorithm. Specifically, implementing the bilinear interpolation algorithm may include the following processing steps:
[0080] Continuing from the previous example where the initial pixel in an odd-numbered row and column of the pixel matrix is the target pixel, the explanation will proceed. For details, please refer to [link to relevant documentation]. Figure 2a , Figure 2a In the diagram, A, B, C, and D are all target pixels. These A, B, C, and D are represented by I... S (x',y')(where, ) indicates that, can be represented as:
[0081] A: P(x',y',i,j);
[0082] B: P(x'+1,y',i,j);
[0083] C: P(x',y'+1,i,j);
[0084] D: P(x'+1,y'+1,i,j).
[0085] Representing A, B, C, and D using I(x,y) (where 0≤x≤X, 0≤y≤Y), they can be expressed as follows:
[0086] A: Q(2x-1,2y-1,i,j);
[0087] B: Q(2x+1,2y-1,i,j);
[0088] C: Q(2x-1,2y+1,i,j);
[0089] D: Q(2x+1,2y+1,i,j).
[0090] Right now:
[0091] Q(2x-1,2y-1,i,j)=P(x',y',i,j);
[0092] Q(2x+1,2y-1,i,j)=P(x'+1,y',i,j);
[0093] Q(2x-1,2y+1,i,j)=P(x',y'+1,i,j);
[0094] Q(2x+1,2y+1,i,j)=P(x'+1,y'+1,i,j).
[0095] For any one of the target pixels A, B, C, and D, it needs to be expanded into an initial pixel by 3 pixels. Taking target pixel A as an example, its corresponding A1, A2, and A3 are all pixels to be calculated when expanding into an initial pixel.
[0096] When calculating A1, it can be calculated by averaging A and B;
[0097] Specifically, the calculation process for A1 is expressed by the following formula:
[0098]
[0099] When calculating A2, it can be calculated by averaging A and C;
[0100] Specifically, the calculation process for A2 is expressed by the following formula:
[0101]
[0102] To calculate A3, you can first calculate the average of C and D, and then average this average with A1 to get A3; alternatively, you can first calculate the average of B and D, and then average this average with A2 to get A3. Let's take the former as an example; the calculation process for A3 can be expressed by the following formula:
[0103] The average of C and D = Q(2x,2y+1,i,j);
[0104]
[0105] For each of the multiple target pixels, the weight values of the three initial pixels to be expanded corresponding to each target pixel can be calculated through the above processing, thereby obtaining the second weight value of each initial pixel and its second neighboring pixels.
[0106] Here, the second neighboring pixel refers to the neighboring pixel of the initial pixel. The properties of the second neighboring pixel can be the same as those of the first neighboring pixel. That is, the second neighboring pixel can also be a pixel whose row number from the target pixel is no greater than m and whose column number from the target pixel is no greater than n. Let's also denote the second neighboring pixel as (i,j), then -m≤i≤m, -n≤j≤n. The first neighboring pixel is the neighboring pixel of the target pixel, and the second neighboring pixel is the neighboring pixel of the initial pixel. The distinction between the first and second neighboring pixels can simply be used to differentiate whether they belong to the target pixel or the initial pixel.
[0107] 140. For each initial pixel, calculate the weighted sum of the brightness of the initial pixel and the second neighboring pixels based on the second weight value corresponding to the initial pixel and the brightness values of the initial pixel and the second neighboring pixels.
[0108] For each initial pixel, according to the formula Calculate the weighted sum of the brightness of any initial pixel and its second neighboring pixels, A(x,y), where I(x+i,y+j) is the brightness value of each initial pixel and its second neighboring pixels, and Q(x,y,i,j) is the weight value of each initial pixel and its second neighboring pixels.
[0109] 150. The target image is enhanced in sharpness based on the brightness weighted sum of each initial pixel to obtain a result image, wherein the sharpness of the result image is stronger than that of the target image.
[0110] Optionally, in one specific embodiment, step 150 may specifically include the following steps 151 to 152:
[0111] 151. For each initial pixel, normalize the initial filtering result based on the brightness weighted sum corresponding to the initial pixel and the initial pixel itself.
[0112] Optionally, in one specific embodiment, step 151 may specifically include the following steps 1511 to 1512:
[0113] 1511. Obtain the normalization parameters.
[0114] Optionally, in one specific embodiment, step 1511 may specifically include the following steps A1 to A2:
[0115] A1. Calculate the sum of the target weight values corresponding to each target pixel in all target pixels to obtain the target weight sum, wherein the target weight value of the target pixel is the weight value of the target pixel and its corresponding first neighboring pixel.
[0116] According to the formula Calculate the target weighted sum U(x',y').
[0117] A2. Expand the sum of the target weight values to obtain the normalization parameter, wherein the normalization parameter is the sum of the target weight values corresponding to each initial pixel in all initial pixels, and the target weight value of the initial pixel is the weight value of the initial pixel and the corresponding second neighboring pixel.
[0118] The expansion of the sum of the target weight values can also be achieved using the bilinear interpolation algorithm, and the specific processing steps are as follows:
[0119] Please see details Figure 2b , Figure 2b The values H, I, J, and K shown are the target weight sums, and their corresponding x' and y' values are... They can be represented as:
[0120] H: U(x',y');
[0121] I: U(x'+1,y');
[0122] J: U(x',y'+1);
[0123] K: U(x'+1,y'+1).
[0124] Representing H, I, J, and K using x and y (where 0 ≤ x ≤ X, 0 ≤ y ≤ Y), they can be expressed as follows:
[0125] H: E(2x-1, 2y-1);
[0126] I: E(2x+1, 2y-1);
[0127] J: E(2x-1, 2y+1);
[0128] K: E(2x+1,2y+1).
[0129] Right now:
[0130] U(x',y')=E(2x-1,2y-1);
[0131] U(x'+1,y')=E(2x+1,2y-1);
[0132] U(x',y'+1)=E(2x-1,2y+1);
[0133] U(x'+1,y'+1)=E(2x+1,2y+1).
[0134] For any of the target weight sums H, I, J, and K, when expanding to normalization parameters, it needs to be expanded with 3 values. Taking the target weight sum H as an example, its corresponding H1, H2, and H3 are all values to be calculated when expanding to normalization parameters.
[0135] When calculating H1, it can be calculated by averaging H and I;
[0136] Specifically, the calculation process for H1 is expressed by the following formula:
[0137]
[0138] When calculating H2, it can be calculated by averaging H and J;
[0139] Specifically, the calculation process for H2 is expressed by the following formula:
[0140]
[0141] To calculate H3, we can first calculate the average of J and K, and then average this average with H1 to obtain H3. The calculation process of H3 can be expressed by the following formula:
[0142] The average value of J and K is E(2x, 2y+1);
[0143]
[0144] In the above implementation, the normalized parameter E(x,y) can be obtained by calculating the sum of the target weight values corresponding to each target pixel and expanding the sum.
[0145] 1512. For each initial pixel, calculate the quotient of the luminance weighted sum corresponding to the initial pixel and the normalization parameter, and determine the quotient as the initial filtering result.
[0146] Alternatively, it can be based on the formula: Calculate the initial filtering result F(x,y).
[0147] In the above steps, the normalization parameter can be calculated first, and then the initial filtering result can be obtained by dividing the weighted sum of the brightness of the initial pixel and its neighboring pixels by the normalization parameter.
[0148] 152. Enhance the sharpness of the target image based on the initial filtering result to obtain the result image.
[0149] Optionally, in one specific embodiment, the initial filtering result is a filtering result with fewer high-frequency details than a first threshold; correspondingly, step 152 may include the following steps 1521 to 1522:
[0150] 1521. Calculate the difference between the brightness value of the initial pixel in the target image and the initial filtering result, and determine the difference as the secondary filtering result.
[0151] The secondary filtering result is the filtering result with more high-frequency details than the second threshold. Both the first and second thresholds can be preset by the user.
[0152] The secondary filtering result H(x,y) is calculated according to the formula H(x,y)=I(x,y)-F(x,y), where I(x,y) is the brightness value of the initial pixel in the target image; F(x,y) is the initial filtering result.
[0153] 1522. Calculate the resulting image based on the preset coefficients and the secondary filtering results.
[0154] According to Formula I enhanced The image of the calculation result of (x,y)=I(x,y)+αH(x,y) is I. enhanced (x,y), where I(x,y) is the brightness value of the initial pixel in the target image; α is a preset coefficient, and the value of α is between 2 and 3.
[0155] In the above steps, an initial filtering result with fewer high-frequency details can be obtained first. Then, the difference between the brightness value of the initial pixel in the target image and the initial filtering result is calculated to obtain a secondary filtering result with more high-frequency details. Subsequently, the result image is calculated using preset coefficients and the secondary filtering result. Because the target image is enhanced with the secondary filtering result containing more high-frequency details, the result image retains more high-frequency details while improving clarity, thus increasing the visual appeal of the image.
[0156] In the image sharpness enhancement method provided in this application embodiment, a second number of target pixels can be selected from a first number of initial pixels, and a first weight value of each target pixel and its corresponding first neighboring pixels can be calculated. The first weight value is then expanded to obtain a second weight value of each initial pixel and its corresponding second neighboring pixels. Next, a brightness-weighted sum of each initial pixel and its respective second neighboring pixels is calculated. This brightness-weighted sum is then normalized to obtain an initial filtering result. Finally, a sharpness-enhanced image is obtained based on the initial filtering result. In the above embodiment, the calculation of the second weight value of the initial pixel and its second neighboring pixels is achieved by calculating the first weight value of the target pixel and its first neighboring pixels, and then expanding the first weight value. Compared to directly calculating each initial pixel and its corresponding second neighboring pixels, this method reduces the computational load, thus effectively improving the problems of long filtering time and display delay that occur when using filters to perform real-time image filtering.
[0157] To better implement the above methods, this application also provides an image sharpness enhancement device, which can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet computer, smart Bluetooth device, laptop computer, personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.
[0158] For example, such as Figure 3As shown, the image sharpness enhancement device may include:
[0159] The pixel filtering unit 301 is used to filter out a second number of target pixels from the first number of initial pixels;
[0160] The weight value calculation unit 302 is used to calculate a first weight value between the target pixel and the first neighboring pixels for each target pixel, wherein the first neighboring pixels are the pixels in the neighborhood of the target pixel;
[0161] The weight value expansion unit 303 is used to expand the first weight value corresponding to each target pixel to obtain the second weight value corresponding to each initial pixel. The second weight value is the weight value between the corresponding initial pixel and the second neighboring pixel. The second neighboring pixel is the pixel in the neighborhood of the initial pixel. The second neighboring pixel has a first number of groups, and the first number of second neighboring pixels corresponds one-to-one with the first number of initial pixels.
[0162] The weighted sum calculation unit 304 is used to calculate the brightness weighted sum of the initial pixel and the second neighboring pixels for each initial pixel based on the second weight value corresponding to the initial pixel and the brightness values of the initial pixel and the second neighboring pixels.
[0163] The sharpness enhancement unit 305 is used to enhance the sharpness of the target image based on the brightness weighted sum of each of the initial pixels to obtain a result image, wherein the sharpness of the result image is stronger than that of the target image.
[0164] Optionally, in one embodiment, the pixel filtering unit 301 is specifically used to obtain pixels with target properties from the first number of initial pixels, and determine the pixels with target properties as target pixels.
[0165] Optionally, in one embodiment, the weight value calculation unit 302 includes:
[0166] A brightness difference calculation subunit is used to calculate the brightness difference between the target pixel and the first neighboring pixel for each target pixel.
[0167] The weight value calculation subunit is used to calculate the first weight value between the target pixel and the first neighboring pixel based on the brightness difference between the target pixel and the first neighboring pixel, the attenuation degree of the spatial proximity factor, and the attenuation degree of the brightness similarity factor.
[0168] Optionally, in one embodiment, the weight value expansion unit 303 is specifically used to expand the first weight value corresponding to each of the target pixels using a bilinear interpolation algorithm to obtain the second weight value corresponding to each initial pixel.
[0169] Optionally, in one embodiment, the sharpness enhancement unit 305 includes:
[0170] The normalization subunit is used to perform normalization processing on each initial pixel based on the brightness weighted sum corresponding to the initial pixel and the initial pixel itself, to obtain the initial filtering result;
[0171] The result enhancement subunit is used to enhance the sharpness of the target image based on the initial filtering result to obtain a result image. Optionally, in one embodiment, the normalization subunit includes:
[0172] The normalization parameter sub-unit is used to obtain the normalization parameter;
[0173] The quotient operation subunit is used to calculate the quotient value of the luminance weighted sum corresponding to each initial pixel and the normalization parameter for each initial pixel, and to determine the quotient value as the initial filtering result.
[0174] Optionally, in one embodiment, the normalized parameter subunit includes:
[0175] The target pixel calculation sub-unit is used to calculate the sum of the target weight values corresponding to each target pixel in all target pixels to obtain the target weight sum, wherein the target weight value of the target pixel is the weight value of the target pixel and the corresponding first neighboring pixel.
[0176] The weight expansion sub-unit is used to expand the sum of the target weight values to obtain the normalization parameter, wherein the normalization parameter is the sum of the target weight values corresponding to each initial pixel in all initial pixels, and the target weight value of the initial pixel is the weight value of the initial pixel and the corresponding second neighboring pixel.
[0177] Optionally, in one implementation, the result enhancement subunit includes:
[0178] The secondary filtering result subunit is used to calculate the difference between the brightness value of the initial pixel in the target image and the initial filtering result, and to determine the difference as the secondary filtering result, wherein the secondary filtering result is a filtering result with more high-frequency details than the second threshold.
[0179] The result image calculation subunit is used to calculate the result image based on preset coefficients and the secondary filtering result.
[0180] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.
[0181] In this embodiment, a second number of target pixels can be selected from a first number of initial pixels, and a first weight value is calculated for each target pixel and its corresponding first neighboring pixels. This first weight value is then expanded to obtain a second weight value for each initial pixel and its corresponding second neighboring pixels. Next, a brightness-weighted sum is calculated for each initial pixel and its corresponding second neighboring pixels. This brightness-weighted sum is then normalized to obtain an initial filtering result. Finally, an image with enhanced sharpness is obtained based on the initial filtering result. In the above embodiment, the calculation of the second weight value between the initial pixels and the second neighboring pixels is achieved by calculating the first weight value between the target pixel and its first neighboring pixels, and then expanding the first weight value. This method reduces the computational load compared to directly calculating the second neighboring pixels of each initial pixel.
[0182] Therefore, the embodiments of this application effectively reduce the filtering time when the filter performs real-time filtering on the image, and improve the problem of display delay.
[0183] Accordingly, this application also provides a computer device, which can be a terminal or a server. The terminal can be a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer, personal digital assistant (PDA) and other terminal devices.
[0184] like Figure 4 As shown, Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device 400 includes a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, and a computer program stored in the memory 402 and executable on the processor. The processor 401 and the memory 402 are electrically connected. Those skilled in the art will understand that the computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0185] The processor 401 is the control center of the computer device 400. It connects various parts of the computer device 400 through various interfaces and lines. By running or loading software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, it performs various functions of the computer device 400 and processes data, thereby monitoring the computer device 400 as a whole.
[0186] In this embodiment, the processor 401 in the computer device 400 loads the instructions corresponding to the processes of one or more applications into the memory 402 according to the following steps, and the processor 401 runs the applications stored in the memory 402 to achieve various functions:
[0187] A second number of target pixels are selected from the first number of initial pixels. For each target pixel, a first weight value is calculated between the target pixel and its first neighboring pixels, where the first neighboring pixels are pixels within the neighborhood of the target pixel. The first weight value corresponding to each target pixel is expanded to obtain a second weight value corresponding to each initial pixel, where the second weight value is the weight value between the corresponding initial pixel and its second neighboring pixels, where the second neighboring pixels are pixels within the neighborhood of the initial pixel. The second neighboring pixels have a first number of groups, and the second neighboring pixels in the first number of groups correspond one-to-one with the first number of initial pixels. For each initial pixel, a brightness weighted sum of the initial pixel and its second neighboring pixels is calculated based on the second weight value corresponding to the initial pixel and the brightness values of the initial pixel and its second neighboring pixels. The target image is then enhanced in sharpness based on the brightness weighted sum of each initial pixel to obtain a result image, wherein the sharpness of the result image is stronger than that of the target image.
[0188] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0189] Optional, such as Figure 4 As shown, the computer device 400 also includes: a touch screen display 403, a radio frequency circuit 404, an audio circuit 405, an input unit 406, and a power supply 407. The processor 401 is electrically connected to the touch screen display 403, the radio frequency circuit 404, the audio circuit 405, the input unit 406, and the power supply 407. Those skilled in the art will understand that... Figure 4 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0190] The touch display screen 403 can be used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. The touch display screen 403 may include a display panel and a touch panel. The display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the computer device. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Optionally, the display panel can be configured using a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar technologies. The touch panel can be used to collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel), generate corresponding operation commands, and execute the corresponding program according to the operation commands. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch location and the signal generated by the touch operation, transmitting the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 401. It can also receive and execute commands from the processor 401. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it transmits the information to the processor 401 to determine the type of touch event. Subsequently, the processor 401 provides corresponding visual output on the display panel based on the type of touch event. In this embodiment, the touch panel and the display panel can be integrated into the touch display screen 403 to achieve input and output functions. However, in some embodiments, the touch panel and the touch display screen 403 can be implemented as two independent components to achieve input and output functions. That is, the touch display screen 403 can also be used as part of the input unit 406 to achieve input functions.
[0191] The radio frequency circuit 404 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other computer devices, and to transmit and receive signals with network devices or other computer devices.
[0192] Audio circuitry 405 can be used to provide an audio interface between a user and a computer device via a speaker and a microphone. Audio circuitry 405 can convert received audio data into electrical signals and transmit them to the speaker, where the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuitry 405, converted back into audio data, and then processed by processor 401 before being transmitted via radio frequency circuitry 404 to, for example, another computer device, or output to memory 402 for further processing. Audio circuitry 405 may also include an earphone jack to facilitate communication between peripheral headphones and the computer device.
[0193] The input unit 406 can be used to receive input numbers, characters, or user characteristic information (such as fingerprints, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
[0194] Power supply 407 is used to supply power to various components of computer device 400. Optionally, power supply 407 can be logically connected to processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. Power supply 407 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0195] although Figure 4 As not shown in the diagram, computer equipment 400 may also include a camera, sensor, wireless fidelity module, Bluetooth module, etc., which will not be described in detail here.
[0196] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0197] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0198] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of computer programs that can be loaded by a processor to execute steps in any of the image sharpness enhancement methods provided in embodiments of this application. For example, the computer program can execute the following steps:
[0199] A second number of target pixels are selected from the first number of initial pixels. For each target pixel, a first weight value is calculated between the target pixel and its first neighboring pixels, where the first neighboring pixels are pixels within the neighborhood of the target pixel. The first weight value corresponding to each target pixel is expanded to obtain a second weight value corresponding to each initial pixel, where the second weight value is the weight value between the corresponding initial pixel and its second neighboring pixels, where the second neighboring pixels are pixels within the neighborhood of the initial pixel. The second neighboring pixels have a first number of groups, and the second neighboring pixels in the first number of groups correspond one-to-one with the first number of initial pixels. For each initial pixel, a brightness weighted sum of the initial pixel and its second neighboring pixels is calculated based on the second weight value corresponding to the initial pixel and the brightness values of the initial pixel and its second neighboring pixels. The target image is then enhanced in sharpness based on the brightness weighted sum of each initial pixel to obtain a result image, wherein the sharpness of the result image is stronger than that of the target image. For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0200] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0201] Since the computer program stored in the computer-readable storage medium can execute the steps of any of the image sharpness enhancement methods provided in the embodiments of this application, the beneficial effects that any of the image sharpness enhancement methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0202] The foregoing has provided a detailed description of an image sharpness enhancement method, apparatus, computer-readable storage medium, and computer device provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for enhancing image sharpness, characterized in that, The method for enhancing the sharpness of a target image, the target image comprising a first number of initial pixels, includes: Select a second number of target pixels from the first number of initial pixels; For each target pixel, a first weight value is calculated between the target pixel and the first neighboring pixels, wherein the first neighboring pixels are the pixels in the neighborhood of the target pixel; Each target pixel is expanded to obtain a second weight value corresponding to each initial pixel. The second weight value is the weight value between the initial pixel and the second neighboring pixel. The second neighboring pixel is the pixel in the neighborhood of the initial pixel. There is a first number of groups of second neighboring pixels. The first number of groups of second neighboring pixels correspond one-to-one with the first number of initial pixels. For each initial pixel, a weighted sum of the brightness of the initial pixel and the second neighboring pixels is calculated based on the second weight value corresponding to the initial pixel and the brightness values of the initial pixel and the second neighboring pixels. The target image is enhanced in sharpness based on the brightness weighted sum of each initial pixel to obtain a result image, wherein the sharpness of the result image is stronger than that of the target image; The step of enhancing the sharpness of the target image based on the brightness weighted sum of each initial pixel to obtain the result image includes: For each initial pixel, a normalization process is performed based on the brightness weighted sum corresponding to the initial pixel and the initial pixel itself to obtain an initial filtering result; Calculate the difference between the brightness value of the initial pixel in the target image and the initial filtering result, and determine the difference as the secondary filtering result; The resulting image is calculated based on preset coefficients and the secondary filtering results.
2. The method as described in claim 1, characterized in that, The step of selecting a second number of target pixels from the first number of initial pixels includes: From the first number of initial pixels, obtain pixels that have the target properties, and determine the pixels with the target properties as target pixels.
3. The method as described in claim 1, characterized in that, For each target pixel, calculating a first weight value between the target pixel and its first neighboring pixels includes: For each target pixel, calculate the brightness difference between the target pixel and the first neighboring pixel; The first weight value of the target pixel and the first neighboring pixel is calculated based on the brightness difference between the target pixel and the first neighboring pixel, the attenuation of the spatial proximity factor, and the attenuation of the brightness similarity factor.
4. The method as described in claim 1, characterized in that, The step of expanding the first weight value corresponding to each of the target pixels to obtain the second weight value corresponding to each initial pixel includes: The first weight value corresponding to each target pixel is expanded using a bilinear interpolation algorithm to obtain the second weight value corresponding to each initial pixel.
5. The method as described in claim 1, characterized in that, The step of performing a normalization process on each initial pixel, based on the luminance weighted sum corresponding to the initial pixel and the initial pixel itself, to obtain an initial filtering result includes: Obtain the normalization parameters; For each initial pixel, the quotient of the luminance-weighted sum corresponding to the initial pixel and the normalization parameter is calculated, and the quotient is determined as the initial filtering result.
6. The method as described in claim 5, characterized in that, The process of obtaining the normalized parameters includes: Calculate the sum of the target weight values corresponding to each target pixel in all target pixels to obtain the target weight sum, wherein the target weight value of the target pixel is the weight value of the target pixel and its corresponding first neighboring pixel; The target weight sum is expanded to obtain the normalization parameter, wherein the normalization parameter is the sum of the target weight values corresponding to each initial pixel in all initial pixels, and the target weight value of each initial pixel is the weight value of the initial pixel and its corresponding second neighboring pixel.
7. An image sharpness enhancement device, characterized in that, For enhancing the sharpness of a target image, the target image comprising a first number of initial pixels, the apparatus includes: A pixel filtering unit is used to filter out a second number of target pixels from the first number of initial pixels; The weight value calculation unit is used to calculate a first weight value between the target pixel and the first neighboring pixels for each target pixel, wherein the first neighboring pixels are the pixels in the neighborhood of the target pixel; The weight value expansion unit is used to expand the first weight value corresponding to each target pixel to obtain the second weight value corresponding to each initial pixel. The second weight value is the weight value between the corresponding initial pixel and the second neighboring pixel. The second neighboring pixel is the pixel in the neighborhood of the initial pixel. The second neighboring pixel has a first number of groups, and the first number of second neighboring pixels corresponds one-to-one with the first number of initial pixels. The weighted sum calculation unit is used to calculate, for each initial pixel, a weighted sum of the brightness of the initial pixel and the second neighboring pixels based on the second weight value corresponding to the initial pixel and the brightness values of the initial pixel and the second neighboring pixels; A sharpness enhancement unit is configured to enhance the sharpness of the target image based on the brightness weighted sum of each initial pixel to obtain a result image, wherein the sharpness of the result image is stronger than that of the target image. The clarity enhancement unit includes: The normalization subunit is used to perform normalization processing on each initial pixel based on the brightness weighted sum corresponding to the initial pixel and the initial pixel itself, to obtain the initial filtering result; The result enhancement subunit is used to enhance the sharpness of the target image based on the initial filtering result to obtain a result image. The result enhancement subunit includes: The secondary filtering result subunit is used to calculate the difference between the brightness value of the initial pixel in the target image and the initial filtering result, and to determine the difference as the secondary filtering result, wherein the secondary filtering result is a filtering result with more high-frequency details than the second threshold. The result image calculation subunit is used to calculate the result image based on preset coefficients and the secondary filtering result.
8. A computer device, characterized in that, The method includes a processor and a memory, the memory storing multiple instructions; the processor loads instructions from the memory to perform the steps in the image sharpness enhancement method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the image sharpness enhancement method as described in any one of claims 1 to 6.