Self-adaptive weighted image interpolation method based on distance regularization
Through the adaptive weighted image interpolation method based on distance regularization, combining Euclidean distance and grayscale values to calculate the weight, and using the Pearson correlation coefficient to perform multi-directional weight fusion, the problems of traditional interpolation methods are solved in high-magnification amplification scenarios, achieving higher image imaging quality and adaptability.
Patent Information
- Application Number
- CN202510639219.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-19
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2045-05-19
AI Technical Summary
Traditional image interpolation methods have problems such as loss of detail, blurring of edges and insufficient adaptability in high-magnification amplification scenarios, making it difficult to effectively preserve image details and clarity.
Adaptive weighted image interpolation method based on distance regularization is used to calculate the Euclidean distance and grayscale values from the target position to the neighboring pixel point, calculate the initial weight, and calculate the multi-direction weight using the Pearson correlation coefficient to perform the final interpolation result fusion.
This method can better preserve image details and improve image imaging quality, especially in high-magnification amplification scenarios, dynamically adjust weight allocation, adapt to complex structures, and reduce noise interference.
Smart Images

Figure CN120182084A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and particularly to an adaptive weighted image interpolation method based on distance regularization. Background Art
[0002] In the field of image processing, interpolation technology is one of the core means for image magnification. Its purpose is to fill the gray values of newly added pixels after magnification through algorithms to retain the details and clarity of the original image as much as possible. Although traditional interpolation methods (such as nearest neighbor interpolation, bilinear interpolation, bicubic interpolation) are simple and efficient, they have significant defects in high-magnification scenarios: I. Detail loss and edge blur. Traditional methods are mostly based on fixed kernel functions or local uniform assumptions and do not fully consider local structural features of images (such as edges, textures). For example, bilinear interpolation performs well in smooth regions but is prone to blurring in high-contrast edge regions, resulting in a decrease in image sharpness. II. Insufficient adaptability: Existing methods usually adopt a single interpolation direction (such as horizontal or vertical) and are difficult to dynamically adjust weight distribution according to the image content, resulting in poor adaptability to complex structures (such as cross edges, irregular textures).
[0003] In recent years, some improved algorithms have tried to optimize the interpolation weights by introducing gradient information or local statistical features. However, the high computational complexity and rigid weight distribution still cannot meet the actual production requirements. Summary of the Invention
[0004] In view of the above technical problems, the present invention proposes an adaptive weighted image interpolation method based on distance regularization. This method combines gray level and distance to calculate weights, which can better retain image details and thus improve the image imaging quality.
[0005] To achieve the above technical objectives, the present invention adopts the following technical solutions: The present invention specifically relates to an adaptive weighted image interpolation method based on distance regularization, which includes: Step 1: Obtain an input image, calculate the size of the output image according to a preset magnification factor, and map the original pixels of the input image to the corresponding positions of the output image according to the magnification factor; Step 2: Obtain the target position to be interpolated in the output image, calculate the four neighborhood pixel points in the diagonal direction of the target position, and obtain the gray values A, B, C, D of the neighborhood pixel points; Step 3: Calculate the Euclidean distances LA, LB, LC, LD from the target position to the four neighborhood pixel points, and calculate the initial weights wA, wB, wC, wD in combination with the gray values. The values of the initial weights wA, wB, wC, wD are the gray values A, B, C, D divided by the Euclidean distances LA, LB, LC, LD respectively; Step 4: According to the initial weights, use the Pearson correlation coefficient to calculate the regularization correlation between the initial weights respectively. The formula is as follows: r_AB = pearson(wA, wB); r_AC = pearson(wA, wC); r_AD = pearson(wA, wD); r_BC = pearson(wB, wC); r_BD = pearson(wB, wD); r_CD = pearson(wC, wD); Calculate the horizontal direction weight w1, the vertical direction weight w2 and the global average weight w3. The formula is as follows: w1 = abs(r_AB + r_CD); w2 = abs(r_AC + r_BD); w3 = abs(r_AD + r_BC); where pearson is the correlation call function and abs is the absolute value call function; Step 5: Fuse the multi-direction weights to output the interpolation result of the target position. The calculation formula is as follows: ; output is the interpolation result.
[0006] Preferably, the method for obtaining the target position to be interpolated in the output image in Step 2 is: If the position of the pixel point in the input image is (i, j), then its corresponding position on the output image is (ni, nj), where n is the magnification factor; Select the points in the output image with the position range from (ni - n, nj - n) to (ni, nj) as the target position.
[0007] Preferably, the method for calculating the four neighborhood pixel points in the diagonal direction of the target position is: If the position of the pixel point in the input image is (i, j), then the adjacent positions of this pixel point are (i - 1, j - 1), (i - 1, j + 1), (i + 1, j - 1), (i + 1, j + 1); If the position of the target position mapped to the input image is between (i - 1, j - 1) and (i, j), then the neighborhood pixel points of the target position in the output image are (ni - n, nj - n), (ni - n, nj + n), (ni + n, nj - n), (ni + n, nj + n).
[0008] Preferably, the formulas for calculating the Euclidean distances LA, LB, LC, and LD from the target position to the four neighboring pixel points are as follows: ; where X is the difference in the abscissa between the target position and the neighboring pixel point, and Y is the difference in the ordinate between the target position and the neighboring pixel point.
[0009] Preferably, the correlation call function in step four is as follows: pearson(x, y) = ; And a λ parameter is introduced into the function to force the weight not to be equal to 1 in the low-gradient region. The formula after introduction is as follows: pearson(x, y) = .
[0010] Preferably, the method further includes normalizing the horizontal direction weight w1, vertical direction weight w2, and global average weight w3 calculated in step four through the softmax function. The calculation formula of the softmax function is: ; where T is the temperature parameter, is the i-th weight, is all the weights traversed (j = 1, 2, 3).
[0011] On the other hand, the present invention also discloses a terminal, including a processor and a storage medium; the storage medium is used to store instructions; the processor is used to operate according to the instructions to execute the steps of the above method.
[0012] The present invention first calculates the initial weight by using the ratio of the gray value of the neighboring pixel point to its Euclidean distance, and then calculates the weights in the horizontal direction, vertical direction, and global average direction according to the Pearson correlation coefficient. The final interpolation result is calculated by using the multi-weight fusion method, so that when the output image is enlarged, the image details are better retained, and the image imaging quality is improved; the present invention also introduces a λ parameter in the low-gradient region to avoid noise amplification caused by too high a single-direction weight, and dynamically suppresses noise interference while retaining the edge sharpness, providing an efficient solution for scenarios with strict requirements for fidelity such as printing and medical imaging. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings described herein are used to provide a further understanding of the present disclosure, and constitute a part of the present disclosure. The illustrative embodiments and descriptions thereof are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings: Figure 1Shows a schematic flow chart of the adaptive weighted image interpolation method of the present invention.
[0014] Figure 2 Shows a schematic diagram of mapping the original pixels of the input image of the present invention into the output image.
[0015] Figure 3 Shows a schematic diagram of the distribution of some points to be interpolated of the present invention.
[0016] Figure 4 Shows a schematic diagram of the positional relationship between the target position and the neighboring pixel points of the present invention.
[0017] Figure 5 Shows a schematic diagram of the input image of the present invention.
[0018] Figure 6 Shows a partial schematic diagram of the output image of the present invention. Detailed implementation manners
[0019] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention.
[0020] Therefore, the detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed present invention, but merely represents selected embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of protection of the present invention.
[0021] As Figure 1 shown, the present invention provides an adaptive weighted image interpolation method based on distance regularization, which specifically includes: Step 1, obtain an input image, calculate the size of the output image according to a preset magnification factor, and map the original pixels of the input image to the corresponding positions of the output image according to the magnification factor. In this step, the output image is enlarged according to the input image. After enlargement, the size of the output image is the magnification factor of the size of the input image. To ensure that the content of the output image is consistent with the content of the input image, the positions of the original pixels in the input image also need to be mapped into the output image. The mapping rule is to map the positions of the original pixels to the output image at intervals multiplied by the magnification factor.
[0022] Taking the magnification factor of five times as an example, as Figure 2As shown in the figure, the coordinates of an original pixel in the input image are (i, j). The left figure is the input image. After being magnified by five times, the coordinates of this original pixel mapped to the output image are (5i, 5j). The right figure in the image is the output image.
[0023] Since the size of the output image is larger than that of the input image, even if all the original pixels are mapped, they cannot completely fill the entire output image. There must be blank pixels between adjacent pixels. As Figure 3 shown in the figure, in the image, the shaded points are the points mapped from the original pixels, and the coordinates are (0, 5j), (5i, 0), and (5i, 5j). There are also several hollow points between these three points. To ensure that the magnified image is still as clear as the original image, pixel values need to be inserted into these hollow points to ensure the imaging quality of the magnified image. The specific insertion method will be described in detail in the subsequent steps.
[0024] Step 2: Obtain the target position to be interpolated in the output image, calculate the four neighboring pixel points in the diagonal direction of the target position, and obtain the gray values A, B, C, and D of the neighboring pixel points; as mentioned in Step 1, Figure 3 the hollow points in Figure 4 are the points to be interpolated. Select a hollow point as the target position. After determining the target position, it can be known that the four neighboring pixel points in the diagonal direction are, taking
[0025] a complete output image as an example. If the selected target position is point X, then its four neighboring pixel points are (0, 0), (0, 5j), (5i, 0), and (5i, 5j). After finding these four points, the gray value corresponding to each point, namely A, B, C, and D, can be obtained. Obtaining the gray values is for the calculation of the initial weights in the subsequent steps. See the following steps for details.
[0025] Step 3: Calculate the Euclidean distances LA, LB, LC, and LD from the target position to the four neighboring pixel points, and calculate the initial weights wA, wB, wC, and wD in combination with the gray values. The values of the initial weights wA, wB, wC, and wD are the gray values A, B, C, and D divided by the Euclidean distances LA, LB, LC, and LD respectively. The calculation formula is as follows: , w(x) is the initial weight (x = A, B, C, D); This step calculates the initial weights by using the ratio of the gray value and the Euclidean distance. The Euclidean distance L refers to the actual distance between two points in an n-dimensional space. The calculation formula for the Euclidean distance is: , where L is LA, LB, LC, and LD; Among them, X is the difference in the abscissa between the target position and the neighboring pixel, and Y is the difference in the ordinate between the target position and the neighboring pixel. Using the Euclidean distance calculation formula, the diagonal distance between the target position and each neighboring pixel can be calculated. Then, according to the calculation formula of the initial weight, ; ; ; , the initial weights wA, wB, wC, and wD can be calculated. However, using only the initial weights for interpolation cannot meet the interpolation requirements of complex images. Therefore, subsequent steps are needed to further improve this weight.
[0026] Step 4: According to the initial weights, use the Pearson correlation coefficient to calculate the regularization correlation between the initial weights respectively. The formula is as follows: r_AB = pearson(wA, wB); r_AC = pearson(wA, wC); r_AD = pearson(wA, wD); r_BC = pearson(wB, wC); r_BD = pearson(wB, wD); r_CD = pearson(wC, wD); The Pearson correlation coefficient is an index to measure the degree of linear correlation between two variables, and its value ranges from -1 to 1. A positive value indicates a positive correlation, a negative value indicates a negative correlation, and 0 indicates no correlation. In Step 3, the initial weights reflect the potential contribution intensity of neighboring pixels to interpolation. By calculating the Pearson correlation coefficient between these weights, it can be analyzed whether the weight changes in different directions (horizontal, vertical, global average) are consistent, thereby inferring the local structure characteristics of the image. The four initial weights are combined in pairs, and their Pearson correlation coefficients are calculated.
[0027] r_AB measures the weight synergy in the horizontal direction (A and D, B and C). If the value of r_AB is high, it indicates that the weight changes of pixels in the horizontal direction are consistent, which may correspond to a horizontal edge. r_AC measures the weight synergy in the vertical direction (A and C, B and D), and so on. The local structure characteristics of the image are inferred according to the correlation.
[0028] Calculate the horizontal direction weight w1, the vertical direction weight w2, and the global average weight w3. The formula is as follows: w1 = abs(r_AB + r_CD); w2 = abs(r_AC + r_BD); w3 = abs(r_AD + r_BC); Among them, pearson is the correlation call function, and abs is the absolute value call function; the absolute value function is further used because negative correlation is avoided from offsetting the positive correlation, ensuring that the weight strength is only determined by the magnitude of the correlation.
[0029] Step Five: Fuse the weights in multiple directions to output the interpolation result of the target position. The calculation formula is as follows: ; output is the interpolation result. The horizontal component is (A + D) / 2, the vertical component is (B + C) / 2, and the average component is (A + B + C + D) / 4. The three directions are fused according to the weights, and finally the pixel value of the target position can be obtained. By running the entire method in a loop, the pixel value of each target position can be obtained, and the content of the finally obtained output image is clearer.
[0030] Although in Step Two, it can be known which points are the target positions according to Figure 3 in computer language, it is necessary to use the computer to sequentially take these points to be interpolated as the target positions for subsequent calculations. Then the method for obtaining the target positions to be interpolated in the output image in Step Two is as follows: If the position of the pixel point in the input image is (i, j), then its corresponding position on the output image is (ni, nj), where n is the magnification factor; Select the points in the output image with the position range from (ni - n, nj - n) to (ni, nj) as the target positions. This range includes not only the horizontal range and the vertical range, but also the entire matrix points belonging to the range between (ni - n, nj - n) and (ni, nj).
[0031] When each target position is obtained, there will be corresponding neighborhood pixel points. The method for calculating the four neighborhood pixel points in the diagonal direction of the target position is as follows: If the position of the pixel point in the input image is (i, j), then the adjacent positions of this pixel point are (i - 1, j - 1), (i - 1, j + 1), (i + 1, j - 1), and (i + 1, j + 1); If the position of the target position mapped to the input image is between (i - 1, j - 1) and (i, j), then the neighborhood pixel points of the target position in the output image are (ni - n, nj - n), (ni - n, nj + n), (ni + n, nj - n), and (ni + n, nj + n). It can be seen from Figure 4 the distribution of the target position and the neighborhood pixel points, and this will not be repeated here.
[0032] Although the application of the Pearson correlation coefficient is disclosed in Step Four, the formula for calculating the correlation is as follows. The correlation call function in Step Four is as follows: pearson(x, y)= ; x and y are the two initial weights for which the correlation is to be calculated respectively. For example, if r_AB = pearson(wA, wB), then x is wA and y is wB. And the λ parameter is introduced in the function to force the weight not to be equal to 1 in the low-gradient region. The formula after introduction is as follows: pearson(x, y)= ; Here, the λ parameter is used to dynamically adjust the weight distribution. In the low-gradient region (such as a flat background), the initial weights may be affected by random noise, resulting in abnormal correlation coefficients. To prevent the denominator from being too small (such as the weight variance approaching 0) and causing unstable calculations; the λ parameter is introduced to force the weight distribution to be balanced in the smooth region, avoiding overdominance in a certain direction, thereby achieving the effect of suppressing noise amplification.
[0033] This method also includes normalizing the horizontal direction weight w1, vertical direction weight w2, and global average weight w3 calculated in step four through the softmax function. The calculation formula of the softmax function is: ; where T is the temperature parameter, is the i-th weight, is all the weights traversed (j = 1, 2, 3). The normalization method is used to convert w1, w2, and w3 into a probability distribution, and its purposes are as follows: enhancing numerical stability and preventing weight overflow; highlighting the dominant direction (such as a higher horizontal weight in the edge region). The parameter T controls the smoothness of the weight distribution. The larger T is, the more uniform the weight distribution is, and the smaller T is, the more prominent the dominant direction is. Assume the original weights are [w1, w2, w3] = [2, 1, 0] and T = 1. Therefore, it can be calculated . Therefore, the interpolated result calculation in step five is performed on the normalized weight values of each item, ensuring that the interpolation is more reasonable and reducing error generation.
[0034] The present invention also discloses a terminal, including a processor and a storage medium; the storage medium is used to store instructions; the processor is used to operate according to the instructions to execute the steps according to the above method.
[0035] In summary, the present invention provides an initial weight by calculating the ratio of the gray value of the neighborhood pixel points to their Euclidean distance, and then calculates the weights in the horizontal direction, vertical direction, and global average of the three directions according to the Pearson correlation coefficient. The final interpolation result is calculated by using the multi-weight fusion method, so that when the output image is enlarged, the image details are better retained, and the image imaging quality is improved. As Figure 5 shown, dense pixel points are selected in the input image, such as Figure 6As shown, when the local part of the output image is enlarged, it can be seen that Figure 5 the imaging of the boxed part in Figure 5 is still clear, and the imaging quality of the output image interpolated by this method is relatively high.
[0036] It should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
Claims
1. An adaptive weighted image interpolation method based on distance regularization, characterized in that: The method includes: Step 1: obtaining an input image, calculating the size of an output image according to a preset magnification factor, and mapping original pixels of the input image to corresponding positions of the output image according to the magnification factor; Step 2: Obtain the target position to be interpolated in the output image, calculate four neighboring pixel points in the diagonal direction of the target position, and obtain the grayscale values A, B, C, and D of the neighboring pixel points; Step 3: Calculate the Euclidean distances LA, LB, LC, and LD from the target position to the four neighboring pixel points, and calculate the initial weights wA, wB, wC, and wD in combination with the grayscale values. The values of the initial weights wA, wB, wC, and wD are the grayscale values A, B, C, and D divided by the Euclidean distances LA, LB, LC, and LD, respectively. Step 4: Based on the initial weights, the regularized correlation between the initial weights is calculated using the Pearson correlation coefficient. The formula is as follows: r_AB = pearson(wA,wB); r_AC = pearson(wA,wC); r_AD = pearson(wA,wD); r_BC = pearson(wB,wC); r_BD=pearson(wB,wD); r_CD = pearson(wC,wD); Calculate the horizontal weight w1, vertical weight w2 and global average weight w3 using the following formula: w1=abs(r_AB+r_CD); w2=abs(r_AC+r_BD); w3=abs(r_AD+r_BC); Among them, pearson is the correlation calling function, and abs is the absolute value calling function; Step 5: Multi-directional weight fusion outputs the interpolation result of the target position. The calculation formula is as follows: ; output is the interpolation result.
2. The adaptive weighted image interpolation method based on distance regularization according to claim 1, characterized in that: The method for obtaining the target position to be interpolated in the output image in step 2 is: If the position of a pixel in the input image is (i, j), then the corresponding position mapped to the output image is (ni, nj), where n is the magnification factor; Select points in the output image whose positions range from (ni-n, nj-n) to (ni, nj) as target positions.
3. The adaptive weighted image interpolation method based on distance regularization according to claim 1 or 2, characterized in that: The method for calculating the four neighboring pixel points in the diagonal direction of the target position is: If the position of a pixel in the input image is (i, j), then the adjacent positions of the pixel are (i-1, j-1), (i-1, j+1), (i+1, j-1), (i+1, j+1); If the target position is mapped to the position in the input image between (i-1, j-1) and (i, j), the neighborhood pixels of the target position in the output image are (ni-n, nj-n), (ni-n, nj+n), (ni+n, nj-n), and (ni+n, nj+n).
4. The adaptive weighted image interpolation method based on distance regularization according to claim 1, characterized in that: The formula for calculating the Euclidean distances LA, LB, LC, and LD from the target position to the four neighboring pixel points is: , where L is LA, LB, LC, LD; Among them, X is the difference between the horizontal coordinates of the target position and the neighboring pixel points, and Y is the difference between the vertical coordinates of the target position and the neighboring pixel points.
5. The adaptive weighted image interpolation method based on distance regularization according to claim 1, characterized in that: The correlation calling function in step 4 is as follows: pearson(x,y)= ; The λ parameter is introduced into the function to force the weight not to be equal to 1 in the low gradient area. The formula after introduction is as follows: pearson(x,y)= 。 6. The adaptive weighted image interpolation method based on distance regularization according to claim 1, characterized in that: The method further includes normalizing the horizontal direction weight w1, the vertical direction weight w2, and the global average weight w3 calculated in step 4 by a softmax function, and the calculation formula of the softmax function is: ; Where T is the temperature parameter, is the i-th weight, are all the weights traversed (j=1, 2, 3).
7. A terminal comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is configured to operate according to the instructions to execute the steps of the method according to any one of claims 1-6.
Citation Information
Patent Citations
Image amplification method based on spline function interpolation algorithm
CN101216935A
Image zooming method based on Newton second-order interpolation
CN110349090A
Automatic image segmentation method based on superpixels and improved fuzzy C-means clustering
CN115131566A
Adaptive weighting constraint subspace block diagonal representation image clustering method and system
CN116681916A
Point cloud compression method and apparatus, electronic device, and storage medium
WO2023245982A1
Cited By
Image processing method and device, medium and product
CN121509827A