Interpolation methods and devices for grayscale images and interpolation methods for color images.
By selecting the smallest grid cell and neighborhood range of the target interpolation point in the grayscale image, calculating the approximate edge direction, and determining the interpolation reference point, the problem of edge blurring and high computational complexity in image interpolation in the prior art is solved, thereby improving visual effects and computational efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI JINGJI SEMICON TECH CO LTD
- Filing Date
- 2022-12-22
- Publication Date
- 2026-04-17
AI Technical Summary
Existing image interpolation techniques suffer from problems such as edge blurring, oscillation, and high computational complexity. In particular, non-adaptive interpolation methods produce step-like phenomena caused by low-pass filtering, while adaptive interpolation methods suffer from excessively high computational complexity.
By selecting the smallest grid cell of the target interpolation point in the grayscale image, calculating the neighborhood range and approximate edge direction, determining the interpolation reference point, and using the interpolation reference point to obtain the grayscale value of the target interpolation point, the interpolation process avoids using pixels on both sides of the image edge for interpolation and uses the interpolation reference point for interpolation processing.
It effectively preserves image edge information, reduces the step phenomenon caused by low-pass filtering, improves visual effect, and reduces computational complexity.
Smart Images

Figure CN116342472B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to an interpolation method and apparatus for grayscale images and an interpolation method for color images. Background Technology
[0002] Interpolation methods are widely used in various scenarios, such as data analysis, cartography, and image processing. The methods used in different scenarios often vary greatly. For one-dimensional curves or two-dimensional surfaces, which often correspond to a specific phenomenon, the same or a few functions are often used to describe all the data. In cartography and geographic research, in addition to point interpolation, which is similar to the commonly understood interpolation, there is also the concept of area interpolation, which is generally used for the re-integration of data between maps of different granularities. In image processing, the interpolation process is often used for resampling required during scaling, rotation, registration, or affine transformations.
[0003] Existing image interpolation techniques mainly fall into two categories: non-adaptive interpolation methods and adaptive interpolation methods.
[0004] Non-adaptive interpolation methods are based on direct pixel manipulation, without considering image features or content. They apply the same pattern to all pixel locations, regardless of whether the region is flat or abrupt. They are easy to implement and have low computational cost. Common non-adaptive interpolation methods include: nearest neighbor interpolation, bilinear interpolation, bicubic interpolation, B-spline interpolation, Lanczos interpolation, Hermite interpolation, etc.
[0005] For adaptive interpolation methods, the quality of the interpolated image mainly depends on the sharpness of the edge normal and the smoothness of the edge tangent. To avoid edge blurring or artifact blurring around the edges caused by non-adaptive interpolation techniques, adaptive interpolation methods consider the image's intensity value, edge information, texture, and other features to preserve high-frequency components as much as possible. Commonly used adaptive interpolation methods include: convex set projection method, edge guidance method, data correlation triangulation method, curvature-based iteration method, orthogonal transformation method, etc.
[0006] However, both non-adaptive and adaptive interpolation methods in the existing technology have obvious shortcomings: First, non-adaptive interpolation techniques actually use low-pass filters, and theoretically do not generate new high-frequency signals. This is especially evident in nearest neighbor interpolation and bilinear interpolation methods. The new values generated after interpolation using these two methods will not exceed the range formed by the four points on which the interpolation depends. However, the new values obtained by methods such as bicubic and Lanczos may exceed the range formed by the sixteen points on which they depend (but this does not mean that an effective high-frequency signal has been generated). This often causes oscillations and ripples (Runge phenomenon) at abrupt changes in the image. To suppress this situation, piecewise interpolation, such as Hermite interpolation and spline interpolation, can be used. Near the edges, this is actually a balance between steps and Runge phenomenon. Moreover, when using non-adaptive interpolation methods, it is assumed that the interpolation function is applicable to every pixel neighborhood of the image, but this does not hold true at abrupt changes and edges in the image.
[0007] Secondly, most adaptive interpolation techniques require iterative processes to optimize the results, which rapidly increases computational complexity, making them unsuitable for applications with high efficiency requirements. Information from the literature indicates that adaptive interpolation methods often take thousands of times longer than non-adaptive interpolation methods. Furthermore, most adaptive interpolation techniques are only applicable to integer multiples of interpolation. This is partly because these methods are often developed for image scaling, and partly because they generally require constructing parameters that serve as indicators during iterative iterations; these parameters often cannot be set for arbitrary scaling factors.
[0008] Therefore, it is necessary to provide a novel grayscale image interpolation method, apparatus, and color image interpolation method to solve the aforementioned problems existing in the prior art. Summary of the Invention
[0009] The purpose of this invention is to provide an interpolation method and apparatus for grayscale images and an interpolation method for color images, which effectively preserve image edge information and improve the visual effect of the processed image.
[0010] In a first aspect, to achieve the above objective, the grayscale image interpolation method of the present invention includes:
[0011] Select any target interpolation point to be interpolated in the grayscale image, and obtain the smallest grid cell of the target interpolation point;
[0012] Based on the smallest grid cell, the neighborhood range of the target interpolation point is obtained;
[0013] Calculate the approximate edge direction of the target interpolation point based on the gray values of the coordinate points in the neighborhood range;
[0014] The interpolation reference point of the target interpolation point is determined based on the approximate edge direction;
[0015] The target interpolation point is interpolated based on the interpolation reference point;
[0016] The grayscale value of the target interpolation point is obtained based on the interpolation reference point, so as to perform interpolation processing on the target interpolation point.
[0017] The beneficial effects of the grayscale image interpolation method described in this invention are as follows: by obtaining the neighborhood range of the target interpolation point in the grayscale image, it is possible to calculate the approximate edge direction of the target interpolation point within the neighborhood range. The position of the interpolation reference point is determined based on the approximate edge direction, and the grayscale value of the target interpolation point is obtained based on the interpolation reference point, thereby performing interpolation processing on the target interpolation point. This scheme avoids using pixels on both sides of the image edge for interpolation at the same time, effectively preserves edge information, greatly reduces the step phenomenon caused by low-pass filtering, improves the visual effect, and is also more conducive to subsequent image processing.
[0018] Optionally, obtaining the smallest grid cell of the target interpolation point includes:
[0019] The initial coordinates (r, c) of the target interpolation point are rounded down to obtain the first coordinates (r0, c0), and the second coordinates (r0+1, c0+1), the third coordinates (r0, c0+1), and the fourth coordinates (r0+1, c0) are obtained based on the first coordinates (r0, c0), where r0 and c0 are integers, and r0≤r, c0≤c;
[0020] The region enclosed by the first coordinate (r0, c0), the third coordinate (r0, c0+1), the second coordinate (r0+1, c0+1), and the fourth coordinate (r0+1, c0) is used as the smallest grid cell of the target interpolation point.
[0021] Optionally, obtaining the neighborhood range of the target interpolation point based on the smallest grid cell includes:
[0022] Calculate the distances between the four sides of the smallest grid cell and the image sides of the grayscale image, and select the minimum horizontal distance and the minimum vertical distance from the four calculated distances;
[0023] Compare the minimum horizontal distance with a preset cutoff threshold, and select the smaller value between the minimum horizontal distance and the preset cutoff threshold as the horizontal dimension L. H ;
[0024] Compare the minimum vertical distance with the preset truncation threshold, and select the smaller value between the minimum vertical distance and the preset truncation threshold as the vertical dimension L. V ;
[0025] Based on the first coordinate (r0, c0) and the horizontal dimension L H and the vertical dimension L V Obtain the fifth coordinate (r0-L) respectively V , c0- L H ), sixth coordinate (r0- L) V , c0+1+ L H ), fourth coordinate (r0+1+ L) V , c0+1+ L H ) and the eighth coordinate (r0+1+ L) V , c0- L H );
[0026] Using the fifth coordinate (r0-L) V , c0- L H ), sixth coordinate (r0- L) V , c0+1+ L H ), seventh coordinate (r0+1+L) V , c0+1+ L H ) and the eighth coordinate (r0+1+ L) V , c0- L H The region enclosed by the vertex is defined as the neighborhood range.
[0027] Optionally, calculating the approximate edge direction of the target interpolation point based on the grayscale values of each coordinate point in the neighborhood range includes:
[0028] Within the neighborhood, all points with row coordinates r0 or r0+1 are combined into a first set of coordinate points, where r0 is the row coordinate value of the first coordinate (r0, c0).
[0029] In the first set of coordinate points, select rows with coordinates r0 and r0+1, and column coordinates with a fixed difference k. i The corresponding multiple sets of first coordinate point pairs are calculated, and the grayscale difference of each set of first coordinate point pairs is averaged to obtain the different fixed difference values k. i The corresponding average grayscale difference g of multiple sets of the first coordinate point pairs i ;
[0030] Select the first average grayscale difference g i The direction determined by the first coordinate point pair corresponding to the minimum absolute value is taken as the first candidate approximate edge direction;
[0031] Within the neighborhood, all points with column coordinates c0 or c0+1 are combined into a second set of coordinate points, where c0 is the column coordinate value of the first coordinate (r0, c0).
[0032] In the second set of coordinate points, select points with column coordinates of c0 and c0+1 and row coordinates that differ by a fixed value m. i The corresponding multiple sets of second coordinate point pairs are calculated, and the grayscale difference of each set of second coordinate point pairs is averaged to obtain the different fixed difference m. i The corresponding average grayscale difference h of multiple sets of the second coordinate point pairs i ;
[0033] Select the second average grayscale difference h i The direction determined by the second coordinate point pair corresponding to the minimum absolute value is taken as the second candidate approximate edge direction;
[0034] The first average grayscale difference g corresponding to the first candidate approximate edge direction is used as the first candidate approximate edge direction. i The second average gray-scale difference h corresponding to the second candidate approximate edge direction i The direction corresponding to the smaller of the two is taken as the approximate edge direction;
[0035] Where, k i For [-L H L H The integer in ], m i For [-L V L V Integers in ].
[0036] Optionally, determining the interpolation reference point of the target interpolation point based on the approximate edge direction includes:
[0037] Extract the multiple sets of coordinate point pairs corresponding to the approximate edge direction, and use them as reference coordinate point pairs;
[0038] Two adjacent pairs of coordinate points are selected sequentially from the reference coordinate points to form multiple quadrilaterals;
[0039] Obtain a reference quadrilateral and use the four vertices of the reference quadrilateral as the interpolation reference points. The reference quadrilateral is the quadrilateral that includes the target interpolation points.
[0040] Optionally, obtaining the reference quadrilateral includes:
[0041] Connect the target interpolation point to the four vertices of the quadrilateral to obtain the four hypotenuses;
[0042] Calculate the sum of the angles between adjacent hypotenuses;
[0043] When the sum of the included angles is 360 degrees, the corresponding quadrilateral is determined to be the reference quadrilateral including the target interpolation point.
[0044] Optionally, obtaining the grayscale value of the target interpolation point based on the interpolation reference point, and performing interpolation processing on the target interpolation point, includes:
[0045] Using the target interpolation point as a reference point, the reference quadrilateral is divided into four sub-parallelograms, and the area of each sub-parallelogram is calculated.
[0046] Obtain the grayscale value at each of the interpolation reference point positions;
[0047] Calculate the grayscale value of the target interpolation point to complete the interpolation process of the target interpolation point;
[0048] The gray value of the target interpolation point is calculated using the following formula:
[0049] I = I a *S a + I b *S b + I c *S c + I d *S d ;
[0050] Where a, b, c, and d are the four interpolation reference points, and I is the gray value of the target interpolation point. a I b I c I d S represents the grayscale values corresponding to the positions of the four interpolation reference points a, b, c, and d, respectively. a S b S c S d The areas of the corresponding sub-parallelograms located at the diagonal opposite each of the four interpolation reference points a, b, c, and d are respectively.
[0051] This invention also discloses a color image interpolation method, comprising:
[0052] The color image is converted into images with three channels: R, G, and B.
[0053] The R channel image is used as the first grayscale image, the G channel image as the second grayscale image, and the B channel image as the third grayscale image. The above-mentioned grayscale image interpolation method is used to interpolate the first grayscale image, the second grayscale image, and the third grayscale image to obtain the interpolation results of the R, G, and B channels respectively.
[0054] The interpolation results of the R, G, and B channels are combined to form the target color image.
[0055] The beneficial effect of the color image interpolation method described in this invention is that by converting the color image into images with three channels (R, G, and B), and converting the images of each channel in the RGB image into first grayscale images, second grayscale images, and third grayscale images respectively, it is possible to use the above-mentioned grayscale image interpolation method to interpolate the channel grayscale images, and then synthesize the interpolation results of each channel to obtain the target color image after interpolation, thereby completing the color image interpolation process and meeting the color image interpolation requirements.
[0056] The present invention also provides an interpolation device for grayscale images, comprising:
[0057] The grid cell acquisition module is used to select any target interpolation point to be interpolated in the grayscale image and obtain the smallest grid cell of the target interpolation point;
[0058] The neighborhood calculation module is used to obtain the neighborhood range of the target interpolation point based on the smallest grid cell;
[0059] An approximate edge direction selection module is used to calculate the approximate edge direction of the target interpolation point based on the gray values of the coordinate points in the neighborhood range;
[0060] An interpolation reference point acquisition module is used to determine the interpolation reference point of the target interpolation point based on the approximate edge direction;
[0061] An interpolation module is used to obtain the grayscale value of the target interpolation point based on the interpolation reference point, so as to perform interpolation processing on the target interpolation point;
[0062] The traversal module is used to perform the above interpolation process on the coordinates of other points to be interpolated in the grayscale image to obtain the interpolated target image.
[0063] The beneficial effects of the grayscale image interpolation device described in this invention correspond one-to-one with the grayscale image interpolation method, and will not be repeated here.
[0064] The present invention also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described grayscale image interpolation method or the above-described color image interpolation method. Attached Figure Description
[0065] Figure 1 This is a flowchart of the grayscale image interpolation method described in an embodiment of the present invention;
[0066] Figure 2 This is a schematic diagram of the smallest grid cell when the grayscale image size is 40×40 in the grayscale image interpolation method described in the embodiment of the present invention;
[0067] Figure 3 This is a schematic diagram of the grayscale image interpolation method described in this embodiment of the invention when the neighborhood range is 6 rows and 6 columns;
[0068] Figure 4 This is a schematic diagram of the grayscale image interpolation method described in this embodiment of the invention when the neighborhood range is 4 rows and 6 columns;
[0069] Figure 5 In the grayscale image interpolation method described in the embodiments of the present invention Figure 4 A schematic diagram of the first set of coordinate points within the neighborhood range;
[0070] Figure 6 In the grayscale image interpolation method described in the embodiments of the present invention Figure 4 A schematic diagram of the second set of coordinate points within the neighborhood range;
[0071] Figure 7 In the grayscale image interpolation method described in the embodiments of the present invention, Figure 4 A schematic diagram of multiple quadrilaterals in the neighborhood where the approximate edge direction is vertical;
[0072] Figure 8 In the grayscale image interpolation method described in the embodiments of the present invention, Figure 4 A schematic diagram of multiple quadrilaterals with approximate edge directions in the neighborhood of the quadrilateral.
[0073] Figure 9 This is a schematic diagram showing the included angle of the target interpolation point in the quadrilateral in the grayscale image interpolation method described in this embodiment of the invention;
[0074] Figure 10 This is a schematic diagram showing how the target interpolation point P divides into sub-parallelograms within the reference quadrilateral ABCD in the grayscale image interpolation method described in this embodiment of the invention.
[0075] Figure 11This is a schematic diagram of the grayscale image interpolation method described in the embodiments of the present invention when the pixel point is in the edge region.
[0076] Figure 12 This is a flowchart of the color image interpolation method described in an embodiment of the present invention;
[0077] Figure 13 This is a structural block diagram of the grayscale image interpolation device described in an embodiment of the present invention.
[0078] Figure 14 This is a structural block diagram of the electronic device described in an embodiment of the present invention. Detailed Implementation
[0079] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions in the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention. Unless otherwise defined, the technical or scientific terms used herein should have the ordinary meaning understood by those skilled in the art. The terms "comprising" and similar expressions used herein mean that the element or object preceding the word covers the element or object listed following the word and its equivalents, but do not exclude other elements or objects.
[0080] To address the problems existing in the prior art, embodiments of the present invention provide a grayscale image interpolation method, with reference to... Figure 1 It includes the following steps:
[0081] S101. Select any target interpolation point to be interpolated in the grayscale image, and obtain the smallest grid cell of the target interpolation point.
[0082] In some embodiments, obtaining the smallest grid cell of the target interpolation point includes:
[0083] The initial coordinates (r, c) of the target interpolation point are rounded down to obtain the first coordinates (r0, c0), and the second coordinates (r0+1, c0+1), the third coordinates (r0, c0+1), and the fourth coordinates (r0+1, c0) are obtained based on the first coordinates (r0, c0), where r0 and c0 are integers, and r0≤r, c0≤c;
[0084] The region enclosed by the first coordinate (r0, c0), the third coordinate (r0, c0+1), the second coordinate (r0+1, c0+1), and the fourth coordinate (r0+1, c0) is used as the smallest grid cell of the target interpolation point.
[0085] In this embodiment, for a target interpolation point with initial coordinates (r, c), in order to determine the neighborhood range of the target interpolation point, since the coordinate values of the initial coordinates (r, c) are not necessarily integers, the coordinate values of the initial coordinates (r, c) are rounded down to obtain the first coordinates (r0, c0), where r0 is the integer part of r and c0 is the integer part of c. At the same time, based on the first coordinates (r0, c0), the second coordinates (r0+1, c0+1), the third coordinates (r0, c0+1), and the fourth coordinates (r0+1, c0) are obtained. This allows the region enclosed by the first coordinates (r0, c0), the third coordinates (r0, c0+1), the second coordinates (r0+1, c0+1), and the fourth coordinates (r0+1, c0) to be used as the smallest grid unit of the target interpolation point, so that the smallest grid unit includes the target interpolation point (r, c) within it, facilitating subsequent interpolation processing.
[0086] S102. Based on the smallest grid cell, obtain the neighborhood range of the target interpolation point.
[0087] In some embodiments, obtaining the neighborhood range of the target interpolation point based on the smallest grid cell includes:
[0088] Calculate the distances between the four sides of the smallest grid cell and the image sides of the grayscale image, and select the minimum horizontal distance and the minimum vertical distance from the four calculated distances;
[0089] Compare the minimum horizontal distance with a preset cutoff threshold, and select the smaller value between the minimum horizontal distance and the preset cutoff threshold as the horizontal dimension L. H ;
[0090] Compare the minimum vertical distance with the preset truncation threshold, and select the smaller value between the minimum vertical distance and the preset truncation threshold as the vertical dimension L. V ;
[0091] Based on the first coordinate (r0, c0) and the horizontal dimension L H and the vertical dimension L V Obtain the fifth coordinate (r0-L) respectively V , c0- L H ), sixth coordinate (r0- L) V, c0+1+ L H ), the seventh coordinate (r0+1+ L) V , c0+1+ L H ) and the eighth coordinate (r0+1+ L) V , c0- L H );
[0092] Using the fifth coordinate (r0-L) V , c0- L H ), sixth coordinate (r0- L) V , c0+1+ L H ), seventh coordinate (r0+1+L) V , c0+1+ L H ) and the eighth coordinate (r0+1+ L) V , c0- L H The region enclosed by the vertex is defined as the neighborhood range.
[0093] After determining the smallest grid cell, the vertical distances between the four sides of the smallest grid cell and the adjacent image sides of the grayscale image are calculated. The four sides of the smallest grid cell are defined as top, bottom, left, and right, and the sides of the grayscale image are also defined as top, bottom, left, and right. The vertical distances between the four sides of the smallest grid cell and the four sides of the adjacent grayscale image, including the left side distance L, are calculated. left Distance L on the right side right Distance L from the top side up Distance L from the bottom side bottom Then, from the four calculated vertical distances, select the minimum horizontal distance and the minimum vertical distance, which is the left side distance L. left Distance L from the right side right The smaller of the two is chosen as the minimum horizontal distance, and the upper side distance L is selected. up Distance L from the bottom side bottom The smaller of the two values is taken as the minimum vertical distance. Then, the horizontal dimension L of the neighborhood range can be determined based on the minimum horizontal distance, the minimum vertical distance, and the preset cutoff length. H and vertical dimension L V And according to the horizontal dimension L H and the vertical dimension L V Determine the neighborhood range A.
[0094] In this embodiment, when the minimum horizontal distance is less than or equal to a preset truncation threshold, the minimum horizontal distance is selected as the horizontal dimension L. H When the minimum horizontal distance is greater than the preset truncation threshold, the preset truncation threshold is selected as the horizontal dimension L. HWhen the minimum vertical distance is less than or equal to the preset truncation threshold, the minimum vertical distance is selected as the vertical dimension L. V When the minimum vertical distance is greater than the preset truncation threshold, the preset truncation threshold is selected as the vertical dimension L. V .
[0095] And in determining the horizontal dimension L of the neighborhood range H and vertical dimension L V Then, based on the first coordinate (r0, c0) and the horizontal dimension L, H and vertical dimension L V Determine the fifth coordinate (r0-L) V , c0- L H ), sixth coordinate (r0- L) V , c0+1+L H ), the seventh coordinate (r0+1+ L) V , c0+1+ L H ) and the eighth coordinate (r0+1+ L) V , c0- L H ), thus setting the fifth coordinate (r0-L) V , c0- L H ), sixth coordinate (r0- L) V , c0+1+ L H ), the seventh coordinate (r0+1+ L) V , c0+1+ L H ) and the eighth coordinate (r0+1+ L) V , c0- L H The neighborhood range is defined as the area enclosed by the four vertices.
[0096] For example, refer to Figure 2 Assuming the grayscale image size is 40×40, and the initial coordinates of the target interpolation point are (1.5, 30.6), then its corresponding first coordinates are (1, 30) and second coordinates are (2, 31). The square cell with diagonal vertices (1, 30) and (2, 31) is then used as the smallest grid cell. The distances from the four sides of the smallest grid cell to the top, bottom, left, and right sides of the current grayscale image are L (the distance from the top side to the bottom side). up , lower side distance L bottom Distance L on the left side left Distance L on the right side right Given values of 1, 38, 30, and 8 respectively, the minimum horizontal distance min(30,8) = 8, and the minimum vertical distance min(1,38) = 1. The preset truncation threshold L is then set. max If set to 2, the horizontal dimension is L. H=min(8, 2)=2, the vertical dimension is L V =min(1, 2)=1. After determining the horizontal and vertical dimensions, the size of the neighborhood range A can be determined based on the coordinates of the first coordinate, the horizontal dimension, and the vertical dimension. Specifically, the neighborhood range A is (r1~r2, c1~c2)r1=1-1=0, r2=1+1+1=3, c1=30-2=28, c2=30+1+2=33, then the neighborhood range A is a rectangle determined by the vertices (0,28), (0,33), (3,28), and (3,33).
[0097] It should be noted that the relative positional relationship between the interpolation coordinates and the image boundary was considered during the neighborhood selection process. This was to ensure that subsequent interpolation would not rely on the grayscale value of a pixel outside the image, which would prevent calculations from being performed. Additionally, a truncation length L was set. max This limits the size of the neighborhood to prevent it from becoming too large, thus reasonably controlling the computational load.
[0098] When L max When =2, refer to Figure 3 The neighborhood is a 6×6 grid. Figure 3 The black dots in the graph are the target interpolation points.
[0099] S103. Calculate the approximate edge direction of the target interpolation point based on the gray values of each coordinate point in the neighborhood range.
[0100] In some embodiments, step S103 includes the following process:
[0101] Within the neighborhood, all points with row coordinates r0 or r0+1 are combined into a first set of coordinate points, where r0 is the row coordinate value of the first coordinate (r0, c0).
[0102] In the first set of coordinate points, select rows with coordinates r0 and r0+1, and column coordinates with a fixed difference k. i The corresponding multiple sets of first coordinate point pairs are calculated, and the grayscale difference of each set of first coordinate point pairs is averaged to obtain the different fixed difference values k. i The corresponding average grayscale difference g of multiple sets of the first coordinate point pairs i ;
[0103] Select the first average grayscale difference g i The direction determined by the first coordinate point pair corresponding to the minimum absolute value is taken as the first candidate approximate edge direction;
[0104] Within the neighborhood, all points with column coordinates c0 or c0+1 are combined into a second set of coordinate points, where c0 is the column coordinate value of the first coordinate (r0, c0).
[0105] In the second set of coordinate points, select points with column coordinates of c0 and c0+1 and row coordinates that differ by a fixed value m. i The corresponding multiple sets of second coordinate point pairs are calculated, and the grayscale difference of each set of second coordinate point pairs is averaged to obtain the different fixed difference m. i The corresponding average grayscale difference h of multiple sets of the second coordinate point pairs i ;
[0106] Select the second average grayscale difference h i The direction determined by the second coordinate point pair corresponding to the minimum absolute value is taken as the second candidate approximate edge direction;
[0107] The average grayscale difference g corresponding to the first candidate approximate edge direction is used as the unit. i The average gray-scale difference h corresponding to the second candidate approximate edge direction i The direction corresponding to the smaller of the two is taken as the approximate edge direction;
[0108] Where, k i For [-L H L H The integer in ], m i For [-L V L V Integers in ].
[0109] In this embodiment, after determining the neighborhood range A of the target interpolation point (r, c), all coordinate points with row coordinates r0 and r0+1 are first selected from the neighborhood range A as the first coordinate point set. Then, within the first coordinate point set, points with row coordinates r0 and r0+1 and a difference in column coordinates of -L are selected. H -L H +1, ..., 0, ..., L H -1,L H The corresponding multiple sets of first coordinate point pairs are calculated, and the grayscale difference of each set of first coordinate point pairs is averaged to obtain the first average grayscale difference V of the multiple sets of first coordinate point pairs corresponding to the different column coordinate differences. -L H, V -L H +1 , …, V0, … , V L H -1 V L H; then select the direction of the first coordinate point corresponding to the smallest first average gray level difference as the first candidate approximate edge direction.
[0110] Similarly, within the neighborhood range A, a second set of coordinate points with column coordinates c0 and c0+1 is selected. Within this second set of coordinate points, points with column coordinates c0 and c0+1 and a difference in row coordinates of -L are selected. V , - L V +1, ..., 0, ..., L V -1,L V The corresponding multiple sets of second coordinate point pairs are calculated, and the grayscale difference of each set of second coordinate point pairs is averaged to obtain the second average grayscale difference H of the multiple sets of second coordinate point pairs corresponding to the different column coordinate differences. -L V, H -L V +1 , …, H0,… , H L V -1 H L V, then select the direction of the second coordinate point corresponding to the smallest second average gray level difference as the second candidate approximate edge direction.
[0111] Then, the absolute values of the average grayscale difference of the first candidate approximate edge direction and the average grayscale difference of the second candidate approximate edge direction are compared, and the direction corresponding to the one with the smaller absolute value is taken as the approximate edge direction.
[0112] For example, with a horizontal dimension L H =2, vertical dimension L V For example, given r0 = 1, r0 = 10, and c0 = 15, refer to... Figure 4 The size of the neighborhood range A is 4 rows and 6 columns. We take the six points with row coordinates 10 and 11 in neighborhood range A as the first coordinate point set, refer to... Figure 5 The first set of coordinate points are U1, U2, U3, U4, U5, U6, and B1, B2, B3, B4, B5, B6; since L H If the column coordinate difference is 2, then select multiple pairs of first coordinate points with column coordinate differences of -2, -1, 0, 1, and 2 respectively from the first coordinate point set, calculate the grayscale difference of the coordinate points in the first coordinate point pair, and then calculate the average value to obtain the first average grayscale difference V of the multiple pairs of first coordinate points with different column coordinate differences. -2 V -1 For example, given multiple pairs of first coordinate points with a column coordinate difference of -2, including four pairs: U1 and B3, U2 and B4, U3 and B5, and U4 and B6, we calculate the grayscale difference between U1 and B3, U2 and B4, U3 and B5, and U4 and B6 respectively. Then, we average the four grayscale differences to obtain the first average grayscale difference V corresponding to a column coordinate difference of -2.-2 For example, if the first coordinate point pair where the column coordinate difference is 1 includes five groups: U2 and B1, U3 and B2, U4 and B3, and U5 and B4, then calculate the grayscale difference between U2 and B1, U3 and B2, U4 and B3, U5 and B4, and U6 and B5 respectively. Then, average these five grayscale differences to obtain the first average grayscale difference V1 corresponding to a column coordinate difference of 1. Finally, select five first average grayscale differences V1. -2 V -1 The direction determined by the first coordinate point pair corresponding to the smallest among V0, V1, and V2 is taken as the first candidate approximate edge direction.
[0113] Similarly, take the four points each with column coordinates 15 and 16 in the neighborhood range A as the second set of coordinate points, refer to... Figure 6 The points in the second coordinate set are L1, L2, L3, L4, R1, R2, R3, R4. Since L... V =1, then select multiple pairs of second coordinate points with row coordinate differences of -1, 0, and 1 respectively in the second coordinate point set, calculate the grayscale difference of the coordinate points in the second coordinate point pair, and then calculate the average value to obtain the second average grayscale difference H of multiple pairs of second coordinate point pairs with different row coordinate differences. -1 H0, H1, and then select the direction determined by the second coordinate point corresponding to the smallest of the three second average gray level differences as the second candidate approximate edge direction.
[0114] Then, the absolute values of the average grayscale difference between the first candidate approximate edge direction and the second candidate approximate edge direction are compared, and the direction with the smaller absolute value is selected as the approximate edge direction.
[0115] S104. Determine the interpolation reference point of the target interpolation point based on the approximate edge direction.
[0116] In some embodiments, determining the interpolation reference point of the target interpolation point based on the approximate edge direction includes:
[0117] Extract the multiple sets of coordinate point pairs corresponding to the approximate edge direction, and use them as reference coordinate point pairs;
[0118] Two adjacent pairs of coordinate points are selected sequentially from the reference coordinate points to form multiple quadrilaterals;
[0119] Obtain a reference quadrilateral and use the four vertices of the reference quadrilateral as the interpolation reference points. The reference quadrilateral is the quadrilateral that includes the target interpolation points.
[0120] In this embodiment, after determining the approximate edge direction of the target interpolation point, since the approximate edge direction contains multiple pairs of coordinate points, in order to further determine the relationship between the current target interpolation point and these pairs of coordinate points, multiple non-repeating quadrilaterals are obtained by combining two adjacent pairs of coordinate points. Then, by judging the relationship between the target interpolation point and the multiple quadrilaterals, a reference quadrilateral that meets the requirements can be selected.
[0121] For example, in Figure 4 Based on this, continue with the horizontal dimension L H =2, vertical dimension L V For example, given r0 = 1, r0 = 10, and c0 = 15, refer to... Figure 7 When V is selected -2 The corresponding coordinate points are used as the approximate edge direction. Then, determine which of the following three quadrilaterals—U1U2B4B3, U2U3B5B4, and U3U4B6B5—the target interpolation point lies in. When V is selected... -1 Using the direction determined by the corresponding coordinate point as the approximate edge direction, determine which of the following two quadrilaterals, U2U3B4B3 and U3U4B5B4, the target interpolation point lies within. If the direction determined by the coordinate point corresponding to V0 is chosen as the approximate edge direction, the target interpolation point lies within quadrilateral U3U4B4B3. If the direction determined by the coordinate point corresponding to V1 is chosen as the approximate edge direction, determine which of the following two quadrilaterals, U3U4B3B2 and U4U5B4B3, the target interpolation point lies within. If the direction determined by the coordinate point corresponding to V2 is chosen as the approximate edge direction, determine which of the following three quadrilaterals, U3U4B2B1, U4U5B3B2, and U5U6B4B3, the target interpolation point lies within. (Reference) Figure 8 When H is selected -1 The corresponding coordinate points are used to determine the approximate edge direction. The system then determines which of the following two quadrilaterals, L1L2R3R2 and L2L3R4R3, the target interpolation point lies within. If the direction determined by the coordinate points corresponding to H0 is chosen as the approximate edge direction, the target interpolation point lies within quadrilateral L2L3R3R2. If the direction determined by the coordinate points corresponding to H1 is chosen as the approximate edge direction, the system determines which of the following two quadrilaterals, L2L3R2R1 and L3L4R3R2, the target interpolation point lies within. Determining which quadrilateral the target interpolation point lies within facilitates the rapid identification of the auxiliary quadrilateral and its corresponding endpoints.
[0122] It should be noted that not all possible cases for determining the reference quadrilateral have been listed above. Since the target interpolation point is located in square U3U4B4B3 or square L2R2R3L3, quadrilaterals that do not intersect with square U3U4B4B3 or square L2R2R3L3 are directly discarded and not listed here.
[0123] In some other embodiments, obtaining the reference quadrilateral includes:
[0124] Connect the target interpolation point to the four vertices of the quadrilateral to obtain the four hypotenuses;
[0125] Calculate the sum of the angles between adjacent hypotenuses;
[0126] When the sum of the included angles is 360 degrees, the corresponding quadrilateral is determined to be the reference quadrilateral including the target interpolation point.
[0127] To further determine whether the target interpolation point lies within the reference quadrilateral, the reference... Figure 9 By connecting the target interpolation point to the four vertices of the reference quadrilateral to form four hypotenuses, the hypotenuses of adjacent pairs are calculated. The sum of the included angles is 360 degrees. If the sum of the included angles is 360 degrees, the target interpolation point is located within the current reference quadrilateral, and the current reference quadrilateral can be selected. If the sum of the included angles is not equal to 360 degrees, the current target interpolation point is not within the reference quadrilateral, and a new reference quadrilateral needs to be selected.
[0128] S105. Obtain the gray value of the target interpolation point based on the interpolation reference point, so as to perform interpolation processing on the target interpolation point.
[0129] In some embodiments, obtaining the grayscale value of the target interpolation point based on the interpolation reference point, and then performing interpolation processing on the target interpolation point, includes:
[0130] Using the target interpolation point as a reference point, the reference quadrilateral is divided into four sub-parallelograms, and the area of each sub-parallelogram is calculated.
[0131] Obtain the grayscale value at each of the interpolation reference point positions;
[0132] Calculate the grayscale value of the target interpolation point to complete the interpolation process of the target interpolation point.
[0133] The interpolation result of the target interpolation point is calculated using the following formula:
[0134] I = I a *S a + I b*S b + I c *S c + I d *S d ;
[0135] Where a, b, c, and d are the four interpolation reference points, and I is the gray value of the target interpolation point. a I b I c I d S represents the grayscale values corresponding to the positions of the four interpolation reference points a, b, c, and d, respectively. a S b S c S d S represents the area of the corresponding sub-parallelogram containing the interpolation reference points at their respective diagonals (a, b, c, and d). a S is the area of the subparallelogram containing the interpolation reference point c. b S is the area of the subparallelogram containing the interpolation reference point d; c S is the area of the subparallelogram containing the interpolation reference point a; d Let b be the area of the subparallelogram containing the interpolation reference point b.
[0136] In this embodiment, reference Figure 10 Let P be the target interpolation point, and let A, B, C, and D be the four vertices of the selected reference quadrilateral L. Draw parallel lines from the target interpolation point P to the four sides of the reference quadrilateral L, obtaining four intersection points E, F, G, and H. This will give us sub-parallelograms A (bound by points AEPG), B (bound by points GBFP), C (bound by points PFCH), and D (bound by points EPHD). By calculating the areas of these four sub-parallelograms, we can then calculate the grayscale value of the target interpolation point based on the areas of the sub-parallelograms and the grayscale values of vertices A, B, C, and D.
[0137] For example, continue to refer to Figure 10 The target interpolation point P lies within the reference quadrilateral ABCD. Assume the coordinates of point A are (x1, y1), point B is (x1+1, y1), point C is (x1+1+k, y1+1), and point D is (x1+k, y1+1); the coordinates of point P are (x1+dx, y1+dy), then the coordinates of point E are (x1+dy*k, y1+dy), the length of EP is dx-dy×k, and the length of PF is 1-dx+dy×k.
[0138] Considering that the area ratio of the sub-parallelogram is inversely proportional to the influence of its corresponding gray value on the interpolation result, the area of sub-parallelogram A is denoted as S. c The area of the interpolated quadrilateral B is denoted as S. d The area of the interpolated quadrilateral C is denoted as S. a The area of the interpolated quadrilateral D is denoted as S. b .
[0139] Then: Sa = PF×(1-dy), Sb = EP×(1-dy), Sc = EP×dy, Sd = PF×dy.
[0140] Let the gray values of points A, B, C, and D be denoted as I. a I b I c I d The grayscale value I after interpolation at point P p = I a ×S a + I b ×S b + I c ×S c + I d ×S d .
[0141] S106. Perform the above interpolation process on the coordinates of other points to be interpolated in the grayscale image to obtain the interpolated target image.
[0142] Then, the above interpolation process is performed on other points to be interpolated in the grayscale image to obtain the interpolation results of each coordinate point, thereby completing the interpolation process of the grayscale image and obtaining the grayscale image after interpolation. Through the above interpolation process, the interpolation process of the target interpolation point can be completed. Since this scheme avoids using pixels on both sides of the edge for interpolation for pixels near the edge, it effectively preserves the edge information, greatly reduces the step phenomenon caused by low-pass filtering, improves the visual effect, and is more conducive to subsequent image processing.
[0143] It's important to note that image edges refer to regions of significant change within an image, as opposed to flat regions with less pronounced changes. Edge regions exhibit the following characteristics: grayscale values change rapidly along the normal direction of the edge and gradually along the tangent direction. When interpolating based on this image, non-adaptive interpolation methods such as bilinear or bicubic interpolation will not cause problems in flat regions (i.e., regions without edges), but in regions containing edges, a noticeable low-pass filtering effect will appear. (Reference) Figure 11When the four nearest neighbors of a point to be interpolated are P, Q, M, and N, bilinear interpolation will directly use the pixel values of all four points for interpolation, thereby losing the original relatively clear image edges and producing steps. However, the solution in this application avoids using the pixels on both sides of the edge for interpolation for pixels near the edge, effectively preserving edge information, greatly reducing the step phenomenon caused by low-pass filtering, improving the visual effect, and being more conducive to subsequent image processing.
[0144] This invention discloses an interpolation method for color images, with reference to... Figure 12 It includes the following steps:
[0145] S1201. Convert the color image into images with three channels: R, G, and B.
[0146] S1202. Using the R channel image as the first grayscale image, the G channel image as the second grayscale image, and the B channel image as the third grayscale image, the first grayscale image, the second grayscale image, and the third grayscale image are interpolated using the grayscale image interpolation method described in any one of claims 1 to 7 to obtain the interpolation results of the R, G, and B channels respectively.
[0147] S1203. Combine the interpolation results of the R, G, and B channels into a target color image.
[0148] The present invention also discloses an interpolation device for grayscale images, with reference to Figure 13 ,include:
[0149] The minimum grid cell acquisition module 1301 is used to select any target interpolation point to be interpolated in a grayscale image and acquire the minimum grid cell of the target interpolation point;
[0150] The neighborhood calculation module 1302 is used to obtain the neighborhood range of the target interpolation point based on the smallest grid cell;
[0151] The approximate edge direction selection module 1303 is used to calculate the approximate edge direction of the target interpolation point based on the gray value of the coordinate point in the neighborhood range.
[0152] The interpolation reference point acquisition module 1304 is used to determine the interpolation reference point of the target interpolation point based on the approximate edge direction;
[0153] Interpolation module 1305 is used to obtain the gray value of the target interpolation point based on the interpolation reference point, so as to perform interpolation processing on the target interpolation point;
[0154] The traversal module 1306 is used to perform the above-mentioned interpolation process on the coordinates of other points to be interpolated in the grayscale image to obtain the interpolated target image.
[0155] It should be noted that the structure and principle of the grayscale image interpolation device described above correspond one-to-one with the steps in the grayscale image interpolation method described above, so they will not be repeated here.
[0156] It should be noted that the division of the various modules in the above device is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. Furthermore, these modules can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some modules can be implemented by processing element calls to software, while others are implemented in hardware. For example, the selection module can be a separate processing element, or it can be integrated into a chip in the above system. Alternatively, it can be stored as program code in the memory of the above system, and its function can be called and executed by a processing element of the system. The implementation of other modules is similar. Moreover, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element mentioned here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed through the integrated logic circuits in the hardware of the processor element or through software instructions.
[0157] For example, these modules can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field-programmable gate arrays (FPGAs). As another example, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a system-on-a-chip (SOC).
[0158] In other embodiments of this application, an electronic device is disclosed, such as... Figure 14As shown, the electronic device includes: one or more processors 1401; a memory 1402; a display 1403; one or more application programs (not shown); and one or more computer programs 1404. These devices can be connected via one or more communication buses 1405. The one or more computer programs 1404 are stored in the memory 1402 and configured to be executed by the one or more processors 1401. The one or more computer programs 1404 include instructions.
[0159] The present invention also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the above-described grayscale image interpolation method.
[0160] The storage medium of this invention stores a computer program, which, when executed by a processor, implements the aforementioned grayscale image interpolation method. The storage medium includes various media capable of storing program code, such as read-only memory (ROM), random access memory (RAM), magnetic disk, USB flash drive, memory card, or optical disk.
[0161] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0162] In the embodiments of this application, the functional units can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0163] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as flash memory, portable hard disk, read-only memory, random access memory, magnetic disk, or optical disk.
[0164] While embodiments of the present invention have been described in detail above, it will be apparent to those skilled in the art that various modifications and variations can be made to these embodiments. However, it should be understood that such modifications and variations fall within the scope and spirit of the invention as set forth in the claims. Furthermore, the invention described herein may have other embodiments and can be implemented or carried out in various ways.
Claims
1. A grayscale image interpolation method, characterized in that, include: Select any target interpolation point to be interpolated in the grayscale image, and obtain the smallest grid cell of the target interpolation point; Obtaining the neighborhood range of the target interpolation point based on the minimum grid cell includes: obtaining the minimum horizontal distance between the minimum grid cell and the grayscale image and the minimum vertical distance between the minimum grid cell and the grayscale image; determining the horizontal and vertical dimensions based on the minimum horizontal distance, the minimum vertical distance, and a preset truncation threshold; and expanding the minimum grid cell based on the horizontal and vertical dimensions to obtain the neighborhood range of the target interpolation point. The approximate edge direction of the target interpolation point is calculated based on the gray values of the coordinate points in the neighborhood range. In the neighborhood range, the direction determined by the coordinate point pair with the smallest absolute value of the average gray difference among the corresponding multiple sets of coordinate point pairs in two adjacent rows or two adjacent columns determined by the smallest grid cell is the approximate edge direction. Determining the interpolation reference point of the target interpolation point based on the approximate edge direction includes: extracting the multiple sets of coordinate point pairs corresponding to the approximate edge direction and using them as reference coordinate point pairs; sequentially selecting two adjacent coordinate point pairs among the reference coordinate points to form multiple quadrilaterals; obtaining a reference quadrilateral and using the four vertices of the reference quadrilateral as the interpolation reference point, wherein the reference quadrilateral is the quadrilateral including the target interpolation point; The grayscale value of the target interpolation point is obtained based on the interpolation reference point, so as to perform interpolation processing on the target interpolation point; The process involves performing the step of obtaining the smallest grid cell of the target interpolation point on other target interpolation points in the grayscale image, and then obtaining the grayscale value of the target interpolation point based on the interpolation reference point, in order to perform interpolation processing on the target interpolation point, thereby obtaining the interpolated target image.
2. The grayscale image interpolation method according to claim 1, characterized in that, The step of obtaining the smallest grid cell of the target interpolation point includes: The initial coordinates (r, c) of the target interpolation point are rounded down to obtain the first coordinates (r0, c0), and the second coordinates (r0+1, c0+1), the third coordinates (r0, c0+1), and the fourth coordinates (r0+1, c0) are obtained based on the first coordinates (r0, c0), where r0 and c0 are integers, and r0≤r, c0≤c; The region enclosed by the first coordinate (r0, c0), the third coordinate (r0, c0+1), the second coordinate (r0+1, c0+1), and the fourth coordinate (r0+1, c0) is used as the smallest grid cell of the target interpolation point.
3. The grayscale image interpolation method according to claim 2, characterized in that, The step of obtaining the neighborhood range of the target interpolation point based on the smallest grid cell includes: Calculate the distances between the four sides of the smallest grid cell and the image sides of the grayscale image, and select the minimum horizontal distance and the minimum vertical distance from the four calculated distances; comparing the minimum horizontal distance with a size of a preset cut-off threshold, and selecting a smaller value between the minimum horizontal distance and the preset cut-off threshold as a horizontal size L H ; Compare the minimum vertical distance with the preset truncation threshold, and select the smaller value between the minimum vertical distance and the preset truncation threshold as the vertical dimension L. V ; Based on the first coordinate (r0, c0) and the horizontal dimension L H and the vertical dimension L V Obtain the fifth coordinate (r0-L) respectively V , c0- L H ), sixth coordinate (r0- L) V , c0+1+ L H ), the seventh coordinate (r0+1+ L) V , c0+1+ L H ) and the eighth coordinate (r0+1+ L) V , c0- L H ); Using the fifth coordinate (r0-L) V , c0- L H ), sixth coordinate (r0-L) V , c0+1+L H ), seventh coordinate (r0+1+L) V , c0+1+L H ) and the eighth coordinate (r0+1+L) V , c0-L H The region enclosed by the vertex is defined as the neighborhood range.
4. The grayscale image interpolation method according to claim 2, characterized in that, The step of calculating the approximate edge direction of the target interpolation point based on the gray values of each coordinate point in the neighborhood range includes: Within the neighborhood, all points with row coordinates r0 or r0+1 are combined into a first set of coordinate points, where r0 is the row coordinate value of the first coordinate (r0, c0). In the first set of coordinate points, select rows with coordinates r0 and r0+1, and column coordinates with a fixed difference k. i The corresponding multiple sets of first coordinate point pairs are calculated, and the grayscale difference of each set of first coordinate point pairs is averaged to obtain the different fixed difference values k. i The corresponding average grayscale difference g of multiple sets of the first coordinate point pairs i ; Select the first average grayscale difference g i The direction determined by the coordinate point pair corresponding to the minimum absolute value is taken as the first candidate approximate edge direction; Within the neighborhood, all points with column coordinates c0 or c0+1 are combined into a second set of coordinate points, where c0 is the column coordinate value of the first coordinate (r0, c0). In the second set of coordinate points, select points with column coordinates of c0 and c0+1 and row coordinates that differ by a fixed value m. i The corresponding multiple sets of second coordinate point pairs are calculated, and the grayscale difference of each set of second coordinate point pairs is averaged to obtain the different fixed difference m. i The corresponding average grayscale difference h of multiple sets of the second coordinate point pairs i ; Select the second average grayscale difference h i The direction determined by the coordinate point pair corresponding to the minimum absolute value is used as the second candidate approximate edge direction; The first average grayscale difference g corresponding to the first candidate approximate edge direction is used as the first candidate approximate edge direction. i The second average gray-scale difference h corresponding to the second candidate approximate edge direction i The direction corresponding to the smaller of the two is taken as the approximate edge direction; Where, k i For [-L H L H The integer in ], m i For [-L V L V The integers in the string, where i is a positive integer, and L... H L is the horizontal distance along the column coordinate direction between the side of the smallest grid cell and the side of the adjacent neighborhood range. V The vertical distance between the side of the smallest grid cell and the side of the adjacent neighborhood range along the row coordinate direction.
5. The grayscale image interpolation method according to claim 1, characterized in that, The process of obtaining the reference quadrilateral includes: Connect the target interpolation point to the four vertices of the quadrilateral to obtain the four hypotenuses; Calculate the sum of the angles between adjacent hypotenuses; When the sum of the included angles is 360 degrees, the corresponding quadrilateral is determined to be the reference quadrilateral including the target interpolation point.
6. The grayscale image interpolation method according to claim 1, characterized in that, The step of obtaining the grayscale value of the target interpolation point based on the interpolation reference point, and then performing interpolation processing on the target interpolation point, includes: Using the target interpolation point as a reference point, the reference quadrilateral is divided into four sub-parallelograms, and the area of each sub-parallelogram is calculated. Obtain the grayscale value at each of the interpolation reference point positions; The grayscale value of the target interpolation point is calculated to complete the interpolation process. The grayscale value of the target interpolation point is calculated using the following formula: I= I a *S a + I b *S b + I c *S c + I d *S d ; Where a, b, c, and d are the four interpolation reference points, and I is the gray value of the target interpolation point. a I b I c I d S represents the grayscale values corresponding to the positions of the four interpolation reference points a, b, c, and d, respectively. a S b S c S d The areas of the corresponding sub-parallelograms located at the diagonal opposite each of the four interpolation reference points a, b, c, and d are respectively.
7. An interpolation method for color images, characterized in that, include: The color image is converted into images with three channels: R, G, and B. Using the R channel image as the first grayscale image, the G channel image as the second grayscale image, and the B channel image as the third grayscale image, the first grayscale image, the second grayscale image, and the third grayscale image are interpolated using the grayscale image interpolation method described in any one of claims 1 to 6 to obtain the interpolation results of the R, G, and B channels respectively. The interpolation results of the R, G, and B channels are combined to form the target color image.
8. An interpolation device for grayscale images, characterized in that, include: The minimum grid cell acquisition module is used to select any target interpolation point to be interpolated in a grayscale image and acquire the minimum grid cell of the target interpolation point; The neighborhood calculation module is used to obtain the neighborhood range of the target interpolation point based on the minimum grid cell, including: obtaining the minimum horizontal distance between the minimum grid cell and the grayscale image and the minimum vertical distance between the minimum grid cell and the grayscale image; determining the horizontal and vertical dimensions based on the minimum horizontal distance, the minimum vertical distance, and a preset truncation threshold; and expanding the minimum grid cell based on the horizontal and vertical dimensions to obtain the neighborhood range of the target interpolation point. An approximate edge direction selection module is used to calculate the approximate edge direction of the target interpolation point based on the gray values of coordinate points in the neighborhood range. In the neighborhood range, the direction determined by the coordinate point pair with the smallest absolute value of the average gray difference among the corresponding multiple sets of coordinate point pairs in two adjacent rows or two adjacent columns determined by the smallest grid cell is the approximate edge direction. An interpolation reference point acquisition module is used to determine the interpolation reference point of the target interpolation point based on the approximate edge direction, including: extracting the multiple sets of coordinate point pairs corresponding to the approximate edge direction and using them as reference coordinate point pairs; sequentially selecting two adjacent coordinate point pairs from the reference coordinate points to form multiple quadrilaterals; acquiring a reference quadrilateral and using the four vertices of the reference quadrilateral as the interpolation reference point, wherein the reference quadrilateral is the quadrilateral including the target interpolation point; An interpolation module obtains the grayscale value of the target interpolation point based on the interpolation reference point, and performs interpolation processing on the target interpolation point; The traversal module is used to perform the steps of obtaining the smallest grid cell of the target interpolation point to obtaining the gray value of the target interpolation point based on the interpolation reference point on other target interpolation points in the grayscale image, so as to perform interpolation processing on the target interpolation point to obtain the interpolated target image.
9. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the grayscale image interpolation method of any one of claims 1 to 6 or the color image interpolation method of claim 7.
Citation Information
Patent Citations
Image amplification processing method based on edge direction difference
CN102682424A
Image processing unit
JP2000115540A