An image magnification method, system, electronic device and computer storage medium

CN115731109BActive Publication Date: 2026-09-22NORTHWESTERN POLYTECHNICAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211513923.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-29
Publication Date
2026-09-22
Estimated Expiration
2042-11-29

AI Technical Summary

Technical Problem

这两者都会降低用户的视觉体验,需要更多的改进

Benefits of technology

本发明获取待进行放大处理的第一图像以及所述第一图像的放大倍数;基于所述放大倍数对所述第一图像进行最近邻域放大,得到第二图像;对所述第一图像中每个像素点的4个角进行边缘分析,得到边缘矩阵;基于所述边缘矩阵对所述第二图像进行调整,得到第三图像。本发明执行简单、运算快速且对并行运算友好,可以在相似的硬件基础上,基本无需硬件升级,直接在电子设备、计算机存储介质和计算机程序产品代替现有的放大算法;效果上,本发明拥有与最近邻放大算法相同清晰度的情况下避免最近邻放大算法的块效应瑕疵问题,大幅度优于现有的通用的线性放大和最近邻域放大算法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115731109B_ABST
    Figure CN115731109B_ABST
Patent Text Reader

Abstract

The application relates to an image magnification method, system, electronic equipment and computer storage medium, and relates to the technical field of image processing. The method comprises the following steps: acquiring a first image to be subjected to magnification processing and a magnification multiple of the first image; performing nearest neighbor domain magnification on the first image based on the magnification multiple to obtain a second image; performing edge analysis on four corners of each pixel point in the first image to obtain an edge matrix; and adjusting the second image based on the edge matrix to obtain a third image. The application can avoid the blocking effect defect problem of the nearest neighbor magnification algorithm while having the same definition as the nearest neighbor magnification algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to an image magnification method, system, electronic device, and computer storage medium. Background Technology

[0002] Image upscaling is a fundamental image processing algorithm. When the image resolution (in pixels) is smaller than the display resolution, the image must be enlarged to match the display resolution. Image upscaling is widely used in various systems, electronic devices, and computer storage media. This is especially true when the mainstream image / video resolution is 1920x1080, while the monitor resolution is 2560x1440 or 3840x2160, requiring matching image upscaling methods to fill the entire display. Similar to other image processing techniques, image upscaling techniques can be broadly categorized into two types: traditional algorithms and machine learning algorithms. Machine learning algorithms generally offer better results but are computationally complex and require a training set matching the input image to achieve optimal upscaling effects, such as NVIDIA's DLSS technology. On the other hand, while traditional image upscaling methods may have lower results, they are computationally simple and universally compatible with various image types, making them suitable for direct application in various systems, electronic devices, and computer storage media. The most common and fast image upscaling methods currently available are linear upscaling and nearest-neighbor upscaling. The former has no blocky artifacts, but will make the image blurry when magnified; the latter is clearer, but has blocky artifacts, and these artifacts are aggravated when magnified at non-integer multiples. Both of these degrade the user's visual experience and require further improvement. Summary of the Invention

[0003] The purpose of this invention is to provide an image magnification method, system, electronic device, and computer storage medium to avoid the block effect defects of the nearest neighbor magnification algorithm while achieving the same clarity as the nearest neighbor magnification algorithm.

[0004] To achieve the above objectives, the present invention provides the following solution: An image magnification method, comprising: Obtain the first image to be magnified and the magnification factor of the first image; Based on the magnification factor, the first image is magnified using the nearest neighbor method to obtain the second image; Edge analysis is performed on the four corners of each pixel in the first image to obtain the edge matrix; The second image is adjusted based on the edge matrix to obtain the third image.

[0005] To achieve the above-mentioned technical objectives, the present invention may also provide an image magnification system, comprising: The acquisition module is used to acquire the first image to be magnified and the magnification factor of the first image; A magnification module is used to perform nearest-neighbor magnification on the first image based on the magnification factor to obtain a second image; The edge analysis module is used to perform edge analysis on the four corners of each pixel in the first image to obtain an edge matrix; The pixel value adjustment module is used to adjust the second image based on the edge matrix to obtain the third image.

[0006] To achieve the above-mentioned technical objectives, the present invention provides an electronic device comprising: One or more processors; A storage device having stored one or more programs and one or more processors; When the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to perform the method described above.

[0007] The present invention also provides a computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described above.

[0008] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects: This invention acquires a first image to be magnified and its magnification factor; performs nearest-neighbor magnification on the first image based on the magnification factor to obtain a second image; performs edge analysis on the four corners of each pixel in the first image to obtain an edge matrix; and adjusts the second image based on the edge matrix to obtain a third image. This invention is simple to execute, fast to operate, and friendly to parallel computing. It can replace existing magnification algorithms on similar hardware with minimal hardware upgrades, directly replacing them in electronic devices, computer storage media, and computer programs. In terms of performance, this invention achieves the same clarity as the nearest-neighbor magnification algorithm while avoiding the block artifacts of the nearest-neighbor magnification algorithm, significantly outperforming existing general-purpose linear magnification and nearest-neighbor magnification algorithms. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0010] Figure 1 A flowchart for image magnification; Figure 2 Example diagrams for five preliminary edge directions; Figure 3 Example diagrams for six specific edge directions, with three preliminary parallel and three perpendicular directions; Figure 4 A flowchart for calculating the specific direction of a horizontal edge; Figure 5 A flowchart for adjusting pixel values; Figure 6 A flowchart for adjusting horizontal edge pixels; Figure 7 Example image showing horizontal edge pixel adjustment; Figure 8 The diagram shows a linear, nearest-neighbor, and enlarged embodiment of the present invention for text images; Figure 9 The diagram shows a magnified embodiment of the linear, nearest neighbor, and game screenshot methods of the present invention. Figure 10 The diagram shows a linear, nearest-neighbor, and enlarged embodiment of the present invention for movie screenshots; Figure 11 The diagram shows a linear, nearest-neighbor, and magnified embodiment of the pixel-style image of the present invention. Detailed Implementation

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

[0012] The purpose of this invention is to provide an image magnification method, system, electronic device, and computer storage medium to avoid the block effect defects of the nearest neighbor magnification algorithm while achieving the same clarity as the nearest neighbor magnification algorithm.

[0013] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0014] like Figure 1 As shown, the present invention provides an image magnification method that improves upon nearest-neighbor magnification of grayscale images and can be extended to RGB color images and hyperspectral images. The image magnification method includes: Step 100: Obtain the first image to be magnified and the magnification factor of the first image.

[0015] Step 200: Perform nearest-neighbor magnification on the first image based on the magnification factor to obtain the second image.

[0016] Step 300: Perform edge analysis on the four corners of each pixel in the first image to obtain an edge matrix. Step 300 specifically includes: reducing the dimension of the first image to obtain a single-channel first image; calculating the edge score of each pixel's four corners in the single-channel first image; the edge score includes horizontal edge score, vertical edge score, diagonal edge score, horizontal convex edge score, and vertical convex edge score; classifying the edges according to the edge scores to obtain preliminary edge directions; determining the specific edge directions based on the single-channel first image and the preliminary edge directions; and recording the preliminary edge directions and the specific edge directions in the edge matrix.

[0017] Step 400: Adjust the second image based on the edge matrix to obtain a third image. Step 400 specifically includes: adjusting the horizontal edges and diagonal edges in the second image based on the edge matrix to obtain an image with adjusted horizontal edges; and adjusting the vertical edges in the image with adjusted horizontal edges to obtain the third image.

[0018] The above steps are as follows: Step 200 specifically includes: Step 201: Use the nearest neighbor algorithm to enlarge I1 to I2, where the pixel value of I2 in column x and row y is: Where, I1∈ The first image has three dimensions: the first two represent columns and rows, respectively, and the third represents the image channels. For example, an RGB image has three channels. I2∈ The second image has three dimensions: the first two represent columns and rows, respectively, and the third represents the image channels. ⌊·⌋ represents the tail removal operation. Let be a real number, and k be the magnification factor of I1. W, H, and L ∈ These represent the length, height, and number of channels, respectively. The length and width correspond to the first and second dimensions, respectively. I2(x,y,:) represents the pixel values ​​of all channels of I2 in column x and row y.

[0019] Step 300 specifically includes: Step 301: Using transspectral averaging, reduce I1 with L channels to I with 1 channel. 1g (When L=1, I) 1g =I1), that is, Among them, I 1g ∈ This is a single-channel first image with two dimensions, representing columns and rows respectively. v represents the v-th channel of I1. 1g (x,y) is I 1g The pixel value in column x and row y.

[0020] Step 310: Analysis I 1g The preliminary edge directions at the four corners of each pixel are recorded in the first channel of the fourth dimension of E. These preliminary edge directions require the calculation of the following five edge scores, which are then stored in S: horizontal edge score; vertical edge score; diagonal edge score; horizontal convex edge score; and vertical convex edge score. E∈ For I 1g The edge matrix has four dimensions. The first two dimensions represent columns and rows, respectively. The third dimension represents the four corners of a pixel (E(:,:,1,:), E(:,:,2,:), E(:,:,3,:), and E(:,:,4,:) record the information of the top-left, top-right, bottom-left, and bottom-right corners of the pixel, respectively). The fourth dimension represents two types of edge information (E(:,:,:,1) and E(:,:,:,2) record the initial edge direction and the specific edge direction, respectively). S∈ For I 1g The scoring matrix has four dimensions. The first two dimensions represent columns and rows, respectively. The third dimension represents the four corners of the pixel (S(:,:,1,:), S(:,:,2,:), S(:,:,3,:) and S(:,:,4,:) record the information of the top left, top right, bottom left and bottom right corners of the pixel, respectively). The fourth dimension represents the five types of scores mentioned above (S(:,:,:,1), S(:,:,:,2), S(:,:,:,3), S(:,:,:,4) and S(:,:,:,5) record the scores of the horizontal edge, vertical edge, diagonal edge, horizontal protruding edge and vertical protruding edge, respectively).

[0021] The initial edge direction of a pixel can be calculated using the following five scores (steps 311-315), with the lower right corner corresponding to each score. Figure 2 (a) to Figure 2 The five types of edges in (e). Figure 2 (a) in the diagram is a schematic diagram of the horizontal edge. Figure 2 (b) in the diagram is a schematic diagram of the vertical edge. Figure 2 (c) in the diagram is a schematic diagram of the diagonal edge. Figure 2 (d) in the diagram is a schematic diagram of the horizontal protruding edge. Figure 2 (e) in the diagram is a schematic representation of the vertically protruding edge. The calculation requires the use of the artificial parameter t. Ω Force ignore values ​​less than t Ω The edge. t ΩImage quality is highest when the value is 0; a value of 8 is recommended.

[0022] Step 311: Calculate I 1g Δ at column x, row y x / 2+Δ y +2.5 angle horizontal edge score: Δ x ∈{–1,1},Δ y ∈{–1,1} represents the x and y coordinates of the angle of a pixel relative to its center. Ω1 and Ω2 are both temporary pixel sets.

[0023] Step 312: Calculate I 1g Δ at column x, row y x / 2+Δ y The score for the vertical edge at a +2.5 angle is obtained by using the same formula as step 311, except for Ω1 and Ω2: Step 313: I 1g Δ at column x, row y x / 2+Δ y The diagonal edge score for +2.5 angle uses the same formula as in step 311, only Ω1 and Ω2 are different: Step 314: Calculate I 1g Δ at column x, row y x / 2+Δ y Scoring for the horizontal convex edge at a +2.5 angle, this step uses the same formula as step 311, only Ω1 and Ω2 are different: Step 315: Calculate I 1g Δ at column x, row y x / 2+Δ y Scoring for the vertical convex edge at a +2.5 angle, this step uses the same formula as step 311, only Ω1 and Ω2 are different: Step 316: Finally, calculate I based on S. 1gThe initial direction of the edge at the corner c of the pixel in column x, row y, is recorded up to the first channel of the fourth dimension of E. When all scores are 0, there is no edge; furthermore, when the diagonal edge score, horizontal convex edge score, or vertical convex edge score is the highest, it is a diagonal edge; furthermore, when the horizontal edge score or vertical edge score is the highest, and the horizontal edge score equals the vertical edge score, it is also a diagonal edge; furthermore, when the horizontal edge score is the highest, it is a horizontal edge; furthermore, when the vertical edge score is the highest, it is a vertical edge. E(x,y,c,1) is I 1g The initial direction of the edge at the corner c of pixel point c in column x and row y. c = Δ x / 2+Δ y +2.5, where c∈{1,2,3,4} represents the four corners of the pixel, (Δ x ,Δ y When ) = (–1,–1), (–1,1), (1,–1), and (1,1), c is 1, 2, 3, and 4 respectively, representing the top left, top right, bottom left, and bottom right corners of the pixel.

[0024] Step 320: Further, if I 1g If the edge at pixel c in column x, row y is either a horizontal or vertical edge, then calculate its specific edge direction n and record it in the second channel of the fourth dimension of E. The specific direction of a horizontal edge can be divided into: angles of tan... -1 The edge of (n), n∈positive integer; the angle is tan -1 The edge of (1 / n), where n ∈ positive integers. No calculation is needed; n with no edge is recorded as 0, and n with diagonal edge is recorded as 1.

[0025] Figure 3 Images (a), (b), and (c) show examples of edges with n = 1, 2, and 3 when the edges are horizontal, respectively. Figure 3 (d), (e), and (f) in the diagram show examples of edges with n = 1, 2, and 3 when the edges are vertical, respectively. The calculation requires the use of an artificial parameter t. n This controls the upper limit of n. t n Image quality is highest when the value is ∞; a value of 6 is recommended.

[0026] Step 321: As Figure 4 As shown, this step calculates I. 1g Δ at column x, row y x / 2+Δ y The specific direction of the horizontal edge at a +2.5 angle.

[0027] Step 321-1: Let n=1, Ω1={I 1g (x,y), I1g (x+Δ x ,y–Δ y ), I 1g (x–Δ x ,y)}, Ω2={I 1g (x,y+Δ y ), I 1g (x+Δ x ,y), I 1g (x–Δ x ,y+Δ y )}. Go to step 321-2.

[0028] Step 321-2: Determine the relationship between Ω1 and Ω2. If min(Ω1)>max(Ω2), go to 321-3; if min(Ω2)>max(Ω1), go to 321-4; otherwise, go to 321-6.

[0029] Step 321-3: If n<t n And (I 1g (x,y)=min(Ω1) Or max(Ω1)–min(Ω1)<min(Ω1)–max(Ω2)) And (max(I 1g (x+Δ x ,y), I in (x,y+Δ y ))=max(Ω1) Or max(Ω2)–min(Ω2)<min(Ω1)–max(Ω2)), then go to 321-5; otherwise, go to 321-6.

[0030] Step 321-4: If n<t n And (I 1g (x,y)=max(Ω1) Or max(Ω1)–min(Ω1)<min(Ω2)–max(Ω1)) And (min(I 1g (x+Δ x ,y), I 1g (x,y+Δ y ))=min(Ω2) Or max(Ω2)–min(Ω2)<min(Ω2)–max(Ω1)), then go to 321-6; otherwise, go to 321-6.

[0031] Step 321-5: Set n=n+1, add I 1g (x+n×Δ x ,y–Δ y ) and I 1g (x–n×Δ x ,y) into Ω1, I1g (x+n×Δ x ,y) and I 1g (x–n×Δ x ,y+Δ y Add Ω2.

[0032] Step 321-6: Place I 1g Δ at column x, row y x / 2+Δ y The +2.5 angle n is written into the second channel of the fourth dimension of E, that is: Step 322: Calculate I 1g Δ at column x, row y x / 2+Δ y The specific direction of the vertical edge at a +2.5 angle. The flowchart for this step is the same as that for step 321, and both can be referred to. Figure 4 Steps 322-2, 322-3, 322-4, and 322-6 are exactly the same as step 321. Steps 322-1 and 322-5 are as follows: Step 322-1: Initialization. Let n=1, Ω1={I 1g (x,y), I 1g (x–Δ x ,y+Δ y ), I 1g (x,y–Δ y )},Ω2={I 1g (x+Δ x ,y), I 1g (x,y+Δ y ), I 1g (x+Δ x ,y–Δ y )}.

[0033] Step 322-5: Adjust n, Ω1, and Ω2. Let n = n + 1, and adjust I... 1g (x–Δ x ,y+n×Δ y ) and I 1g (x,y–n×Δ y Add Ω1, I 1g (x,y+n×Δ y ) and I 1g (x+Δ x ,y–n×Δ y Add Ω2.

[0034] Step 400 specifically includes: Step 401: such as Figure 5As shown, this step adjusts I2 based on E to obtain I3. This invention adjusts the horizontal, vertical, and diagonal edges simultaneously, or alternatively, the diagonal, horizontal, and vertical edges can be adjusted sequentially. I3∈ The third image has three dimensions: the first two dimensions represent columns and rows, and the third dimension represents the image channels.

[0035] Step 401-1: Copy all pixel values ​​from I2 to I3. The pixel values ​​of I3 in column x and row y are: Step 401-2: Run a for loop, initialize x=1, loop x=x+1, until x is no longer ≤W.

[0036] Step 401-3: Inside the for loop in step 401-2, perform a second for loop, initialize y=1, loop y=y+1, until y is no longer ≤H.

[0037] Step 401-4: Inside the for loop of step 401-3, perform the third for loop to initialize Δ. x =-1, loop Δ x =Δ x +2, until Δ x No longer ≤1.

[0038] Step 401-5: Inside the for loop of step 401-4, perform the fourth for loop to initialize Δ. y =-1, loop Δ y =Δ y +2, until Δ y No longer ≤1.

[0039] Step 401-6: Within the for loop of step 401-5, determine the edge properties of the current angle. If E(x,y,Δ) x / 2+Δ y +2.5,1) = horizontal edge or diagonal edge, then run step 410; if E(x,y,Δ) = horizontal edge or diagonal edge, then run step 410; x / 2+Δ y If +2.5,1) = vertical edge, then run step 420; if E(x,y,Δ) x / 2+Δ y If +2.5,1) = no edge, then proceed to the next 401-5 for loop.

[0040] Step 410: As Figure 6As shown, this step adjusts the horizontal edge pixels of pixel I3, which corresponds to the pixel c-angle of I1 in column x, row y. This step only adjusts I3, and the corresponding pixel set is the c-angle of the rectangle I3([k×(x-1)]+1:[k×x],[k×(y-1)]+1:[k×y]). The adjustment effect is as follows. Figure 7 As shown, [·] represents rounding. The set of pixels to be adjusted is roughly a right triangle, and the height H of this triangle needs to be calculated. Δ and bottom length W Δ .

[0041] Step 410-1: Initialize I 1g Δ at column x, row y x / 2+Δ y p, d at +2.5 angle x d y And n. Where p is the pixel value to be replaced, which takes the value of the pixel in column x and row y as Δ. x Direction and Δ y The direction is the pixel closest to it, that is: |·| represents the absolute value operation. n is the pixel value in column x and row y. Δ x / 2+Δ y The specific direction of the edge at a +2.5 angle, namely: And d x and d y These are all temporary variables, used to facilitate writing the following formulas, respectively: Step 410-2: Calculate the Δ value of I1 at the pixel point in column x and row y. x / 2+Δ y The height H of the triangle with a +2.5 angle Δ ,Right now: · This is for rounding up to the nearest integer.

[0042] Step 410-3: Perform a for loop, initializing i=0, looping i=i+1, until i is no longer ≤H. Δ 'i' represents the vertical position of the pixel to be adjusted within the triangle.

[0043] Step 410-4: Within the for loop of step 410-3, calculate the Δ value of pixel I1 in column x and row y. x / 2+Δ y The base length W of the triangle with a +2.5 angle Δ ,Right now: Step 410-5: Similarly, within the for loop of step 410-3, perform a second for loop, initializing j=0, looping j=j+1, until j is no longer ≤ W. Δ j represents the horizontal position of the pixel to be adjusted within the triangle.

[0044] Step 410-6: Within the for loop of step 410-5, adjust the pixel value of I3([k×x]-i,[k×y]-j,:). When j <W Δ If the value is p, adjust this pixel to p; otherwise, adjust this pixel to the weighted average of p and I1(x,y), that is: in, k p The weights are for the weighted average.

[0045] Step 420: For I 1g In column x, row y, pixel Δ x / 2+Δ y Adjust the vertical edge pixels of I3 corresponding to the +2.5 angle. The flowchart for this step is the same as that for step 410, and both can be referred to. Figure 6 Steps 420-2, 420-3, 420-4, and 420-5 are exactly the same as step 410. The different steps 420-1 and 420-6 are as follows: Step 420-1: Calculate I 1g In column x, row y, pixel Δ x / 2+Δ y p, d at +2.5 angle x d y And n. The formulas for calculating p and n are exactly the same as in step 410-1, while d... x and d y They are respectively: Step 420-6: Within the for loop of step 420-5, adjust the pixel value of I3([k×x]-j,[k×y]-i,:). When j <W Δ If the value is p, adjust this pixel to p; otherwise, adjust this pixel to the weighted average of p and I1(x,y), that is: in, .

[0046] This embodiment provides an image magnification method based on nearest neighbor, including: acquiring a first image to be magnified and a magnification factor of the first image; performing nearest neighbor magnification on the first image based on the magnification factor to obtain a second image; performing edge analysis on the four corners of each pixel in the first image to obtain an edge matrix; and adjusting the second image based on the edge matrix to obtain a third image. This algorithm requires no preprocessing, pre-training, or post-processing steps, thus featuring fast computation, simple deployment, the same clarity as the nearest neighbor magnification algorithm, and the absence of the block artifacts inherent in the nearest neighbor magnification algorithm.

[0047] To demonstrate the effectiveness and generalization performance of the method of this invention, this embodiment inputs four types of images (text, games, movies, pixel art) and four magnification levels (4 / 3x, 1.5x, 2x, 3x), and respectively... Figures 8 to 11 Display the magnified visual effects of these four types of images. Among them, Figure 8 Targeted text images, Figure 9 This refers to the game graphics. Figure 10 It is aimed at movie images. Figure 11 It is designed for pixel-style images. Figures 8 to 11 (a) in the text refers to the input image. Figures 8 to 11 (b) in the image are all linearly magnified images at a magnification of 4 / 3. Figures 8 to 11 In the examples (c), the nearest neighbor magnification is 4 / 3 times. Figures 8 to 11 In the figures (d), all images are magnified 4 / 3 times according to the present invention. Figures 8 to 11 In the image, (e) represents a linear magnification of 1.5 times. Figures 8 to 11 In the examples, (f) represents the nearest neighbor magnification image at a factor of 1.5. Figures 8 to 11 In the image (g), all images are magnified 1.5 times according to the present invention. Figures 8 to 10 In the image, (h) represents a linearly magnified image of 2x. Figures 8 to 10 In the image, (i) represents a magnified nearest neighbor image of 2x. Figures 8 to 10 In the figures (j), each image is a 2x magnified image as presented in this invention. Figures 8 to 10 In the image, (k) represents a linear magnification of 3 times. Figures 8 to 10 In the image, (l) represents a 3x magnified nearest neighbor image. Figures 8 to 10 In the above examples, (m) represents a 3x magnified image as proposed in this invention. Note: All images in the above embodiments have been fixed at 100% scaling.

[0048] Figure 8The magnified effect of the text image is shown. It is clear that the magnification effect of this invention is sharper than linear magnification, and the sharper the magnification, the clearer it becomes. On the other hand, the nearest neighbor method distorts the image at non-integer magnification (4 / 3x, 1.5x) and exhibits noticeable blockiness at high magnification (2x, 3x). These defects are not present in the magnified image of this invention.

[0049] Figure 9 The image shows a magnified screenshot of the game. As can be seen in this embodiment, nearest-neighbor magnification produces a noticeable blocky effect, such as the tree branches on the left. This blocky effect can even be observed in linear magnification. In contrast, this invention makes the edges of the tree branches smoother to the greatest extent possible, and the smoother the effect becomes with increasing magnification. This invention achieves the best magnification effect in this embodiment.

[0050] Figure 10 The image shows a magnified view of a noisy movie screenshot. This invention can effectively track the direction of hair and muscle texture, making them clearer without producing a blocky effect.

[0051] Figure 11 The magnification effect of a pixel-style image is shown. Images magnified using this invention retain this pixel style without modifying any parameters, producing a magnified image identical to the nearest neighbor image.

[0052] Summarize Figures 8 to 11 This invention achieves the best results among the three magnification algorithms mentioned above, and is particularly well-suited for magnifying game screenshots. Furthermore, this invention can effectively track the direction of fine textures in relatively noisy images and intelligently preserve pixel style caused by block artifacts. Therefore, this invention can meet the image magnification needs of most scenarios.

[0053] This invention features simple calculation, clear magnified images, and no blockiness. It can replace existing general magnification algorithms—nearest neighbor magnification and linear magnification—on the displays of various software, applications, and systems. Compared to nearest neighbor magnification, this invention offers the same clarity without the blockiness issues of near neighbor magnification; compared to linear magnification, this invention provides greater clarity, significantly improving the visual effect. Although this invention is relatively complex compared to linear magnification and nearest-neighbor magnification, it only uses basic operations such as addition, subtraction, multiplication, division, and numerical comparison, with fewer steps and extremely fast computation speed. Furthermore, these basic operations can significantly reduce hardware complexity during deployment. In addition, most of the computations in this invention can be performed in parallel on a GPU platform, thus achieving real-time image magnification with low power consumption, high resolution, and high refresh rate.

[0054] In summary, this invention can directly replace existing common linear magnification and nearest-neighbor magnification algorithms on the display end of various software, applications, and systems, based on similar hardware and requiring virtually no hardware upgrades. Compared with linear magnification and nearest-neighbor magnification, the magnification algorithm of this invention has significant advantages in visual effects, while possessing fewer imperfections from linear magnification and a clearer image from nearest-neighbor magnification.

[0055] The present invention provides an image magnification system, comprising: The acquisition module is used to acquire the first image to be magnified and the magnification factor of the first image.

[0056] The magnification module is used to perform nearest-neighbor magnification on the first image based on the magnification factor to obtain the second image.

[0057] The edge analysis module is used to perform edge analysis on the four corners of each pixel in the first image to obtain an edge matrix.

[0058] The pixel value adjustment module is used to adjust the second image based on the edge matrix to obtain the third image.

[0059] In practical applications, the edge analysis module specifically includes: The channel reduction unit is used to reduce the dimension of the first image to obtain a single-channel first image. An edge score calculation unit is used to calculate the direction score of the edges at the four corners of each pixel based on the single-channel first image; the direction score includes horizontal direction score, vertical direction score, diagonal direction score, horizontal convex edge score, and vertical convex edge score; An edge preliminary classification unit is used to classify edges based on their scores to obtain preliminary edge directions. The edge specific direction determination unit is used to determine the specific direction of the edge based on the single-channel first image and the preliminary edge direction; An edge matrix determination unit is used to record the preliminary direction of the edge and the specific direction of the edge into an edge matrix.

[0060] In practical applications, the pixel value adjustment module specifically includes: The pixel value adjustment unit is used to adjust the horizontal edge pixels of the horizontal edge and the diagonal edge in the second image based on the edge matrix to obtain an image with adjusted horizontal edge pixels; and to adjust the vertical edge pixels of the image with adjusted horizontal edge pixels to obtain a third image.

[0061] Meanwhile, the present invention provides an electronic device, comprising: A storage device on which one or more programs are stored; One or more processors; When the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to perform the method as described in any of the foregoing.

[0062] The present invention provides a computer storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the method described in any of the above-mentioned embodiments.

[0063] The present invention also provides a computer program product that, when the instructions in the computer program product are executed by a processor, implements the method as described in any of the above.

[0064] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.

[0065] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. An image magnification method, characterized in that, include: Obtain the first image to be magnified and the magnification factor of the first image; Based on the magnification factor, the first image is magnified using the nearest neighbor method to obtain the second image; Edge analysis is performed on the four corners of each pixel in the first image to obtain an edge matrix. Specifically, this includes: reducing the dimension of the first image to obtain a single-channel first image; calculating the edge score of each pixel's four corners in the single-channel first image; the edge score includes horizontal edge score, vertical edge score, diagonal edge score, horizontal convex edge score, and vertical convex edge score; classifying the edges based on the edge scores to obtain preliminary edge directions; determining the specific edge directions based on the single-channel first image and the preliminary edge directions; and recording the preliminary edge directions and the specific edge directions in the edge matrix E; where E is the first image I. 1g The edge matrix has four dimensions. The first two dimensions represent columns and rows, respectively. The third dimension represents the four corners of a pixel, with E(:,:,1,:), E(:,:,2,:), E(:,:,3,:), and E(:,:,4,:) recording the information of the top-left, top-right, bottom-left, and bottom-right corners of the pixel, respectively. The fourth dimension represents two types of edge information, with E(:,:,:,1) and E(:,:,:,2) recording the initial edge direction and the specific edge direction, respectively. S is the first image I. 1g The scoring matrix has four dimensions. The first two dimensions represent columns and rows, respectively. The third dimension represents the four corners of the pixel. S(:,:,1,:), S(:,:,2,:), S(:,:,3,:), and S(:,:,4,:) record the information of the top left, top right, bottom left, and bottom right corners of the pixel, respectively. The fourth dimension represents the above five scores. S(:,:,:,1), S(:,:,:,2), S(:,:,:,3), S(:,:,:,4), and S(:,:,:,5) record the scores of the horizontal edge, vertical edge, diagonal edge, horizontal protruding edge, and vertical protruding edge, respectively. Calculating the initial direction of the edge includes: calculating the first image I of a single channel. 1g Δ at column x, row y x / 2+Δ y +2.5 angle horizontal edge score: ; Δ x ∈{–1,1},Δ y ∈{–1,1} represents the x and y coordinates of the relative position of the pixel's angle with respect to the pixel's center, (Δ x ,Δ y When ) = (–1,–1), (–1,1), (1,–1), and (1,1), c is 1, 2, 3, and 4 respectively, representing the top-left, top-right, bottom-left, and bottom-right corners of the pixel; Ω1 and Ω2 are both temporary pixel sets; S is the score matrix; t Ω These are manual parameters. The calculation methods for vertical edge score, diagonal edge score, horizontal convex edge score, and vertical convex edge score are the same as those for horizontal edge score, only Ω1 and Ω2 are different; Calculate I 1g Δ at column x, row y x / 2+Δ y When scoring at a vertical edge angle of +2.5, ; I 1g Δ at column x, row y x / 2+Δ y When scoring at the diagonal edge of +2.5 angle, ; Calculate I 1g Δ at column x, row y x / 2+Δ y When scoring at a +2.5 angle horizontal convex edge. ; Calculate I 1g Δ at column x, row y x / 2+Δ y When scoring for a vertical convex edge with a +2.5 angle, ; Based on S-computation 1g The initial direction of the edge at the corner c of the pixel point in column x, row y is recorded up to the first channel of the fourth dimension of E; when all scores are 0, there is no edge; when the diagonal edge score, horizontal convex edge score, or vertical convex edge score is the highest, it is a diagonal edge; when the horizontal edge score or vertical edge score is the highest, and the horizontal edge score is equal to the vertical edge score, it is a diagonal edge; when the horizontal edge score is the highest, it is a horizontal edge; when the vertical edge score is the highest, it is a vertical edge. If I 1g If the edge of pixel c in column x, row y is either a horizontal or vertical edge, then calculate its specific edge direction n and record it in the second channel of the fourth dimension of E; the specific direction of a horizontal edge can be divided into: angle tan -1 The edge of (n), n∈positive integer, with an angle of tan -1 (1 / n) edge; n is recorded as 0 for no edge, and n is recorded as 1 for diagonal edge; Calculate I 1g Δ at column x, row y x / 2+Δ y The specific direction of the horizontal edge at a +2.5 angle; Step 321-1: let n=1, Ω₁={I 1g (x,y),I 1g (x+Δ x ,y–Δ y ),I 1g (x–Δ x ,y)}, Ω₂={I 1g (x,y+Δ y ),I 1g (x+Δ x ,y),I 1g (x–Δ x ,y+Δ y )}; proceed to step 321-2; Step 321-2: Determine the relationship between Ω1 and Ω2; if min(Ω1) > max(Ω2), then proceed to step 321-3; if min(Ω2) > max(Ω1), then proceed to step 321-4; otherwise, proceed to step 321-6. Step 321-3: if n<t n And(I 1g (x,y)=min(Ω1)Or max(Ω1)–min(Ω1)<min(Ω1)–max(Ω2))And(max(I 1g (x+Δ x ,y),I in (x,y+Δ y ))=max(Ω1)Or max(Ω2)–min(Ω2)<min(Ω1)–max(Ω2)), then execute 321-5; otherwise, execute 321-6; t n is a manual parameter; Step 321-4: if n<t n And(I 1g (x,y)=max(Ω1)Or max(Ω1)–min(Ω1)<min(Ω2)–max(Ω1))And(min(I 1g (x+Δ x ,y),I 1g (x,y+Δ y ))=min(Ω2)Or max(Ω2)–min(Ω2)<min(Ω2)–max(Ω1)), then execute 321-6; otherwise, execute 321-6; Step 321-5: Let n = n + 1, and set I... 1g (x+n×Δ x ,y–Δ y ) and I 1g (x–n×Δ x Add Ω1, I to y) 1g (x+n×Δ x ,y) and I 1g (x–n×Δ x ,y+Δ y Add Ω2; Step 321-6: Place I 1g Δ at column x, row y x / 2+Δ y The +2.5 angle n is written into the second channel of the fourth dimension of E, that is: ; Calculate I 1g Δ at column x, row y x / 2+Δ y The specific direction of the vertical edge at a +2.5 angle is calculated using the same steps as the specific direction of the horizontal edge, except that step 322-1: initialization; let n=1, Ω1={I 1g (x,y),I 1g (x–Δ x ,y+Δ y ),I 1g (x,y–Δ y )},Ω2={I 1g (x+Δ x ,y),I 1g (x,y+Δ y ),I 1g (x+Δ x ,y–Δ y )}; Step 322-5: Let n = n + 1, and set I... 1g (x–Δ x ,y+n×Δ y ) and I 1g (x,y–n×Δ y Add Ω1, I 1g (x,y+n×Δ y ) and I 1g (x+Δ x ,y–n×Δ y Add Ω2; Adjusting the second image based on the edge matrix to obtain the third image specifically includes: adjusting the horizontal edges and diagonal edges of the second image based on the edge matrix to obtain an image with adjusted horizontal edges; and adjusting the vertical edges of the image with adjusted horizontal edges to obtain the third image. Copy all pixel values ​​from the second image I2 to the third image I3, and determine the edge properties of the current corner; if E(x,y,Δ) x / 2+Δ y +2.5,1) = horizontal edge or diagonal edge, then run step 410; if E(x,y,Δ) = horizontal edge or diagonal edge, then run step 410; x / 2+Δ y If +2.5,1) = vertical edge, then run step 420; if E(x,y,Δ) x / 2+Δ y If +2.5,1) = no edge, then continue copying; Step 410: Adjust the horizontal edge pixels of pixel I3 corresponding to the corner c of pixel I1 in column x, row y of the first image; only adjust I3, and the corresponding pixel set is the corner c of the rectangle I3([k×(x-1)]+1:[k×x],[k×(y-1)]+1:[k×y]); k is the magnification factor of the first image; Step 410-1: Initialize I 1g Δ at column x, row y x / 2+Δ y p, d at +2.5 angle x d y and n; where p is the pixel value to be replaced, and its value is the pixel value at column x and row y, Δ. x Direction and Δ y The direction is the pixel closest to it; d x d y For temporary variables; ; Step 410-2: Calculate the Δ value of I1 at the pixel point in column x and row y. x / 2+Δ y The height H of the triangle with a +2.5 angle Δ ; Step 410-3: Perform a for loop, initializing i=0, looping i=i+1, until i is no longer ≤H. Δ ; i is the vertical position of the pixel to be adjusted in the triangle; Step 410-4: Within the for loop of step 410-3, calculate the Δ value of pixel I1 in column x and row y. x / 2+Δ y The base length W of a triangle with a +2.5 angle Δ ; Step 410-5: Similarly, within the for loop of step 410-3, perform a second for loop, initializing j=0, looping j=j+1, until j is no longer ≤ W. Δ j represents the horizontal position of the pixel to be adjusted within the triangle. Step 410-6: Within the for loop of step 410-5, adjust the pixel value of I3([k×x]-i,[k×y]-j,:); when j <W Δ If the value is p, adjust this pixel to p; otherwise, adjust this pixel to the weighted average of p and I1(x,y). Step 420: For I 1g In column x, row y, pixel Δ x / 2+Δ y Adjust the vertical edge pixels of I3 corresponding to the +2.5 angle; this step is the same as step 410. Steps 420-1 and 410-1 are completely identical, differing only in the temporary variables. Steps 420-2, 420-3, 420-4, and 420-5 are completely identical to steps 410-2, 410-3, 410-4, and 410-5. The difference between step 420-6 and step 410-6 is that: within the for loop of step 420-5, the pixel value of I3([k×x]-j,[k×y]-i,:) is adjusted.

2. An image magnification system, characterized in that, The image magnification system employs the image magnification method of claim 1, and the image magnification system comprises: The acquisition module is used to acquire the first image to be magnified and the magnification factor of the first image; A magnification module is used to perform nearest-neighbor magnification on the first image based on the magnification factor to obtain a second image; The edge analysis module is used to perform edge analysis on the four corners of each pixel in the first image to obtain an edge matrix; The pixel value adjustment module is used to adjust the second image based on the edge matrix to obtain the third image.

3. The image magnification system according to claim 2, characterized in that, The edge analysis module specifically includes: The channel reduction unit is used to reduce the dimension of the first image to obtain a single-channel first image; An edge score calculation unit is used to calculate the direction score of the edges at the four corners of each pixel in the single-channel first image; the direction score includes horizontal direction score, vertical direction score, diagonal direction score, horizontal convex edge score, and vertical convex edge score. An edge preliminary direction determination unit is used to classify edges based on the edge scores to obtain preliminary edge directions; The edge specific direction determination unit is used to determine the specific direction of the edge based on the single-channel first image and the preliminary edge direction; An edge matrix determination unit is used to record the preliminary direction of the edge and the specific direction of the edge into an edge matrix.

4. The image magnification system according to claim 2, characterized in that, The pixel value adjustment module specifically includes: A pixel value adjustment unit is used to adjust the horizontal edge pixels of the horizontal edges and diagonal edges in the second image based on the edge matrix; to obtain an image with adjusted horizontal edge pixels; and to adjust the vertical edges of the image with adjusted horizontal edge pixels to obtain a third image.

5. An electronic device, characterized in that, include: One or more processors; A storage device on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the method as described in claim 1.

6. A computer storage medium, characterized in that, It stores a computer program thereon, wherein the computer program, when executed by a processor, implements the method as described in claim 1.