Image processing method, device, electronic device and computer readable storage medium

The method improves image quality by distinguishing edge and non-edge pixels in high-resolution frames, using smoothing for non-edge pixels and enhancement for edge pixels, addressing the uniform processing issues in existing methods.

CN112150368BActive Publication Date: 2025-01-03BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910568721.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-27
Publication Date
2025-01-03
Estimated Expiration
2039-06-27

AI Technical Summary

Technical Problem

Existing image processing methods that compress high-resolution image frames to reduce bandwidth and save network costs often result in reduced image quality due to uniform processing of pixels with different parameters, leading to compression noise and loss of details.

Method used

An image processing method that uses a preset edge detection algorithm to differentiate between edge and non-edge pixels, applying a smoothing algorithm to non-edge pixels and an enhancement algorithm to edge pixels, thereby improving image quality by tailoring processing methods to pixel types.

Benefits of technology

Enhances image quality by separately processing edge and non-edge pixels, reducing noise and preserving details, resulting in improved visual output compared to uniform pixel processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112150368B_ABST
    Figure CN112150368B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides an image processing method, device, electronic device and computer-readable storage medium, the method comprising: processing an image frame to be processed by a preset edge detection algorithm, determining edge pixels belonging to edge areas and non-edge pixels belonging to non-edge areas in the image frame to be processed, processing the grayscale values ​​of non-edge pixels based on a preset image smoothing algorithm, processing the grayscale values ​​of edge pixels based on a preset image enhancement algorithm, and obtaining a processed image frame to be processed according to the processed grayscale values ​​of pixels in the image frame to be processed. Based on the above processing, the image quality of the processed image frame can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, device, electronic device and computer-readable storage medium. Background Art

[0002] With the rapid development of computer technology, image frames are becoming more and more high-resolution, resulting in an exponential increase in the size of video resources composed of image frames. In order to reduce the bandwidth occupied by video resources during transmission and save network costs, it is usually necessary to compress the image frames in the video resources. Compressing image frames will reduce the image quality to a certain extent. For example, compression noise will be generated in the compressed image frames, or the details of the image frames will be lost.

[0003] In the prior art, an image enhancement method can be generally used to process a compressed image frame (which can be referred to as an image frame to be processed) to enhance the details of the image frame to be processed. For example, an unsharp mask enhancement algorithm can be used to process the image frame to be processed, or a Retinex (retinal cortex theory) enhancement algorithm can be used to process the image frame to be processed.

[0004] However, since image parameters of different pixels are different, processing all pixels in the image frame to be processed in the same manner may reduce the display effect of some pixels after processing, that is, the image quality of the processed image frame is low. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide an image processing method, device, electronic device and computer-readable storage medium, which can improve the image quality of processed image frames. The specific technical solution is as follows:

[0006] In a first aspect, in order to achieve the above-mentioned purpose, an embodiment of the present application discloses an image processing method, the method comprising:

[0007] Processing the image frame to be processed by a preset edge detection algorithm to determine edge pixel points belonging to the edge area and non-edge pixel points belonging to the non-edge area in the image frame to be processed;

[0008] Based on a preset image smoothing algorithm, the grayscale value of the non-edge pixel is processed;

[0009] Based on a preset image enhancement algorithm, the grayscale value of the edge pixel is processed;

[0010] The processed image frame to be processed is obtained according to the grayscale values ​​of the processed pixels in the image frame to be processed.

[0011] Optionally, the processing of the image frame to be processed by a preset edge detection algorithm to determine edge pixel points belonging to an edge area and non-edge pixel points belonging to a non-edge area in the image frame to be processed includes:

[0012] For each pixel in the image frame to be processed, the gradient of the grayscale value corresponding to the pixel in multiple preset directions is calculated;

[0013] Determine the target gradient with the largest value from the gradients of the grayscale value corresponding to the pixel point in multiple preset directions;

[0014] Determining a gradient threshold according to the distribution of target gradients corresponding to each pixel in the image frame to be processed;

[0015] According to the magnitude relationship between the gradient threshold and the target gradient corresponding to each pixel point, edge pixel points and non-edge pixel points in the image frame to be processed are determined.

[0016] Optionally, determining the gradient threshold according to the distribution of target gradients corresponding to each pixel in the image frame to be processed includes:

[0017] Determining a lower limit gradient according to a distribution histogram of target gradients corresponding to each pixel point in the image frame to be processed, wherein the proportion of pixel points in the image frame to be processed whose corresponding target gradients are less than or equal to the lower limit gradient is a first preset ratio;

[0018] Based on a first preset formula and the lower limit gradient, a gradient threshold is obtained, wherein the first preset formula is:

[0019] Y1=min(max(X1,0),Z1)

[0020] X1 represents the lower limit gradient, Y1 represents the gradient threshold, and Z1 represents a preset value.

[0021] Optionally, determining edge pixels and non-edge pixels in the image frame to be processed according to the magnitude relationship between the gradient threshold and the target gradient corresponding to each pixel point includes:

[0022] For each pixel in the image frame to be processed, determining whether a target gradient corresponding to the pixel is less than the gradient threshold;

[0023] If the target gradient corresponding to the pixel point is less than the gradient threshold, the pixel point is determined to be a non-edge pixel point;

[0024] If the target gradient corresponding to the pixel point is not less than the gradient threshold, the pixel point is determined to be an edge pixel point.

[0025] Optionally, before processing the grayscale values ​​of the edge pixels based on a preset image enhancement algorithm, the method further includes:

[0026] For each pixel point in the image frame to be processed, determining the direction to which the target gradient corresponding to the pixel point belongs as the target direction;

[0027] The processing of the grayscale values ​​of the edge pixels based on a preset image enhancement algorithm includes:

[0028] For each edge pixel, calculate the reference grayscale value of the target direction corresponding to the edge pixel;

[0029] Determine the edge type of the edge pixel point according to the target gradient corresponding to the edge pixel point and the reference grayscale value of the corresponding target direction;

[0030] The grayscale value of the edge pixel is processed according to the image enhancement algorithm corresponding to the edge type of the edge pixel.

[0031] Optionally, the reference grayscale value in the target direction corresponding to the edge pixel point includes a first reference grayscale value and a second reference grayscale value;

[0032] The step of determining the edge type of the edge pixel point according to the target gradient corresponding to the edge pixel point and the reference grayscale value of the corresponding target direction includes:

[0033] Based on a second preset formula, the first reference gray value and the second reference gray value, a first gray threshold, a second gray threshold and a third gray threshold are obtained, wherein the second preset formula is:

[0034]

[0035] S1 represents a first reference gray value, S2 represents a second reference gray value, T1 represents a first gray threshold, T2 represents a second gray threshold, and T3 represents a third gray threshold;

[0036] If the target gradient corresponding to the edge pixel point is less than the first grayscale threshold, determining that the edge type of the edge pixel point is the first edge type;

[0037] If the target gradient corresponding to the edge pixel point is not less than the first grayscale threshold and not greater than the second grayscale threshold, determine that the edge type of the edge pixel point is the second edge type;

[0038] If the target gradient corresponding to the edge pixel point is greater than the second grayscale threshold and not greater than the third grayscale threshold, determine that the edge type of the edge pixel point is the third edge type;

[0039] If the target gradient corresponding to the edge pixel point is greater than the third grayscale threshold, it is determined that the edge type of the edge pixel point is the fourth edge type.

[0040] Optionally, the processing of the grayscale value of the edge pixel point according to the image enhancement algorithm corresponding to the edge type of the edge pixel point includes:

[0041] If the edge type of the edge pixel is the first edge type, calculate the product of the first preset coefficient and the target gradient corresponding to the edge pixel, and use the difference between the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing;

[0042] If the edge type of the edge pixel is the second edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the difference between the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing, wherein the second preset coefficient is greater than the first preset coefficient;

[0043] If the edge type of the edge pixel is the third edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the sum of the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing;

[0044] If the edge type of the edge pixel is the fourth edge type, the product of the first preset coefficient and the target gradient corresponding to the edge pixel is calculated, and the sum of the grayscale value of the edge pixel and the calculated product is used as the grayscale value of the edge pixel after processing.

[0045] In a second aspect, in order to achieve the above-mentioned purpose, the embodiment of the present application further discloses an image processing device, the device comprising:

[0046] A determination module, used to process the image frame to be processed by a preset edge detection algorithm to determine edge pixel points belonging to the edge area and non-edge pixel points belonging to the non-edge area in the image frame to be processed;

[0047] A smoothing module, used for processing the grayscale values ​​of the non-edge pixels based on a preset image smoothing algorithm;

[0048] An enhancement module, used for processing the grayscale value of the edge pixel points based on a preset image enhancement algorithm;

[0049] The processing module is used to obtain the processed image frame to be processed according to the grayscale values ​​of the processed pixels in the image frame to be processed.

[0050] Optionally, the determination module is specifically configured to calculate, for each pixel in the image frame to be processed, the gradient of the grayscale value corresponding to the pixel in multiple preset directions;

[0051] Determine the target gradient with the largest value from the gradients of the grayscale value corresponding to the pixel point in multiple preset directions;

[0052] Determining a gradient threshold according to the distribution of target gradients corresponding to each pixel in the image frame to be processed;

[0053] According to the magnitude relationship between the gradient threshold and the target gradient corresponding to each pixel point, edge pixel points and non-edge pixel points in the image frame to be processed are determined.

[0054] Optionally, the determination module is specifically used to determine the lower limit gradient according to the distribution histogram of the target gradient corresponding to each pixel point in the image frame to be processed, wherein the proportion of the pixel points whose corresponding target gradient in the image frame to be processed is less than and equal to the lower limit gradient is a first preset ratio;

[0055] Based on a first preset formula and the lower limit gradient, a gradient threshold is obtained, wherein the first preset formula is:

[0056] Y1=min(max(X1,0),Z1)

[0057] X1 represents the lower limit gradient, Y1 represents the gradient threshold, and Z1 represents a preset value.

[0058] Optionally, the determination module is specifically configured to determine, for each pixel in the image frame to be processed, whether a target gradient corresponding to the pixel is less than the gradient threshold;

[0059] If the target gradient corresponding to the pixel point is less than the gradient threshold, the pixel point is determined to be a non-edge pixel point;

[0060] If the target gradient corresponding to the pixel point is not less than the gradient threshold, the pixel point is determined to be an edge pixel point.

[0061] Optionally, the determination module is further configured to determine, for each pixel in the image frame to be processed, a direction to which a target gradient corresponding to the pixel belongs as the target direction;

[0062] The enhancement module is specifically used to calculate, for each edge pixel point, a reference grayscale value of the target direction corresponding to the edge pixel point;

[0063] Determine the edge type of the edge pixel point according to the target gradient corresponding to the edge pixel point and the reference grayscale value of the corresponding target direction;

[0064] The grayscale value of the edge pixel is processed according to the image enhancement algorithm corresponding to the edge type of the edge pixel.

[0065] Optionally, the reference grayscale value in the target direction corresponding to the edge pixel point includes a first reference grayscale value and a second reference grayscale value;

[0066] The enhancement module is specifically used to obtain a first grayscale threshold, a second grayscale threshold, and a third grayscale threshold based on a second preset formula, the first reference grayscale value, and the second reference grayscale value, wherein the second preset formula is:

[0067]

[0068] S1 represents a first reference gray value, S2 represents a second reference gray value, T1 represents a first gray threshold, T2 represents a second gray threshold, and T3 represents a third gray threshold;

[0069] If the target gradient corresponding to the edge pixel point is less than the first grayscale threshold, determining that the edge type of the edge pixel point is the first edge type;

[0070] If the target gradient corresponding to the edge pixel point is not less than the first grayscale threshold and not greater than the second grayscale threshold, determine that the edge type of the edge pixel point is the second edge type;

[0071] If the target gradient corresponding to the edge pixel point is greater than the second grayscale threshold and not greater than the third grayscale threshold, determine that the edge type of the edge pixel point is the third edge type;

[0072] If the target gradient corresponding to the edge pixel point is greater than the third grayscale threshold, it is determined that the edge type of the edge pixel point is the fourth edge type.

[0073] Optionally, the enhancement module is specifically configured to calculate, if the edge type of the edge pixel point is the first edge type, a product of a first preset coefficient and a target gradient corresponding to the edge pixel point, and use a difference between the grayscale value of the edge pixel point and the calculated product as the grayscale value of the edge pixel point after processing;

[0074] If the edge type of the edge pixel is the second edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the difference between the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing, wherein the second preset coefficient is greater than the first preset coefficient;

[0075] If the edge type of the edge pixel is the third edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the sum of the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing;

[0076] If the edge type of the edge pixel is the fourth edge type, the product of the first preset coefficient and the target gradient corresponding to the edge pixel is calculated, and the sum of the grayscale value of the edge pixel and the calculated product is used as the grayscale value of the edge pixel after processing.

[0077] On the other hand, in order to achieve the above-mentioned purpose, an embodiment of the present application further discloses an electronic device, the electronic device comprising a memory and a processor;

[0078] The memory is used to store computer programs;

[0079] The processor is used to implement the steps of the image processing method described in the first aspect when executing the program stored in the memory.

[0080] On the other hand, in order to achieve the above-mentioned purpose, an embodiment of the present application further discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the image processing method described in the first aspect above are implemented.

[0081] On the other hand, in order to achieve the above-mentioned purpose, an embodiment of the present application further discloses a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the steps of the image processing method described in the first aspect above.

[0082] The embodiment of the present application provides an image processing method, which can process the image frame to be processed by a preset edge detection algorithm, determine the edge pixels belonging to the edge area and the non-edge pixels belonging to the non-edge area in the image frame to be processed, and then process the grayscale values ​​of the non-edge pixels based on the preset image smoothing algorithm, and process the grayscale values ​​of the edge pixels based on the preset image enhancement algorithm, and then, according to the grayscale values ​​of the processed pixels in the image frame to be processed, the processed image frame to be processed can be obtained. Based on the above processing, different methods are adopted for processing the non-edge pixels and edge pixels in the image frame to be processed, respectively. Compared with the prior art, all pixels in the image frame to be processed are processed according to the same method, which can improve the image quality of the processed image frame.

[0083] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0084] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, 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 work.

[0085] Figure 1 A flowchart of an image processing method provided in an embodiment of the present application;

[0086] Figure 2 A flowchart of a method for determining non-edge pixels and edge pixels provided in an embodiment of the present application;

[0087] Figure 3 A schematic diagram of the distribution of grayscale values ​​of pixels provided in an embodiment of the present application;

[0088] Figure 4 A schematic diagram of weights of adjacent pixels in different directions provided in an embodiment of the present application;

[0089] Figure 5 A flowchart of a method for processing the grayscale value of edge pixels provided in an embodiment of the present application;

[0090] Figure 6 A flowchart of an example of an image processing method provided in an embodiment of the present application;

[0091] Figure 7 A structural diagram of an image processing device provided in an embodiment of the present application;

[0092] Figure 8 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0093] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0094] In the related art, since image parameters of different pixels in the image frame to be processed are different, processing all pixels in the image frame to be processed in the same way may reduce the display effect of certain pixels after processing, that is, the image quality of the processed image frame is low.

[0095] In order to solve the above problems, an embodiment of the present application provides an image processing method, which can be applied to an electronic device, which may be a terminal, or the electronic device may also be a server, and the electronic device is used to process image frames.

[0096] The electronic device can process the image frame to be processed by using a preset edge detection algorithm to determine edge pixel points belonging to the edge area and non-edge pixel points belonging to the non-edge area in the image frame to be processed.

[0097] Then, the electronic device may process the grayscale values ​​of non-edge pixels based on a preset image smoothing algorithm, and process the grayscale values ​​of edge pixels based on a preset image enhancement algorithm.

[0098] Furthermore, the electronic device can obtain the processed image frame to be processed according to the processed grayscale values ​​of the pixels in the image frame to be processed.

[0099] Based on the above processing, the electronic device can adopt different methods to process the non-edge pixels and edge pixels in the image frame to be processed respectively. Compared with the prior art, all pixels in the image frame to be processed are processed in the same way, which can improve the image quality of the processed image frame.

[0100] See also Figure 1 , Figure 1 A flowchart of an image processing method provided in an embodiment of the present application, the method may include the following steps:

[0101] S101: Processing the image frame to be processed by using a preset edge detection algorithm to determine edge pixel points belonging to an edge area and non-edge pixel points belonging to a non-edge area in the image frame to be processed.

[0102] The image frame to be processed can be a single image, or it can be any image frame extracted by the electronic device from the video resource. The image frame to be processed can usually be an image frame in RGB (Red Green Blue) format, that is, the image frame whose image quality is currently to be improved.

[0103] The preset edge detection algorithm may be an algorithm used in the related art to detect edge regions of image frames. By using the preset edge detection algorithm, the pixel points included in the edge region of the image frame to be processed (i.e., edge pixel points) and the pixel points included in the non-edge region (i.e., non-edge pixel points) may be determined.

[0104] The edge area in the image frame is where the image attributes suddenly change in the image frame. It is the place with the greatest uncertainty in the image frame and where the image information is most concentrated. The edge area contains rich information.

[0105] Therefore, edge pixels and non-edge pixels in the image frame to be processed can be processed separately.

[0106] In one implementation, edge pixels and non-edge pixels may be determined based on the grayscale values ​​of pixels in the image frame to be processed.

[0107] Optional, see Figure 2 , S101 may include the following steps:

[0108] S1011: For each pixel in the image frame to be processed, calculate the gradient of the grayscale value corresponding to the pixel in multiple preset directions.

[0109] In the image frame, the gradients of the grayscale values ​​corresponding to the edge pixels and the non-edge pixels in different directions are quite different. Therefore, the edge pixels and the non-edge pixels can be determined according to the gradients of the corresponding grayscale values ​​in different directions.

[0110] The electronic device can convert the image frame to be processed in RGB format into an image frame in YUV (Luminance Chrominance Chroma) format. For example, the image frame to be processed can be converted into YUV420 format and the image parameter of the Y channel, ie, the gray value, can be extracted.

[0111] In one implementation, the electronic device may calculate the gradient (which may be referred to as directional gradient) of the grayscale value corresponding to the pixel point (which may be referred to as the current pixel point) in multiple preset directions based on a Sobel operator.

[0112] See also Figure 3 , Figure 3 A schematic diagram of the grayscale value distribution of pixels provided in an embodiment of the present application.

[0113] Figure 3 In the formula, f(x,y) represents the grayscale value of the current pixel, f(x-1,y-1) represents the grayscale value of the pixel to the upper left of the current pixel, f(x,y-1) represents the grayscale value of the pixel above the current pixel, f(x+1,y-1) represents the grayscale value of the pixel to the upper right of the current pixel, f(x-1,y) represents the grayscale value of the pixel to the left of the current pixel, f(x+1,y) represents the grayscale value of the pixel to the right of the current pixel, f(x-1,y+1) represents the grayscale value of the pixel to the lower left of the current pixel, f(x,y+1) represents the grayscale value of the pixel below the current pixel, and f(x+1,y+1) represents the grayscale value of the pixel to the lower right of the current pixel.

[0114] The preset directions can be set by technicians based on experience, for example, the preset directions can be 0°, 45°, 90° and 135°. The electronic device can calculate the gradient of the grayscale value of the current pixel in different directions based on the weights of adjacent pixels in different directions.

[0115] Accordingly, see Figure 4 , Figure 4 A schematic diagram of the weights of adjacent pixels in different directions provided in an embodiment of the present application.

[0116] Figure 4 In the figure, the upper left corner is a schematic diagram of the weights of adjacent pixel points when the preset direction is the direction corresponding to 0°.

[0117] The upper right corner is a schematic diagram of the weights of adjacent pixel points when the preset direction corresponds to 45°.

[0118] The lower left side is a schematic diagram of the weights of adjacent pixel points when the preset direction corresponds to 90°.

[0119] The lower right corner is a schematic diagram of the weights of adjacent pixel points when the preset direction corresponds to 135°.

[0120] The nine circles in each figure represent the current pixel and eight adjacent pixels, respectively.

[0121] Accordingly, combined Figure 4 According to the following formula, the directional gradient corresponding to the current pixel point in multiple preset directions can be calculated:

[0122] s W1 (x,y)=|f(x-1,y-1)+2*f(x,y-1)+f(x+1,y-1)-f(x-1,y+1)-2*f(x,y+1)-f(x+1,y+1)|;

[0123] s W2 (x,y)=|f(x,y-1)+2*f(x+1,y-1)+f(x+1,y)-f(x-1,y)-2*f(x-1,y+1)-f(x,y+1)|;

[0124] s W3 (x,y)=|f(x+1,y-1)+2*f(x+1,y)+f(x+1,y+1)-f(x-1,y-1)-2*f(x-1,y)-f(x-1,y+1)|;

[0125] s W4(x,y)=|f(x+1,y)+2*f(x+1,y+1)+f(x,y+1)-f(x,y-1)-2*f(x-1,y-1)-f(x-1,y)|.

[0126] Among them, s W1 (x, y) represents the directional gradient corresponding to the current pixel when the preset direction is the direction corresponding to 0°; s W2 (x, y) represents the directional gradient corresponding to the current pixel when the preset direction is the direction corresponding to 45°; s W3 (x, y) represents the directional gradient corresponding to the current pixel when the preset direction is the direction corresponding to 90°; s W4 (x, y) represents the directional gradient corresponding to the current pixel when the preset direction is the direction corresponding to 135°.

[0127] S1012: Determine a target gradient with the largest value from the gradients of the grayscale value corresponding to the pixel point in multiple preset directions.

[0128] After obtaining the directional gradients corresponding to the current pixel point under multiple preset directions, the electronic device can use the directional gradient with the largest value as the target gradient.

[0129] Furthermore, the electronic device can obtain the target gradient corresponding to each pixel point in the image frame to be processed.

[0130] S1013: Determine a gradient threshold according to the distribution of target gradients corresponding to each pixel in the image frame to be processed.

[0131] After obtaining the target gradient corresponding to each pixel point, the electronic device can count the distribution of the target gradient corresponding to the pixel point, and determine the gradient threshold (which can be called the first gradient threshold) based on the distribution of the target gradient. The determined first gradient threshold can be used to determine whether a pixel point is an edge pixel point.

[0132] Optionally, the method for determining the first gradient threshold may include the following steps:

[0133] Step 1: Determine the lower limit gradient according to the distribution histogram of the target gradient corresponding to each pixel in the image frame to be processed.

[0134] The proportion of pixels in the image frame to be processed whose corresponding target gradient is less than or equal to the lower limit gradient is the first preset ratio. The first preset ratio can be set by technicians based on experience, for example, the first preset ratio can be 5%.

[0135] In one implementation, after obtaining the target gradient corresponding to each pixel point in the image frame to be processed, the electronic device can generate a distribution histogram of the target gradient, and then the electronic device can use the target gradient corresponding to the range containing 5% of the pixel points on the left side of the distribution histogram as the lower limit gradient.

[0136] Step 2: Based on the first preset formula and the lower limit gradient, a gradient threshold is obtained.

[0137] Among them, the first preset formula is:

[0138] Y1=min(max(X1,0),Z1)

[0139] X1 represents the lower limit gradient, Y1 represents the first gradient threshold, and Z1 represents a preset value (which may be referred to as a first preset value). The specific value of Z1 may be set by a technician based on experience, for example, Z1 may be 64.

[0140] After obtaining the lower limit gradient, the electronic device can calculate the first gradient threshold according to the first preset formula.

[0141] S1014: Determine edge pixels and non-edge pixels in the image frame to be processed according to the magnitude relationship between the gradient threshold and the target gradient corresponding to each pixel.

[0142] In one implementation, for a certain pixel point in the image frame to be processed, if the target gradient corresponding to the pixel point is less than the determined first gradient threshold, the electronic device can determine that the pixel point is a non-edge pixel point.

[0143] If the target gradient corresponding to the pixel point is greater than or equal to the determined first gradient threshold, the electronic device may determine that the pixel point is an edge pixel point.

[0144] Furthermore, the electronic device can determine all edge pixels and non-edge pixels in the image frame to be processed.

[0145] In one implementation, an upper limit gradient may also be determined, wherein the proportion of pixels in the image frame to be processed whose corresponding target gradient is greater than or equal to the upper limit gradient is a second preset ratio, which may be set by a technician based on experience, for example, the second preset ratio may be 5%.

[0146] Furthermore, another gradient threshold (which may be referred to as a second gradient threshold) may be determined according to the following formula:

[0147] Y2=min(max(X2,Z2),255)

[0148] X2 represents the upper limit gradient, Y2 represents the second gradient threshold, and Z2 represents the second preset value. The specific value of Z2 can be set by technicians based on experience, for example, Z2 can be 128.

[0149] Correspondingly, if the target gradient corresponding to a pixel point is greater than or equal to the first gradient threshold and less than or equal to the second gradient threshold, the pixel point can be determined as a weak edge area; if the target gradient corresponding to the pixel point is greater than the second gradient threshold, the pixel point can be determined as a strong edge area.

[0150] S102: Processing the grayscale values ​​of non-edge pixels based on a preset image smoothing algorithm.

[0151] In actual operation, the main reason for distortion in non-edge areas is the influence of noise. Therefore, for non-edge pixels, the electronic device can process the grayscale values ​​of non-edge pixels according to a preset image smoothing algorithm to obtain processed grayscale values.

[0152] The preset image smoothing algorithm may be a Gaussian filtering algorithm, a mean filtering algorithm, or other image smoothing algorithms for removing noise.

[0153] S103: Processing the grayscale values ​​of edge pixels based on a preset image enhancement algorithm.

[0154] In actual operation, the main reason for distortion in edge areas is loss of details. Therefore, for edge pixels, the electronic device can process the grayscale values ​​of edge pixels according to a preset image enhancement algorithm to obtain processed grayscale values.

[0155] The preset image enhancement algorithm may be a sharpening filter algorithm, or may be other image enhancement algorithms for enhancing image details.

[0156] It is understandable that the embodiment of the present application does not limit the execution order of S102 and S103.

[0157] Optionally, the edge type of the edge pixel point may be determined according to the reference grayscale value, and different image enhancement algorithms may be used to process edge pixels of different edge types.

[0158] Optionally, for each pixel in the image frame to be processed, when determining the target gradient corresponding to the pixel, the direction to which the target gradient corresponding to the pixel belongs may also be determined as the target direction.

[0159] For example, for a certain pixel point, the electronic device determines that the target gradient corresponding to the pixel point is the directional gradient corresponding to the current pixel point when the preset direction is the direction corresponding to 0°. Then the electronic device can determine that the target direction corresponding to the pixel point is the direction corresponding to 0°.

[0160] Accordingly, see Figure 5 , S103 may include the following steps:

[0161] S1031: For each edge pixel, calculate a reference grayscale value of a target direction corresponding to the edge pixel.

[0162] In one implementation, for each edge pixel, after determining the target direction corresponding to the edge pixel, the electronic device can also calculate a reference grayscale value of the target direction corresponding to the edge pixel to determine the edge type of the edge pixel based on the reference grayscale value.

[0163] S1032: Determine the edge type of the edge pixel point according to the target gradient corresponding to the edge pixel point and the reference grayscale value of the corresponding target direction.

[0164] Optionally, the reference grayscale value in the target direction corresponding to the edge pixel point may include a first reference grayscale value and a second reference grayscale value.

[0165] In one implementation, for each edge pixel point, after determining the target direction corresponding to the edge pixel point, the electronic device can calculate the first reference grayscale value and the second reference grayscale value of the target direction corresponding to the edge pixel point according to the following formula.

[0166]

[0167] At this time, the edge pixel is the current pixel, f W11 and f W12 They represent the first reference grayscale value and the second reference grayscale value when the target direction is the direction corresponding to 0°. W21 and f W22 They respectively represent the first reference grayscale value and the second reference grayscale value when the target direction is the direction corresponding to 45°. W31 and f W32 They respectively represent the first reference grayscale value and the second reference grayscale value when the target direction is the direction corresponding to 90°. W41 and f W42 They respectively represent the first reference grayscale value and the second reference grayscale value when the target direction is the direction corresponding to 135°.

[0168] Accordingly, S1032 may include the following steps:

[0169] Step 1: Based on a second preset formula, a first reference grayscale value and a second reference grayscale value, a first grayscale threshold, a second grayscale threshold and a third grayscale threshold are obtained.

[0170] Among them, the second preset formula is:

[0171]

[0172] S1 represents a first reference gray value, S2 represents a second reference gray value, T1 represents a first gray threshold, T2 represents a second gray threshold, and T3 represents a third gray threshold.

[0173] After obtaining the first reference grayscale value and the second reference grayscale value, the electronic device can calculate the first grayscale threshold, the second grayscale threshold and the third grayscale threshold according to the second preset formula.

[0174] Step 2: If the target gradient corresponding to the edge pixel is less than the first grayscale threshold, the edge type of the edge pixel is determined to be the first edge type; if the target gradient corresponding to the edge pixel is not less than the first grayscale threshold and not greater than the second grayscale threshold, the edge type of the edge pixel is determined to be the second edge type; if the target gradient corresponding to the edge pixel is greater than the second grayscale threshold and not greater than the third grayscale threshold, the edge type of the edge pixel is determined to be the third edge type; if the target gradient corresponding to the edge pixel is greater than the third grayscale threshold, the edge type of the edge pixel is determined to be the fourth edge type.

[0175] After obtaining the first grayscale threshold, the second grayscale threshold and the third grayscale threshold, the electronic device can compare the target gradient, the first grayscale threshold, the second grayscale threshold and the third grayscale threshold corresponding to the edge pixel point, and determine the edge type of the edge pixel point based on the size relationship.

[0176] S1033: Processing the grayscale value of the edge pixel point according to the image enhancement algorithm corresponding to the edge type of the edge pixel point.

[0177] After determining the edge type of the edge pixel, the electronic device may process the grayscale value of the edge pixel using an image enhancement algorithm corresponding to the edge type of the edge pixel.

[0178] According to the edge type, the gray value of the edge pixel is processed, which can include the following four cases:

[0179] Case 1: If the edge type of the edge pixel is the first edge type, the product of the first preset coefficient and the target gradient corresponding to the edge pixel is calculated, and the difference between the grayscale value of the edge pixel and the calculated product is used as the grayscale value of the edge pixel after processing.

[0180] Case two: if the edge type of the edge pixel is the second edge type, the product of the second preset coefficient and the target gradient corresponding to the edge pixel is calculated, and the difference between the grayscale value of the edge pixel and the calculated product is used as the grayscale value of the edge pixel after processing, wherein the second preset coefficient is greater than the first preset coefficient.

[0181] Case three, if the edge type of the edge pixel is the third edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the sum of the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing.

[0182] Case four, if the edge type of the edge pixel is the fourth edge type, calculate the product of the first preset coefficient and the target gradient corresponding to the edge pixel, and use the sum of the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing.

[0183] In one implementation, the electronic device may process the grayscale value of the edge pixel according to the following formula.

[0184] g1(x,y)=f(x,y)-γ1*s(x,y);

[0185] g2(x,y)=f(x,y)-γ2*s(x,y);

[0186] g3(x,y)=f(x,y)+γ2*s(x,y);

[0187] g4(x,y)=f(x,y)+γ1*s(x,y).

[0188] Among them, g1(x,y) represents the grayscale value of the edge pixel after processing when the edge type of the edge pixel is the first edge type; g2(x,y) represents the grayscale value of the edge pixel after processing when the edge type of the edge pixel is the second edge type; g3(x,y) represents the grayscale value of the edge pixel after processing when the edge type of the edge pixel is the third edge type; g4(x,y) represents the grayscale value of the edge pixel after processing when the edge type of the edge pixel is the fourth edge type; f(x,y) represents the grayscale value of the edge pixel before processing, s(x,y) represents the target gradient corresponding to the edge pixel, γ1 represents the first preset coefficient, and γ2 represents the second preset coefficient.

[0189] For example, γ1 may be 1 / 24, and γ2 may be 1 / 12, but the present invention is not limited thereto.

[0190] S104: Obtaining a processed image frame to be processed according to the processed grayscale values ​​of the pixels in the image frame to be processed.

[0191] After obtaining the processed grayscale value of each pixel in the image frame to be processed, the electronic device can convert the parameters of the UV channel of each pixel and the processed grayscale value into RGB format, and then obtain the processed image frame to be processed.

[0192] It can be seen that according to the image processing method of the embodiment of the present application, different methods are adopted to process the non-edge pixels and edge pixels in the image frame to be processed. Compared with the prior art, all pixels in the image frame to be processed are processed in the same way, which can improve the image quality of the processed image frame.

[0193] In addition, the image processing method of the present application only processes the parameters of the Y channel, and the image parameters of the Y channel (ie, grayscale values) have no relationship with the color of the image. Therefore, the processed image frame will not produce color difference.

[0194] See also Figure 6 , Figure 6 This is a flowchart of an example of an image processing method provided in an embodiment of the present application. The method may include the following steps:

[0195] S601: Acquire an image frame to be processed.

[0196] S602: For each pixel in the image frame to be processed, calculate the gradient of the grayscale value corresponding to the pixel in multiple preset directions.

[0197] S603: Determine a target gradient with the largest value from the gradients of the grayscale value corresponding to the pixel point in multiple preset directions, and determine the direction to which the target gradient corresponding to the pixel point belongs as the target direction.

[0198] S604: Determine a lower limit gradient according to a distribution histogram of target gradients corresponding to each pixel in the image frame to be processed.

[0199] The proportion of pixels in the image frame to be processed whose corresponding target gradient is less than or equal to the lower limit gradient is 5%.

[0200] S605: Obtain a first gradient threshold based on a first preset formula and a lower limit gradient.

[0201] Among them, the first preset formula is:

[0202] Y1=min(max(X1,0),64)

[0203] X1 represents the lower gradient limit, and Y1 represents the first gradient threshold.

[0204] S606: If the target gradient corresponding to the pixel point is less than the first gradient threshold, determine that the pixel point is a non-edge pixel point; if the target gradient corresponding to the pixel point is not less than the first gradient threshold, determine that the pixel point is an edge pixel point.

[0205] S607: Based on a preset image smoothing algorithm, grayscale values ​​of non-edge pixels in the image frame to be processed are processed.

[0206] S608: For each edge pixel in the image frame to be processed, calculate a first reference grayscale value and a second reference grayscale value in a target direction corresponding to the edge pixel.

[0207] S609: Based on the second preset formula, the first reference grayscale value and the second reference grayscale value, obtain a first grayscale threshold, a second grayscale threshold and a third grayscale threshold.

[0208] Among them, the second preset formula is:

[0209]

[0210] S1 represents a first reference gray value, S2 represents a second reference gray value, T1 represents a first gray threshold, T2 represents a second gray threshold, and T3 represents a third gray threshold.

[0211] S6010: Determine the edge type of the edge pixel point according to the target gradient, the first grayscale threshold, the second grayscale threshold, and the third grayscale threshold corresponding to the edge pixel point.

[0212] S6011: If the edge type of the edge pixel is the first edge type, calculate the product of the first preset coefficient and the target gradient corresponding to the edge pixel, and use the difference between the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing; if the edge type of the edge pixel is the second edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the difference between the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing; if the edge type of the edge pixel is the third edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the sum of the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing; if the edge type of the edge pixel is the fourth edge type, calculate the product of the first preset coefficient and the target gradient corresponding to the edge pixel, and use the sum of the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing.

[0213] The second preset coefficient is greater than the first preset coefficient.

[0214] S6012: Obtain a processed image frame to be processed according to the processed grayscale values ​​of the pixels in the image frame to be processed.

[0215] and Figure 1 Corresponding to the method embodiment of Figure 7 , Figure 7 A structural diagram of an image processing device provided in an embodiment of the present application, the device may include:

[0216] The determination module 701 is used to process the image frame to be processed by using a preset edge detection algorithm to determine edge pixels belonging to the edge area and non-edge pixels belonging to the non-edge area in the image frame to be processed;

[0217] A smoothing module 702 is used to process the grayscale values ​​of non-edge pixels based on a preset image smoothing algorithm;

[0218] The enhancement module 703 is used to process the grayscale values ​​of edge pixels based on a preset image enhancement algorithm;

[0219] The processing module 704 is used to obtain a processed image frame to be processed according to the processed grayscale values ​​of the pixels in the image frame to be processed.

[0220] Optionally, the determination module 701 is specifically configured to calculate, for each pixel in the image frame to be processed, the gradient of the grayscale value corresponding to the pixel in multiple preset directions;

[0221] Determine the target gradient with the largest value from the gradients of the grayscale value corresponding to the pixel point in multiple preset directions;

[0222] Determine the gradient threshold according to the distribution of the target gradient corresponding to each pixel in the image frame to be processed;

[0223] According to the magnitude relationship between the gradient threshold and the target gradient corresponding to each pixel, edge pixels and non-edge pixels in the image frame to be processed are determined.

[0224] Optionally, the determination module 701 is specifically configured to determine a lower limit gradient according to a distribution histogram of target gradients corresponding to each pixel point in the image frame to be processed, wherein the proportion of pixel points in the image frame to be processed whose corresponding target gradients are less than or equal to the lower limit gradient is a first preset ratio;

[0225] Based on the first preset formula and the lower limit gradient, a gradient threshold is obtained, wherein the first preset formula is:

[0226] Y=min(max(X,0),Z)

[0227] X represents the lower limit gradient, Y represents the gradient threshold, and Z represents the preset value.

[0228] Optionally, the determination module 701 is specifically configured to determine, for each pixel in the image frame to be processed, whether a target gradient corresponding to the pixel is less than a gradient threshold;

[0229] If the target gradient corresponding to the pixel is less than the gradient threshold, the pixel is determined to be a non-edge pixel;

[0230] If the target gradient corresponding to the pixel is not less than the gradient threshold, the pixel is determined to be an edge pixel.

[0231] Optionally, the determination module 701 is further configured to determine, for each pixel in the image frame to be processed, a direction to which a target gradient corresponding to the pixel belongs as the target direction;

[0232] The enhancement module 703 is specifically configured to calculate, for each edge pixel point, a reference grayscale value of a target direction corresponding to the edge pixel point;

[0233] Determine the edge type of the edge pixel point according to the target gradient corresponding to the edge pixel point and the reference grayscale value of the corresponding target direction;

[0234] The grayscale value of the edge pixel is processed according to the image enhancement algorithm corresponding to the edge type of the edge pixel.

[0235] Optionally, the reference grayscale value in the target direction corresponding to the edge pixel point includes a first reference grayscale value and a second reference grayscale value;

[0236] The enhancement module 703 is specifically used to obtain a first grayscale threshold, a second grayscale threshold and a third grayscale threshold based on a second preset formula, a first reference grayscale value and a second reference grayscale value, wherein the second preset formula is:

[0237]

[0238] S1 represents a first reference gray value, S2 represents a second reference gray value, T1 represents a first gray threshold, T2 represents a second gray threshold, and T3 represents a third gray threshold;

[0239] If the target gradient corresponding to the edge pixel point is less than the first grayscale threshold, determining that the edge type of the edge pixel point is the first edge type;

[0240] If the target gradient corresponding to the edge pixel point is not less than the first grayscale threshold and not greater than the second grayscale threshold, determine that the edge type of the edge pixel point is the second edge type;

[0241] If the target gradient corresponding to the edge pixel point is greater than the second grayscale threshold and not greater than the third grayscale threshold, determining that the edge type of the edge pixel point is the third edge type;

[0242] If the target gradient corresponding to the edge pixel point is greater than the third grayscale threshold, it is determined that the edge type of the edge pixel point is the fourth edge type.

[0243] Optionally, the enhancement module 703 is specifically configured to calculate, if the edge type of the edge pixel point is the first edge type, a product of a first preset coefficient and a target gradient corresponding to the edge pixel point, and use a difference between the grayscale value of the edge pixel point and the calculated product as the grayscale value of the edge pixel point after processing;

[0244] If the edge type of the edge pixel point is the second edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel point, and use the difference between the grayscale value of the edge pixel point and the calculated product as the grayscale value of the edge pixel point after processing, wherein the second preset coefficient is greater than the first preset coefficient;

[0245] If the edge type of the edge pixel is the third edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the sum of the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing;

[0246] If the edge type of the edge pixel is the fourth edge type, the product of the first preset coefficient and the target gradient corresponding to the edge pixel is calculated, and the sum of the grayscale value of the edge pixel and the calculated product is used as the grayscale value of the edge pixel after processing.

[0247] As can be seen from the above, the image processing device based on the embodiment of the present application processes the image frame to be processed by a preset edge detection algorithm, determines the edge pixels belonging to the edge area and the non-edge pixels belonging to the non-edge area in the image frame to be processed, processes the grayscale values ​​of the non-edge pixels based on the preset image smoothing algorithm, processes the grayscale values ​​of the edge pixels based on the preset image enhancement algorithm, and obtains the processed image frame to be processed according to the processed grayscale values ​​of the pixels in the image frame to be processed. Based on the above processing, the image quality of the processed image frame can be improved.

[0248] The present application also provides an electronic device, such as Figure 8 As shown, it includes a memory 801 and a processor 802;

[0249] Memory 801, used for storing computer programs;

[0250] The processor 802 is used to implement the image processing method provided in the embodiment of the present application when executing the program stored in the memory 801.

[0251] Specifically, the above image processing method includes:

[0252] The image frame to be processed is processed by a preset edge detection algorithm to determine edge pixel points belonging to the edge area and non-edge pixel points belonging to the non-edge area in the image frame to be processed;

[0253] Based on the preset image smoothing algorithm, the grayscale values ​​of non-edge pixels are processed;

[0254] Based on the preset image enhancement algorithm, the gray value of the edge pixel is processed;

[0255] According to the grayscale values ​​of the processed pixels in the image frame to be processed, a processed image frame to be processed is obtained.

[0256] It should be noted that other implementations of the above image processing method are the same as those of the above method embodiments and will not be described in detail here.

[0257] The electronic device may be provided with a communication interface for realizing communication between the electronic device and other devices.

[0258] The processor, communication interface, and memory communicate with each other via a communication bus, and the communication bus mentioned here may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc.

[0259] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0260] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0261] The embodiment of the present application also provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on a computer, the computer executes the image processing method provided by the embodiment of the present application.

[0262] Specifically, the above image processing method includes:

[0263] The image frame to be processed is processed by using a preset edge detection algorithm to determine edge pixel points belonging to the edge area and non-edge pixel points belonging to the non-edge area in the image frame to be processed;

[0264] Based on the preset image smoothing algorithm, the grayscale values ​​of non-edge pixels are processed;

[0265] Based on the preset image enhancement algorithm, the gray value of the edge pixel is processed;

[0266] According to the processed grayscale values ​​of the pixels in the image frame to be processed, a processed image frame to be processed is obtained.

[0267] It should be noted that other implementations of the above image processing method are the same as those of the above method embodiments and will not be described in detail here.

[0268] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the image processing method provided by the embodiment of the present application.

[0269] Specifically, the above image processing method includes:

[0270] The image frame to be processed is processed by using a preset edge detection algorithm to determine edge pixel points belonging to the edge area and non-edge pixel points belonging to the non-edge area in the image frame to be processed;

[0271] Based on the preset image smoothing algorithm, the grayscale values ​​of non-edge pixels are processed;

[0272] Based on the preset image enhancement algorithm, the gray value of the edge pixel is processed;

[0273] According to the processed grayscale values ​​of the pixels in the image frame to be processed, a processed image frame to be processed is obtained.

[0274] It should be noted that other implementations of the above image processing method are the same as those of the above method embodiments and will not be described in detail here.

[0275] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.

[0276] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0277] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0278] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. An image processing method, characterized in that: The method comprises: Processing the image frame to be processed by a preset edge detection algorithm to determine edge pixel points belonging to the edge area and non-edge pixel points belonging to the non-edge area in the image frame to be processed; Based on a preset image smoothing algorithm, the grayscale value of the non-edge pixel is processed; Based on a preset image enhancement algorithm, the grayscale value of the edge pixel is processed; Obtaining the processed image frame to be processed according to the processed grayscale values ​​of the pixels in the image frame to be processed; Before processing the grayscale values ​​of the edge pixels based on the preset image enhancement algorithm, the method further includes: For each pixel point in the image frame to be processed, the direction to which the target gradient corresponding to the pixel point belongs is determined as the target direction; the target gradient corresponding to each pixel point is: the gradient with the largest value among the gradients of the grayscale value corresponding to the pixel point in multiple preset directions; The processing of the grayscale values ​​of the edge pixels based on a preset image enhancement algorithm includes: For each edge pixel, calculate the reference grayscale value of the target direction corresponding to the edge pixel; Determine the edge type of the edge pixel point according to the target gradient corresponding to the edge pixel point and the reference grayscale value of the corresponding target direction; Processing the grayscale value of the edge pixel point according to the image enhancement algorithm corresponding to the edge type of the edge pixel point; The reference grayscale value of the target direction corresponding to the edge pixel point includes a first reference grayscale value and a second reference grayscale value; The step of determining the edge type of the edge pixel point according to the target gradient corresponding to the edge pixel point and the reference grayscale value of the corresponding target direction includes: Based on a second preset formula, the first reference gray value and the second reference gray value, a first gray threshold, a second gray threshold and a third gray threshold are obtained, wherein the second preset formula is: S1 represents a first reference gray value, S2 represents a second reference gray value, T1 represents a first gray threshold, T2 represents a second gray threshold, and T3 represents a third gray threshold; If the target gradient corresponding to the edge pixel point is less than the first grayscale threshold, determining that the edge type of the edge pixel point is the first edge type; If the target gradient corresponding to the edge pixel point is not less than the first grayscale threshold and not greater than the second grayscale threshold, determine that the edge type of the edge pixel point is the second edge type; If the target gradient corresponding to the edge pixel point is greater than the second grayscale threshold and not greater than the third grayscale threshold, determine that the edge type of the edge pixel point is the third edge type; If the target gradient corresponding to the edge pixel point is greater than the third grayscale threshold, it is determined that the edge type of the edge pixel point is the fourth edge type.

2. The method according to claim 1, characterized in that The method of processing the image frame to be processed by using a preset edge detection algorithm to determine edge pixel points belonging to an edge area and non-edge pixel points belonging to a non-edge area in the image frame to be processed includes: For each pixel in the image frame to be processed, the gradient of the grayscale value corresponding to the pixel in multiple preset directions is calculated; Determine the target gradient with the largest value from the gradients of the grayscale value corresponding to the pixel point in multiple preset directions; Determining a gradient threshold according to the distribution of target gradients corresponding to each pixel in the image frame to be processed; According to the magnitude relationship between the gradient threshold and the target gradient corresponding to each pixel point, edge pixel points and non-edge pixel points in the image frame to be processed are determined.

3. The method according to claim 2, characterized in that Determining the gradient threshold according to the distribution of the target gradient corresponding to each pixel in the image frame to be processed includes: Determining a lower limit gradient according to a distribution histogram of target gradients corresponding to each pixel point in the image frame to be processed, wherein the proportion of pixel points in the image frame to be processed whose corresponding target gradients are less than or equal to the lower limit gradient is a first preset ratio; Based on the first preset formula and the lower limit gradient, a gradient threshold is obtained, wherein the first preset formula is: Y1=min(max(X1,0),Z1) X1 represents the lower limit gradient, Y1 represents the gradient threshold, and Z1 represents a preset value.

4. The method according to claim 3, characterized in that The step of determining edge pixels and non-edge pixels in the image frame to be processed according to the magnitude relationship between the gradient threshold and the target gradient corresponding to each pixel point comprises: For each pixel in the image frame to be processed, determining whether a target gradient corresponding to the pixel is less than the gradient threshold; If the target gradient corresponding to the pixel point is less than the gradient threshold, the pixel point is determined to be a non-edge pixel point; If the target gradient corresponding to the pixel point is not less than the gradient threshold, the pixel point is determined to be an edge pixel point.

5. The method according to claim 1, characterized in that The processing of the grayscale value of the edge pixel point according to the image enhancement algorithm corresponding to the edge type of the edge pixel point includes: If the edge type of the edge pixel is the first edge type, calculate the product of the first preset coefficient and the target gradient corresponding to the edge pixel, and use the difference between the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing; If the edge type of the edge pixel is the second edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the difference between the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing, wherein the second preset coefficient is greater than the first preset coefficient; If the edge type of the edge pixel is the third edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the sum of the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing; If the edge type of the edge pixel is the fourth edge type, the product of the first preset coefficient and the target gradient corresponding to the edge pixel is calculated, and the sum of the grayscale value of the edge pixel and the calculated product is used as the grayscale value of the edge pixel after processing.

6. An image processing device, characterized in that: The device comprises: A determination module, used to process the image frame to be processed by a preset edge detection algorithm to determine edge pixel points belonging to the edge area and non-edge pixel points belonging to the non-edge area in the image frame to be processed; A smoothing module, used for processing the grayscale values ​​of the non-edge pixels based on a preset image smoothing algorithm; An enhancement module, used for processing the grayscale value of the edge pixel points based on a preset image enhancement algorithm; A processing module, used for obtaining the processed image frame to be processed according to the grayscale values ​​of the processed pixels in the image frame to be processed; The determination module is further used to determine, for each pixel in the image frame to be processed, a direction to which a target gradient corresponding to the pixel belongs as a target direction; the target gradient corresponding to each pixel is: a gradient with the largest value among the gradients of the grayscale value corresponding to the pixel in multiple preset directions; The enhancement module is specifically used to calculate, for each edge pixel point, a reference grayscale value of the target direction corresponding to the edge pixel point; Determine the edge type of the edge pixel point according to the target gradient corresponding to the edge pixel point and the reference grayscale value of the corresponding target direction; Processing the grayscale value of the edge pixel point according to the image enhancement algorithm corresponding to the edge type of the edge pixel point; The reference grayscale value of the target direction corresponding to the edge pixel point includes a first reference grayscale value and a second reference grayscale value; The enhancement module is specifically used to obtain a first grayscale threshold, a second grayscale threshold, and a third grayscale threshold based on a second preset formula, the first reference grayscale value, and the second reference grayscale value, wherein the second preset formula is: S1 represents a first reference gray value, S2 represents a second reference gray value, T1 represents a first gray threshold, T2 represents a second gray threshold, and T3 represents a third gray threshold; If the target gradient corresponding to the edge pixel point is less than the first grayscale threshold, determining that the edge type of the edge pixel point is the first edge type; If the target gradient corresponding to the edge pixel point is not less than the first grayscale threshold and not greater than the second grayscale threshold, determine that the edge type of the edge pixel point is the second edge type; If the target gradient corresponding to the edge pixel point is greater than the second grayscale threshold and not greater than the third grayscale threshold, determine that the edge type of the edge pixel point is the third edge type; If the target gradient corresponding to the edge pixel point is greater than the third grayscale threshold, it is determined that the edge type of the edge pixel point is the fourth edge type.

7. The device according to claim 6, characterized in that The determination module is specifically used to calculate the gradient of the grayscale value corresponding to each pixel in the image frame to be processed in multiple preset directions; Determine the target gradient with the largest value from the gradients of the grayscale value corresponding to the pixel point in multiple preset directions; Determining a gradient threshold according to the distribution of target gradients corresponding to each pixel in the image frame to be processed; According to the magnitude relationship between the gradient threshold and the target gradient corresponding to each pixel point, edge pixel points and non-edge pixel points in the image frame to be processed are determined.

8. The device according to claim 7, characterized in that The determination module is specifically used to determine the lower limit gradient according to the distribution histogram of the target gradient corresponding to each pixel point in the image frame to be processed, wherein the proportion of the pixel points whose corresponding target gradient in the image frame to be processed is less than or equal to the lower limit gradient is a first preset ratio; Based on the first preset formula and the lower limit gradient, a gradient threshold is obtained, wherein the first preset formula is: Y1=min(max(X1,0),Z1) X1 represents the lower limit gradient, Y1 represents the gradient threshold, and Z1 represents a preset value.

9. The device according to claim 8, characterized in that The determination module is specifically configured to determine, for each pixel in the image frame to be processed, whether a target gradient corresponding to the pixel is less than the gradient threshold; If the target gradient corresponding to the pixel point is less than the gradient threshold, the pixel point is determined to be a non-edge pixel point; If the target gradient corresponding to the pixel point is not less than the gradient threshold, the pixel point is determined to be an edge pixel point.

10. The device according to claim 6, characterized in that The enhancement module is specifically configured to calculate, if the edge type of the edge pixel is the first edge type, a product of a first preset coefficient and a target gradient corresponding to the edge pixel, and use a difference between the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing; If the edge type of the edge pixel is the second edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the difference between the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing, wherein the second preset coefficient is greater than the first preset coefficient; If the edge type of the edge pixel is the third edge type, calculate the product of the second preset coefficient and the target gradient corresponding to the edge pixel, and use the sum of the grayscale value of the edge pixel and the calculated product as the grayscale value of the edge pixel after processing; If the edge type of the edge pixel is the fourth edge type, the product of the first preset coefficient and the target gradient corresponding to the edge pixel is calculated, and the sum of the grayscale value of the edge pixel and the calculated product is used as the grayscale value of the edge pixel after processing.

11. An electronic device, characterized in that: including memory and processor; The memory is used to store computer programs; The processor is used to implement the method steps described in any one of claims 1-5 when executing the program stored in the memory.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 5 are implemented.