A method and terminal for processing images

By calculating the discrete total variation of each pixel in the image and generating an optical flow map, the problem of image display errors and poor quality in the existing technology is solved, and better image smoothing and motion compensation effects are achieved.

CN113129218BActive Publication Date: 2024-10-25TCL TECHNOLOGY GROUP CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201911396720.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-30
Publication Date
2024-10-25
Estimated Expiration
2039-12-30

AI Technical Summary

Technical Problem

The existing technology uses a method that combines Gaussian smoothed data items with non-local median filtering, which results in image display errors and poor image quality, and is prone to ghosting.

Method used

By calculating the discrete total variation of each pixel in the image, and obtaining the target pixel in the preset area, the optical flow value is calculated based on the number of target pixels and the total variation, and an optical flow map is generated to perform image smoothing. .

Benefits of technology

It improves image display quality and clarity, avoids display errors, and improves the effect of motion compensation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113129218B_ABST
    Figure CN113129218B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of computer technology, and provides a method and terminal for processing images, including: obtaining an image to be processed; calculating the total discrete variation of each pixel in the image to be processed; obtaining the target pixel corresponding to each pixel in the preset area corresponding to each pixel; calculating the optical flow value of the corresponding pixel based on the number of target pixels and the total variation of the target pixels; generating an optical flow map of the image to be processed based on the optical flow values ​​of each pixel. In the above method, the terminal performs smoothing on the image to be processed based on the total variation of the image, obtains the corresponding optical flow map, and uses the smoothed image to display on the terminal, which improves the image display quality and clarity, and is less prone to display errors.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and in particular, relates to a method and a terminal for processing an image. Background Art

[0002] The use of motion compensation to compensate continuous images can improve the clarity of image display; when performing motion compensation, the most important thing is to smooth the optical flow. However, in the prior art, the optical flow is smoothed by combining the data items after Gaussian smoothing and non-local median filtering. This method of smoothing the optical flow is prone to cause image errors on the display screen, or cause the image quality of the display screen to be poor and ghosting to appear. Summary of the invention

[0003] In view of this, an embodiment of the present application provides a method and terminal for processing an image to solve the problem that the traditional method of smoothing optical flow easily causes image errors displayed on the display screen, or causes the image displayed on the display screen to have poor quality and ghosting.

[0004] A first aspect of an embodiment of the present application provides a method for processing an image, comprising:

[0005] Get the image to be processed;

[0006] Calculating the discrete total variation of each pixel point in the image to be processed; the discrete total variation is the total variation obtained after performing discrete processing on the total variation of each pixel point in the image to be processed;

[0007] In a preset area corresponding to each pixel point, a target pixel point corresponding to each pixel point is obtained; the discrete total variation of the target pixel point is the same as the discrete total variation of the corresponding pixel point;

[0008] Based on the number of the target pixels and the total variation of the target pixels, calculating the optical flow value of the corresponding pixel;

[0009] Based on the optical flow values ​​of the pixels, an optical flow map of the image to be processed is generated.

[0010] Furthermore, in order to accurately calculate the discrete total variation corresponding to each image to be processed and improve the quality of the image to be processed, calculating the discrete total variation corresponding to each pixel point in the image to be processed specifically includes:

[0011] Acquire the brightness of each pixel in the image to be processed, and calculate the gradient value of each pixel based on the brightness;

[0012] Calculate the total variation of each pixel based on each gradient value;

[0013] normalizing the total variation;

[0014] The normalized total variation is discretized to obtain the discrete total variation of each pixel.

[0015] Furthermore, in order to accurately calculate the discrete total variation corresponding to each image to be processed and improve the quality of the image to be processed, the total variation after normalization is discretized to obtain the discrete total variation of each pixel point, which specifically includes:

[0016] Calculate the product between the normalized total variation and the preset value;

[0017] The product is approximately rounded to obtain the discrete total variation of each pixel point.

[0018] Furthermore, selecting a suitable processing area when smoothing each pixel in the image to be processed can make the smoothing effect of the image to be processed better. The present application also includes: based on the position of each pixel in the image to be processed, setting a preset area corresponding to each pixel.

[0019] Furthermore, in order to improve the quality and clarity of the image to be processed and make the processed image to be processed better, based on the number of the target pixels and the total variation of the target pixels, calculating the optical flow value of the corresponding pixel specifically includes:

[0020] Counting the number of target pixel points corresponding to each pixel point;

[0021] Calculate the sum of total variations of target pixel points corresponding to each pixel point;

[0022] The sum of the total variations of the target pixels is divided by the number of the target pixels, and the calculation result is approximately rounded to obtain the optical flow value of each pixel.

[0023] Furthermore, in order to improve the display clarity of the image to be processed on the terminal display interface and avoid ghosting, the present application also includes using the optical flow map to perform frame insertion processing on the image to be processed to obtain the image to be played.

[0024] A second aspect of an embodiment of the present invention provides a terminal for processing an image, the terminal comprising:

[0025] A first acquisition unit, used for acquiring an image to be processed;

[0026] A first calculation unit is used to calculate the discrete total variation of each pixel point in the image to be processed; the discrete total variation is the total variation obtained after the total variation of each pixel point in the image to be processed is discretely processed;

[0027] A second acquisition unit is used to acquire a target pixel corresponding to each pixel in a preset area corresponding to each pixel; the discrete total variation of the target pixel is the same as the discrete total variation of the corresponding pixel;

[0028] A second calculation unit, configured to calculate an optical flow value of the corresponding pixel based on the number of the target pixel points and the total variation of the target pixel points;

[0029] A generating unit is used to generate an optical flow map of the image to be processed based on the optical flow value of each pixel point.

[0030] Furthermore, the first computing unit includes:

[0031] A brightness acquisition unit, used to acquire the brightness of each pixel in the image to be processed, and calculate the gradient value of each pixel based on the brightness;

[0032] A total variation calculation unit, used for calculating the total variation of each pixel point based on each gradient value;

[0033] A total variation calculation unit, used for normalizing the total variation;

[0034] The discrete processing unit is used to perform discrete processing on the normalized total variation to obtain the discrete total variation of each pixel point.

[0035] Furthermore, the discrete processing unit is specifically used for:

[0036] Calculate the product between the normalized total variation and the preset value;

[0037] The product is approximately rounded to obtain the discrete total variation of each pixel point.

[0038] Furthermore, the second computing unit is specifically configured to:

[0039] Counting the number of target pixel points corresponding to each pixel point;

[0040] Calculate the sum of total variations of target pixel points corresponding to each pixel point;

[0041] The sum of the total variations of the target pixels is divided by the number of the target pixels, and the calculation result is approximately rounded to obtain the optical flow value of each pixel.

[0042] Furthermore, the terminal further includes:

[0043] The setting unit is used to set a preset area corresponding to each pixel point based on the position of each pixel point in the image to be processed.

[0044] Furthermore, the terminal further includes:

[0045] The frame insertion processing unit is used to perform frame insertion processing on the image to be processed by using the optical flow map to obtain the image to be played.

[0046] A third aspect of an embodiment of the present invention provides another terminal, including a processor, an input device, an output device, and a memory, wherein the processor, the input device, the output device, and the memory are interconnected, wherein the memory is used to store a computer program that supports the terminal to execute the above method, the computer program includes program instructions, and the processor is configured to call the program instructions to perform the following steps:

[0047] Get the image to be processed;

[0048] Calculating the discrete total variation of each pixel point in the image to be processed; the discrete total variation is the total variation obtained after performing discrete processing on the total variation of each pixel point in the image to be processed;

[0049] In a preset area corresponding to each pixel point, a target pixel point corresponding to each pixel point is obtained; the discrete total variation of the target pixel point is the same as the discrete total variation of the corresponding pixel point;

[0050] Based on the number of the target pixels and the total variation of the target pixels, calculating the optical flow value of the corresponding pixel;

[0051] Based on the optical flow values ​​of the pixels, an optical flow map of the image to be processed is generated.

[0052] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0053] Get the image to be processed;

[0054] Calculating the discrete total variation of each pixel point in the image to be processed; the discrete total variation is the total variation obtained after performing discrete processing on the total variation of each pixel point in the image to be processed;

[0055] In a preset area corresponding to each pixel point, a target pixel point corresponding to each pixel point is obtained; the discrete total variation of the target pixel point is the same as the discrete total variation of the corresponding pixel point;

[0056] Based on the number of the target pixels and the total variation of the target pixels, calculating the optical flow value of the corresponding pixel;

[0057] Based on the optical flow values ​​of the pixels, an optical flow map of the image to be processed is generated.

[0058] The method and terminal for processing an image provided by the embodiment of the present application have the following beneficial effects:

[0059] In an embodiment of the present application, an image to be processed is obtained; the total discrete variation of each pixel in the image to be processed is calculated; in a preset area corresponding to each pixel, the target pixel corresponding to each pixel is obtained; based on the number of target pixels and the total variation of the target pixels, the optical flow value of the corresponding pixel is calculated; based on the optical flow values ​​of each pixel, an optical flow map of the image to be processed is generated. In an embodiment of the present invention, the image to be processed is smoothed based on the total variation of the image to obtain a corresponding optical flow map. The smoothed image is used to display on a terminal, which improves the image display quality and clarity, is less prone to display errors, and improves the effect of motion compensation. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0061] Figure 1 is a flowchart of an implementation method of an image processing method provided by an embodiment of the present application;

[0062] Figure 2 is a flowchart of an implementation method of an image processing method provided by another embodiment of the present application;

[0063] Figure 3 is a schematic diagram of a terminal for processing images provided by an embodiment of the present application;

[0064] Figure 4 It is a schematic diagram of a terminal for processing images provided in another embodiment of the present application. DETAILED DESCRIPTION

[0065] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0066] See also Figure 1 , Figure 1is a schematic flow chart of a method for processing an image provided by an embodiment of the present invention. The execution subject of the method for processing an image in this embodiment is a terminal, which includes but is not limited to mobile terminals such as smart phones, tablet computers, personal digital assistants (PDAs), and may also include terminals such as desktop computers. Figure 1 The method of processing an image may include:

[0067] S101: Acquire an image to be processed.

[0068] When the terminal detects an instruction to process an image, it obtains the image to be processed. The instruction to process an image can be triggered by the user, such as when the user clicks on an option to process an image in the terminal. The terminal can obtain the image to be processed from all images to be processed; it can also obtain the image to be processed from a video to be processed; or it can be an image to be processed uploaded by a user. For example, the first image corresponding to time t0 in a video sequence to be processed is obtained as the image to be processed, or the second image corresponding to time t1 in the video sequence is obtained as the image to be processed; this is only an exemplary description and is not limited to this.

[0069] S102: Calculate the discrete total variation of each pixel in the image to be processed; the discrete total variation is the total variation obtained after performing discrete processing on the total variation of each pixel in the image to be processed.

[0070] The terminal calculates the total discrete variation of each pixel in the image to be processed; the total discrete variation is the total variation obtained after the total variation of each pixel in the image to be processed is discretely processed. Specifically, the terminal obtains the brightness corresponding to each pixel in the image to be processed, and calculates the gradient values ​​of these pixels based on the brightness; calculates the total variation corresponding to each pixel based on these gradient values, normalizes the total variation, and discretizes the normalized total variation to obtain the discrete total variation of each pixel.

[0071] Furthermore, in order to accurately calculate the discrete total variation corresponding to each pixel point and improve the quality of the image to be processed, S102 may include: S1021-S1024, which are specifically as follows:

[0072] S1021: Obtain the brightness of each pixel in the image to be processed, and calculate the gradient value of each pixel based on the brightness.

[0073] The terminal obtains the brightness corresponding to each pixel in the image to be processed, and calculates the gradient values ​​corresponding to each of these pixel points in the image to be processed based on these brightnesses. Specifically, the terminal obtains the brightness corresponding to the pixel in the image to be processed, such as the brightness obtained is I(x,y); the corresponding gradient value is calculated based on the brightness I(x,y). Among them, (x,y) is the horizontal coordinate and vertical coordinate of the pixel in the image to be processed; the gradient value can include the horizontal gradient value and the vertical gradient value. The specific calculation method is as follows:

[0074] Horizontal gradient value: G x (x,y)=I(x+1,y)-I(x,y)

[0075] Vertical gradient value: G y (x,y)=I(x,y+1)-I(x,y)

[0076] Among them, G x (x, y) represents the horizontal gradient value corresponding to the pixel point, G y (x,y) represents the vertical gradient value corresponding to the pixel.

[0077] S1022: Calculate the total variation of each pixel based on each gradient value.

[0078] The terminal calculates the total variation corresponding to each pixel point according to each calculated gradient value. Specifically, the terminal calculates the total variation corresponding to each pixel point according to the calculated horizontal gradient value and vertical gradient value corresponding to each pixel point. The total variation can be calculated by the following formula:

[0079] Total variation:

[0080] For example, the calculated horizontal gradient value: G x (x, y) and the calculated vertical gradient value: G y Substituting (x,y) into the formula for calculating total variation, the total variation can be found.

[0081] S1023: Normalize the total variation.

[0082] The terminal normalizes the total variation, that is, the terminal obtains the calculated total variation corresponding to each pixel point, and normalizes these total variations to the interval [0,1]; it can be understood as mapping the data to the range of 0-1. Specifically, the terminal adds the total variation of all pixels calculated in the image to be processed to obtain the sum of the total variation; the total variation of each pixel in the image to be processed is divided by the sum of the total variation, and the obtained value is the value after the normalization of the total variation, which is in the interval [0,1].

[0083] S1024: Discretize the normalized total variation to obtain a discrete total variation of each pixel.

[0084] The terminal discretizes the normalized total variation to obtain the discrete total variation of each pixel. Specifically, the normalized total variation is in the interval [0,1], and the values ​​in [0,1] are discretized; for example, each value in [0,1] is multiplied by a preset value, and each product is approximated to an integer to obtain the discrete total variation corresponding to each value in [0,1], that is, the discrete total variation corresponding to each pixel in the image to be processed is obtained. The preset value is a positive integer, and the specific value is set by the user, and there is no limitation on this.

[0085] Furthermore, in order to accurately calculate the discrete total variation corresponding to each pixel point and improve the quality of the image to be processed, S1024 may include: S10241-S10242, which are specifically as follows:

[0086] S10241: Calculate the product of the normalized total variation and a preset value.

[0087] The terminal calculates the product of the normalized total variation and a preset value. The preset value is a positive integer, and the specific value is set by the user, and there is no limitation on this. For example, the terminal multiplies each normalized total variation by a positive integer N to obtain a corresponding product.

[0088] S10242: Approximately round the product to obtain a discrete total variation of each pixel point.

[0089] The terminal performs approximate rounding processing on each product to obtain the discrete total variation corresponding to each product, that is, the discrete total variation corresponding to each pixel point in each image to be processed. Specifically, the terminal selects the positive integer closest to each product, and records the positive integer as the discrete total variation of the product, that is, the discrete total variation corresponding to each pixel point in each image to be processed.

[0090] S103: In a preset area corresponding to each pixel point, obtaining a target pixel point corresponding to each pixel point; the discrete total variation of the target pixel point is the same as the discrete total variation of the corresponding pixel point.

[0091] The terminal obtains a preset area corresponding to each pixel point, and obtains a target pixel point corresponding to the pixel point in the preset area. The discrete total variation of the target pixel point is the same as the discrete total variation of the pixel point, that is, the target pixel point is a pixel point in the preset area whose discrete total variation is equal to the discrete total variation of the pixel point. For example, in an application scenario, (2m+1) represents the length of the preset area, and (2n+1) represents the width of the preset area, forming an area with a certain pixel point as the center point and an area of ​​(2m+1)(2n+1). Both m and n are positive integers greater than 0. The values ​​of m and n can be set by the user according to the actual situation, for example, m=2, n=1, and there is no limitation on this.

[0092] Furthermore, selecting a suitable processing area when smoothing each pixel in the image to be processed can make the smoothing effect of the image to be processed better. Before S103, it can also include: based on the position of each pixel in the image to be processed, setting a preset area corresponding to each pixel.

[0093] The terminal sets a preset area corresponding to each pixel point based on the position of each pixel point in the image to be processed. Specifically, the terminal obtains the pixel value corresponding to each pixel point in each image to be processed, and the position of the pixel point in the image to be processed can be determined by the pixel value, and the corresponding preset area is set for the pixel point at the position. For example, with the position of a certain pixel point in the image to be processed as the center and (2m+1)(2n+1) as the size, a preset area is set for the pixel point. Among them, the size of the preset area can be set and adjusted by the user, and there is no limitation on this.

[0094] S104: Calculate the optical flow value of the corresponding pixel based on the number of the target pixel and the total variation of the target pixel.

[0095] The terminal calculates the optical flow value corresponding to each pixel based on the number of target pixels corresponding to each pixel and the total variation of the target pixels. Specifically, the terminal counts the number of target pixels corresponding to each pixel; calculates the sum of the total variation of the target pixels corresponding to each pixel; calculates the quotient between the sum of the total variation and the number of target pixels; and performs approximate rounding on the calculated quotient to obtain the optical flow value corresponding to each pixel.

[0096] Furthermore, in order to improve the quality and clarity of the image to be processed and make the processed image to be processed better, S104 may include: S1041-S1043, which are as follows:

[0097] S1041: Count the number of target pixel points corresponding to each pixel point.

[0098] The terminal obtains the preset area corresponding to each pixel point, and counts the number of target pixel points corresponding to the pixel point in the preset area. For example, in an application scenario, the preset area corresponding to a pixel point in the image to be processed is an area centered at the position of the pixel point and having a size of (2m+1)(2n+1). In the area of ​​(2m+1)(2n+1), the target pixel points whose discrete total variation is the same as the discrete total variation of the pixel point are obtained, and the number of these target pixel points is counted and recorded.

[0099] S1042: Calculate the sum of the total variations of the target pixel points corresponding to each of the pixel points.

[0100] The terminal calculates the sum of the total variations of all target pixels corresponding to each pixel. That is, the terminal adds the total variations of all target pixels corresponding to each pixel in the image to be processed, and records the summed value as the sum of the total variations.

[0101] S1043: Divide the sum of the total variations of the target pixels by the number of the target pixels, and perform approximate rounding processing on the calculation result to obtain the optical flow value of each pixel.

[0102] The terminal divides the total variation of the target pixel points by the number of target pixel points, and performs approximate rounding processing on the calculation result to obtain the optical flow value of each pixel point. Specifically, the sum of the total variation of all target pixel points corresponding to each pixel point in each image to be processed is divided by the number of all target pixel points corresponding to each pixel point to obtain the quotient. The terminal performs approximate rounding processing on the calculated quotient to obtain the optical flow value corresponding to each pixel point. That is, the terminal selects an integer closest to the quotient for the quotient, and records the integer as the optical flow value corresponding to the pixel point. In the same way, the optical flow value corresponding to each pixel point in each image to be processed can be obtained.

[0103] For example, the sum of the total variation of the target pixel points corresponding to the pixel points with a discrete total variation of k in a certain image to be processed can be: Among them, m, n, -m, -n constitute the preset area corresponding to the pixel point, and k represents the discrete total variation. The number of target pixels corresponding to the pixel point can be expressed as: The optical flow value corresponding to this pixel is: F(x k ,y k )=[T A (x k ,y k )÷T B (x k ,y k )], where [] represents the approximate rounding operation.

[0104] Furthermore, when a target pixel point corresponding to the pixel point is not found in the preset area, the discrete total variation corresponding to the pixel point can be directly used as the optical flow value corresponding to the pixel point.

[0105] S105: Generate an optical flow map of the image to be processed based on the optical flow value of each pixel point.

[0106] The terminal obtains the optical flow value of each pixel and generates an optical flow map of the image to be processed for each pixel. It can be understood that the calculated optical flow value of each pixel is the pixel value corresponding to each pixel after processing, and the optical flow map of the image to be processed can be generated based on these processed pixels. Specifically, the optical flow map is obtained by the terminal first obtaining the image to be processed, calculating the discrete total variation of each pixel in the image to be processed; in the preset area corresponding to each pixel, obtaining the target pixel corresponding to each pixel; based on the number of target pixels and the total variation of the target pixels, calculating the optical flow value of the corresponding pixel; and then generating the optical flow map of the image to be processed based on the optical flow values ​​of each pixel. It can be understood that the optical flow map is the optical flow map obtained by the terminal after smoothing the image to be processed based on the total variation of the image. The optical flow of small-sized textures in the image is smoothed in the obtained optical flow map, thereby effectively avoiding motion compensation errors caused by small-sized texture matching errors. For ease of understanding, in an application scenario, the terminal obtains the first image corresponding to time t0 in a video sequence to be processed, and obtains the second image corresponding to time t1 in the video sequence; the first image and the second image are processed as follows, and the first image is used as an example for explanation. Obtain the brightness corresponding to each pixel in the first image, such as the brightness obtained is I(x, y); calculate the corresponding gradient value according to the brightness I(x, y); the gradient value may include a horizontal gradient value: G x (x, y) and the vertical gradient value G y (x, y); the terminal calculates the total variation corresponding to each pixel point based on the calculated horizontal gradient value and vertical gradient value corresponding to each pixel point, for example, the total variation: The terminal normalizes the total variation, and discretizes the normalized total variation to obtain the discrete total variation of each pixel; for example, the terminal calculates the product between the normalized total variation and a preset value, and rounds each product approximately to an integer to obtain the discrete total variation corresponding to each product, that is, the discrete total variation corresponding to each pixel in each image to be processed. The terminal obtains the preset area corresponding to each pixel, and obtains the target pixel corresponding to the pixel in the preset area; for example, in an application scenario, the preset area corresponding to a pixel in the image to be processed is an area centered at the position of the pixel and having a size of (2m+1)(2n+1). In the area of ​​(2m+1)(2n+1) size, search for the target pixel whose discrete total variation is the same as the discrete total variation of the pixel; count the number of target pixels in each preset area; calculate the sum of the total variations of all target pixels corresponding to each pixel; calculate the quotient between the sum of the total variations and the number; perform approximate rounding on the calculated quotient to obtain the optical flow value corresponding to each pixel. For example, the sum of the total variations of the target pixels corresponding to the pixel whose discrete total variation is k in the first image can be: Among them, m, n, -m, -n constitute the preset area corresponding to the pixel point, and k represents the discrete total variation. The number of target pixels corresponding to the pixel point can be expressed as: The optical flow value corresponding to this pixel is: F(x k ,y k )=[T A (x k ,y k )÷T B (x k ,y k )], wherein the symbol [] represents an approximate rounding operation. Based on all the pixels and the optical flow values ​​corresponding to each pixel, an optical flow map corresponding to the first image is generated.

[0107] In an embodiment of the present application, an image to be processed is obtained; the total discrete variation of each pixel in the image to be processed is calculated; in a preset area corresponding to each pixel, the target pixel corresponding to each pixel is obtained; based on the number of target pixels and the total variation of the target pixels, the optical flow value of the corresponding pixel is calculated; based on the optical flow values ​​of each pixel, an optical flow map of the image to be processed is generated. In an embodiment of the present invention, the image to be processed is smoothed based on the total variation of the image to obtain a corresponding optical flow map. The smoothed image is used to display on a terminal, which improves the image display quality and clarity, is less prone to display errors, and improves the effect of motion compensation.

[0108] See also Figure 2 , Figure 21 is a schematic flow chart of a method for processing an image provided by another embodiment of the present invention. The execution subject of the method for processing an image in this embodiment is a terminal, which includes but is not limited to mobile terminals such as smart phones, tablet computers, personal digital assistants, and may also include terminals such as desktop computers.

[0109] The difference between this embodiment and the previous embodiment is S206. S201-S205 in this embodiment are exactly the same as S101-S105 in the previous embodiment. Please refer to the relevant description of S101-S105 in the previous embodiment for details, which will not be repeated here.

[0110] Furthermore, in order to improve the display clarity of the image to be processed on the terminal display interface and avoid ghosting, S206 may be included after S205, as follows:

[0111] S206: Perform frame insertion processing on the image to be processed by using the optical flow map to obtain an image to be played.

[0112] The terminal uses the optical flow map to perform interpolation processing on the image to be processed, that is, inserting the optical flow map before or after the corresponding image to be processed to obtain the image to be played. For example, there are two images to be processed, namely the first image to be processed and the second image to be processed, and the corresponding two optical flow maps are the first optical flow map and the second optical flow map. Insert the first optical flow map before the first image to be processed, or insert the first optical flow map after the first image to be processed; insert the second optical flow map before the second image to be processed, or insert the second optical flow map after the second image to be processed to obtain the image to be played. For example, the images to be played are the first image to be processed, the first interpolated image to be processed, the second image to be processed, and the second interpolated image to be processed; this is only an exemplary description and is not limited to this. The image to be played can be played on the terminal, or the terminal can send the image to be played to other playback devices for playback by other playback devices.

[0113] In an embodiment of the present application, an image to be processed is obtained; the total discrete variation of each pixel in the image to be processed is calculated; in a preset area corresponding to each pixel, the target pixel corresponding to each pixel is obtained; based on the number of target pixels and the total variation of the target pixels, the optical flow value of the corresponding pixel is calculated; based on the optical flow values ​​of each pixel, an optical flow map of the image to be processed is generated. In an embodiment of the present invention, the image to be processed is smoothed based on the total variation of the image to obtain a corresponding optical flow map. The smoothed image is used to display on a terminal, which improves the image display quality and clarity, is less prone to display errors, and improves the effect of motion compensation.

[0114] See also Figure 3 , Figure 3is a schematic diagram of a terminal for processing an image provided by an embodiment of the present application. The terminal includes units for executing Figure 1 , Figure 2 For details, please refer to the steps in the corresponding embodiment. Figure 1 , Figure 2 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 3 ,include:

[0115] A first acquisition unit 310 is used to acquire an image to be processed;

[0116] A first calculation unit 320 is used to calculate the discrete total variation of each pixel point in the image to be processed; the discrete total variation is the total variation obtained after the total variation of each pixel point in the image to be processed is discretely processed;

[0117] A second acquisition unit 330 is used to acquire a target pixel corresponding to each pixel in a preset area corresponding to each pixel; the discrete total variation of the target pixel is the same as the discrete total variation of the corresponding pixel;

[0118] A second calculation unit 340, configured to calculate an optical flow value of the corresponding pixel based on the number of the target pixel points and the total variation of the target pixel points;

[0119] The generating unit 350 is configured to generate an optical flow map of the image to be processed based on the optical flow value of each pixel point.

[0120] Furthermore, the first calculation unit 320 includes:

[0121] A brightness acquisition unit, used to acquire the brightness of each pixel in the image to be processed, and calculate the gradient value of each pixel based on the brightness;

[0122] A total variation calculation unit, used for calculating the total variation of each pixel point based on each gradient value;

[0123] A total variation calculation unit, used for normalizing the total variation;

[0124] The discrete processing unit is used to perform discrete processing on the normalized total variation to obtain the discrete total variation of each pixel point.

[0125] Furthermore, the discrete processing unit is specifically used for:

[0126] Calculate the product between the normalized total variation and the preset value;

[0127] The product is approximately rounded to obtain the discrete total variation of each pixel point.

[0128] Furthermore, the second calculating unit 340 is specifically configured to:

[0129] Counting the number of target pixel points corresponding to each pixel point;

[0130] Calculate the sum of total variations of target pixel points corresponding to each pixel point;

[0131] The sum of the total variations of the target pixels is divided by the number of the target pixels, and the calculation result is approximately rounded to obtain the optical flow value of each pixel.

[0132] Furthermore, the terminal further includes:

[0133] The setting unit is used to set a preset area corresponding to each pixel point based on the position of each pixel point in the image to be processed.

[0134] Furthermore, the terminal further includes:

[0135] The frame insertion processing unit is used to perform frame insertion processing on the image to be processed by using the optical flow map to obtain the image to be played.

[0136] See also Figure 4 , Figure 4 FIG. 1 is a schematic diagram of a terminal for processing images provided by another embodiment of the present application. Figure 4 As shown, the terminal 4 of this embodiment includes: a processor 40, a memory 41, and a computer-readable instruction 42 stored in the memory 41 and executable on the processor 40. When the processor 40 executes the computer-readable instruction 42, the steps in the above-mentioned various methods for processing images are implemented, such as Figure 1 Alternatively, when the processor 40 executes the computer-readable instructions 42, the functions of each unit in the above embodiments are realized, for example, Figure 3 The functions of units 310 to 350 are shown.

[0137] Exemplarily, the computer-readable instruction 42 may be divided into one or more units, which are stored in the memory 41 and executed by the processor 40 to complete the present application. The one or more units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer-readable instruction 42 in the terminal 4. For example, the computer-readable instruction 42 may be a first acquisition unit, a first calculation unit, a second acquisition unit, a second calculation unit, and a generation unit, and the specific functions of each unit are as described above.

[0138] The terminal may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will appreciate that Figure 4 It is only an example of terminal 4 and does not constitute a limitation on terminal 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal may also include an input and output terminal, a network access terminal, a bus, etc.

[0139] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0140] The memory 41 may be an internal storage unit of the terminal 4, such as a hard disk or memory of the terminal 4. The memory 41 may also be an external storage terminal of the terminal 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal 4. Further, the memory 41 may also include both an internal storage unit of the terminal 4 and an external storage terminal. The memory 41 is used to store the computer-readable instructions and other programs and data required by the terminal. The memory 41 may also be used to temporarily store data that has been output or is to be output.

[0141] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for processing an image, characterized in that: include: Get the image to be processed; Calculating the total discrete variation of each pixel in the image to be processed; The discrete total variation is the total variation obtained after performing discrete processing on the total variation of each pixel in the image to be processed; In a preset area corresponding to each pixel point, a target pixel point corresponding to each pixel point is obtained; the discrete total variation of the target pixel point is the same as the discrete total variation of the corresponding pixel point; Based on the number of the target pixels and the total variation of the target pixels, calculating the optical flow value of the corresponding pixel; The calculating of the optical flow value of each pixel based on the number of target pixels and the total variation of the target pixels includes: counting the number of target pixels corresponding to each pixel; calculating the sum of the total variation of the target pixels corresponding to each pixel; dividing the sum of the total variation of the target pixels corresponding to each pixel by the number of the target pixels corresponding to each pixel, and performing approximate rounding processing on the calculation result to obtain the optical flow value of each pixel; Based on the optical flow values ​​of the pixels, an optical flow map of the image to be processed is generated.

2. The method according to claim 1, characterized in that Calculating the discrete total variation of each pixel in the image to be processed includes: Acquire the brightness of each pixel in the image to be processed, and calculate the gradient value of each pixel based on the brightness; Calculate the total variation of each pixel based on each gradient value; normalizing the total variation; The normalized total variation is discretized to obtain the discrete total variation of each pixel.

3. The method according to claim 2, characterized in that The process of performing discretization on the normalized total variation to obtain the discrete total variation of each pixel point includes: Calculate the product between the normalized total variation and the preset value; The product is approximately rounded to obtain the discrete total variation of each pixel point.

4. The method according to claim 1, characterized in that Before obtaining the target pixel corresponding to each pixel in the preset area corresponding to each pixel, the method further includes: Based on the position of each pixel in the image to be processed, a preset area corresponding to each pixel is set.

5. The method according to any one of claims 1 to 4, characterized in that: After generating the optical flow map of the image to be processed based on the optical flow values ​​of each of the pixel points, the method further includes: The optical flow map is used to perform frame insertion processing on the image to be processed to obtain an image to be played.

6. A terminal for processing an image, characterized in that: include: A first acquisition unit, used for acquiring an image to be processed; A first calculation unit, used to calculate the discrete total variation of each pixel point in the image to be processed; The discrete total variation is the total variation obtained after performing discrete processing on the total variation of each pixel in the image to be processed; A second acquisition unit is used to acquire a target pixel corresponding to each pixel in a preset area corresponding to each pixel; the discrete total variation of the target pixel is the same as the discrete total variation of the corresponding pixel; A second calculation unit, configured to calculate an optical flow value of the corresponding pixel based on the number of the target pixel points and the total variation of the target pixel points; The calculating of the optical flow value of each pixel based on the number of target pixels and the total variation of the target pixels includes: counting the number of target pixels corresponding to each pixel; calculating the sum of the total variation of the target pixels corresponding to each pixel; dividing the sum of the total variation of the target pixels corresponding to each pixel by the number of the target pixels corresponding to each pixel, and performing approximate rounding processing on the calculation result to obtain the optical flow value of each pixel; A generating unit is used to generate an optical flow map of the image to be processed based on the optical flow value of each pixel point.

7. The terminal according to claim 6, characterized in that The terminal further includes: The setting unit is used to set a preset area corresponding to each pixel point based on the position of each pixel point in the image to be processed.

8. A terminal for processing an image, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the computer-readable instructions, the method according to any one of claims 1 to 5 is implemented.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.