An image scaling method based on edge perception and content adaptive interpolation

By employing an image scaling method that combines edge awareness and content-adaptive interpolation, the contradiction between edge and detail preservation in existing technologies is resolved, achieving efficient and real-time image scaling effects and improving edge clarity and detail representation.

CN122048637BActive Publication Date: 2026-06-26SHENG MICROELECTRONICS (SUZHOU) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENG MICROELECTRONICS (SUZHOU) CO LTD
Filing Date
2026-04-15
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing image scaling algorithms present a trade-off in preserving edges and details. Simple and efficient linear interpolation methods cannot preserve edges and details, while complex content-aware methods may introduce geometric distortion and have a large computational load, failing to meet real-time requirements.

Method used

An image scaling method based on edge awareness and content adaptive interpolation is adopted. By calculating the deviation between local background and pixels, the weights are adaptively adjusted. Combined with a hardware-friendly iterative comparison algorithm, the computational complexity is reduced and the edge sharpness is improved.

Benefits of technology

It achieves significant enhancement of edge sharpness and detail in scaled images while maintaining high efficiency, making it suitable for real-time image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122048637B_ABST
    Figure CN122048637B_ABST
Patent Text Reader

Abstract

The application discloses an image scaling method based on edge perception and content adaptive interpolation. Firstly, edge detection is performed on an input original image to obtain edge strength representing the richness of image details. Secondly, according to the edge strength, the distribution of the two values with the highest weights in an interpolation function is adaptively adjusted. For a position with higher edge strength, a larger weight distribution is adopted to better preserve edge and detail features. For a position with lower edge strength, a smaller weight distribution is adopted. Finally, pixel resampling of the whole image is completed by using the interpolation kernel after adaptive adjustment, and an output image with a target resolution is generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image processing and relates to an image scaling method based on edge perception and content adaptive interpolation. Background Technology

[0002] Image scaling is a fundamental and crucial operation in digital image processing, widely used in display adaptation, image editing, computer vision, remote sensing imagery, and mobile internet. Its core objective is to alter the image resolution while preserving as much of the original image's essential visual information as possible, such as edge sharpness, texture detail, and overall visual fidelity.

[0003] Traditional image scaling algorithms are mainly divided into two categories: linear interpolation algorithms, such as nearest neighbor interpolation, bilinear interpolation, and bicubic interpolation. These algorithms are computationally simple and efficient, but they generally have a significant drawback: they treat all pixels equally, using a uniform convolution kernel for interpolation calculations. For smooth regions, these methods perform reasonably well, but when processing regions containing rich edges and textures, they produce obvious blurring, jagged edges, or loss of detail, resulting in a deterioration in the visual quality of the scaled image.

[0004] Another type is content-aware image scaling algorithms, such as seam carving. These methods change the image size by finding and removing or adding "unimportant" pixel lines (seams) in the image, thus better preserving the main content objects. However, seam carving algorithms are prone to severe content distortion and structural distortion when processing images with complex structured textures or dense foreground objects, and their computational complexity is relatively high, making them unsuitable for applications with high real-time requirements.

[0005] Therefore, there is a clear contradiction in existing technologies: simple and efficient linear interpolation methods cannot preserve edges and details, while content-preserving methods such as seam carving may introduce geometric distortion and are computationally intensive. The market urgently needs a new image scaling technology that can maintain the efficiency of traditional interpolation methods while significantly enhancing the detail representation of scaled images, especially edge sharpness.

[0006] To address this, the present invention proposes an image scaling method based on edge perception and content adaptive interpolation. Summary of the Invention

[0007] This invention provides an image scaling method based on edge awareness and content adaptive interpolation, comprising the following steps:

[0008] Step 1: Calculate the scaling steps in the horizontal and vertical directions based on the resolution of the source and target images. Determine the processing order of horizontal before vertical or vertical before horizontal based on the image scaling strategy, and allocate an intermediate buffer for storing the single-dimensional interpolation results.

[0009] Step 2: Perform horizontal and vertical interpolation on the image sequentially. For each target pixel position in the current processing direction, locate the four adjacent consecutive pixels by scaling step and calculate the initial interpolation weights. Estimate the local background based on the four-pixel mean, calculate the absolute deviation between the inner two pixels and the background, perceive the edge through the deviation, and use a hardware-friendly iterative comparison algorithm to quantify the deviation ratio and direction indicator. Accordingly, adaptively transfer some weights from the inner pixels on one side to the inner pixels on the other side. Use the adjusted weights to perform a weighted summation on the four pixels to obtain the interpolation result in the current direction and store it in the corresponding storage location.

[0010] Step 3: Repeat Step 2 until all target rows and columns are traversed to complete the pixel resampling calculation for the entire image. Write the final calculated pixel values ​​into the corresponding coordinates of the target image to generate the output image at the target resolution.

[0011] Furthermore, in step one, the scaling ratio and step size need to be determined:

[0012] The input source image S1-1 has a height of H_src and a width of W_src, and the target size has a height of H_dst and a width of W_dst;

[0013] S1-2 Calculates the scaling step in the horizontal direction: StepX = W_src / W_dst;

[0014] S1-3 Calculates the scaling step in the vertical direction: StepY = H_src / H_dst;

[0015] All the width, height, and step size measurements above are in pixels.

[0016] Furthermore, in step one, an intermediate buffer needs to be allocated to store the intermediate results after horizontal or vertical scaling:

[0017] S1-4 creates a temporary storage area as an intermediate buffer with the following dimensions: height of at least 4 pixels and width of W_dst or W_src. The order in which vertical and horizontal processing is performed affects the buffer width. To reduce the buffer size, when the image is enlarged, vertical processing is performed first, followed by horizontal processing, and the buffer width is W_src. When the image is reduced, horizontal processing is performed first, followed by vertical processing, and the buffer width is W_dst.

[0018] Furthermore, step two includes:

[0019] S2-1 Horizontal scaling: Perform the following operation on each row of the source image:

[0020] For each row of the source image, Row_src(i), where i ranges from 0 to H_src-1, scale it to the target width W_dst and store the result in the i-th row of the intermediate buffer;

[0021] For each pixel position j on the target width, j ranging from 0 to W_dst-1, perform the following operations:

[0022] 1. Map back to the current row and locate adjacent pixels:

[0023] Step 1: Calculate the corresponding floating-point coordinates in the current line: x = j StepX;

[0024] Step 2: Round the coordinate x: x0 = floor(x);

[0025] The third step is to obtain the four adjacent pixels on the horizontal plane of the current row: P_left_left(x0-1, i), P_left(x0, i), P_right(x0+1, i), P_right_right(x0+2, i).

[0026] 2. Calculate the initial weights in the horizontal direction:

[0027] Step 1: Calculate the offset: dx = x - x0;

[0028] Step 2: Based on dx and the preset interpolation kernel function: Calculate the initial weights W_ll, W_l, W_r, and W_rr for the four pixels, and calculate W_ll = W(1+dx), W_l = W(dx), W_r = W(1-dx), and W_rr = W(2-dx) in sequence.

[0029] 3. Horizontal edge perception and content-adaptive weight adjustment:

[0030] Step 1: Calculate the background estimate: background_estimate = (P_left_left + P_left + P_right + P_right_right) / 4;

[0031] Step 2: Adaptively obtain the weight adjustment values ​​based on the background estimate (background_estimate) and the values ​​of P_left and P_right:

[0032] P2 = |P_left – background_estimate|;

[0033] P3 = |P_right – background_estimate|;

[0034] The absolute values ​​of each RGB channel need to be calculated separately and then added together.

[0035] Then, an efficient, hardware-friendly algorithm is used to estimate the ratio between P2 and P3. First, the absolute difference between the two pixel values, diff = |P2 - P3|, is calculated, and a direction flag is recorded. It is true when P2 > P3, and false otherwise.

[0036] Subsequently, half of P3 is used as the initial reference value, i.e., the reference threshold compare = P3 >> 1;

[0037] In each iteration of the loop, the current difference (diff) is compared with a dynamically changing reference threshold (compare);

[0038] Based on the comparison result, determine whether the current bit position of the output result res is 0 or 1, where the iteration number is i, and i starts counting from 1:

[0039] If diff < compare, then the current position is 0, and the value of the reference threshold compare is lowered;

[0040] compare = compare - (P3 >> (i+1));

[0041] If diff is not less than compare, the current position is 1, and the value of the reference threshold compare is increased.

[0042] compare = compare + (P3 >> (i+1));

[0043] The step size used to adjust the reference threshold is halved after each iteration, making the comparison process increasingly accurate.

[0044] After all iterations, we finally obtain an integer value res between 0 and 7. The res value from 0 to 7 represents the ratio of |P2-P3| to P3 in the range of 8 intervals (0, 1 / 8), (1 / 8, 2 / 8)...(7 / 8, +∞). This res value, together with the direction flag, is used as the output.

[0045] This method can be completed using only comparison, shifting, and addition operations, avoiding floating-point operations or division operations required in traditional computing. This greatly reduces computational complexity and hardware implementation area, making it very suitable for real-time, high-performance edge-aware computing in the image processing pipeline.

[0046] If flag is 0 (false) at this point, then delta_h = W_l res >> 3;

[0047] If flag is 1 (true), then delta_h = -(W_l res >> 3);

[0048] Adjust the intermediate weights (e.g., increase the weights on the side with the larger gradient): W_l' = W_l - delta_h, W_r' = W_r + delta_h;

[0049] 4. Blend and save intermediate results:

[0050] Step 1: Calculate the horizontal scaling result at this location: Temp(i, j) = P_ll W_ll + P_l W_l'+ P_r W_r' + P_rr W_rr;

[0051] The second step is to store Temp(i, j) in the i-th row and j-th column of the intermediate buffer image.

[0052] Furthermore, step two includes:

[0053] S2-2 Vertical scaling: Scale column j of the intermediate buffer image, with height H_src, to the target height H_dst; for each pixel position i at the target height, i ranging from 0 to H_dst-1, perform the following operations:

[0054] 1. Map back to the current column and locate adjacent pixels:

[0055] Step 1: Calculate the corresponding floating-point coordinates in the current column: y = i StepY;

[0056] Step 2: Round the coordinate y: y0 = floor(y);

[0057] Step 3: Obtain the four adjacent vertical pixels in the current column:

[0058] P_top_top(j, y0-1);

[0059] P_top(j, y0);

[0060] P_bottom(j, y0+1);

[0061] P_bottom_bottom(j, y0+2);

[0062] 2. Calculate the initial weights in the vertical direction:

[0063] Step 1: Calculate the offset: dy = y - y0;

[0064] The second step is to calculate the initial weights W_tt, W_t, W_b, and W_bb of the four pixels based on dy and the preset interpolation kernel function.

[0065] 3. Vertical edge perception and weight adjustment:

[0066] Step 1: Calculate the background estimate: background_estimate = (P_top_top + P_top + P_bottom + P_bottom_bottom) / 4;

[0067] The second step is to adaptively obtain the weight adjustment value Delta_v based on the background_estimate, P_top, and P_bottom values. The specific calculation logic is the same as that for the horizontal direction.

[0068] Step 3: Adjust the intermediate weights: W_t' = W_t - Delta_v, W_b' = W_b + Delta_v;

[0069] 4. Blend to obtain the final pixels:

[0070] Step 1: Calculate the final pixel value at this location: Dst(i, j) = P_tt W_tt + P_t W_t' +P_b W_b' + P_bb W_bb;

[0071] The second step is to write this value into the final output image Dst(i, j).

[0072] After scaling all rows and columns, the final target image Dst is output. Attached Figure Description

[0073] Figure 1 The diagram shown is a flowchart of the present invention;

[0074] Figure 2 The diagram shown is a schematic of the intermediate buffer zone of the present invention;

[0075] Figure 3 The image shown is a schematic diagram of a single line of source data according to the present invention;

[0076] Figure 4 The diagram shown is a flowchart of the horizontal adaptive weight adjustment process of the present invention.

[0077] Figure 5 The diagram shown is a flowchart of the vertical adaptive weight adjustment process of the present invention.

[0078] Figure 6 The image shown is a comparison of the output image quality of the present invention: A1 is the result of normal scaling, and A2 is the result of scaling using the present method; B1 shows that the lines are uneven in brightness when scaled normally, while B2 shows that the brightness is uniform and clear when scaled using the present method. Detailed Implementation

[0079] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0080] Please see Figure 1-6 This invention provides an image scaling method based on edge awareness and content adaptive interpolation, comprising the following steps:

[0081] Step 1: Calculate the scaling steps in the horizontal and vertical directions based on the resolution of the source and target images. Determine the processing order of horizontal before vertical or vertical before horizontal based on the image scaling strategy, and allocate an intermediate buffer for storing the single-dimensional interpolation results.

[0082] Step 2: Perform horizontal and vertical interpolation on the image sequentially. For each target pixel position in the current processing direction, locate the four adjacent consecutive pixels by scaling step and calculate the initial interpolation weights. Estimate the local background based on the four-pixel mean, calculate the absolute deviation between the inner two pixels and the background, perceive the edge through the deviation, and use a hardware-friendly iterative comparison algorithm to quantify the deviation ratio and direction indicator. Accordingly, adaptively transfer some weights from the inner pixels on one side to the inner pixels on the other side. Use the adjusted weights to perform a weighted summation on the four pixels to obtain the interpolation result in the current direction and store it in the corresponding storage location.

[0083] Step 3: Repeat Step 2 until all target rows and columns are traversed to complete the pixel resampling calculation for the entire image. Write the final calculated pixel values ​​into the corresponding coordinates of the target image to generate the output image at the target resolution.

[0084] In step one, the scaling ratio and step size need to be determined:

[0085] The input source image S1-1 has a height of H_src and a width of W_src, and the target size has a height of H_dst and a width of W_dst;

[0086] S1-2 Calculates the scaling step in the horizontal direction: StepX = W_src / W_dst;

[0087] S1-3 Calculates the scaling step in the vertical direction: StepY = H_src / H_dst;

[0088] All the width, height, and step size measurements above are in pixels.

[0089] In step one, an intermediate buffer needs to be allocated to store the intermediate results after horizontal or vertical scaling:

[0090] S1-4 creates a temporary storage area as an intermediate buffer with the following dimensions: height of at least 4 pixels and width of W_dst or W_src. The order in which vertical and horizontal processing is performed affects the buffer width. To reduce the buffer size, when the image is enlarged, vertical processing is performed first, followed by horizontal processing, and the buffer width is W_src. When the image is reduced, horizontal processing is performed first, followed by vertical processing, and the buffer width is W_dst.

[0091] Step two includes:

[0092] S2-1 Horizontal scaling: Perform the following operation on each row of the source image:

[0093] For each row of the source image, Row_src(i), where i ranges from 0 to H_src-1, scale it to the target width W_dst and store the result in the i-th row of the intermediate buffer;

[0094] For each pixel position j on the target width, j ranging from 0 to W_dst-1, perform the following operations:

[0095] 1. Map back to the current row and locate adjacent pixels:

[0096] Step 1: Calculate the corresponding floating-point coordinates in the current line: x = j StepX;

[0097] Step 2: Round the coordinate x: x0 = floor(x);

[0098] The third step is to obtain the four adjacent pixels on the horizontal plane of the current row: P_left_left(x0-1, i), P_left(x0, i), P_right(x0+1, i), P_right_right(x0+2, i).

[0099] 2. Calculate the initial weights in the horizontal direction:

[0100] Step 1: Calculate the offset: dx = x - x0;

[0101] Step 2: Based on dx and the preset interpolation kernel function: Calculate the initial weights W_ll, W_l, W_r, and W_rr for the four pixels, and calculate W_ll = W(1+dx), W_l = W(dx), W_r = W(1-dx), and W_rr = W(2-dx) in sequence.

[0102] 3. Horizontal edge perception and content-adaptive weight adjustment:

[0103] Step 1: Calculate the background estimate: background_estimate = (P_left_left + P_left + P_right + P_right_right) / 4;

[0104] Step 2: Adaptively obtain the weight adjustment values ​​based on the background estimate (background_estimate) and the values ​​of P_left and P_right:

[0105] P2 = |P_left – background_estimate|;

[0106] P3 = |P_right – background_estimate|;

[0107] The absolute values ​​of each RGB channel need to be calculated separately and then added together.

[0108] Then, an efficient, hardware-friendly algorithm is used to estimate the ratio between P2 and P3. First, the absolute difference between the two pixel values, diff = |P2 - P3|, is calculated, and a direction flag is recorded. It is true when P2 > P3, and false otherwise.

[0109] Subsequently, half of P3 is used as the initial reference value, i.e., the reference threshold compare = P3 >> 1;

[0110] The core of the algorithm is a successive approximation loop that executes a fixed number of times, for example, 3 times, to produce a quantized output res with a fixed number of bits (e.g., 3 bits). This output value represents the ratio between P2 and P3.

[0111] In each iteration of the loop, the current difference (diff) is compared with a dynamically changing reference threshold (compare);

[0112] Based on the comparison result, determine whether the current bit position of the output result res is 0 or 1, where the iteration number is i, and i starts counting from 1:

[0113] If diff < compare, then the current position is 0, and the value of the reference threshold compare is lowered;

[0114] compare = compare - (P3 >> (i+1));

[0115] If diff is not less than compare, the current position is 1, and the value of the reference threshold compare is increased.

[0116] compare = compare + (P3 >> (i+1));

[0117] The step size used to adjust the reference threshold is halved after each iteration, making the comparison process increasingly accurate.

[0118] After all iterations, we finally obtain an integer value res between 0 and 7. The res value from 0 to 7 represents the ratio of |P2-P3| to P3 in the range of 8 intervals (0, 1 / 8), (1 / 8, 2 / 8)...(7 / 8, +∞). This res value, together with the direction flag, is used as the output.

[0119] This method can be completed using only comparison, shifting, and addition operations, avoiding floating-point operations or division operations required in traditional computing. This greatly reduces computational complexity and hardware implementation area, making it very suitable for real-time, high-performance edge-aware computing in the image processing pipeline.

[0120] If flag is 0 (false) at this point, then delta_h = W_l res >> 3;

[0121] If flag is 1 (true), then delta_h = -(W_l res >> 3);

[0122] Adjust the intermediate weights (e.g., increase the weights on the side with the larger gradient): W_l' = W_l - delta_h, W_r' = W_r + delta_h;

[0123] 4. Blend and save intermediate results:

[0124] Step 1: Calculate the horizontal scaling result at this location: Temp(i, j) = P_ll W_ll + P_l W_l'+ P_r W_r' + P_rr W_rr;

[0125] The second step is to store Temp(i, j) in the i-th row and j-th column of the intermediate buffer image.

[0126] Step two includes:

[0127] S2-2 Vertical scaling: Scale column j of the intermediate buffer image, with height H_src, to the target height H_dst; for each pixel position i at the target height, i ranging from 0 to H_dst-1, perform the following operations:

[0128] 1. Map back to the current column and locate adjacent pixels:

[0129] Step 1: Calculate the corresponding floating-point coordinates in the current column: y = i StepY;

[0130] Step 2: Round the coordinate y: y0 = floor(y);

[0131] Step 3: Obtain the four adjacent vertical pixels in the current column:

[0132] P_top_top(j, y0-1);

[0133] P_top(j, y0);

[0134] P_bottom(j, y0+1);

[0135] P_bottom_bottom(j, y0+2);

[0136] 2. Calculate the initial weights in the vertical direction:

[0137] Step 1: Calculate the offset: dy = y - y0;

[0138] The second step is to calculate the initial weights W_tt, W_t, W_b, and W_bb of the four pixels based on dy and the preset interpolation kernel function.

[0139] 3. Vertical edge perception and weight adjustment:

[0140] Step 1: Calculate the background estimate: background_estimate = (P_top_top + P_top + P_bottom + P_bottom_bottom) / 4;

[0141] The second step is to adaptively obtain the weight adjustment value Delta_v based on the background_estimate, P_top, and P_bottom values. The specific calculation logic is the same as that for the horizontal direction.

[0142] Step 3: Adjust the intermediate weights: W_t' = W_t - Delta_v, W_b' = W_b + Delta_v;

[0143] 4. Blend to obtain the final pixels:

[0144] Step 1: Calculate the final pixel value at this location: Dst(i, j) = P_tt W_tt + P_t W_t' +P_b W_b' + P_bb W_bb;

[0145] The second step is to write this value into the final output image Dst(i, j).

[0146] After scaling all rows and columns, the final target image Dst is output.

[0147] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is limited by the appended claims and their equivalents.

Claims

1. An image scaling method based on edge perception and content adaptive interpolation, characterized in that, Includes the following steps: Step 1: Calculate the scaling steps in the horizontal and vertical directions based on the resolution of the source and target images. Determine the processing order of horizontal before vertical or vertical before horizontal based on the image scaling strategy, and allocate an intermediate buffer for storing the single-dimensional interpolation results. Step 2: Perform horizontal and vertical interpolation on the image sequentially. For each target pixel position in the current processing direction, locate the four adjacent consecutive pixels by scaling step and calculate the initial interpolation weights. Estimate the local background based on the four-pixel mean, calculate the absolute deviation between the inner two pixels and the background, perceive the edge through the deviation, and use a hardware-friendly iterative comparison algorithm to quantify the deviation ratio and direction indicator. Accordingly, adaptively transfer some weights from the inner pixels on one side to the inner pixels on the other side. Use the adjusted weights to perform a weighted summation on the four pixels to obtain the interpolation result in the current direction and store it in the corresponding storage location. Step 3: Repeat Step 2 until all target rows and columns are traversed to complete the pixel resampling calculation for the entire image. Write the final calculated pixel values ​​into the corresponding coordinates of the target image to generate the output image at the target resolution.

2. The image scaling method based on edge perception and content adaptive interpolation according to claim 1, characterized in that, In step one, the scaling ratio and step size need to be determined: The input source image S1-1 has a height of H_src and a width of W_src, and the target size has a height of H_dst and a width of W_dst; S1-2 Calculates the scaling step in the horizontal direction: StepX = W_src / W_dst; S1-3 Calculates the scaling step in the vertical direction: StepY = H_src / H_dst; All the width, height, and step size measurements above are in pixels.

3. The image scaling method based on edge perception and content adaptive interpolation according to claim 2, characterized in that: In step one, an intermediate buffer needs to be allocated to store the intermediate results after horizontal or vertical scaling: S1-4 creates a temporary storage area as an intermediate buffer with the following dimensions: height of at least 4 pixels and width of W_dst or W_src. The order in which vertical and horizontal processing is performed affects the buffer width. To reduce the buffer size, when the image is enlarged, vertical processing is performed first, followed by horizontal processing, and the buffer width is W_src. When the image is reduced, horizontal processing is performed first, followed by vertical processing, and the buffer width is W_dst.

4. The image scaling method based on edge perception and content adaptive interpolation according to claim 3, characterized in that, Step two includes: S2-1 Horizontal scaling: Perform the following operation on each row of the source image: For each row of the source image, Row_src(i), where i ranges from 0 to H_src-1, scale it to the target width W_dst and store the result in the i-th row of the intermediate buffer; For each pixel position j on the target width, j ranging from 0 to W_dst-1, perform the following operations: (1) Map back to the current row and locate adjacent pixels: Step 1: Calculate the corresponding floating-point coordinates in the current line: x = j StepX; Step 2: Round the coordinate x: x0 = floor(x); The third step is to obtain the four adjacent pixels on the horizontal axis of the current row: P_left_left(x0-1, i), P_left(x0,i), P_right(x0+1, i), P_right_right(x0+2, i); (2) Calculate the initial weights in the horizontal direction: Step 1: Calculate the offset: dx = x - x0; Step 2: Based on dx and the preset interpolation kernel function: Calculate the initial weights W_ll, W_l, W_r, and W_rr for the four pixels, and calculate W_ll = W(1+dx), W_l = W(dx), W_r = W(1-dx), and W_rr = W(2-dx) in sequence. (3) Horizontal edge perception and content adaptive weight adjustment: Step 1: Calculate the background estimate: background_estimate = (P_left_left + P_left + P_right + P_right_right) / 4; Step 2: Adaptively obtain the weight adjustment values ​​based on the background estimate (background_estimate) and the values ​​of P_left and P_right: P2 = |P_left – background_estimate|; P3 = |P_right – background_estimate|; The absolute values ​​of each RGB channel need to be calculated separately and then added together. Then, an efficient, hardware-friendly algorithm is used to estimate the ratio between P2 and P3. First, the absolute difference between the two pixel values, diff = |P2 - P3|, is calculated, and a direction flag is recorded. It is true when P2 > P3, and false otherwise. Subsequently, half of P3 is used as the initial reference value, i.e., the reference threshold compare = P3 >> 1; In each iteration of the loop, the current difference (diff) is compared with a dynamically changing reference threshold (compare); Based on the comparison result, determine whether the current bit position of the output result res is 0 or 1, where the iteration number is i, and i starts counting from 1: If diff < compare, then the current position is 0, and the value of the reference threshold compare is lowered; compare = compare - (P3 >> (i+1)); If diff is not less than compare, the current position is 1, and the value of the reference threshold compare is increased. compare = compare + (P3 >> (i+1)); The step size used to adjust the reference threshold is halved after each iteration, making the comparison process increasingly accurate. After all iterations, we finally obtain an integer value res between 0 and 7. The res value from 0 to 7 represents the ratio of |P2-P3| to P3 in the range of 8 intervals (0, 1 / 8), (1 / 8, 2 / 8)...(7 / 8, +∞). This res value is output together with the direction flag. If flag is 0 at this point, then delta_h = W_l res >> 3; If flag is 1, then delta_h = -(W_l res >> 3); Adjust the intermediate weights: W_l' = W_l - delta_h, W_r' = W_r + delta_h; (4) Mix and save intermediate results: Step 1: Calculate the horizontal scaling result at this location: Temp(i, j) = P_ll W_ll + P_l W_l' + P_r W_r' + P_rr W_rr; The second step is to store Temp(i, j) in the i-th row and j-th column of the intermediate buffer image.

5. The image scaling method based on edge perception and content adaptive interpolation according to claim 4, characterized in that, Step two includes: S2-2 Vertical scaling: Scale column j of the intermediate buffer image, with height H_src, to the target height H_dst; for each pixel position i at the target height, i ranging from 0 to H_dst-1, perform the following operations: (1) Map back to the current column and locate adjacent pixels: Step 1: Calculate the corresponding floating-point coordinates in the current column: y = i StepY; Step 2: Round the coordinate y: y0 = floor(y); Step 3: Obtain the four adjacent vertical pixels in the current column: P_top_top(j, y0-1); P_top(j, y0); P_bottom(j, y0+1); P_bottom_bottom(j, y0+2); (2) Calculate the initial weights in the vertical direction: Step 1: Calculate the offset: dy = y - y0; The second step is to calculate the initial weights W_tt, W_t, W_b, and W_bb of the four pixels based on dy and the preset interpolation kernel function. (3) Vertical edge perception and weight adjustment: Step 1: Calculate the background estimate: background_estimate = (P_top_top + P_top + P_bottom + P_bottom_bottom) / 4; The second step is to adaptively obtain the weight adjustment value Delta_v based on the background_estimate, P_top, and P_bottom values. The specific calculation logic is the same as that for the horizontal direction. Step 3: Adjust the intermediate weights: W_t' = W_t - Delta_v, W_b' = W_b + Delta_v; (4) Blending to obtain the final pixel: Step 1: Calculate the final pixel value at this location: Dst(i, j) = P_tt W_tt + P_t W_t' + P_b W_b' + P_bb W_bb; The second step is to write this value into the final output image Dst(i, j).

6. The image scaling method based on edge perception and content adaptive interpolation according to claim 5, characterized in that, After scaling all rows and columns in step three, the final target image Dst is output.