Picture scaling method and apparatus, and storage medium
By using multiple convolution centers and adaptive scaling factors during image scaling, the problem of uneven image edges is solved, achieving smoother image edges and improved scaling efficiency.
Patent Information
- Application Number
- PCT/CN2025/091018
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-08-09
- Filing Date
- 2025-04-24
- Publication Date
- 2026-02-12
AI Technical Summary
In existing technologies, image edges appear jagged and stepped after scaling, resulting in uneven edges.
Image scaling is achieved using a method based on multiple convolution centers and adaptive scaling factors. By calculating the vertical and horizontal convolution centers and convolution weights, frequency domain aliasing is avoided, ensuring smooth image edges.
It achieves smooth image edges, avoids the appearance of jagged edges, and improves the flexibility and efficiency of image scaling.
Smart Images

Figure CN2025091018_12022026_PF_FP_ABST
Abstract
Description
Method, device and storage medium for scaling picture
[0001] The present application claims priority to the Chinese patent application No. 202411097695.X, filed on August 9, 2024, and entitled "Method, device and storage medium for scaling picture", the entire content of which is incorporated herein by reference. TECHNICAL FIELD
[0002] The present application relates to the field of image processing, in particular to a method, device and storage medium for scaling picture. BACKGROUND
[0003] Picture scaling refers to starting from an original picture, reducing or increasing the number of pixels in the original picture to achieve the purpose of reducing or enlarging the original picture. Picture scaling, as a basic image processing operation, is widely used in terminal devices, such as mobile phones, watches, computers and other terminal devices.
[0004] In the related art, after scaling the original picture into a target picture, the image edges included in the target picture have stepped jaggies, resulting in unsmooth image edges in the target picture. For example, an original picture with a size of 1024*1024 includes a fruit image, after scaling the original picture into a target picture with a size of 135*135, the edges of the fruit image included in the target picture have stepped jaggies, making the edges of the fruit image included in the target picture unsmooth. SUMMARY
[0005] The present application provides a method, device and storage medium for scaling picture to make the image edges in the picture smooth. The technical solution is as follows:
[0006] In a first aspect, the present application provides a method for scaling picture, in which a plurality of convolution centers are obtained based on a scaling coefficient, the scaling coefficient is a coefficient for scaling an original picture, the plurality of convolution centers are used to scale the width and / or height of the original picture, the original picture includes Q rows and K columns of pixel points, Q and K are both integers greater than 1. The original picture is scaled based on the plurality of convolution centers and the scaling coefficient to obtain a target picture, the target picture includes M rows and N columns of pixel points, M and N are both integers greater than 1, and M is not equal to Q and / or N is not equal to K.
[0007] The scaling coefficient is introduced in the process of scaling the original picture based on the plurality of convolution centers, so that the scaling process is adaptively adjusted with the scaling coefficient when the original picture is scaled, so that the image edges in the target picture do not have stepped jaggies, and the image edges become smooth.
[0008] In a possible implementation, the plurality of convolution centers comprises M longitudinal convolution centers and / or N transverse convolution centers, the M longitudinal convolution centers are used to scale the height of the original picture, and the N transverse convolution centers are used to scale the width of the original picture. The scaling coefficients comprise longitudinal scaling coefficients and / or transverse scaling coefficients, the longitudinal scaling coefficients are equal to M / Q, and the transverse scaling coefficients are equal to N / K.
[0009] In another possible implementation, the plurality of convolution centers comprises M longitudinal convolution centers and N transverse convolution centers, and the scaling coefficients comprise longitudinal scaling coefficients and transverse scaling coefficients. The width of the original picture is scaled based on the N transverse convolution centers and the transverse scaling coefficients to obtain a first intermediate picture, the first intermediate picture comprises Q rows and N columns of pixel points. The height of the first intermediate picture is scaled based on the M longitudinal convolution centers and the longitudinal scaling coefficients to obtain the target picture. In this way, the width of the original picture is scaled first and then the height is scaled, improving the flexibility of scaling.
[0010] In another possible implementation, a plurality of first pixel points are obtained from mth row pixel points comprised in the original picture based on the nth transverse convolution center, n=0, 1, 2, …, N-1, m=0, 1, 2, …, Q-1, the plurality of first pixel points comprise at least one first pixel point with a column number less than or equal to the nth transverse convolution center and at least one first pixel point with a column number greater than the nth transverse convolution center. A convolution weight of each first pixel point is obtained based on the column number of each first pixel point, the nth transverse convolution center, and the transverse scaling coefficient. A pixel point in the mth row and the nth column comprised in the first intermediate picture is obtained based on each first pixel point and the convolution weight of each first pixel point.
[0011] In another possible implementation, the number of the plurality of first pixel points is equal to a first number, and the first number is determined based on the transverse scaling coefficient. The first number is the length of the transverse convolution window, and the first number is determined based on the transverse scaling coefficient, so that the length of the transverse convolution window is adaptively adjusted according to the transverse scaling coefficient, and the smoothness of the image edge in the target picture can be further improved.
[0012] In another possible implementation, the number of the plurality of first pixel points is equal to a first number, and the first number is determined based on the transverse scaling coefficient. The first number is the length of the transverse convolution window, and the first number is determined based on the transverse scaling coefficient, so that the length of the transverse convolution window is adaptively adjusted according to the transverse scaling coefficient, and the smoothness of the image edge in the target picture can be further improved.
[0013] In another possible implementation, based on the vth longitudinal convolution center, a plurality of second pixel points are obtained from the kth column of pixel points included in the first intermediate picture, v = 0, 1, 2, …, M-1, k = 0, 1, 2, …, N-1, the plurality of second pixel points include at least one second pixel point with a row number less than or equal to the vth longitudinal convolution center and at least one second pixel point with a row number greater than the vth longitudinal convolution center. A convolution weight of each second pixel point is obtained based on the row number of each second pixel point, the vth longitudinal convolution center, and a longitudinal scaling factor. A pixel point in the vth row and the kth column included in the target picture is obtained based on each second pixel point and the convolution weight of each second pixel point.
[0014] In the formula, since the convolution weight of each second pixel point is obtained based on the row number of each second pixel point, the vth longitudinal convolution center, and the longitudinal scaling factor, the frequency domain aliasing does not occur when the picture is scaled by using the horizontal scaling factor and the longitudinal scaling factor. The convolution kernel function used for the convolution operation is adaptively adjusted according to the scaling factor, so that the distance between each second pixel point in the convolution window and the convolution center is adjusted by the scaling factor, the frequency domain aliasing is avoided when the picture is scaled, and the convolution weight is changed when the scaling factor is changed, so that the image edges in the target picture obtained by scaling do not have stepped sawtooth edges, and the image edges are smoothed.
[0015] In another possible implementation, the number of the plurality of second pixel points is equal to a second number, and the second number is determined based on the longitudinal scaling factor. The second number is the height of the longitudinal convolution window, and the second number is determined based on the longitudinal scaling factor, so that the height of the longitudinal convolution window is adaptively adjusted according to the longitudinal scaling factor, and the smoothness of the image edges in the target picture can be further improved.
[0016] In another possible implementation, the plurality of convolution centers include M longitudinal convolution centers and N horizontal convolution centers, and the scaling factor includes a longitudinal scaling factor and a horizontal scaling factor. The height of the original picture is scaled based on the M longitudinal convolution centers and the longitudinal scaling factor to obtain a second intermediate picture, and the second intermediate target picture includes M rows and K columns of pixel points. The width of the second intermediate picture is scaled based on the N horizontal convolution centers and the horizontal scaling factor to obtain the target picture. In this way, the height of the original picture can be scaled first and then the width can be scaled, and the flexibility of scaling can be improved.
[0017] In another possible implementation, the plurality of convolution centers includes M longitudinal convolution centers and N transverse convolution centers, and the scaling coefficients include longitudinal scaling coefficients and transverse scaling coefficients. An image region is obtained from the original picture based on an nth transverse convolution center and an mth longitudinal convolution center, n = 0, 1, 2, …, N-1, m = 0, 1, 2, …, M-1, the image region including a plurality of rows and a plurality of columns of pixels, the plurality of columns of pixels in the image region including at least one column of pixels with a column number less than or equal to the nth transverse convolution center and at least one column of pixels with a column number greater than the nth transverse convolution center, and the plurality of rows of pixels in the image region including at least one row of pixels with a row number less than or equal to the mth longitudinal convolution center and at least one row of pixels with a row number greater than the mth longitudinal convolution center. A transverse convolution weight of each pixel in the image region is obtained based on a column number of the pixel, the nth transverse convolution center, and the transverse scaling coefficients. A longitudinal convolution weight of each pixel in the image region is obtained based on a row number of the pixel, the mth longitudinal convolution center, and the longitudinal scaling coefficients. A pixel in an mth row and an nth column included in the target picture is obtained based on each pixel, the transverse convolution weight of the pixel, and the longitudinal convolution weight of the pixel. In this way, the width and the height of the original picture can be scaled simultaneously, and the scaling efficiency is improved.
[0018] In a second aspect, the present application provides a device for scaling a picture, configured to perform the method in the first aspect or any possible implementation of the first aspect. Specifically, the device includes units for performing the method in the first aspect or any possible implementation of the first aspect.
[0019] In a third aspect, the present application provides a computing device cluster, including at least one computing device, each computing device including a processor and a memory;
[0020] The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster performs the method in the first aspect or any possible implementation of the first aspect.
[0021] In a fourth aspect, the present application provides a computer program product including instructions, which, when executed by a computing device cluster, cause the computing device cluster to perform the method in the first aspect or any possible implementation of the first aspect.
[0022] In a fifth aspect, the present application provides a computer-readable storage medium including computer program instructions, which, when executed by a computing device cluster, cause the computing device cluster to perform the method in the first aspect or any possible implementation of the first aspect.
[0023] In a sixth aspect, this application provides a chip including a memory and a processor, wherein the memory is used to store computer instructions, and the processor is used to call and execute the computer instructions from the memory to perform the method in the first aspect or any possible implementation thereof. Attached Figure Description
[0024] Figure 1 is a schematic diagram of the structure of a computing device provided in an embodiment of this application;
[0025] Figure 2 is a schematic diagram of another computing device provided in an embodiment of this application;
[0026] Figure 3 is a flowchart of a method for scaling an image according to an embodiment of this application;
[0027] Figure 4 is a schematic diagram of a scaled image provided in an embodiment of this application;
[0028] Figure 5 is a schematic diagram of another scaled image provided in an embodiment of this application;
[0029] Figure 6 is a schematic diagram of another scaled image provided in an embodiment of this application;
[0030] Figure 7 is a flowchart of another method for scaling images provided in an embodiment of this application;
[0031] Figure 8 is a schematic diagram of another scaled image provided in an embodiment of this application;
[0032] Figure 9 is a schematic diagram of another scaled image provided in an embodiment of this application;
[0033] Figure 10 is a flowchart of another method for scaling images provided in an embodiment of this application;
[0034] Figure 11 is a schematic diagram of another scaled image provided in an embodiment of this application;
[0035] Figure 12 is a schematic diagram of a device structure for scaling images provided in an embodiment of this application;
[0036] Figure 13 is a schematic diagram of the structure of a computing device provided in an embodiment of this application;
[0037] Figure 14 is a schematic diagram of a cluster structure for scaling images provided in an embodiment of this application;
[0038] Figure 15 is a schematic diagram of another cluster structure for scaling images provided in an embodiment of this application. Detailed Implementation
[0039] The image zoom function is used to reduce the size of an image or increase its size.
[0040] In some embodiments, the picture scaling operation implemented by the picture scaling function can include one or more of the following operations: reducing the width of the picture, reducing the height of the picture, reducing the width and height of the picture, reducing the width and enlarging the height of the picture, enlarging the width and reducing the height of the picture, enlarging the width of the picture, enlarging the height of the picture, or enlarging the width and height of the picture.
[0041] The picture scaling function can be applied to a computing device that has an application scenario of picture scaling. The application scenario uses the picture scaling function to scale a picture to meet the requirements of high-end and delicate visual effects. Optionally, the computing device can be a device in a mobile phone, a computer, a server, or a cloud service platform.
[0042] For example, there is an icon scaling application scenario of "one-key skin changing" on a terminal device such as a mobile phone or a computer. The original picture that needs to be scaled in the icon scaling application scenario is an icon. The target picture is obtained by scaling the width and / or height of the original picture, the target picture is used as a new icon, and the original icon is replaced by the new icon to achieve the "one-key skin changing" visual effect.
[0043] For another example, there is a theme wallpaper scaling application scenario on a terminal device such as a mobile phone or a computer. The original picture that needs to be scaled in the theme wallpaper scaling application scenario is a theme wallpaper. The target picture is obtained by scaling the width and / or height of the original picture, the target picture is used as a new wallpaper, and the new wallpaper is displayed on the desktop of the terminal device.
[0044] Referring to FIG. 1, the computing device includes an application layer, a framework layer, and a system foundation service layer. The application layer is used to run different applications installed on the computing device. The framework layer includes at least one interface. The system foundation service layer includes at least one function corresponding to the at least one interface.
[0045] When a target application needs to execute a certain function, the target application can determine the interface corresponding to the function. The target application is a certain application running on the application layer. The target application calls the function through the interface and executes the function.
[0046] For example, referring to FIG. 2, the application layer of the computing device is used to run applications such as a player, a wallpaper, and a camera. The framework layer includes management interfaces, scaling interfaces, and encoding interfaces. The system foundation service layer includes plug-in management functions, picture scaling functions, and image encoding functions. The management interfaces correspond to the plug-in management functions. The scaling interfaces correspond to the picture scaling functions. The encoding interfaces correspond to the image encoding functions.
[0047] When the picture scaling function needs to be executed, an application such as a player, a wallpaper, or a camera located at the application layer can call the picture scaling function through the scaling interface, and scale the picture by executing the picture scaling function. The picture can be scaled by using a filtering algorithm in a non-adaptive scaling algorithm. For details of the implementation of scaling the picture, refer to any of the embodiments.
[0048] Referring to FIG. 3, the embodiment of the present application provides a method 300 of scaling a picture. The execution subject of the method 300 can be the computing device shown in FIG. 1 or FIG. 2. The method 300 is used to scale the width of an original picture to obtain a first intermediate picture, the original picture includes Q rows and K columns of pixel points, the first intermediate picture includes Q rows and N columns of pixel points, scale the height of the first intermediate picture to obtain a target picture, the target picture includes M rows and N columns of pixel points, M, N, Q, and K are all integers greater than 1, M is not equal to Q and / or N is not equal to K. The method 300 includes the following processes.
[0049] In step 301, a plurality of convolution centers are obtained based on a scaling coefficient. The plurality of convolution centers include M longitudinal convolution centers and / or N transverse convolution centers. The M longitudinal convolution centers are used to scale the height of the original picture, and the N transverse convolution centers are used to scale the width of the original picture.
[0050] The scaling coefficient is a coefficient for scaling the original picture to the target picture. The scaling coefficient includes a longitudinal scaling coefficient and / or a transverse scaling coefficient. The longitudinal scaling coefficient is equal to M / Q, and the transverse scaling coefficient is equal to N / K.
[0051] In a case where the width of the original picture needs to be reduced or the width of the original picture needs to be enlarged, the N transverse convolution centers need to be obtained based on the scaling coefficient.
[0052] For example, in a case where the width of the original picture needs to be reduced to obtain the target picture, the width and the height of the original picture need to be reduced to obtain the target picture, the width of the original picture needs to be reduced and the height of the original picture needs to be enlarged to obtain the target picture, the width of the original picture needs to be enlarged and the height of the original picture needs to be reduced to obtain the target picture, the width of the original picture needs to be enlarged to obtain the target picture, or the width and the height of the original picture need to be enlarged to obtain the target picture, the N transverse convolution centers need to be obtained based on the scaling coefficient.
[0053] In a case where the height of the original picture needs to be reduced or the height of the original picture needs to be enlarged, the M longitudinal convolution centers need to be obtained based on the scaling coefficient.
[0054] For example, in a case that a target picture is needed to be obtained by reducing a height of an original picture, a target picture is needed to be obtained by reducing a width and a height of an original picture, a target picture is needed to be obtained by reducing a width of an original picture and enlarging a height of the original picture, a target picture is needed to be obtained by enlarging a width of an original picture and reducing a height of the original picture, a target picture is needed to be obtained by enlarging a height of an original picture, or a target picture is needed to be obtained by enlarging a width and a height of an original picture, M vertical convolution centers need to be obtained based on a scaling coefficient.
[0055] In some embodiments, for the M vertical convolution centers, the M vertical convolution centers are obtained based on a vertical scaling coefficient.
[0056] Optionally, for the athvertical convolution center, a = 0, 1, 2, …, M-1, the athvertical convolution center is obtained based on a vertical scaling coefficient according to a first formula as follows.
[0057] The first formula is: D av = (a + 0.5) / r v - 0.5.
[0058] In the first formula, D av is the athvertical convolution center, and r v is the vertical scaling coefficient. The M vertical convolution centers are M vertical coordinates on a vertical axis of a coordinate system of the original picture.
[0059] In some embodiments, for the N horizontal convolution centers, the N horizontal convolution centers are obtained based on a horizontal scaling coefficient.
[0060] Optionally, for the bthhorizontal convolution center, b = 0, 1, 2, …, N-1, the bthhorizontal convolution center is obtained based on a horizontal scaling coefficient according to a second formula as follows.
[0061] The second formula is: D bh = (b + 0.5) / r h - 0.5.
[0062] In the second formula, D bh is the bthhorizontal convolution center, and r h is the horizontal scaling coefficient. The N horizontal convolution centers are N horizontal coordinates on a horizontal axis of a coordinate system of the original picture.
[0063] For example, as shown in FIG. 4, an original picture includes 16 rows and 12 columns of pixel points, i.e., Q = 16 and K = 12, and a target picture obtained by scaling the original picture includes 4 rows and 3 columns of pixel points, i.e., M = 4 and N = 3. A vertical scaling coefficient r v = M / Q = 4 / 16 = 1 / 4, and a horizontal scaling coefficient r h = N / K = 3 / 12 = 1 / 4.
[0064] based on the longitudinal scaling factor r v , four longitudinal convolution centers are obtained according to the first formula, and the four longitudinal convolution centers are 1.5, 5.5, 9.5 and 13.5 respectively. The 1.5, 5.5, 9.5 and 13.5 are four longitudinal coordinates on the longitudinal axis of the coordinate system of the original picture.
[0065] based on the longitudinal scaling factor r h , three longitudinal convolution centers are obtained according to the second formula, and the three longitudinal convolution centers are 1.5, 5.5 and 9.5 respectively. The 1.5, 5.5 and 9.5 are three longitudinal coordinates on the longitudinal axis of the coordinate system of the original picture.
[0066] Step 302: based on the N longitudinal convolution centers and the longitudinal scaling factor, the width of the original picture is scaled to obtain a first intermediate picture, and the first intermediate picture includes Q rows and N columns of pixel points.
[0067] In step 302, the width of the original picture is scaled to obtain the first intermediate picture through the operations of 3021-3023 as follows.
[0068] 3021: based on the nth longitudinal convolution center and the mth row of pixel points included in the original picture, a plurality of first pixel points are obtained, n=0, 1, 2, …, N-1, m=0, 1, 2, …, Q-1, the plurality of first pixel points include at least one first pixel point with a column number less than or equal to the nth longitudinal convolution center and at least one first pixel point with a column number greater than the nth longitudinal convolution center.
[0069] wherein the number of the plurality of first pixel points is the first number.
[0070] In 3021, based on the nth longitudinal convolution center and the first number, a longitudinal convolution window is determined. The left boundary position of the longitudinal convolution window is floor(D nh )-L h +1, and the right boundary position of the longitudinal convolution window is floor(D nh )+L h . Wherein, floor() is a down rounding operation, D nh is the nth longitudinal convolution center, L h is half of the first number, and the first number is the length of the longitudinal convolution window. Based on the longitudinal convolution window and the mth row of pixel points included in the original picture, the plurality of first pixel points are obtained, and the longitudinal convolution window includes the plurality of first pixel points.
[0071] floor() is a down rounding operation, for example, floor(1.5)=1, and also for example, floor(2.5)=2.
[0072] The number of the first pixel points in the transverse convolution window, whose column number is less than or equal to the number of the at least one first pixel point of the nth transverse convolution center, is equal to the first number of one half, and the number of the first pixel points in the transverse convolution window, whose column number is greater than or equal to the number of the at least one first pixel point of the nth transverse convolution center, is equal to the first number of one half.
[0073] The first pixel points in the transverse convolution window include the first floor(D nh )-L h +1 first pixel point, the first floor(D nh )-L h +2 first pixel point,..., and the first floor(D nh )+L h +L first pixel point.
[0074] When the value of n is small, such as n=0 or 1, the first floor(D nh )-L h +1 may be less than 0, and the first floor(D nh )-L h +1 first pixel point to the first -1 first pixel point in the transverse convolution window are all the same as the first 0 pixel point in the mth row of pixel points. The first 0 first pixel point to the first floor(D nh )+L h +L first pixel point in the transverse convolution window are respectively the first 0 pixel point to the first floor(D nh )+L h +L pixel point in the mth row of pixel points.
[0075] When the value of n is large, such as n=N-2 or N-1, the first floor(D nh )+L h +L may be greater than K-1, and the first floor(D nh )-L h +1 first pixel point to the first K-1 first pixel point in the transverse convolution window are respectively the first floor(D nh )-L h +1 pixel point to the first K-1 pixel point in the mth row of pixel points. The first K first pixel point to the first floor(D nh )+L h +L first pixel point in the transverse convolution window are all the same as the first K-1 pixel point in the mth row of pixel points.
[0076] When the value of n is other values, the first floor(D nh )-L h +1 is greater than or equal to 0, and the first floor(D nh )+L hIt may be less than or equal to K-1, the floor(D) in the horizontal convolution window nh )-L h +1 from the first pixel to the floor (D) nh )+L h The first pixel is the floor (D) of the m-th row of pixels. nh )-L h +1 to the floor(D) nh )+L h Each pixel.
[0077] For example, see Figure 5, assuming the first number is 8, the first number L is half of the first number. h =4, m=0, n=0, the center of the 0th horizontal convolution is 1.5. Based on the center of the 0th horizontal convolution and the first number 8, the horizontal convolution window is determined. The left boundary position of the horizontal convolution window is floor(D). nh )-L h +1 = 1 - 4 + 1 = -2, the right boundary position of the horizontal convolution window is floor(D) nh )+L h =1+4=5. Based on the horizontal convolution window and the pixels in row 0 of the original image, obtain the eight first pixels included in the horizontal convolution window. The horizontal convolution window includes the -2nd, -1st, 0th, and 1st first pixels with column numbers less than or equal to 1.5 of the 0th horizontal convolution center, and the 2nd, 3rd, 4th, and 5th first pixels with column numbers greater than or equal to 1.5 of the 0th horizontal convolution center. Among them, the -2nd first pixel and the -1st first pixel are the same as the 0th pixel in the 0th row of pixels. The 0th first pixel, the 1st first pixel, the 2nd first pixel, the 3rd first pixel, the 4th first pixel, and the 5th first pixel are the 0th pixel, the 1st pixel, the 2nd pixel, the 3rd pixel, the 4th pixel, and the 5th pixel in the 0th row of pixels, respectively.
[0078] In some embodiments, the first number is a first specified number threshold, or the first number is an integer value determined based on a horizontal scaling factor.
[0079] Optionally, obtain an integer S that satisfies the condition shown in the third formula below. h Set the first number to 2*S h The first number represents the length of the horizontal convolution window. This first number is derived from the horizontal scaling factor, allowing the length of the horizontal convolution window to be dynamically adjusted as the horizontal scaling factor changes. This can improve the smoothness of image edges in the target image after scaling the original image to obtain the target image.
[0080] The third formula is:
[0081] 3022: Obtain the convolution weight of each first pixel point based on the column number of each first pixel point, the n-th transverse convolution center and the transverse scaling coefficient.
[0082] In 3022, for each first pixel point, the column number of the first pixel point is i, and the convolution weight of the first pixel point can be obtained according to the following fourth formula.
[0083] The fourth formula is:
[0084] In the fourth formula, W i is the convolution weight of the first pixel point, start_h is equal to floor(D nh -L h +1, end_h is equal to floor(D nh +L h , K(r h *x) is the convolution kernel, and x=D nh -i can represent the distance between the n-th transverse convolution center and the i-th first pixel point.
[0085] Optionally, the convolution kernel is:
[0086] Optionally, the convolution kernel is a Gaussian convolution kernel, and the Gaussian convolution kernel is: σ is a specified parameter value.
[0087] Optionally, the convolution kernel is a triangular convolution kernel, and the triangular convolution kernel is: h K(r h *x) = 1 - |r
[0088] Optionally, the convolution kernel is a cosine kernel, and the cosine kernel is:
[0089] The convolution kernel can also be other convolution kernels. For example, the convolution kernel can be K(f(r h *x)), f() is a function with real numbers as input and output, and the output is a non-constant value, such as f(r h ) = log(r h ). That is, K(r h *x) in the fourth formula can be replaced by K(f(r h *x)), and other convolution kernels are not listed one by one here.
[0090] 3023: obtaining a pixel point in the mth row and the nth column of the first intermediate picture based on each first pixel point and a convolution weight of each first pixel point.
[0091] In 3023, the pixel point in the mth row and the nth column of the first intermediate picture is obtained based on each first pixel point and a convolution weight of each first pixel point according to the following fifth formula.
[0092] The fifth formula is as follows:
[0093] In the fifth formula, P mn is a pixel value of the pixel point in the mth row and the nth column of the first intermediate picture, P i is a pixel value of the ith first pixel point.
[0094] In some embodiments, if it is required to reduce the width of the original picture or to enlarge the width of the original picture to obtain the target picture, the first intermediate picture is the target picture, so that the step 303 does not need to be continuously executed, and the operation ends.
[0095] Step 303: scaling the height of the first intermediate picture based on the M longitudinal convolution centers and the longitudinal scaling coefficient to obtain the target picture.
[0096] In step 303, the height of the first intermediate picture is scaled to obtain the target picture through the operations of 3031-3033 as follows.
[0097] 3031: obtaining a plurality of second pixel points based on the vth longitudinal convolution center and the pixel points in the kth column of the first intermediate picture, v = 0, 1, 2, …, M-1, k = 0, 1, 2, …, N-1, the plurality of second pixel points including at least one second pixel point with a row number less than or equal to the vth longitudinal convolution center and at least one second pixel point with a row number greater than the vth longitudinal convolution center.
[0098] The number of the plurality of second pixel points is a second number.
[0099] In 3031, a longitudinal convolution window is determined based on the vth longitudinal convolution center and the second number. The upper boundary position of the longitudinal convolution window is floor(D vv )-L v +1, and the lower boundary position of the longitudinal convolution window is floor(D vv )+L v . Wherein, D vv is the vth longitudinal convolution center, L v is one half of the second number, and the second number is the height of the longitudinal convolution window. The plurality of second pixel points are obtained based on the longitudinal convolution window and the pixel points in the kth column of the first intermediate picture, and the longitudinal convolution window includes the plurality of second pixel points.
[0100] In the longitudinal convolution window, the number of the at least one second pixel point whose row number is less than or equal to one-half of the second number of the at least one second pixel point of the vth longitudinal convolution center is equal to one-half of the second number, and the number of the at least one second pixel point whose row number is greater than or equal to one-half of the second number of the at least one second pixel point of the vth longitudinal convolution center is equal to one-half of the second number.
[0101] The plurality of second pixel points in the longitudinal convolution window include the first floor(D vv )-L v +1 second pixel point, the second floor(D vv )-L v +2 second pixel point, …, and the (floor(D vv )+L v )th second pixel point.
[0102] When the value of v is small, such as v=0 or 1, the floor(D vv )-L v +1 can be less than 0, and the first floor(D vv )-L v +1 second pixel point to the -1th second pixel point in the longitudinal convolution window are all the same as the 0th pixel point in the kth column of pixel points. The 0th second pixel point to the floor(D vv )+L v th second pixel point in the longitudinal convolution window are respectively the 0th pixel point to the floor(D vv )+L v th pixel point in the kth column of pixel points.
[0103] When the value of v is large, such as v=M-2 or M-1, the floor(D vv )+L v can be greater than Q-1, and the first floor(D vv )-L v +1 second pixel point to the Q-1th second pixel point in the longitudinal convolution window are respectively the first floor(D vv )-L v +1 pixel point to the Q-1th pixel point in the kth column of pixel points. The Qth second pixel point to the floor(D vv )+L v th second pixel point in the longitudinal convolution window are all the same as the Q-1th pixel point in the kth column of pixel points.
[0104] When the value of v is other values, the floor(D vv )-L v +1 is greater than or equal to 0, and the floor(D vv )+Lv may be less than or equal to Q-1, the first floor(D vv )-L v +1 second pixel point to the last floor(D vv )+L v second pixel point in the kth column of pixels is the first floor(D vv )-L v +1 pixel point to the last floor(D vv )+L v pixel point in the kth column of pixels.
[0105] For example, referring to FIG. 6, it is assumed that the second number is 8, the second number L v is 4, v = 0, k = 0, and the 0th vertical convolution center is 1.5. Based on the 0th vertical convolution center and the second number 8, a vertical convolution window is determined. The upper boundary position of the vertical convolution window is floor(D vv )-L v +1 = 1-4+1 = -2, and the lower boundary position of the vertical convolution window is floor(D vv )+L v = 1+4 = 5. Based on the 0th column of pixels included in the first intermediate picture and the vertical convolution window, eight second pixel points included in the vertical convolution window are obtained. The vertical convolution window includes the -2nd, -1st, 0th, and 1st second pixel points with row numbers less than or equal to the 0th vertical convolution center 1.5 and the 2nd, 3rd, 4th, and 5th second pixel points with row numbers greater than or equal to the 0th vertical convolution center 1.5. Among them, the -2nd and -1st second pixel points are the same as the 0th pixel point in the 0th column of pixels, and the 0th, 1st, 2nd, 3rd, 4th, and 5th second pixel points are the 0th, 1st, 2nd, 3rd, 4th, and 5th pixel points in the 0th column of pixels, respectively.
[0106] In some embodiments, the second number is a second specified number threshold, or the second number is an integer value determined based on the vertical scaling factor.
[0107] Optionally, an integer S v satisfying the following sixth formula is obtained: S v is set to be equal to 2*SThe second number is the height of the vertical convolution window. It is obtained based on the vertical scaling factor, so that the height of the vertical convolution window can be dynamically adjusted as the vertical scaling factor changes. This can improve the smoothness of image edges in the target image after scaling the original image to obtain the target image.
[0108] Sixth Formula:
[0109] 3032: Obtain the convolution weights of each second pixel based on the row number of each second pixel, the vth vertical convolution center, and the vertical scaling factor.
[0110] For each second pixel, whose row number is j, the convolution weight of the second pixel can be obtained according to the seventh formula below.
[0111] Seventh Formula:
[0112] In the seventh formula, W j For the convolution weights of the second pixel, start_v equals floor(D vv )-L v +1, end_v equals floor(D vv )+L v ,K(r v *y) is the convolution kernel. y = D vv -j can represent the distance between the v-th vertical convolution center and the j-th second pixel.
[0113] Optionally, the convolution kernel is:
[0114] Optionally, the convolution kernel is a Gaussian convolution kernel, and the Gaussian convolution kernel is: σ is a specified parameter value.
[0115] Optionally, the convolution kernel is a triangular convolution kernel, and the triangular convolution kernel is: K(r v *y)=1-|r v *y|.
[0116] Optionally, the convolution kernel is a cosine product kernel, which is:
[0117] The convolution kernel can also be other types of convolution kernels; for example, the convolution kernel can be K(f(r)). v f() is a function whose input and output are both real numbers, but whose output is a non-fixed value, for example, f(r)*y). v ) = log(r v That is, K(r) in the seventh formula can be... v Replace *y) with K(f(r) v) for other convolution kernels are not listed here.
[0118] 3033: obtaining a pixel point in the vth row and the kth column of the target picture based on each second pixel point and the convolution weight of each second pixel point.
[0119] In 3033, the pixel point in the vth row and the kth column of the target picture is obtained based on each second pixel point and the convolution weight of each second pixel point according to the following eighth formula.
[0120] The eighth formula is as follows:
[0121] In the eighth formula, P vk is the pixel value of the pixel point in the vth row and the kth column of the target picture, P j is the pixel value of the jth second pixel point.
[0122] In the embodiments of the present application, a plurality of first pixel points are obtained based on the nth horizontal convolution center and the pixel points in the mth row of the original picture. The convolution weight of each first pixel point is obtained based on the column number of each first pixel point, the nth horizontal convolution center and the horizontal scaling coefficient. The pixel point in the mth row and the nth column of the first intermediate picture is obtained based on each first pixel point and the convolution weight of each first pixel point. A plurality of second pixel points are obtained from the pixel points in the kth column of the first intermediate picture based on the vth vertical convolution center. The convolution weight of each second pixel point is obtained based on the row number of each second pixel point, the vth vertical convolution center and the vertical scaling coefficient. The pixel point in the vth row and the kth column of the target picture is obtained based on each second pixel point and the convolution weight of each second pixel point. Since the convolution weight of each first pixel point is obtained based on the column number of each first pixel point, the nth horizontal convolution center and the horizontal scaling coefficient, and the convolution weight of each second pixel point is obtained based on the row number of each second pixel point, the vth vertical convolution center and the vertical scaling coefficient, the frequency domain aliasing does not occur when scaling the picture through the horizontal scaling coefficient and the vertical scaling coefficient. The convolution kernel function used for convolution operation is adaptively adjusted with the scaling coefficient, so that the distance between the pixel points in the convolution window and the convolution center is adjusted by the scaling coefficient, the frequency domain aliasing is avoided when scaling, so that the image edges in the target picture obtained by scaling do not appear as stepped sawtooth, and the image edges become smooth.
[0123] Referring to FIG. 7, the embodiment of the present application provides a method 700 for scaling a picture, and an execution subject of the method 700 can be the computing device shown in FIG. 1 or FIG. 2. The method 700 is used for scaling a height of an original picture to obtain a second intermediate picture, the original picture including Q rows and K columns of pixel points, the second intermediate picture including M rows and K columns of pixel points, and scaling a width of the second intermediate picture to obtain a target picture, the target picture including M rows and N columns of pixel points, M, N, Q and K are all integers greater than 1, and M is not equal to Q and / or N is not equal to K. The method 700 includes the following procedures.
[0124] Step 701: The same as step 301, which is not described in detail here.
[0125] Step 702: Based on the M vertical convolution centers and the vertical scaling coefficient, the height of the original picture is scaled to obtain the second intermediate picture, and the second intermediate picture includes M rows and K columns of pixel points.
[0126] In step 702, the height of the original picture is scaled to obtain the second intermediate picture through the following operations 7021-7023.
[0127] 7021: Based on the mth vertical convolution center and the nth column of pixel points included in the original picture, a plurality of third pixel points are obtained, m=0, 1, 2, …, M-1, n=0, 1, 2, …, K-1, and the plurality of third pixel points include at least one third pixel point with a row number less than or equal to the mth vertical convolution center and at least one third pixel point with a row number greater than the mth vertical convolution center.
[0128] The number of the plurality of third pixel points is a second number.
[0129] In 7021, based on the mth vertical convolution center and the second number, a vertical convolution window is determined. An upper boundary position of the vertical convolution window is floor(D mv )-L v +1, and a lower boundary position of the vertical convolution window is floor(D mv )+L v . Wherein, D mv is the mth vertical convolution center, L v is one half of the second number, and the second number is a height of the vertical convolution window. Based on the vertical convolution window and the nth column of pixel points included in the original picture, the plurality of third pixel points are obtained, and the vertical convolution window includes the plurality of third pixel points.
[0130] The number of the third pixel points in the longitudinal convolution window whose row number is less than or equal to one half of the second number of the at least one third pixel point of the mth longitudinal convolution center is equal to one half of the second number, and the number of the third pixel points in the longitudinal convolution window whose row number is greater than or equal to one half of the second number of the at least one third pixel point of the mth longitudinal convolution center is equal to one half of the second number.
[0131] The third pixel points in the longitudinal convolution window include the first floor(D mv )-L v +1 third pixel point, the first floor(D mv )-L v +2 third pixel point,..., and the first floor(D mv )+L v +L third pixel point.
[0132] When the value of m is small, such as m=0 or 1, the first floor(D mv )-L v +1 third pixel point in the longitudinal convolution window is less than 0, and the first floor(D mv )-L v +1 third pixel point to the first -1 third pixel point in the longitudinal convolution window are the same as the first 0 pixel point in the nth column of pixel points. The first 0 third pixel point to the first floor(D mv )+L v +L third pixel point in the longitudinal convolution window are the first 0 pixel point to the first floor(D mv )+L v +L pixel point in the nth column of pixel points, respectively.
[0133] When the value of m is large, such as m=M-2 or M-1, the first floor(D mv )+L v +L third pixel point in the longitudinal convolution window is greater than Q-1, and the first floor(D mv )-L v +1 third pixel point to the first Q-1 third pixel point in the longitudinal convolution window are the first floor(D mv )-L v +1 pixel point to the first Q-1 pixel point in the nth column of pixel points, respectively. The first Q third pixel point to the first floor(D mv )+L v +L third pixel point in the longitudinal convolution window are the same as the first Q-1 pixel point in the nth column of pixel points.
[0134] When the value of m is other values, the first floor(D mv )-L v +1 third pixel point in the longitudinal convolution window is greater than or equal to 0, and the first floor(D mv )+L vmay be less than or equal to Q-1, the first floor(D mv )-L v +1 third pixel point to the floor(D mv )+L v th third pixel point in the nth column of pixel points. mv )-L v +1 pixel point to the floor(D mv )+L v th pixel point in the nth column of pixel points.
[0135] For example, referring to FIG. 8, it is assumed that the second number is 8, the second number L v = 4, m = 0, n = 0, and the 0th longitudinal convolution center is 1.5. Based on the 0th longitudinal convolution center and the second number 8, a longitudinal convolution window is determined. The upper boundary position of the longitudinal convolution window is floor(D mv )-L v +1 = 1-4+1 = -2, and the lower boundary position of the longitudinal convolution window is floor(D mv )+L v = 1+4 = 5. Based on the longitudinal convolution window and the 0th column of pixel points included in the original picture, eight third pixel points included in the longitudinal convolution window are obtained. The longitudinal convolution window includes the -2th third pixel point, the -1th third pixel point, the 0th third pixel point, and the 1th third pixel point with row numbers less than or equal to the 0th longitudinal convolution center 1.5, and the 2th third pixel point, the 3th third pixel point, the 4th third pixel point, and the 5th third pixel point with row numbers greater than or equal to the 0th longitudinal convolution center 1.5. Among them, the -2th third pixel point and the -1th third pixel point are the same as the 0th pixel point in the 0th column of pixel points, and the 0th third pixel point, the 1th third pixel point, the 2th third pixel point, the 3th third pixel point, the 4th third pixel point, and the 5th third pixel point are the 0th pixel point, the 1st pixel point, the 2nd pixel point, the 3rd pixel point, the 4th pixel point, and the 5th pixel point in the 0th column of pixel points, respectively.
[0136] In some embodiments, the second number is a second specified number threshold, or the second number is an integer value determined based on the longitudinal scaling factor.
[0137] 7022: Obtain a convolution weight of each third pixel point based on a row number of each third pixel point, the mth longitudinal convolution center, and the longitudinal scaling factor.
[0138] At 7022, based on the row number of each third pixel point, the mth transverse convolution center and the transverse scaling coefficient, a detailed obtaining process of the convolution weight of each third pixel point can be referred to related content in step 3032 shown in FIG. 3, which will not be described in detail here.
[0139] 7023: Based on each third pixel point and the convolution weight of each third pixel point, a pixel point in the mth row and the nth column included in the second intermediate picture is obtained.
[0140] The detailed obtaining process can be referred to related content in step 3033 shown in FIG. 3, which will not be described in detail here.
[0141] Step 703: Based on the N transverse convolution centers and the transverse scaling coefficient, the width of the second intermediate picture is scaled to obtain the target picture.
[0142] In step 703, the width of the second intermediate picture is scaled to obtain the target picture through operations of 7031-7033 as follows.
[0143] 7031: Based on the vth transverse convolution center and the kth row of pixel points included in the second intermediate picture, a plurality of fourth pixel points are obtained, v=0, 1, 2, …, N-1, k=0, 1, 2, …, M-1, the plurality of fourth pixel points include at least one fourth pixel point with a column number less than or equal to the vth transverse convolution center and at least one fourth pixel point with a column number greater than the vth transverse convolution center.
[0144] The number of the plurality of fourth pixel points is a second number.
[0145] In 7031, based on the vth transverse convolution center and the first number, a transverse convolution window is determined. The left boundary position of the transverse convolution window is floor(D vh )-L h +1, and the right boundary position of the transverse convolution window is floor(D vh )+L h . Wherein, D vh is the vth transverse convolution center. Based on the transverse convolution window and the kth row of pixel points included in the second intermediate picture, the plurality of fourth pixel points are obtained, and the transverse convolution window includes the plurality of fourth pixel points.
[0146] In the transverse convolution window, the number of at least one fourth pixel point with a column number less than or equal to the vth transverse convolution center is equal to one half of the first number, and the number of at least one fourth pixel point with a column number greater than or equal to the vth transverse convolution center is equal to one half of the first number.
[0147] The plurality of fourth pixel points in the transverse convolution window include the floor(D vh )-Lh +1 fourth pixel point, the floor(D vh )-L h +2 fourth pixel point, …, the floor(D vh )+L h th fourth pixel point.
[0148] When the value of v is small, such as v = 0 or 1, the floor(D vh )-L h +1 can be less than 0, the floor(D vh )-L h +1 fourth pixel point in the transverse convolution window to the -1th fourth pixel point are all the same as the 0th pixel point in the kth row of pixel points. The 0th fourth pixel point to the floor(D vh )+L h th fourth pixel point in the transverse convolution window are respectively the 0th pixel point to the floor(D vh )+L h th pixel point in the kth row of pixel points.
[0149] When the value of v is large, such as v = N-2 or N-1, the floor(D vh )+L h can be greater than K-1, the floor(D vh )-L h +1 fourth pixel point to the K-1th fourth pixel point in the transverse convolution window are respectively the floor(D vh )-L h +1 pixel point to the K-1th pixel point in the kth row of pixel points. The Kth fourth pixel point to the floor(D vh )+L h th fourth pixel point in the transverse convolution window are all the same as the K-1th pixel point in the kth row of pixel points.
[0150] When the value of v is other values, the floor(D vh )-L h +1 is greater than or equal to 0, the floor(D vh )+L h can be less than or equal to K-1, the floor(D vh )-L h +1 fourth pixel point to the floor(D vh )+L h th fourth pixel point in the transverse convolution window are respectively the floor(D vh )-L h +1 pixel point to the floor(Dvh )+L h pixel points.
[0151] For example, referring to FIG. 9, it is assumed that the first number is 8, the first number L h = 4, v = 0, k = 0, and the 0th horizontal convolution center is 1.5. Based on the 0th horizontal convolution center and the first number 8, a horizontal convolution window is determined. The left boundary position of the horizontal convolution window is floor(D vh )-L h + 1 = 1 - 4 + 1 = -2, and the right boundary position of the horizontal convolution window is floor(D vh )+L h = 1 + 4 = 5. Based on the horizontal convolution center and the 0th row of pixel points included in the second intermediate picture, eight fourth pixel points are obtained. The horizontal convolution window includes the -2th fourth pixel point, the -1th fourth pixel point, the 0th fourth pixel point, and the 1th fourth pixel point with column numbers less than or equal to the 0th horizontal convolution center 1.5, and the 2th fourth pixel point, the 3th fourth pixel point, the 4th fourth pixel point, and the 5th fourth pixel point with column numbers greater than or equal to the 0th horizontal convolution center 1.5. Among them, the -2th fourth pixel point and the -1th fourth pixel point are the same as the 0th pixel point in the 0th row of pixel points, and the 0th fourth pixel point, the 1th fourth pixel point, the 2th fourth pixel point, the 3th fourth pixel point, the 4th fourth pixel point, and the 5th fourth pixel point are the 0th pixel point, the 1st pixel point, the 2nd pixel point, the 3rd pixel point, the 4th pixel point, and the 5th pixel point in the 0th row of pixel points, respectively.
[0152] In some embodiments, the first number is a first specified number threshold, or the first number is an integer value determined based on the horizontal scaling factor.
[0153] 7032: Obtain a convolution weight of each fourth pixel point based on the column number of each fourth pixel point, the vth horizontal convolution center, and the horizontal scaling factor.
[0154] In 7032, the detailed obtaining process of obtaining the convolution weight of each fourth pixel point based on the column number of each fourth pixel point, the vth horizontal convolution center, and the horizontal scaling factor can be referred to the related content in step 3022 shown in FIG. 3, which will not be described in detail here.
[0155] 7033: Obtain a pixel point in the kth row and the vth column included in the target picture based on each fourth pixel point and the convolution weight of each fourth pixel point.
[0156] The detailed obtaining process can be referred to the related content in step 3023 shown in FIG. 3, which will not be described in detail here.
[0157] In the embodiment of the present application, a plurality of third pixel points are obtained based on the mth longitudinal convolution center and the nth column of pixel points included in the original picture. A convolution weight of each third pixel point is obtained based on the row number of each third pixel point, the mth longitudinal convolution center and the longitudinal scaling factor. A pixel point in the mth row and the nth column included in the second intermediate picture is obtained based on each third pixel point and the convolution weight of each third pixel point. A plurality of fourth pixel points are obtained based on the vth transverse convolution center and the kth row of pixel points included in the second intermediate picture. A convolution weight of each fourth pixel point is obtained based on the column number of each fourth pixel point, the vth transverse convolution center and the transverse scaling factor. A pixel point in the kth row and the vth column included in the target picture is obtained based on each fourth pixel point and the convolution weight of each fourth pixel point. Since the convolution weight of each third pixel point is obtained based on the row number of each third pixel point, the mth longitudinal convolution center and the longitudinal scaling factor, and the convolution weight of each fourth pixel point is obtained based on the column number of each fourth pixel point, the vth transverse convolution center and the transverse scaling factor, the frequency domain aliasing does not occur when scaling the picture through the transverse scaling factor and the longitudinal scaling factor. The convolution kernel function used for convolution operation is adaptively adjusted with the scaling factor, so that the distance between the pixel points in the convolution window and the convolution center is adjusted by the scaling factor, the frequency domain aliasing is avoided when scaling, the convolution weight is changed when the scaling factor changes, the image edges in the target picture obtained by scaling do not appear as stepped sawtooth, and the image edges become smooth.
[0158] Referring to FIG. 10, the embodiment of the present application provides a method 1000 for scaling a picture, and the execution subject of the method 1000 can be the computing device shown in FIG. 1 or FIG. 2. The method 1000 is used to scale the width and height of an original picture to obtain a target picture, and the target picture includes M rows and N columns of pixel points, M, N, Q and K are all integers greater than 1, M is not equal to Q and / or N is not equal to K. The method 1000 includes the following processes.
[0159] Step 1001: The same as step 301, which will not be described in detail here.
[0160] Step 1002: An image region is obtained based on the nth transverse convolution center, the mth longitudinal convolution center and the original picture, n=0, 1, 2, …, N-1, m=0, 1, 2, …, M-1.
[0161] The image region includes a plurality of rows of pixel points and a plurality of columns of pixel points, the plurality of columns of pixel points in the image region include at least one column of pixel points with a column number less than or equal to the n th horizontal convolution center and at least one column of pixel points with a column number greater than the n th horizontal convolution center. The plurality of rows of pixel points in the image region include at least one row of pixel points with a row number less than or equal to the m th vertical convolution center and at least one row of pixel points with a row number greater than the m th vertical convolution center.
[0162] The number of columns of the plurality of columns of pixel points is a first number, and the number of rows of the plurality of rows of pixel points is a second number.
[0163] In step 1002, a convolution window is determined based on the n th horizontal convolution center, the m th vertical convolution center, the first number and the second number. The left boundary position of the convolution window is floor(D nh )-L h +1, the right boundary position of the convolution window is floor(D nh )+L h , the upper boundary position of the convolution window is floor(D mv )-L v +1, and the lower boundary position of the convolution window is floor(D mv )+L v . Wherein, D nh is the n th horizontal convolution center, D mv is the m th vertical convolution center, L h is one half of the first number, L v is one half of the second number, the first number is the width of the convolution window, and the second number is the height of the convolution window. The image region is obtained based on the convolution window and the original picture, and the convolution window includes the image region.
[0164] Optionally, the left boundary position of the convolution window can be the horizontal coordinate of the left boundary of the convolution window, that is, the horizontal coordinate of the left boundary of the convolution window is floor(D nh )-L h +1. The right boundary position of the convolution window can be the horizontal coordinate of the right boundary of the convolution window, that is, the horizontal coordinate of the right boundary of the convolution window is floor(D nh )+L h . The upper boundary position of the convolution window can be the vertical coordinate of the upper boundary of the convolution window, that is, the vertical coordinate of the upper boundary of the convolution window is floor(D mv )-L v +1. The lower boundary position of the convolution window can be the vertical coordinate of the lower boundary of the convolution window, that is, the vertical coordinate of the lower boundary of the convolution window is floor(D mv )+L v .
[0165] In the convolution window, the column number of the at least one column of pixel points less than or equal to one half of the first number of columns of the at least one column of pixel points centered at the nth horizontal convolution center, and the column number of the at least one column of pixel points greater than or equal to one half of the first number of columns of the at least one column of pixel points centered at the nth horizontal convolution center. In addition, in the convolution window, the row number of the at least one row of pixel points less than or equal to one half of the second number of rows of the at least one row of pixel points centered at the mth vertical convolution center, and the row number of the at least one row of pixel points greater than or equal to one half of the second number of rows of the at least one row of pixel points centered at the mth vertical convolution center.
[0166] The image region includes an ith row and jth column pixel point, i is an integer greater than or equal to floor(D mv )-L v +1 and less than or equal to floor(D mv )+L v , j is an integer greater than or equal to floor(D nh )-L h +1 and less than or equal to floor(D nh )+L h .
[0167] When n is small, such as n = 0 or 1, floor(D nh )-L h +1 can be less than 0, and / or, when m is small, such as m = 0 or 1, floor(D mv )-L v +1 can be less than 0. Alternatively,
[0168] When n is large, such as n = N-2 or N-1, floor(D nh )+L h may be greater than K-1, and / or, when m is large, such as m = M-2 or M-1, floor(D mv )+L v may be greater than Q-1. Alternatively,
[0169] When n is other values, floor(D nh )-L h +1 is greater than or equal to 0, floor(D nh )+L h may be less than or equal to K-1, and / or, when m is other values, floor(D mv )-L v +1 is greater than or equal to 0, floor(D mv )+L v may be less than or equal to Q-1.
[0170] If i is less than 0, the i-th row j-th column pixel point is the same as the 0-th row j-th column pixel point. If j is less than 0, the i-th row j-th column pixel point is the same as the i-th row 0-th column pixel point. If i is greater than or equal to 0 and less than or equal to Q-1, and j is greater than or equal to 0 and less than or equal to K-1, the i-th row j-th column pixel point is the same as the i-th row j-th column pixel point in the original picture. If i is greater than Q-1, the i-th row j-th column pixel point is the same as the Q-1-th row j-th column pixel point. If j is greater than K-1, the i-th row j-th column pixel point is the same as the i-th row K-1-th column pixel point.
[0171] For example, referring to FIG. 11, it is assumed that the first number is 4, the second number is 4, the first number L h = 2, the second number L v = 2, m = 0, n = 0, the 0-th horizontal convolution center is 1.5, and the 0-th vertical convolution center is 1.5. Based on the 0-th horizontal convolution center 1.5, the first number 4, the 0-th vertical convolution center 1.5, and the second number 4, a convolution window is determined. The left boundary position of the convolution window is floor(D nh )-L h + 1 = 1-2+1 = 0, the right boundary position of the convolution window is floor(D nh )+L h = 1+2 = 3. The upper boundary position of the convolution window is floor(D mv )-L v + 1 = 1-2+1 = 0, and the lower boundary position of the convolution window is floor(D mv )+L v = 1+2 = 3. An image region located in the convolution window is determined in the original picture, and the image region includes 4*4 pixel points at the top left corner of the original picture.
[0172] In some embodiments, the first number is a first specified number threshold, or the first number is an integer value determined based on the horizontal scaling coefficient.
[0173] In some embodiments, the second number is a second specified number threshold, or the second number is an integer value determined based on the vertical scaling coefficient.
[0174] Step 1003: Obtain a horizontal convolution weight of each pixel point in the image region based on the column number of each pixel point, the n-th horizontal convolution center, and the horizontal scaling coefficient.
[0175] In step 1003, for each pixel point, the pixel point is an i-th row j-th column pixel point, i.e., the column number of the pixel point is i, and the horizontal convolution weight of the pixel point can be obtained according to the following ninth formula.
[0176] Ninth formula:
[0177] In the ninth formula, W ij_h is the horizontal convolution weight of the pixel point, start_h is equal to floor(D nh -L h +1, end_h is equal to floor(D nh +L h , and K(r h *x) is the convolution kernel.
[0178] Step 1004: Based on the row number of each pixel point, the mth vertical convolution center and the vertical scaling coefficient, the vertical convolution weight of each pixel point is obtained.
[0179] In step 1004, for each pixel point, the pixel point is the i-th row and j-th pixel point, that is, the row number of the pixel point is j, and the vertical convolution weight of the pixel point can be obtained according to the following tenth formula.
[0180] Tenth formula:
[0181] In the tenth formula, W ij_v is the vertical convolution weight of the pixel point, start_v is equal to floor(D mv -L v +1, end_v is equal to floor(D mv +L v , and K(r v *y) is the convolution kernel.
[0182] Step 1005: Based on each pixel point, the horizontal convolution weight and the vertical convolution weight of each pixel point, the pixel point included in the mth row and the nth column of the target picture is obtained.
[0183] In step 1005, based on each pixel point, the horizontal convolution weight and the vertical convolution weight of each pixel point, the pixel point included in the mth row and the nth column of the target picture is obtained according to the following eleventh formula.
[0184] Eleventh formula:
[0185] In the eleventh formula, P mn is the pixel value of the pixel point included in the mth row and the nth column of the target picture, and P ij is the pixel value of the i-th row and j-th column pixel point.
[0186] Repeating the above steps 1002-1005 can obtain each pixel point in the target picture.
[0187] In the embodiment of the present application, the image region is obtained based on the nth transverse convolution center, the mth longitudinal convolution center and the original picture. The transverse convolution weight of each pixel point is obtained based on the column number of each pixel point, the nth transverse convolution center and the transverse scaling coefficient. The longitudinal convolution weight of each pixel point is obtained based on the row number of each pixel point, the mth longitudinal convolution center and the longitudinal scaling coefficient. The pixel point of the mth row and the nth column included in the target picture is obtained based on each pixel point, the transverse convolution weight and the longitudinal convolution weight of each pixel point. In this way, the width and the height of the original picture can be scaled at the same time, and the scaling efficiency is improved. Wherein, the transverse convolution weight of each pixel point is obtained based on the column number of each pixel point, the nth transverse convolution center and the transverse scaling coefficient, and the longitudinal convolution weight of each pixel point is obtained based on the row number of each pixel point, the mth longitudinal convolution center and the longitudinal scaling coefficient. In this way, by using the transverse scaling coefficient and the longitudinal scaling coefficient, the frequency domain aliasing does not occur when the picture is scaled. The convolution kernel function used for convolution operation is adaptively adjusted according to the scaling coefficient, so that the distance between the pixel point in the convolution window and the convolution center is adjusted by the scaling coefficient, the frequency domain aliasing is avoided when the picture is scaled, and the convolution weight changes when the scaling coefficient changes, so that the image edge in the target picture obtained by scaling does not appear stepped sawtooth, and the image edge becomes smooth.
[0188] In addition to scaling the picture, the above embodiment can also be used as a low-pass filter to filter any discrete signal to achieve the purpose of down-sampling.
[0189] Referring to FIG. 12, an apparatus 1200 for scaling a picture is provided in the embodiment of the present application. The apparatus 1200 can be deployed on the computing device shown in FIG. 1 or FIG. 2, or can be deployed on the computing device in the method 300 shown in FIG. 3, the method 700 shown in FIG. 7 or the method 1000 shown in FIG. 10. The apparatus 1200 comprises:
[0190] The obtaining unit 1201 is configured to obtain a plurality of convolution centers based on a scaling coefficient. The scaling coefficient is a coefficient used for scaling an original picture. The plurality of convolution centers are used for scaling the width and / or the height of the original picture. The original picture comprises Q rows and K columns of pixel points. Q and K are both integers greater than 1.
[0191] The scaling unit 1202 is configured to scale the original picture based on the plurality of convolution centers and the scaling coefficient to obtain a target picture. The target picture comprises M rows and N columns of pixel points. M and N are both integers greater than 1. M is not equal to Q and / or N is not equal to K.
[0192] Optionally, the obtaining unit 1201 obtains the plurality of convolution centers based on the scaling factor. Details can be referred to related contents in step 301 of method 300 shown in FIG. 3, step 701 of method 700 shown in FIG. 7, or step 1001 of method 1000 shown in FIG. 10, which will not be described in detail here.
[0193] Optionally, the scaling unit 1202 scales the original picture based on the plurality of convolution centers and the scaling factor to obtain the target picture. Details can be referred to related contents in steps 302-303 of method 300 shown in FIG. 3, steps 702-703 of method 700 shown in FIG. 7, or steps 1002-1004 of method 1000 shown in FIG. 10, which will not be described in detail here.
[0194] Optionally, the plurality of convolution centers include M longitudinal convolution centers and / or N transverse convolution centers, the M longitudinal convolution centers are used to scale the height of the original picture, and the N transverse convolution centers are used to scale the width of the original picture.
[0195] The scaling factor includes a longitudinal scaling factor and / or a transverse scaling factor, the longitudinal scaling factor is equal to M / Q, and the transverse scaling factor is equal to N / K.
[0196] Optionally, the plurality of convolution centers include M longitudinal convolution centers and N transverse convolution centers, and the scaling factor includes a longitudinal scaling factor and a transverse scaling factor. The scaling unit 1202 is configured to:
[0197] Scale the width of the original picture based on the N transverse convolution centers and the transverse scaling factor to obtain a first intermediate picture, the first intermediate picture includes Q rows and N columns of pixel points.
[0198] Scale the height of the first intermediate picture based on the M longitudinal convolution centers and the longitudinal scaling factor to obtain the target picture.
[0199] Optionally, the scaling unit 1202 scales the width of the original picture based on the N transverse convolution centers and the transverse scaling factor to obtain the first intermediate picture. Details can be referred to related contents in step 302 of method 300 shown in FIG. 3, which will not be described in detail here.
[0200] Optionally, the scaling unit 1202 scales the height of the first intermediate picture based on the M longitudinal convolution centers and the longitudinal scaling factor to obtain the target picture. Details can be referred to related contents in step 303 of method 300 shown in FIG. 3, which will not be described in detail here.
[0201] Optionally, the scaling unit 1202 is configured to:
[0202] based on the n th horizontal convolution center, a plurality of first pixel points are obtained from the m th row of pixel points included in the original picture, n = 0, 1, 2, …, N-1, m = 0, 1, 2, …, Q-1, the plurality of first pixel points include at least one first pixel point with a column number less than or equal to the n th horizontal convolution center and at least one first pixel point with a column number greater than the n th horizontal convolution center;
[0203] based on the column number of each first pixel point, the n th horizontal convolution center and the horizontal scaling factor, a convolution weight of each first pixel point is obtained;
[0204] based on each first pixel point and the convolution weight of each first pixel point, a pixel point in the m th row and the n th column of the first intermediate picture is obtained.
[0205] Optionally, the scaling unit 1202 obtains a plurality of first pixel points from the m th row of pixel points included in the original picture based on the n th horizontal convolution center, which can refer to the related content in 3021 of method 300 shown in FIG. 3, and will not be described in detail here.
[0206] Optionally, the scaling unit 1202 obtains a convolution weight of each first pixel point based on the column number of each first pixel point, the n th horizontal convolution center and the horizontal scaling factor, which can refer to the related content in 3022 of method 300 shown in FIG. 3, and will not be described in detail here.
[0207] Optionally, the scaling unit 1202 obtains a pixel point in the m th row and the n th column of the first intermediate picture based on each first pixel point and the convolution weight of each first pixel point, which can refer to the related content in 3023 of method 300 shown in FIG. 3, and will not be described in detail here.
[0208] Optionally, the number of the plurality of first pixel points is equal to a first number, and the first number is determined based on the horizontal scaling factor.
[0209] Optionally, the scaling unit 1202 is configured to:
[0210] based on the v th vertical convolution center, a plurality of second pixel points are obtained from the k th column of pixel points included in the first intermediate picture, v = 0, 1, 2, …, M-1, k = 0, 1, 2, …, N-1, the plurality of second pixel points include at least one second pixel point with a row number less than or equal to the v th vertical convolution center and at least one second pixel point with a row number greater than the v th vertical convolution center;
[0211] based on the row number of each second pixel point, the v th vertical convolution center and the vertical scaling factor, a convolution weight of each second pixel point is obtained;
[0212] The scaling unit 1202 obtains the pixel point in the vth row and the kth column of the target picture based on each second pixel point and the convolution weight of each second pixel point. For details, please refer to 3033 in the method 300 shown in FIG. 3.
[0213] Optionally, the scaling unit 1202 obtains the plurality of second pixel points from the pixel points in the kth column of the first intermediate picture based on the vth longitudinal convolution center. For details, please refer to 3031 in the method 300 shown in FIG. 3.
[0214] Optionally, the scaling unit 1202 obtains the convolution weight of each second pixel point based on the row number of each second pixel point, the vth longitudinal convolution center, and the longitudinal scaling factor. For details, please refer to 3032 in the method 300 shown in FIG. 3.
[0215] Optionally, the scaling unit 1202 obtains the pixel point in the vth row and the kth column of the target picture based on each second pixel point and the convolution weight of each second pixel point. For details, please refer to 3033 in the method 300 shown in FIG. 3.
[0216] Optionally, the number of the plurality of second pixel points is equal to the second number, and the second number is determined based on the longitudinal scaling factor.
[0217] Optionally, the plurality of convolution centers include M longitudinal convolution centers and N transverse convolution centers, and the scaling factor includes a longitudinal scaling factor and a transverse scaling factor. The scaling unit 1202 is configured to:
[0218] The scaling unit 1202 scales the height of the original picture based on the M longitudinal convolution centers and the longitudinal scaling factor to obtain a second intermediate picture, and the second intermediate target picture includes M rows and K columns of pixel points.
[0219] The scaling unit 1202 scales the width of the second intermediate picture based on the N transverse convolution centers and the transverse scaling factor to obtain the target picture.
[0220] Optionally, the scaling unit 1202 scales the height of the original picture based on the M longitudinal convolution centers and the longitudinal scaling factor to obtain the second intermediate picture. For details, please refer to the related content in step 302 of the method 300 shown in FIG. 3.
[0221] Optionally, the scaling unit 1202 scales the width of the second intermediate picture based on the N transverse convolution centers and the transverse scaling factor to obtain the target picture. For details, please refer to the related content in step 303 of the method 300 shown in FIG. 3.
[0222] Optionally, the plurality of convolution centers include M longitudinal convolution centers and N transverse convolution centers, and the scaling factor includes a longitudinal scaling factor and a transverse scaling factor. The scaling unit 1202 is configured to:
[0223] obtaining an image region from the original picture based on the nth transverse convolution center and the mth longitudinal convolution center, n = 0, 1, 2, …, N-1, m = 0, 1, 2, …, M-1, the image region including a plurality of rows and a plurality of columns of pixel points, the plurality of columns of pixel points in the image region including at least one column of pixel points with a column number less than or equal to the nth transverse convolution center and at least one column of pixel points with a column number greater than the nth transverse convolution center, the plurality of rows of pixel points in the image region including at least one row of pixel points with a row number less than or equal to the mth longitudinal convolution center and at least one row of pixel points with a row number greater than the mth longitudinal convolution center;
[0224] obtaining a transverse convolution weight of each pixel point based on a column number of each pixel point in the image region, the nth transverse convolution center and a transverse scaling factor;
[0225] obtaining a longitudinal convolution weight of each pixel point based on a row number of each pixel point, the mth longitudinal convolution center and a longitudinal scaling factor;
[0226] obtaining a pixel point included in the mth row and the nth column of the target picture based on each pixel point, the transverse convolution weight and the longitudinal convolution weight of each pixel point.
[0227] Optionally, the scaling unit 1202 can obtain the image region from the original picture based on the nth transverse convolution center and the mth longitudinal convolution center, which can refer to the related content in step 1002 of the method 100 shown in FIG. 10, and will not be described in detail here.
[0228] Optionally, the scaling unit 1202 can obtain the transverse convolution weight of each pixel point based on the column number of each pixel point in the image region, the nth transverse convolution center and the transverse scaling factor, which can refer to the related content in step 1003 of the method 100 shown in FIG. 10, and will not be described in detail here.
[0229] Optionally, the scaling unit 1202 can obtain the longitudinal convolution weight of each pixel point based on the row number of each pixel point, the mth longitudinal convolution center and the longitudinal scaling factor, which can refer to the related content in step 1004 of the method 100 shown in FIG. 10, and will not be described in detail here.
[0230] Optionally, the scaling unit 1202 can obtain the pixel point included in the mth row and the nth column of the target picture based on each pixel point, the transverse convolution weight and the longitudinal convolution weight of each pixel point, which can refer to the related content in step 1004 of the method 100 shown in FIG. 10, and will not be described in detail here.
[0231] In the embodiments of the present application, the acquisition unit acquires a plurality of convolution centers based on the scaling coefficient, and the scaling unit scales the original picture based on the plurality of convolution centers and the scaling coefficient to obtain the target picture. The scaling coefficient is introduced in the process of scaling the original picture based on the plurality of convolution centers to obtain the target picture, so that when the scaling unit scales the original picture, the scaling process is adaptively adjusted with the scaling coefficient, so that the image edges in the target picture will not appear stepped sawtooth, and the image edges will be smooth.
[0232] Referring to FIG. 13, an embodiment of the present application provides a computing device 1300. For example, the computing device 1300 can be the computing device shown in FIG. 1 or FIG. 2, or the computing device 1300 can be the computing device in the method 600 shown in FIG. 3, the method 700 shown in FIG. 7, or the method 1000 shown in FIG. 10, etc.
[0233] As shown in FIG. 13, the computing device 1300 includes a bus 1302, a processor 1304, a memory 1306, and a communication interface 1308. The processor 1304, the memory 1306, and the communication interface 1308 communicate through the bus 1302. The computing device 1300 can be a server or a terminal device. It should be understood that the number of processors and memories in the computing device 1300 is not limited in the present application.
[0234] The bus 1302 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one line is shown in FIG. 13, but it does not mean that there is only one bus or only one type of bus. The bus 1302 can include a path for transmitting information between various components (e.g., the processor 1304, the memory 1306, the communication interface 1308) of the computing device 1300.
[0235] The processor 1304 can include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP), etc.
[0236] The memory 1306 can include volatile memory, such as random access memory (RAM), and non-volatile memory, such as read-only memory (ROM), flash memory, a hard disk drive (HDD), or a solid-state drive (SSD).
[0237] Referring to FIG. 13, the memory 1306 stores executable program code, which the processor 1304 executes to implement the functions of the obtaining unit 1201 and the scaling unit 1202 in the apparatus 1200 shown in FIG. 12, respectively, to implement the method provided by any of the above embodiments. That is, the memory 1306 has instructions for performing the method provided by any of the above embodiments. Alternatively,
[0238] The communication interface 1308 uses a transceiving module such as, but not limited to, a network interface card or a transceiver to enable communication between the computing device 1300 and other devices or communication networks.
[0239] The embodiments of the present disclosure also provide a cluster of scaled pictures. The cluster of scaled pictures includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a notebook computer, or a smartphone.
[0240] As shown in FIG. 14, the cluster of scaled pictures includes at least one computing device 1300. The memory 1306 in one or more computing devices 1300 in the cluster of scaled pictures can store the same instructions for performing the method provided by any of the above embodiments.
[0241] In some possible implementations, the memory 1306 in one or more computing devices 1300 in the cluster of scaled pictures can also respectively store partial instructions for performing the method of scaling pictures. In other words, the combination of one or more computing devices 1300 can collectively execute the instructions for performing the method provided by any of the above embodiments.
[0242] In some possible implementation, one or more computing devices in the cluster of scaled pictures can be connected through a network. Wherein, the network can be a wide area network, a local area network, or the like. FIG. 15 shows one possible implementation. As shown in FIG. 15, two computing devices 1300A and 1300B are connected through a network. Specifically, the computing devices are connected to the network through a communication interface in each computing device.
[0243] In this kind of possible implementation, the memory 1306 in the computing device 1300A stores instructions for performing the function of the obtaining unit 1201 in the embodiment shown in FIG. 12. Meanwhile, the memory 1306 in the computing device 1300B stores instructions for performing the function of the scaling unit 1202 in the embodiment shown in FIG. 12.
[0244] It should be understood that the functions of the computing device 1300A shown in FIG. 15 can also be completed by multiple computing devices 1300. Similarly, the functions of the computing device 1300B can also be completed by multiple computing devices 1300.
[0245] The embodiments of the present application also provide another cluster of scaled pictures. The connection relationship between the computing devices in the cluster of scaled pictures can be similar to the connection mode of the cluster of scaled pictures described with reference to FIG. 15. The difference is that the memory 1306 in one or more computing devices 1300 in the cluster of scaled pictures can store the same instructions for performing the method provided in any of the above embodiments.
[0246] In some possible implementation, the memory 1306 in one or more computing devices 1300 in the cluster of scaled pictures can also respectively store part of the instructions for performing the method provided in any of the above embodiments. In other words, the combination of one or more computing devices 1300 can collectively execute the instructions for performing the method provided in any of the above embodiments.
[0247] The embodiments of the present application also provide a computer program product containing instructions. The computer program product can be a software or program product containing instructions, which can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device is caused to perform the method provided in any of the above embodiments.
[0248] The embodiments of the present application further provide a computer readable storage medium. The computer readable storage medium can be any available medium or data storage device that can store the instructions of the present application and be accessed by a computing device. The computer readable storage medium can be a magnetic medium (e.g., a floppy diskette, a hard disk drive, a magnetic tape), an optical medium (e.g., a DVD), a semiconductor medium (e.g., a solid state hard drive) or the like. The computer readable storage medium includes instructions that instruct the computing device to perform the method provided by any of the embodiments described above.
[0249] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or can be instructed by a program to complete the related hardware, and the program can be stored in a computer readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0250] The above description is only optional embodiments of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method of scaling a picture, characterized by, The method comprises: obtaining a plurality of convolution centers based on scaling coefficients, the scaling coefficients being coefficients for scaling an original picture, the plurality of convolution centers being used for scaling a width and / or a height of the original picture, the original picture comprising Q rows and K columns of pixel points, Q and K each being an integer greater than 1; scaling the original picture based on the plurality of convolution centers and the scaling coefficients to obtain a target picture, the target picture comprising M rows and N columns of pixel points, M and N each being an integer greater than 1, M not equal to Q and / or N not equal to K.
2. The method of claim 1, wherein, The plurality of convolution centers comprises M longitudinal convolution centers and / or N transverse convolution centers, the M longitudinal convolution centers being used for scaling the height of the original picture, and the N transverse convolution centers being used for scaling the width of the original picture. The scaling coefficients comprise longitudinal scaling coefficients and / or transverse scaling coefficients, the longitudinal scaling coefficients being equal to M / Q, and the transverse scaling coefficients being equal to N / K.
3. The method of claim 1 or 2, wherein, The plurality of convolution centers comprises M longitudinal convolution centers and N transverse convolution centers, and the scaling coefficients comprise longitudinal scaling coefficients and transverse scaling coefficients; and the scaling the original picture based on the plurality of convolution centers and the scaling coefficients to obtain a target picture comprises: scaling the width of the original picture based on the N transverse convolution centers and the transverse scaling coefficients to obtain a first intermediate picture, the first intermediate picture comprising Q rows and N columns of pixel points; scaling the height of the first intermediate picture based on the M longitudinal convolution centers and the longitudinal scaling coefficients to obtain the target picture.
4. The method of claim 3, wherein, The scaling the width of the original picture based on the N transverse convolution centers and the transverse scaling coefficients to obtain a first intermediate picture comprises: based on an nth transverse convolution center, obtaining a plurality of first pixel points from mth row pixel points comprised in the original picture, n = 0, 1, 2, …, N-1, m = 0, 1, 2, …, Q-1, the plurality of first pixel points comprising at least one first pixel point with a column number less than or equal to the nth transverse convolution center and at least one first pixel point with a column number greater than the nth transverse convolution center; based on a column number of each first pixel point, the nth transverse convolution center and the transverse scaling coefficients, obtaining a convolution weight of the each first pixel point; based on the each first pixel point and the convolution weight of the each first pixel point, obtaining a pixel point in the mth row and the nth column comprised in the first intermediate picture.
5. The method of claim 4, wherein, A number of the plurality of first pixel points is equal to a first number, the first number being determined based on the transverse scaling coefficients.
6. The method according to any one of claims 3 to 5, wherein, The scaling the height of the first intermediate picture based on the M longitudinal convolution centers and the longitudinal scaling coefficients to obtain the target picture comprises: obtaining a plurality of second pixel points from the first intermediate picture based on the vth longitudinal convolution center, v = 0, 1, 2, …, M-1, k = 0, 1, 2, …, N-1, the plurality of second pixel points including at least one second pixel point with a row number less than or equal to the vth longitudinal convolution center and at least one second pixel point with a row number greater than the vth longitudinal convolution center; obtaining a convolution weight of each second pixel point based on a row number of the each second pixel point, the vth longitudinal convolution center and the longitudinal scaling factor; obtaining a pixel point in the vth row and the kth column of the target picture based on the each second pixel point and the convolution weight of the each second pixel point.
7. The method of claim 6, wherein, A number of the plurality of second pixel points is equal to a second number, the second number being determined based on the longitudinal scaling factor.
8. The method of claim 1 or 2, wherein, The plurality of convolution centers includes M longitudinal convolution centers and N transverse convolution centers, and the scaling factor includes a longitudinal scaling factor and a transverse scaling factor; and the scaling of the original picture based on the plurality of convolution centers and the scaling factor to obtain the target picture includes: scaling a height of the original picture based on the M longitudinal convolution centers and the longitudinal scaling factor to obtain a second intermediate picture, the second intermediate target picture including M rows and K columns of pixel points; scaling a width of the second intermediate picture based on the N transverse convolution centers and the transverse scaling factor to obtain the target picture.
9. The method of claim 1 or 2, wherein, The plurality of convolution centers includes M longitudinal convolution centers and N transverse convolution centers, and the scaling factor includes a longitudinal scaling factor and a transverse scaling factor; and the scaling of the original picture based on the plurality of convolution centers and the scaling factor to obtain the target picture includes: obtaining an image region from the original picture based on an nth transverse convolution center and an mth longitudinal convolution center, n = 0, 1, 2, …, N-1, m = 0, 1, 2, …, M-1, the image region including a plurality of rows and a plurality of columns of pixel points, the plurality of columns of pixel points in the image region including at least one column of pixel points with a column number less than or equal to the nth transverse convolution center and at least one column of pixel points with a column number greater than the nth transverse convolution center, and the plurality of rows of pixel points in the image region including at least one row of pixel points with a row number less than or equal to the mth longitudinal convolution center and at least one row of pixel points with a row number greater than the mth longitudinal convolution center; obtaining a transverse convolution weight of each pixel point in the image region based on a column number of the each pixel point, the nth transverse convolution center and the transverse scaling factor; obtaining a longitudinal convolution weight of the each pixel point based on a row number of the each pixel point, the mth longitudinal convolution center and the longitudinal scaling factor; obtaining a pixel point in the mth row and the nth column of the target picture based on the each pixel point, the transverse convolution weight and the longitudinal convolution weight of the each pixel point.
10. An apparatus for scaling a picture, characterized by The apparatus includes: The acquisition unit is configured to acquire a plurality of convolution centers based on scaling coefficients, the scaling coefficients being coefficients used for scaling an original picture, the plurality of convolution centers being used for scaling a width and / or a height of the original picture, the original picture comprising Q rows and K columns of pixel points, Q and K each being an integer greater than 1; The scaling unit is configured to scale the original picture based on the plurality of convolution centers and the scaling coefficients to obtain a target picture, the target picture comprising M rows and N columns of pixel points, M and N each being an integer greater than 1, M not being equal to Q and / or N not being equal to K.
11. The apparatus of claim 10, wherein, The plurality of convolution centers comprises M longitudinal convolution centers and / or N transverse convolution centers, the M longitudinal convolution centers being used for scaling the height of the original picture, and the N transverse convolution centers being used for scaling the width of the original picture. The scaling coefficients comprise a longitudinal scaling coefficient and / or a transverse scaling coefficient, the longitudinal scaling coefficient being equal to M / Q, and the transverse scaling coefficient being equal to N / K.
12. The apparatus of claim 10 or 11, wherein, The plurality of convolution centers comprises M longitudinal convolution centers and N transverse convolution centers, and the scaling coefficients comprise a longitudinal scaling coefficient and a transverse scaling coefficient; and the scaling unit is configured to: scale the width of the original picture based on the N transverse convolution centers and the transverse scaling coefficient to obtain a first intermediate picture, the first intermediate picture comprising Q rows and N columns of pixel points; scale the height of the first intermediate picture based on the M longitudinal convolution centers and the longitudinal scaling coefficient to obtain the target picture.
13. The apparatus of claim 12, wherein, The scaling unit is configured to: acquire a plurality of first pixel points from mth rows of pixel points comprised in the original picture based on an nth transverse convolution center, n = 0, 1, 2, …, N-1, m = 0, 1, 2, …, Q-1, the plurality of first pixel points comprising at least one first pixel point with a column number less than or equal to the nth transverse convolution center and at least one first pixel point with a column number greater than the nth transverse convolution center; acquire a convolution weight of each first pixel point based on a column number of the each first pixel point, the nth transverse convolution center, and the transverse scaling coefficient; obtain a pixel point in the mth row and the nth column of the first intermediate picture based on the each first pixel point and the convolution weight of the each first pixel point.
14. The apparatus of claim 13, wherein, A number of the plurality of first pixel points is equal to a first number, the first number being determined based on the transverse scaling coefficient.
15. The apparatus of any one of claims 12-14, wherein, The scaling unit is configured to: acquire a plurality of second pixel points from kth columns of pixel points comprised in the first intermediate picture based on a vth longitudinal convolution center, v = 0, 1, 2, …, M-1, k = 0, 1, 2, …, N-1, the plurality of second pixel points comprising at least one second pixel point with a row number less than or equal to the vth longitudinal convolution center and at least one second pixel point with a row number greater than the vth longitudinal convolution center; acquire a convolution weight of each second pixel point based on a row number of the each second pixel point, the vth longitudinal convolution center, and the longitudinal scaling coefficient; and obtain a pixel point in the kth column and the vth row of the target picture based on the each second pixel point and the convolution weight of the each second pixel point. Based on the each second pixel point and the convolution weight of the each second pixel point, a pixel point in a vth row and a kth column included in the target picture is obtained.
16. The apparatus of claim 15, wherein, The number of the plurality of second pixel points is equal to a second number, and the second number is determined based on the vertical scaling coefficient.
17. The apparatus of claim 10 or 11, wherein, The plurality of convolution centers include M vertical convolution centers and N horizontal convolution centers, and the scaling coefficient includes a vertical scaling coefficient and a horizontal scaling coefficient; and the scaling unit is configured to: scale a height of the original picture based on the M vertical convolution centers and the vertical scaling coefficient to obtain a second intermediate picture, the second intermediate target picture including M rows and K columns of pixel points; scale a width of the second intermediate picture based on the N horizontal convolution centers and the horizontal scaling coefficient to obtain the target picture.
18. The apparatus of claim 10 or 11, wherein, The plurality of convolution centers include M vertical convolution centers and N horizontal convolution centers, and the scaling coefficient includes a vertical scaling coefficient and a horizontal scaling coefficient; and the scaling unit is configured to: obtain an image region from the original picture based on an nth horizontal convolution center and an mth vertical convolution center, n = 0, 1, 2, …, N-1, and m = 0, 1, 2, …, M-1, the image region including a plurality of rows and a plurality of columns of pixel points, the plurality of columns of pixel points in the image region including at least one column of pixel points with a column number less than or equal to the nth horizontal convolution center and at least one column of pixel points with a column number greater than the nth horizontal convolution center, and the plurality of rows of pixel points in the image region including at least one row of pixel points with a row number less than or equal to the mth vertical convolution center and at least one row of pixel points with a row number greater than the mth vertical convolution center; obtain a horizontal convolution weight of each pixel point in the image region based on a column number of the each pixel point, the nth horizontal convolution center, and the horizontal scaling coefficient; obtain a vertical convolution weight of the each pixel point based on a row number of the each pixel point, the mth vertical convolution center, and the vertical scaling coefficient; obtain a pixel point in an mth row and an nth column included in the target picture based on the each pixel point, the horizontal convolution weight of the each pixel point, and the vertical convolution weight of the each pixel point.
19. A cluster of computing devices, characterized in that, The at least one computing device includes a processor and a memory. The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the computing device cluster to perform the method of any one of claims 1-9.
20. A computer-readable storage medium, characterized in that, The computer program instructions, when executed by a computing device cluster, cause the computing device cluster to perform the method of any one of claims 1-9.
21. A computer program product comprising instructions, wherein: The instructions, when executed by a computing device cluster, cause the computing device cluster to perform the method of any one of claims 1-9.
Citation Information
Patent Citations
Image zooming method and apparatus
CN101296338A
Image zooming method and device, computer equipment and storage medium
CN109903224A
Image interpolation method and device, electronic equipment and storage medium
CN116843555A