Adaptive Weighted Image Interpolation Method Based on Distance Regularization

Through the adaptive weighted image interpolation method based on distance regularization, the weight is calculated using the grayscale value of neighboring pixel points and Euclidean distance, and the multi-directional weight fusion is combined with the Pearson correlation coefficient, the problems of details loss and insufficient adaptability in high-magnification amplification scenarios are solved, and the image imaging quality is improved.

CN120182084BActive Publication Date: 2025-08-05XIAN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510639219.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-19
Publication Date
2025-08-05
Estimated Expiration
2045-05-19

AI Technical Summary

Technical Problem

Traditional image interpolation methods have lost details and blurred edges in high-magnification amplification scenarios, insufficient adaptability, and difficulty in dynamic adjustment of weight allocation, resulting in poor adaptability of complex structures.

Method used

Adaptive weighted image interpolation method based on distance regularization is adopted, and multi-direction weight fusion interpolation is performed by calculating the grayscale value of neighboring pixel points and calculating the weights with Pearson correlation coefficient.

Benefits of technology

It improves image imaging quality, retains image details, suppresses noise interference, and is suitable for scenes such as printing and medical images that require strict fidelity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120182084B_ABST
    Figure CN120182084B_ABST
Patent Text Reader

Abstract

The present invention relates to an adaptive weighted image interpolation method based on distance regularization. The method comprises the following steps: obtaining an input image, calculating the size of an output image according to a preset magnification factor, and mapping the original pixels of the input image to corresponding positions in the output image according to the magnification factor; step two, obtaining a target position to be interpolated in the output image, and calculating four neighboring pixels in the diagonal direction of the target position; step three, calculating the Euclidean distance from the target position to the four neighboring pixels, and calculating initial weights in combination with grayscale values; step four, calculating the regularized correlation between the initial weights using the Pearson correlation coefficient based on the initial weights, calculating the horizontal weight w1, the vertical weight w2, and the global average weight w3; and step five, fusing the multi-directional weights to output the interpolation result of the target position. The image interpolation algorithm calculates interpolation by fusing the multi-directional weights, which can better preserve image details, thereby improving image quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular 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 methods for image magnification. Its purpose is to use algorithms to fill in the grayscale values of newly added pixels after magnification to preserve the details and clarity of the original image as much as possible. Traditional interpolation methods (such as nearest neighbor interpolation, bilinear interpolation, and bicubic interpolation) are simple and efficient, but they have significant drawbacks in high-magnification scenarios:

[0003] 1. Loss of detail and blurred edges. Traditional methods are often based on fixed kernel functions or local uniformity assumptions, and fail to fully consider the local structural features of the image (such as edges and textures). For example, bilinear interpolation performs well in smooth areas, but is prone to blurring in high-contrast edge regions, resulting in reduced image sharpness. 2. Insufficient adaptability: Existing methods typically use a single interpolation direction (such as horizontal or vertical), making it difficult to dynamically adjust weight distribution based on image content. This results in poor adaptability to complex structures (such as intersecting edges and irregular textures).

[0004] In recent years, some improved algorithms have attempted to optimize interpolation weights by introducing gradient information or local statistical features. However, the high computational complexity and rigid weight distribution still cannot meet actual production needs. Summary of the Invention

[0005] In response to the above technical problems, the present invention proposes an adaptive weighted image interpolation method based on distance regularization. This method combines grayscale and distance to calculate weights, which can better preserve image details and thus improve image quality.

[0006] In order to achieve the above technical objectives, the present invention adopts the following technical solutions:

[0007] The present invention specifically relates to an adaptive weighted image interpolation method based on distance regularization, which comprises:

[0008] 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;

[0009] Step 2: Obtain the target position to be interpolated in the output image, calculate four neighboring pixels in the diagonal direction of the target position, and obtain the grayscale values A, B, C, and D of the neighboring pixels;

[0010] Step 3: Calculate the Euclidean distances LA, LB, LC, and LD from the target position to the four neighboring pixels, and calculate the initial weights wA, wB, wC, and wD based on 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.

[0011] 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:

[0012] r_AB=pearson(wA,wB);

[0013] r_AC=pearson(wA,wC);

[0014] r_AD=pearson(wA,wD);

[0015] r_BC=pearson(wB,wC);

[0016] r_BD=pearson(wB,wD);

[0017] r_CD=pearson(wC,wD);

[0018] Calculate the horizontal weight w1, vertical weight w2 and global average weight w3 using the following formula:

[0019] w1=abs(r_AB+r_CD);

[0020] w2=abs(r_AC+r_BD);

[0021] w3=abs(r_AD+r_BC);

[0022] Among them, pearson is the correlation calling function, abs is the absolute value calling function;

[0023] Step 5: Multi-directional weight fusion outputs the interpolation result of the target position. The calculation formula is as follows:

[0024] ;

[0025] output is the interpolation result.

[0026] Preferably, the method for obtaining the target position to be interpolated in the output image in step 2 is:

[0027] If the position of the pixel point 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;

[0028] Select points with positions in the range (ni-n, nj-n) to (ni, nj) in the output image as target positions.

[0029] Preferably, the method for calculating the four neighboring pixel points in the diagonal direction of the target position is:

[0030] 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), and (i+1, j+1).

[0031] If the target position is mapped to the position in the input image between (i-1, j-1) and (i, j), then 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).

[0032] Preferably, the formula for calculating the Euclidean distances LA, LB, LC, and LD from the target position to the four neighboring pixel points is:

[0033] ;

[0034] 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.

[0035] Preferably, the correlation calling function in step 4 is as follows:

[0036] pearson(x,y)= ;

[0037] The lambda parameter is introduced into the function to force the weight to be different from 1 in the low gradient area. The formula after introduction is as follows:

[0038] pearson(x,y)= .

[0039] Preferably, the method further comprises normalizing the horizontal weight w1, vertical weight w2, and global average weight w3 calculated in step 4 by a softmax function, wherein the calculation formula of the softmax function is:

[0040] ;

[0041] Where T is the temperature parameter, is the i-th weight, are all the weights traversed (j=1, 2, 3).

[0042] On the other hand, the present invention further discloses a terminal, comprising 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.

[0043] The present invention first calculates the initial weight using the ratio of the grayscale value of the neighborhood pixel points to their Euclidean distance, then calculates the weights in the horizontal, vertical and global average directions based on the Pearson correlation coefficient, and uses a multi-weight fusion method to calculate the final interpolation result, so that the output image can better retain image details when magnified, thereby improving the image imaging quality. The present invention also introduces the λ parameter in low-gradient areas to avoid noise amplification caused by excessive weight in a single direction. While retaining edge sharpness, it dynamically suppresses noise interference, providing an efficient solution for scenarios with strict fidelity requirements such as printing and medical imaging. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings:

[0045] Figure 1 The figure shows a flow chart of the adaptive weighted image interpolation method of the present invention.

[0046] Figure 2 A schematic diagram showing mapping of original pixels of an input image to an output image according to the present invention is shown.

[0047] Figure 3 A schematic diagram showing the distribution of some points to be interpolated according to the present invention is shown.

[0048] Figure 4 A schematic diagram showing the positional relationship between the target position and the neighboring pixel points of the present invention is shown.

[0049] Figure 5 A schematic diagram of an input image of the present invention is shown.

[0050] Figure 6 A partial schematic diagram of the output image of the present invention is shown. DETAILED DESCRIPTION

[0051] In order to make the purpose, 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 in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.

[0052] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but rather merely represents selected embodiments of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort are intended to fall within the scope of protection of the present invention.

[0053] like Figure 1 As shown, the present invention provides an adaptive weighted image interpolation method based on distance regularization, which specifically includes:

[0054] 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. This step is to amplify the output image according to the input image. After amplification, the size of the output image is a magnification factor of the size of the input image. In order to ensure that the content of the output image is consistent with that of the input image, the positions of the original pixels in the input image also need to be mapped to the output image. The mapping rule is to map the original pixel positions multiplied by the magnification factor to the output image.

[0055] Take the magnification of five times as an example, Figure 2 As shown in the figure, there is an original pixel in the input image with coordinates (i, j). The left picture is the input image. Then, after five times magnification, the coordinates of the original pixel mapped to the output image are (5i, 5j). The right picture in the image is the output image.

[0056] Since the size of the output image is larger than the input image, even if all the original pixels are mapped, the entire output image cannot be completely filled. There must be blank pixels between adjacent pixels, such as Figure 3 As shown in the figure, the shadow points in the image are the points mapped from the original pixels, and their coordinates are (0, 5j), (5i, 0), and (5i, 5j). There are also several hollow points between these three points. In order to ensure that the enlarged image is still as clear as the original image, it is necessary to insert pixel values into these hollow points to ensure the imaging quality of the enlarged image. The specific insertion method is described in detail in the subsequent steps.

[0057] Step 2: Get the target position to be interpolated in the output image, calculate the four neighboring pixels in the diagonal direction of the target position, and get the grayscale values A, B, C, and D of the neighboring pixels; as mentioned in step 1, Figure 3 The hollow point is the point to be interpolated. Select a hollow point as the target position. After determining the target position, you can know the four neighboring pixel points in the diagonal direction. Figure 4Taking a complete output image as an example, the target position is point X, then its four neighboring pixel points are (0, 0), (0, 5j), (5i, 0), (5i, 5j). After finding these four points, the grayscale values A, B, C, and D corresponding to each point can be obtained. The grayscale values are obtained for the calculation of the initial weights in the subsequent steps. See the steps below for details.

[0058] Step 3: Calculate the Euclidean distances LA, LB, LC, and LD from the target location to the four neighboring pixels, and calculate the initial weights wA, wB, wC, and wD based on the grayscale values. 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. The calculation formula is as follows:

[0059] , w(x) is the initial weight (x=A, B, C, D);

[0060] This step uses the ratio of grayscale value to Euclidean distance to calculate the initial weight. Euclidean distance L refers to the true distance between two points in n-dimensional space. The calculation formula of Euclidean distance is:

[0061] , where L is LA, LB, LC, LD;

[0062] 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. Using the Euclidean distance calculation formula, the diagonal distance between the target position and each neighboring pixel point can be calculated. Then, according to the calculation formula of the initial weight, the ; ; ; , the initial weights wA, wB, wC, and wD can be calculated. However, simply using the initial weights for interpolation cannot meet the interpolation requirements of complex images, so subsequent steps are required to further improve this weight.

[0063] 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:

[0064] r_AB=pearson(wA,wB);

[0065] r_AC=pearson(wA,wC);

[0066] r_AD=pearson(wA,wD);

[0067] r_BC=pearson(wB,wC);

[0068] r_BD=pearson(wB,wD);

[0069] r_CD=pearson(wC,wD);

[0070] The Pearson correlation coefficient measures the degree of linear correlation between two variables, ranging from -1 to 1. Positive values indicate positive correlation, negative values indicate negative correlation, and 0 indicates no correlation. In step 3, the initial weights reflect the potential contribution of neighboring pixels to the interpolation. By calculating the Pearson correlation coefficient between these weights, we can analyze whether the weight changes in different directions (horizontal, vertical, and global average) are consistent, thereby inferring the local structural features of the image. The four initial weights are then combined pairwise to calculate their Pearson correlation coefficients.

[0071] r_AB measures the coordination of weights in the horizontal direction (A and D, B and C). A high r_AB value indicates that the weights of pixels in the horizontal direction change consistently, possibly corresponding to a horizontal edge. r_AC measures the coordination of weights in the vertical direction (A and C, B and D), and so on. Local structural features of the image can be inferred based on correlation.

[0072] Calculate the horizontal weight w1, vertical weight w2 and global average weight w3 using the following formula:

[0073] w1=abs(r_AB+r_CD);

[0074] w2=abs(r_AC+r_BD);

[0075] w3=abs(r_AD+r_BC);

[0076] Among them, pearson is the correlation call function, and abs is the absolute value call function. The absolute value function is further used to avoid negative correlation offsetting positive correlation and ensure that the weight strength is determined only by the size of the correlation.

[0077] Step 5: Multi-directional weight fusion outputs the interpolation result of the target position. The calculation formula is as follows:

[0078] ;

[0079] The output is the interpolation result, with the horizontal component being (A+D) / 2, the vertical component being (B+C) / 2, and the average component being (A+B+C+D) / 4. The three directions are fused according to the weights to ultimately obtain the pixel value at the target position. The entire method is looped to obtain the pixel value at each target position, and the final output image has clearer content.

[0080] In step 2, although according to Figure 3We can know which points are the target positions, but in computer language, we need to use the computer to sequentially use these points to be interpolated as target positions for subsequent calculations. So the method for obtaining the target positions to be interpolated in the output image in step 2 is:

[0081] If the position of the pixel point 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;

[0082] The points in the output image with a position range of (ni-n, nj-n) to (ni, nj) are selected as the target positions. This range includes not only the horizontal range and the vertical range, but also the entire matrix points between (ni-n, nj-n) to (ni, nj).

[0083] When each target position is obtained, there will be corresponding neighboring pixel points. The method for calculating the four neighboring pixel points in the diagonal direction of the target position is:

[0084] 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), and (i+1, j+1).

[0085] If the target position is mapped to the position in the input image between (i-1, j-1) and (i, j), then the neighboring pixels 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), which is Figure 4 The distribution of the target position and the neighboring pixels can be seen in , which will not be repeated.

[0086] Although the application of the Pearson correlation coefficient is disclosed in step 4, the formula for calculating the correlation is as follows. The correlation calling function in step 4 is as follows:

[0087] pearson(x,y)= ; x and y are the two initial weights for which we want to calculate the correlation. For example, r_AB=pearson(wA,wB), then x is wA and y is wB. We also introduce the λ parameter into the function to force the weight to be different from 1 in low gradient areas. The formula after introduction is as follows:

[0088] pearson(x,y)= ;

[0089] Here, the λ parameter is used to dynamically adjust the weight distribution. In low-gradient areas (such as flat backgrounds), the initial weights may be affected by random noise, resulting in abnormal correlation coefficients. In order to prevent the denominator from being too small (such as the weight variance approaching 0) and causing calculation instability, the λ parameter is introduced to force a balanced weight distribution in smooth areas to avoid excessive dominance in one direction, thereby suppressing noise amplification.

[0090] The method further includes normalizing the horizontal weight w1, vertical weight w2, and global average weight w3 calculated in step 4 by a softmax function, wherein the calculation formula of the softmax function is:

[0091] ;

[0092] Where T is the temperature parameter, is the i-th weight, are all the weights traversed (j=1, 2, 3). Normalization is used to convert w1, w2, and w3 into probability distributions. The purpose is as follows: to enhance numerical stability and prevent weight overflow; to highlight the dominant direction (for example, the horizontal weight in the edge area is higher). The parameter T controls the smoothness of the weight distribution. The larger T is, the more uniform the weight distribution is; the smaller T is, the more prominent the dominant direction is. Assuming the original weights are [w1, w2, w3] = [2, 1, 0], T = 1, we can calculate Therefore, the interpolation results of step 5 are calculated based on the normalized weight values to ensure that the interpolation is more reasonable and reduce errors.

[0093] The present invention also discloses a terminal, comprising 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.

[0094] In summary, the present invention provides a method for calculating the initial weight by the ratio of the grayscale value of the neighborhood pixel point and its Euclidean distance, and then calculates the weights of the horizontal direction, vertical direction and global average according to the Pearson correlation coefficient, and calculates the final interpolation result by using a multi-weight fusion method, so that the output image can better retain the image details when it is enlarged, thereby improving the image quality. Figure 5 As shown in , dense pixels are selected in the input image, such as Figure 6 As shown, by locally enlarging the output image, it can be seen Figure 5 The image of the selected part in the middle frame is still clear, and the output image interpolated using this method has high imaging quality.

[0095] It should be noted that, in this document, relational terms such as "first" and "second" are used only 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 terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

Claims

1. 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 pixels in the diagonal direction of the target position, and obtain the grayscale values A, B, C, and D of the neighboring pixels; Step 3: Calculate the Euclidean distances LA, LB, LC, and LD from the target position to the four neighboring pixels, and calculate the initial weights wA, wB, wC, and wD based on 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, 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 the pixel point 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 with positions in the range (ni-n, nj-n) to (ni, nj) in the output image 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), and (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), then 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 regularization calling function in step 4 is as follows: ; The lambda parameter is introduced into the function to force the weight to be different from 1 in the low gradient area. The formula after introduction is as follows: 。 6. The adaptive weighted image interpolation method based on distance regularization according to claim 1, characterized in that: The method further includes normalizing the weights w1, w2, and w3 calculated in step 4 by using a Softmax function, where the calculation formula of the Softmax function is: ; Where T is the temperature parameter, is the i-th weight, For all traversed weights 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 to 6.

Citation Information

Patent Citations

  • Image amplification method based on spline function interpolation algorithm

    CN101216935A

  • Automatic image segmentation method based on superpixels and improved fuzzy C-means clustering

    CN115131566A