Image edge compensation processing method and system
By using first-order and second-order differential convolution kernel groups for detection and compensation, the problems of insufficient edge detection accuracy and color distortion in traditional image processing algorithms are solved, and accurate compensation and optimization of image edges are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-15
- Publication Date
- 2026-03-24
AI Technical Summary
Traditional image processing algorithms are prone to problems such as color distortion and edge blurring when processing edges. They also cannot adapt to the characteristics of different image content, ignore the mutual influence between multiple channels, have limited edge detection accuracy, and are prone to misjudgment or missed judgment.
A first-order differential convolution kernel group is used to process each grayscale channel of the image. Image edges are detected by first-order and second-order differential convolution kernel groups. Combined with preset thresholds and compensation operations, each color channel is independently judged and compensated to optimize the brightness transition effect between edge pixels and adjacent pixels.
It achieves accurate detection and compensation of image edges, avoids abnormal bright spots, and improves the display quality of image edges.
Smart Images

Figure CN121728232A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of display, and particularly relates to an image edge compensation processing method and system. BACKGROUND
[0002] In digital image processing and display technology, the processing quality of edge regions directly affects the visual effect of images. Traditional image processing algorithms are prone to color distortion, edge blurring and other problems when processing edges, especially in high-contrast edge regions, due to the differences in response characteristics of different color channels, often resulting in color edging phenomenon.
[0003] The existing edge compensation methods mainly have the following problems: first, most methods use fixed compensation parameters, which cannot adapt to the characteristics of different image contents; second, traditional methods often process based on a single channel, ignoring the mutual influence between multiple channels; in addition, the detection accuracy of the existing technology for edges is limited, which is prone to misjudgment or omission, based on which, the present application provides an image edge compensation processing method and system. SUMMARY
[0004] To solve the above problems, the present application discloses an image edge compensation processing method and system.
[0005] In a first aspect, the present application discloses an image edge compensation processing method, comprising: receiving an input image to be processed, the image to be processed comprising at least one gray scale channel, each pixel in the gray scale channel having a gray scale value, the gray scale value being used to represent the brightness information of the pixel; constructing a first-order differential convolution kernel group, the first-order differential convolution kernel group comprising a first weight matrix for row direction detection and a second weight matrix for column direction detection; for each gray scale channel of the image to be processed, performing the following operations on each target pixel in the channel: determining a first-order row neighborhood window and a first-order column neighborhood window of the target pixel, the size of the first-order row neighborhood window being consistent with the first weight matrix, and the size of the first-order column neighborhood window being consistent with the second weight matrix; multiplying each weight value in the first weight matrix with the gray scale value of the pixel at the corresponding position in the first-order row neighborhood window one by one and summing up to obtain a first-order row feature value of the target pixel; multiplying each weight value in the second weight matrix with the gray scale value of the pixel at the corresponding position in the first-order column neighborhood window one by one and summing up to obtain a first-order column feature value of the target pixel; For each target pixel in each gray scale channel, it is judged whether the absolute value of the first-order row feature value is not less than a preset first threshold value and / or whether the absolute value of the first-order column feature value is not less than a preset second threshold value; if yes, the target pixel is determined to be an edge pixel in the gray scale channel; if one of the two conditions is met, the target pixel is an edge pixel in the corresponding direction and is not an edge pixel in the non-corresponding direction, and the first-order feature value in the non-corresponding direction is 0; if both are no, the target pixel is determined to be not an edge pixel of the gray scale channel, and the values of the first-order column feature value and the first-order row feature value are both 0; A preset compensation operation is performed on the gray scale values of the edge pixels in each gray scale channel to optimize the brightness transition effect of the edge pixels and the adjacent pixels. Based on the pixel gray scale values of all the compensated gray scale channels, an optimized image is output.
[0006] In a second aspect, the present application discloses an image edge compensation processing system, comprising: An image receiving module is configured to receive an inputted image to be processed. A convolution kernel construction module is configured to construct a first-order differential convolution kernel group or a second-order differential convolution kernel group. A first-order differential convolution kernel group and a second-order differential convolution kernel group; A feature value calculation module is configured to perform a feature value calculation operation on each target pixel in each gray scale channel of the image to be processed. An edge determination module is configured to perform an edge determination on each target pixel in each gray scale channel. A compensation processing module is configured to perform a preset compensation operation on the edge pixels in each gray scale channel. An image output module is configured to output an optimized image based on the pixel gray scale values of all the compensated gray scale channels.
[0007] The present application has the following advantages: 1. The image is processed by differential convolution, wherein the gray scale values of each color channel of each pixel in the image are extracted, so that the edge of the pixel can be determined by the feature value representing the degree of light and dark change, and each color channel is independently determined by the above-mentioned differential convolution, so that the image edge can be accurately detected, and when the edge pixels are compensated, each color channel is independently compensated, effectively avoiding the problem of abnormal bright spots at the image edge.
[0008] 2. In the RGB three color channels in the color image, the corresponding luminance value of each pixel can be calculated based on the extracted gray scale value by setting the preset luminance conversion formula, and the luminance value is taken as the gray scale value of the pixel in the single channel gray scale image, thereby converting the multi-channel gray scale value into the single channel gray scale value, so that the number of judgment can be reduced and the overhead can be reduced when the edge is judged. BRIEF DESCRIPTION OF DRAWINGS
[0009] Figure 1 is a flow diagram of an image edge compensation processing method disclosed by the present application; Figure 2 is a flow diagram of the judgment of the edge pixel in the image edge compensation processing method disclosed by the present application; Figure 3 is a schematic diagram of the first weight matrix in the image edge compensation processing method disclosed by the present application; Figure 4 is a schematic diagram of the second weight matrix in the image edge compensation processing method disclosed by the present application; Figure 5 is a schematic diagram of the third weight matrix in the image edge compensation processing method disclosed by the present application; Figure 6 is a schematic diagram of the fourth weight matrix in the image edge compensation processing method disclosed by the present application. DETAILED DESCRIPTION
[0010] Referring to the drawings Figures 1-6 The present application discloses an image edge compensation processing method, comprising the following steps: S1: receiving an input image to be processed, the image to be processed comprising at least one gray scale channel, each pixel in the gray scale channel having a gray scale value, the gray scale value being used to represent the brightness information of the pixel; S2: constructing a first-order differential convolution kernel group, the first-order differential convolution kernel group comprising a first weight matrix for row direction detection and a second weight matrix for column direction detection; S3: For each gray level channel of the image to be processed, for each target pixel in the channel, the following operations are performed: determining a first-order row neighborhood window and a first-order column neighborhood window of the target pixel, the size of the first-order row neighborhood window being consistent with the first weight matrix, and the size of the first-order column neighborhood window being consistent with the second weight matrix; multiplying each weight value in the first weight matrix with the gray level value of the pixel at the corresponding position in the first-order row neighborhood window, and then summing up to obtain a first-order row feature value of the target pixel; multiplying each weight value in the second weight matrix with the gray level value of the pixel at the corresponding position in the first-order column neighborhood window, and then summing up to obtain a first-order column feature value of the target pixel, wherein the neighborhood window contains all the pixels in the region centered on the target pixel, and the size of the region can be designed according to actual conditions. When the region is designed to be larger, the ability to determine whether the target pixel is an edge pixel is greater, and when the region is designed to be smaller, the ability to determine whether the target pixel is an edge pixel is smaller. S4: For each target pixel in each gray level channel, it is determined whether the absolute value of the first-order row feature value is not less than a preset first threshold value, wherein the first-order row feature value represents the degree of brightness change of the target pixel in the row direction, and / or whether the absolute value of the first-order column feature value is not less than a preset second threshold value, wherein the first-order column feature value represents the degree of brightness change of the target pixel in the column direction. If one of the two conditions is met, the target pixel is an edge pixel in the corresponding direction, is not an edge pixel in the non-corresponding direction, and the first-order feature value in the non-corresponding direction is 0. If both are false, it is determined that the target pixel is not an edge pixel of the gray level channel, and the values of the first-order column feature value and the first-order row feature value are both 0. The advantage of this is that when compensation is performed, the gray level values of a pixel in the row direction and the column direction can be compensated at the same time, i.e., when a pixel is only an edge pixel in the row direction, the gray level compensation value in the column direction is 0 because the first-order feature value in the column direction is 0. Similarly, when a pixel is only an edge pixel in the column direction, the gray level compensation value in the row direction is 0.
[0011] S5: Perform a preset compensation operation on the gray level value of each edge pixel in each gray level channel to optimize the brightness transition effect of the edge pixel and the adjacent pixel.
[0012] In this embodiment, the edge pixel is prone to brightness deviation, which makes it highlight abnormal brightness at the edge. Through compensation of the gray level value, it can be smooth from the perspective of visual brightness, and the display effect of the edge image can be improved. S6: Based on the compensated pixel gray level values of all gray level channels, an optimized image is output.
[0013] In this embodiment, the optimized image no longer has the condition of abnormal bright spots at the edge.
[0014] In one feasible embodiment, the first weight matrix is an m-row, n-column first-order differential convolution kernel, where: n is an odd number not less than 3, m is a positive integer not less than 1, and the sum of all weights in the first weight matrix is 0, such as... Figure 3 As shown; The first weight matrix uses the ((n+1) / 2)th column as the middle column, and all rows in the middle column have a weight of 0. The columns to the left of the middle column are symmetrically distributed with respect to the columns to the right of the middle column. The weights of the left columns are all negative, and the weights of the right columns are all positive. The absolute values of the weights of the left columns and the right columns at symmetrical positions are equal. The first value is defined as the sum of all weights in the right column of the first weight matrix multiplied by the maximum gray level value of the gray channel. This maximum gray level value is the theoretical maximum value of the pixel gray level in that gray channel, determined by the image quantization bit depth. Generally, the theoretical maximum value of a pixel gray level is 2^n - 1, where n is the image quantization bit depth. In a typical 8-bit image, the maximum gray level value is 255. Therefore, the first value is: 255 × (A + B + C + D + E + F) by Figure 3 For example, when determining whether a target pixel is an edge pixel in the row direction, the second row and third column of the first weight matrix are aligned with the target pixel, while the other parts of the first weight matrix correspond to the neighborhood window of the target pixel. That is, A, B, C, D, E, F, -A, -B, -C, -E, and -F are all weight values corresponding to pixels in the neighborhood window. In one feasible scheme, the weight value can be designed to be 2. n The larger the weight value is set, the higher the accuracy of edge detection. The value of n ranges from 0 to 6. Among them, the weight values B, D, F, -B, -D, and -F corresponding to pixels closer to the target pixel can be set to be greater than those of A, C, E, -A, -C, and -E located on both sides. This is because for pixels in the neighborhood window, the closer they are to the target pixel, the more accurate the edge detection will be.
[0015] When the image is a higher-precision 10-bit or 16-bit image, the maximum grayscale value becomes 1023 or 65535. The preset first threshold is greater than 0 and not greater than the first value. Specifically, when setting the first threshold, it can be represented as the product of a coefficient not greater than 1 and the maximum grayscale value. This first threshold represents the row determination value of edge pixels in the row direction. The row determination value depends on the performance of the display chip and the requirements for determining edge pixels in the row direction. The larger the value, the lower the judgment standard in the row direction, and the lower the computational cost of the display chip. Conversely, the lower the value of the first threshold, the higher the judgment standard in the row direction, and the higher the accuracy of edge judgment in the row direction. However, at the same time, the computational cost of the display chip is higher. Therefore, the first threshold can be adjusted according to the actual product's requirements for displaying edge pixels in the row direction to select an appropriate pixel edge judgment capability.
[0016] In one feasible embodiment, the second weight matrix is a first-order differential convolution kernel with rows of j and columns of i, where: j is an odd number not less than 3, i is a positive integer not less than 1, and the sum of all weights in the second weight matrix is 0, such as... Figure 4 As shown; The second weight matrix uses the ((j+1) / 2)th row as the middle row, and all column weights in the middle row are 0; The rows above the middle row and the rows below the middle row are symmetrically distributed, and the weights of the upper rows are all negative, while the weights of the lower rows are all positive. The absolute values of the weights of the upper rows and the lower rows at symmetrical positions are equal. by Figure 4 For example, when determining whether a target pixel is an edge pixel in the row direction, the second row and second column of the second weight matrix are aligned with the target pixel, while the other parts of the first weight matrix correspond to the neighborhood window of the target pixel. That is, G, H, I, -G, -H, and -I are the weight values corresponding to the pixels in the neighborhood window. In one feasible scheme, the weight value can be designed to be 2. n The larger the weight value is set, the higher the accuracy of edge detection. The value of n ranges from 0 to 6.
[0017] The second value is defined as the sum of all weights in the lower row of the second weight matrix multiplied by the maximum grayscale value of the grayscale channel. Taking an 8-bit image as an example, the second value is: 255×(G+H+I) The preset second threshold is greater than 0 and not greater than the second value; When setting the second threshold, it can be represented as the product of a coefficient no greater than 1 and the maximum grayscale value. This second threshold represents the column judgment value of edge pixels in the column direction. The column judgment value also depends on the performance of the display chip and the requirements for judging edge pixels in the column direction. A larger value indicates a lower judgment standard in the row direction and lower computational cost for the display chip. Conversely, a lower second threshold indicates a higher judgment standard in the row direction and higher accuracy in edge judgment, but also higher computational cost for the display chip. Therefore, the second threshold can be adjusted according to the actual product's requirements for column-direction edge display to select an appropriate pixel edge judgment capability.
[0018] In one feasible embodiment, the image to be processed is an RGB color image, which contains three grayscale channels: an R channel, a G channel, and a B channel, wherein: The grayscale value of the R channel is the R channel value of the pixel in the RGB color image, the grayscale value of the G channel is the G channel value of the pixel in the RGB color image, and the grayscale value of the B channel is the B channel value of the pixel in the RGB color image. As can be seen in this embodiment, this solution can perform brightness and darkness edge compensation processing on a single-channel grayscale image, and can also process color images. The processing method is to separate the color image into multiple independent color channels R, G, and B, and then perform grayscale processing on each color channel to achieve grayscale compensation for the above multiple color channels respectively.
[0019] In one feasible embodiment, for a target pixel determined to be an edge pixel, a preset grayscale compensation operation is performed in the R channel, G channel, and B channel of its corresponding RGB color image to determine the grayscale compensation value of the edge pixel in the current channel. The calculation process includes: (1) Define the grayscale ratio of the edge pixel in the current channel: the grayscale ratio is the ratio of the input grayscale value of the pixel to the maximum grayscale value of the current channel; (2) Calculate the third value: The first-order row feature value ratio is determined, which is the ratio of the first-order row feature value of the pixel to the fourth value; the fourth value is the sum of the products of the maximum gray level value of the current channel and the weights of each weight in the right column of the first weight matrix, wherein the fourth value can be characterized as the theoretical maximum value of the first-order row feature value, in the above calculation method; Determine the first-order column feature value ratio: the first-order column feature value ratio is the ratio of the first-order column feature value of the pixel to the fifth value; the fifth value is the sum of the products of the maximum gray level value of the current channel and the weights of each weight in the lower row of the second weight matrix, wherein the fifth value can be characterized as the theoretical maximum value of the first-order column feature value; The third value is the sum of "the product of the first-order row eigenvalue ratio and the first compensation weight" and "the product of the first-order column eigenvalue ratio and the second compensation weight"; where: The first compensation weight is the compensation coefficient in the row direction, which is equal to the maximum grayscale value of the current channel minus the "color shift grayscale value of the row direction color edge in the current channel when transitioning from a full white image to a full black image". The above compensation coefficient is a reference compensation value. That is, when the extreme edge display state is taken, the two sides of the edge are black and white. At this time, a pixel located at the edge in the row direction has a color shift phenomenon. That is, theoretically, the pixel is white, but from a visual point of view, the pixel has a color shift, that is, it is not white when viewed. After the above reference compensation value is added to the pixel for compensation, the pixel is visually white. The compensation coefficient in the color image includes three grayscale compensation values in the red color channel, green color channel and blue color channel respectively. The second compensation weight is the compensation coefficient in the column direction, which is equal to the maximum grayscale value of the current channel minus the "color shift grayscale value of the column direction color edge in the current channel when transitioning from a full white image to a full black image". The above compensation coefficient is another reference compensation value. That is, when the extreme edge display state is taken, the two sides of the edge are black and white. At this time, a pixel located at the edge in the column direction has a color shift phenomenon. That is, theoretically, the pixel is white, but from a visual point of view, the pixel has a color shift, that is, it is not white when viewed. After the above reference compensation value is added to the pixel for compensation, the pixel is visually white. The compensation coefficient also includes three grayscale compensation values in the red color channel, green color channel and blue color channel respectively in the color image. (3) The gray level compensation value is the product of the gray level ratio in step (1) and the third value in step (2). The actual compensation value of the current target pixel in the two directions can be obtained by multiplying the two reference compensation values with the ratio of the first-order feature values in the two directions.
[0020] In one feasible embodiment, based on the compensated pixel grayscale values of all grayscale channels, an optimized image is output, including: Calculate the output grayscale value of the edge pixel in the current channel. The output grayscale value is the input grayscale value of the pixel minus the grayscale compensation value. The compensated R-channel grayscale values, G-channel grayscale values, and B-channel grayscale values are recombined into pixel values of the RGB color image to obtain the optimized RGB color image; In this embodiment, pixel compensation is optimized by decomposing a color image into grayscale values of multiple grayscale channels, compensating the grayscale values of each grayscale channel, and then restoring the pixel values of the color image.
[0021] In one feasible embodiment, the image to be processed is a single-channel grayscale image, which is obtained by converting an RGB color image; the conversion process includes: For each pixel in the RGB color image, the R channel value, G channel value, and B channel value are extracted. The corresponding brightness value is calculated based on a preset brightness conversion formula. The brightness value is used as the grayscale value of the pixel in the single-channel grayscale image. At this time, the brightness information of the pixel in the single-channel grayscale image is represented by the grayscale value. The RGB color image is proportionally converted into a single-channel grayscale image. The advantage of this is that the brightness features of the target pixel can be separated. By increasing the brightness features, the accuracy of edge detection can be improved. The brightness conversion formula is Y = ×R + b × G + c × B, where a, b, and c are weight coefficients, and a + b + c = 1. In most cases, Y = 0.299R + 0.587G + 0.114B.
[0022] In one feasible embodiment, after obtaining the first-order column feature value of the target pixel in step S3, before determining whether the absolute value of the first-order row feature value of each target pixel in the grayscale channel is greater than a preset first threshold, and / or whether the absolute value of the first-order column feature value is greater than a preset second threshold in step S4, the following steps are further included: S01: Construct a second-order differential convolution kernel group, which includes a third weight matrix for row direction detection and a fourth weight matrix for column direction detection. The third weight matrix is as follows: Figure 5 As shown, the fourth weight matrix is as follows: Figure 6 As shown.
[0023] S02: For each grayscale channel of the image to be processed, perform the following operations on each target pixel within that channel: determine the second-order row neighborhood window and the second-order column neighborhood window of the target pixel, wherein the size of the second-order row neighborhood window is consistent with the third weight matrix, and the size of the second-order column neighborhood window is consistent with the fourth weight matrix; multiply each weight value in the third weight matrix by the grayscale value of the corresponding pixel in the second-order row neighborhood window and sum them to obtain the second-order row feature value of the target pixel; multiply each weight value in the fourth weight matrix by the grayscale value of the corresponding pixel in the second-order column neighborhood window and sum them to obtain the second-order column feature value of the target pixel.
[0024] In this embodiment, the second-order row feature value and the second-order column feature value respectively characterize whether the target pixel is darker or brighter than its neighboring pixels in the neighborhood window in two directions. If the target pixel is brighter than its neighboring pixels, it is not considered an edge pixel. Even if the first-order feature value of the target pixel is greater than the first threshold, the target pixel is still identified as a non-edge pixel. Only when the target pixel is darker than its neighboring pixels in both directions and the first-order feature value of the target pixel is greater than the first threshold will the target pixel be identified as an edge pixel. The advantage of this is that the calculation of the first-order feature value of the target pixel only considers the brightness change of the neighborhood window and does not consider its own brightness. In this embodiment, by adding consideration of its own brightness through the second-order feature value, the accuracy of edge pixel judgment can be better achieved.
[0025] In one feasible embodiment, the third weight matrix is a 1-row, h-column second-order differential convolution kernel, wherein: h is an odd number not less than 3, and the sum of all weights in the third weight matrix is 0; The third weight matrix uses the ((h+1) / 2)th column as the middle column, and the row weight of the middle column is negative; the columns to the left of the middle column are symmetrically distributed with the columns to the right of the middle column, and the weight values of the left column and the right column at the symmetrical position are equal. by Figure 5 For example, when determining whether a target pixel is an edge in the row direction, the first row and third column represent the weight value -J corresponding to the target pixel, while K and L on both sides represent the weight values corresponding to pixels within the neighborhood window. The specific values of K and L can be set to 2. n Where n ranges from 0 to 6. In practical use, the value of K can be set to be greater than the value of L. This is because the neighboring window pixels corresponding to the value of K are closer to the target pixel. The closer to the target pixel, the higher the weight value assigned to it will be than the weight value assigned to it that is farther away from the target pixel, the more accurate the edge judgment will be.
[0026] The sixth value is defined as the sum of all weights in any column of the third weight matrix multiplied by the maximum grayscale value of the grayscale channel. The preset third threshold is greater than 0 and not greater than the sixth value. The maximum grayscale value is the numerical result of the third weight matrix calculated using a second-order convolution kernel when the input image is displayed as a black-and-white image with black-and-white edges in the middle column. For example, for an 8-bit image... Figure 5 As shown, at this point, the grayscale values of the middle value and the black border side are both 0. Therefore, the sixth value is: 255×(K+L) The fourth weight matrix is an e-row, 1-column second-order differential convolution kernel, where: e is an odd number not less than 3, and the sum of all weights in the fourth weight matrix is 0; The fourth weight matrix uses the ((e+1) / 2)th row as the middle row, and the row weight of the middle row is negative; the rows above the middle row and the rows below the middle row are symmetrically distributed, and the weight values of the upper row and the lower row at the symmetrical position are equal. by Figure 6 For example, when determining whether a target pixel is an edge in the row direction, the first column of the second row contains the weight value -J corresponding to the target pixel, while the two N values on either side are the weight values corresponding to pixels within the neighborhood window. The specific values of K and L can be set to 2. n , where n ranges from 0 to 6.
[0027] The seventh value is defined as the sum of all weights in any row of the fourth weight matrix multiplied by the maximum grayscale value of the grayscale channel. The preset fourth threshold is greater than 0 and not greater than the seventh value. The third weight matrix is calculated using a second-order convolution kernel when the maximum grayscale value (i.e., when the input image has one side black and one side white, and the middle row has black and white edges). For example, in an 8-bit image... Figure 6 As shown, the seventh value is: 255×N In one feasible embodiment, a preset compensation operation is performed on the grayscale value of the edge pixels within each grayscale channel, including: The edge pixel positions determined in the single-channel grayscale image are mapped to the RGB color image, and the pixels with corresponding coordinates in the RGB color image are determined as edge pixels that need to be compensated. For the edge pixels in the RGB color image that need compensation, independent preset grayscale compensation operations are performed in the R channel, G channel, and B channel respectively.
[0028] In one feasible embodiment, for the edge pixels in the RGB color image that need compensation, independent preset grayscale compensation operations are performed in the R channel, G channel, and B channel respectively to determine the grayscale compensation value of the edge pixels in the current channel. The calculation process includes: (1) Define the grayscale ratio of the edge pixel in the current channel: the grayscale ratio is the ratio of the input grayscale value of the pixel to the maximum grayscale value of the current channel; (2) Calculate the eighth value: Determine the first-order row feature value ratio: the first-order row feature value ratio is the ratio of the first-order row feature value of the pixel to the fourth value; the fourth value is the sum of the products of the maximum gray level value of the current channel and the weights of each weight in the right column of the first weight matrix; Determine the first-order column feature value ratio: the first-order column feature value ratio is the ratio of the first-order column feature value of the pixel to the fifth value; the fifth value is the sum of the products of the maximum gray level value of the current channel and the weights of each weight in the lower row of the second weight matrix; Determine the second-order feature ratio: Define the second-order feature value as the sum of the squares of the second-order row feature value and the squares of the second-order column feature value, raised to the power of 2. The second-order feature ratio is the ratio of the second-order feature value of the pixel to the largest second-order feature value; the largest second-order feature value is the sixth value of the second-order row feature value and the seventh value of the second-order column feature value. The eighth value is the product of the sum of "the product of the first-order row eigenvalue ratio and the third compensation weight" and "the product of the first-order column eigenvalue ratio and the fourth compensation weight" and the second-order eigenvalue ratio; wherein, the eighth value is the compensation value of the current color channel.
[0029] The third compensation weight is the compensation coefficient in the row direction, which is equal to the maximum gray level value of the current channel minus the "color shift gray level value of the colored edge in the row direction in the current channel when transitioning from a white image to a black image"; The fourth compensation weight is a compensation coefficient in the column direction, which is equal to the maximum grayscale value of the current channel minus the color shift grayscale value of the colored edge in the column direction in the current channel when transitioning from a white image to a black image.
[0030] Meanwhile, the present invention also provides an image edge compensation processing system, which is applied to the image edge compensation method provided above. The image edge compensation system includes: The image receiving module is used to receive the input image to be processed, which can be either a single-channel grayscale image or a color image with three color channels (RGB). The kernel construction module is used to construct a set of first-order differential convolution kernels, or; First-order differential convolution kernel group and second-order differential convolution kernel group; The feature value calculation module is used to perform feature value calculation operations on each target pixel in each grayscale channel of the image to be processed. The edge detection module is used to perform edge detection on target pixels within each grayscale channel; Compensation processing module: used to perform preset compensation operations on edge pixels within each grayscale channel; Image output module: Used to output an optimized image based on the compensated pixel grayscale values of all grayscale channels. For single-channel grayscale images, the image output module directly outputs the compensated optimized image. For color images, the image output module will supplement the grayscale values of multiple color channels to restore the optimized color image.
[0031] In one feasible embodiment, the image to be processed includes at least one grayscale channel, and each pixel in the grayscale channel has a grayscale value. The grayscale value is used to characterize the brightness information of the pixel. For a single-channel grayscale image, the grayscale value can directly express the brightness information of the pixel. For a color image, a preset brightness conversion formula can be used to convert the color image into a brightness image, and the brightness information of the pixel can be represented by the grayscale value.
[0032] In one feasible embodiment, the convolution kernel construction module is used to construct a first-order differential convolution kernel group and / or a second-order differential convolution kernel group; wherein, the first-order differential convolution kernel group includes a first weight matrix for row direction detection and a second weight matrix for column direction detection; the second-order differential convolution kernel group includes a third weight matrix for row direction detection and a fourth weight matrix for column direction detection.
[0033] In one feasible embodiment, the feature value calculation module is used to perform feature value calculation operations on each target pixel in each grayscale channel of the image to be processed: If only a first-order differential convolution kernel group is constructed, the first-order row neighborhood window and the first-order column neighborhood window of the target pixel are determined. In the first-order neighborhood window, the row neighborhood window contains at least three columns (an odd number of columns) and one row, which are used to determine the degree of brightness change of the target pixel in the row direction. The column neighborhood window contains at least three rows (an odd number of rows) and one row, which are used to determine the degree of brightness change of the target pixel in the column direction. At this time, the first weight matrix is multiplied and summed with the gray level value of the pixel in the first-order row neighborhood window to obtain the first-order row feature value, which quantifies the degree of brightness change in the row direction. The second weight matrix is multiplied and summed with the gray level value of the pixel in the first-order column neighborhood window to obtain the first-order column feature value, which quantifies the degree of brightness change in the column direction. If a second-order differential convolution kernel group is constructed simultaneously, based on the calculation of the first-order feature values, the second-order row neighborhood window and the second-order column neighborhood window of the target pixel are determined. The second-order row feature value is obtained by multiplying the third weight matrix with the grayscale value of the pixel in the second-order row neighborhood window and summing the results. The second-order column feature value is obtained by multiplying the fourth weight matrix with the grayscale value of the pixel in the second-order column neighborhood window and summing the results. The second-order row feature value and the second-order column feature value respectively represent the brightness of the target pixel itself compared with the brightness of other pixels in the neighborhood window.
[0034] In one feasible embodiment, the edge determination module is used to perform edge determination for target pixels within each grayscale channel: When based solely on first-order feature values, it is determined whether the absolute value of the first-order row feature value is not less than a preset first threshold, and / or whether the absolute value of the first-order column feature value is not less than a preset second threshold; if yes, it is determined to be an edge pixel. In the above determination, at this time, the first-order feature value can be used to determine whether there is a drastic change in brightness on both sides of the target pixel, while the target pixel itself is not used as a reference. When combining second-order feature values, it is determined whether the absolute value of the first-order row feature value is not less than a preset first threshold and whether the absolute value of the second-order row feature value is not greater than a preset third threshold, and the pixel is determined to be a row edge pixel; it is determined whether the absolute value of the first-order column feature value is not less than a preset second threshold and whether the absolute value of the second-order column feature value is not greater than a preset fourth threshold, and the pixel is determined to be a column edge pixel; if it is a row edge pixel and / or a column edge pixel, it is determined to be an edge pixel. The second-order feature value can reflect whether the target pixel is brighter or darker than the pixels in the neighborhood window. Setting the brighter target pixels as non-edge pixels can perform multiple judgments on some areas that are not easy to distinguish as edges, improve the accuracy of edge judgment, and distinguishing between row edge pixels and column edge pixels helps to compensate in both row and column directions.
[0035] In one feasible embodiment, the compensation processing module is used to perform a preset compensation operation on the edge pixels within each grayscale channel: If the image to be processed is an RGB color image, the grayscale compensation value is calculated independently in the R channel, G channel and B channel respectively. The output grayscale value is obtained by subtracting the grayscale compensation value from the input grayscale value. After obtaining the three output grayscale values, the grayscale values of the R / G / B channels are output separately.
[0036] If the image to be processed is a single-channel grayscale image, the compensation operation is performed directly on the edge pixels of that channel; if the single-channel grayscale image is converted from an RGB color image, the edge pixel positions can be mapped to the original RGB color image, and the compensation operation is performed on each of the three channels respectively.
[0037] As is known from common technical knowledge, this invention can be implemented through other embodiments that do not depart from its spirit or essential characteristics. Therefore, the disclosed embodiments described above are merely illustrative in all respects and are not the only ones. All modifications within the scope of this invention or its equivalents are included in this invention.
Claims
1. An image edge compensation processing method, characterized in that, Includes the following steps: The system receives an input image to be processed, the image to be processed including at least one grayscale channel, each pixel in the grayscale channel having a grayscale value, the grayscale value being used to characterize the brightness information of the pixel; Construct a first-order differential convolution kernel group, which includes a first weight matrix for row direction detection and a second weight matrix for column direction detection; For each grayscale channel of the image to be processed, perform the following operations on each target pixel within that channel: determine the first-order row neighborhood window and the first-order column neighborhood window of the target pixel, wherein the size of the first-order row neighborhood window is consistent with the first weight matrix, and the size of the first-order column neighborhood window is consistent with the second weight matrix; multiply each weight value in the first weight matrix by the grayscale value of the corresponding pixel in the first-order row neighborhood window and sum them to obtain the first-order row feature value of the target pixel; The first-order column feature value of the target pixel is obtained by multiplying each weight value in the second weight matrix with the gray level value of the corresponding pixel in the first-order column neighborhood window one by one and summing them. For each target pixel in a grayscale channel, determine whether the absolute value of the first-order row feature value is not less than a preset first threshold, and / or whether the absolute value of the first-order column feature value is not less than a preset second threshold; if yes, then the target pixel is determined to be an edge pixel in the grayscale channel; if only one of the two conditions is met, then the target pixel is an edge pixel in the corresponding direction and not an edge pixel in the non-corresponding direction, and the first-order feature value in the non-corresponding direction is 0; if both conditions are not met, then the target pixel is determined not to be an edge pixel in the grayscale channel, and the values of the first-order column feature value and the first-order row feature value are both 0. Perform a preset compensation operation on the grayscale value of edge pixels in each grayscale channel to optimize the brightness transition effect between edge pixels and adjacent pixels; The optimized image is output based on the compensated pixel grayscale values of all grayscale channels.
2. The method according to claim 1, characterized in that, The first weight matrix is an m-row, n-column first-order differential convolution kernel, where: n is an odd number not less than 3, m is a positive integer not less than 1, and the sum of all weights in the first weight matrix is 0; The first weight matrix uses the ((n+1) / 2)th column as the middle column, and all rows in the middle column have a weight of 0. The columns to the left of the middle column are symmetrically distributed with respect to the columns to the right of the middle column. The weights of the left columns are all negative, and the weights of the right columns are all positive. The absolute values of the weights of the left columns and the right columns at symmetrical positions are equal. The first value is defined as the sum of all weights in the right column of the first weight matrix multiplied by the maximum gray level value of the gray level channel, wherein the maximum gray level value is the theoretical maximum value of the pixel gray level value in the gray level channel, which is determined by the number of bits of image quantization, and the preset first threshold is greater than 0 and not greater than the first value.
3. The method according to claim 2, characterized in that, The second weight matrix is a first-order differential convolution kernel with row j and column i, where: j is an odd number not less than 3, i is a positive integer not less than 1, and the sum of all weights in the second weight matrix is 0; The second weight matrix uses the ((j+1) / 2)th row as the middle row, and all column weights in the middle row are 0; The rows above the middle row and the rows below the middle row are symmetrically distributed, and the weights of the upper rows are all negative, while the weights of the lower rows are all positive. The absolute values of the weights of the upper rows and the lower rows at symmetrical positions are equal. The second value is defined as the sum of all weights in the lower row of the second weight matrix multiplied by the maximum gray level value of the gray level channel. The preset second threshold is greater than 0 and not greater than the second value.
4. The method according to any one of claims 1-3, characterized in that, The image to be processed is an RGB color image, which contains three grayscale channels: the R channel, the G channel, and the B channel. The grayscale value of the R channel is the R channel value of the pixel in the RGB color image, the grayscale value of the G channel is the G channel value of the pixel in the RGB color image, and the grayscale value of the B channel is the B channel value of the pixel in the RGB color image.
5. The method according to claim 4, characterized in that, For target pixels identified as edge pixels, a preset grayscale compensation operation is performed in the R, G, and B channels of their respective RGB color images to determine the grayscale compensation value of the edge pixel in the current channel. The calculation process includes: (1) Define the grayscale ratio of the edge pixel in the current channel: the grayscale ratio is the ratio of the input grayscale value of the pixel to the maximum grayscale value of the current channel; (2) Calculate the third value: Determine the first-order row feature value ratio, which is the ratio of the first-order row feature value of the pixel to the fourth value; the fourth value is the sum of the products of the maximum gray level value of the current channel and the weights of each weight in the right column of the first weight matrix; Determine the first-order column feature value ratio: the first-order column feature value ratio is the ratio of the first-order column feature value of the pixel to the fifth value; the fifth value is the sum of the products of the maximum gray level value of the current channel and the weights of each weight in the lower row of the second weight matrix; The third value is the sum of "the product of the first-order row eigenvalue ratio and the first compensation weight" and "the product of the first-order column eigenvalue ratio and the second compensation weight"; where: The first compensation weight is the compensation coefficient in the row direction, which is equal to the maximum gray level value of the current channel minus "the color shift gray level value of the colored edge in the row direction in the current channel when transitioning from a pure white image to a pure black image"; The second compensation weight is the compensation coefficient in the column direction, which is equal to the maximum grayscale value of the current channel minus "the color shift grayscale value of the colored edge in the column direction in the current channel when transitioning from a pure white image to a pure black image"; (3) The gray level compensation value is the product of the gray level ratio in step (1) and the third value in step (2).
6. The method according to claim 5, characterized in that, Based on the compensated pixel grayscale values of all grayscale channels, the optimized image is output, including: Calculate the output grayscale value of the edge pixel in the current channel. The output grayscale value is the input grayscale value of the pixel minus the grayscale compensation value. The compensated R-channel grayscale values, G-channel grayscale values, and B-channel grayscale values are recombined into pixel values of the RGB color image to obtain the optimized RGB color image.
7. The method according to any one of claims 1-3, characterized in that, The image to be processed is a single-channel grayscale image, which is obtained by converting an RGB color image; the conversion process includes: For each pixel in the RGB color image, the R channel value, G channel value, and B channel value are extracted, and the corresponding brightness value is calculated based on a preset brightness conversion formula. The brightness value is then used as the grayscale value of the pixel in the single-channel grayscale image.
8. The method according to claim 7, characterized in that, The preset brightness conversion formula is Y = a×R+b×G+c×B, where a, b, and c are weighting coefficients, and a+b+c=1.
9. The method according to claim 7, characterized in that, After obtaining the first-order column feature value of the target pixel, before determining whether the absolute value of its first-order row feature value is greater than a preset first threshold and / or whether the absolute value of its first-order column feature value is greater than a preset second threshold for each target pixel in the grayscale channel, the method further includes: Construct a second-order differential convolution kernel group, which includes a third weight matrix for row direction detection and a fourth weight matrix for column direction detection; For each grayscale channel of the image to be processed, the following operations are performed on each target pixel within that channel: A second-order row neighborhood window and a second-order column neighborhood window are determined for the target pixel. The size of the second-order row neighborhood window is consistent with the third weight matrix, and the size of the second-order column neighborhood window is consistent with the fourth weight matrix. Each weight value in the third weight matrix is multiplied one by one with the grayscale value of the corresponding pixel within the second-order row neighborhood window, and then summed to obtain the second-order row feature value of the target pixel. Each weight value in the fourth weight matrix is multiplied one by one with the grayscale value of the corresponding pixel within the second-order column neighborhood window, and then summed to obtain the second-order column feature value of the target pixel.
10. The method according to claim 9, characterized in that, For each target pixel in a grayscale channel, it is determined whether the absolute value of the first-order row feature value is not less than a preset first threshold, and / or whether the absolute value of the first-order column feature value is not less than a preset second threshold. If so, the target pixel is determined to be an edge pixel within the grayscale channel, including: If the absolute value of the first-order row feature value is not less than a preset first threshold, and the absolute value of the second-order row feature value is not greater than a preset third threshold, then the target pixel is determined to be a row edge pixel in the grayscale channel. If both are true, the target pixel is determined to be a column edge pixel in the grayscale channel. If the absolute value of the first-order column feature value is not less than a preset second threshold, and the absolute value of the second-order column feature value is not greater than a preset fourth threshold, then the target pixel is determined to be a column edge pixel in the grayscale channel. If the target is a row edge pixel and / or a column edge pixel, then the target pixel is determined to be an edge pixel in the grayscale channel.
11. The method according to claim 10, characterized in that, The third weight matrix is a 1-row, h-column second-order differential convolution kernel, where: h is an odd number not less than 3, and the sum of all weights in the third weight matrix is 0; The third weight matrix uses the ((h+1) / 2)th column as the middle column, and the row weight of the middle column is negative; the columns to the left of the middle column are symmetrically distributed with the columns to the right of the middle column, and the weight values of the left column and the right column at the symmetrical position are equal. The sixth value is defined as the sum of all weights in both columns of the third weight matrix multiplied by the maximum gray level value of the gray level channel. The preset third threshold is greater than 0 and not greater than the sixth value.
12. The method according to claim 10 or 11, characterized in that, The fourth weight matrix is an e-row, 1-column second-order differential convolution kernel, where: e is an odd number not less than 3, and the sum of all weights in the fourth weight matrix is 0; The fourth weight matrix uses the ((e+1) / 2)th row as the middle row, and the row weight of the middle row is negative; the rows above the middle row and the rows below the middle row are symmetrically distributed, and the weight values of the upper row and the lower row at the symmetrical position are equal. The seventh value is defined as the sum of all weights in both rows of the fourth weight matrix multiplied by the maximum gray level value of the gray level channel. The preset fourth threshold is greater than 0 and not greater than the seventh value.
13. The method according to claim 12, characterized in that, Perform a preset compensation operation on the grayscale values of edge pixels within each grayscale channel, including: The edge pixel positions determined in the single-channel grayscale image are mapped to the RGB color image, and the pixels with corresponding coordinates in the RGB color image are determined as edge pixels that need to be compensated. For the edge pixels in the RGB color image that need compensation, independent preset grayscale compensation operations are performed in the R channel, G channel, and B channel respectively.
14. The method according to claim 13, characterized in that, For the edge pixels in the RGB color image that need compensation, independent preset grayscale compensation operations are performed in the R channel, G channel, and B channel respectively to determine the grayscale compensation value of the edge pixels in the current channel. The calculation process includes: (1) Define the grayscale ratio of the edge pixel in the current channel: the grayscale ratio is the ratio of the input grayscale value of the pixel to the maximum grayscale value of the current channel; (2) Calculate the eighth value: Determine the first-order row feature value ratio: the first-order row feature value ratio is the ratio of the first-order row feature value of the pixel to the fourth value; the fourth value is the sum of the products of the maximum gray level value of the current channel and the weights of each weight in the right column of the first weight matrix; Determine the first-order column feature value ratio: the first-order column feature value ratio is the ratio of the first-order column feature value of the pixel to the fifth value; the fifth value is the sum of the products of the maximum gray level value of the current channel and the weights of each weight in the lower row of the second weight matrix; Determine the second-order feature ratio: Define the second-order feature value as the first half power of the sum of the squares of the second-order row feature values and the squares of the second-order column feature values. The second-order feature ratio is the ratio of the second-order feature value of a pixel to the largest second-order feature value. The largest second-order feature value is the theoretical maximum value of the second-order feature value, including: The sixth value is taken for the second-order row eigenvalue; Furthermore, the eigenvalue of the second-order column takes the seventh value; The eighth value is the product of the sum of "the product of the first-order row eigenvalue ratio and the third compensation weight" and "the product of the first-order column eigenvalue ratio and the fourth compensation weight" and the second-order eigenvalue ratio; wherein... The third compensation weight is a compensation coefficient in the row direction, which is equal to the maximum grayscale value of the current channel minus the "color shift grayscale value of the row direction colored edge in the current channel when transitioning from a pure white image to a pure black image"; The fourth compensation weight is a compensation coefficient in the column direction, which is equal to the maximum grayscale value of the current channel minus the color shift grayscale value of the colored edge in the column direction in the current channel when the image transitions from a pure white image to a pure black image. The eighth value is the compensation value for the current channel.
15. An image edge compensation processing system, characterized in that, include: An image receiving module is used to receive the input image to be processed; The kernel construction module is used to construct a set of first-order differential convolution kernels, or; First-order differential convolution groups and second-order differential convolution kernel groups; The feature value calculation module is used to perform feature value calculation operations on each target pixel in each grayscale channel of the image to be processed. The edge detection module is used to perform edge detection for target pixels within each grayscale channel; Compensation processing module: used to perform preset compensation operations on edge pixels within each grayscale channel; Image output module: Used to output an optimized image based on the compensated pixel grayscale values of all grayscale channels.
16. The image processing system according to claim 15, characterized in that, The image to be processed includes at least one grayscale channel, and each pixel in the grayscale channel has a grayscale value, which is used to characterize the brightness information of the pixel.
17. The image processing system according to claim 15, characterized in that, The first-order differential convolution kernel group includes a first weight matrix for row direction detection and a second weight matrix for column direction detection; the second-order differential convolution kernel group includes a third weight matrix for row direction detection and a fourth weight matrix for column direction detection.
18. The image processing system according to claim 15, characterized in that, The feature value calculation module is used to perform feature value calculation operations on each target pixel in each grayscale channel of the image to be processed: If only a first-order differential convolution kernel group is constructed, the first-order row neighborhood window and the first-order column neighborhood window of the target pixel are determined. The first weight matrix is multiplied and summed with the gray level values of the pixels in the first-order row neighborhood window to obtain the first-order row feature value. The second weight matrix is multiplied and summed with the gray level values of the pixels in the first-order column neighborhood window to obtain the first-order column feature value. If a second-order differential convolution kernel group is constructed simultaneously, based on the calculation of the first-order feature values, the second-order row neighborhood window and the second-order column neighborhood window of the target pixel are determined. The second-order row feature value is obtained by multiplying the third weight matrix with the gray level value of the pixel in the second-order row neighborhood window and summing the results. The second-order column feature value is obtained by multiplying the fourth weight matrix with the gray level value of the pixel in the second-order column neighborhood window and summing the results.
19. The image processing system according to claim 15, characterized in that, The edge detection module is used to perform edge detection for target pixels within each grayscale channel: When based solely on first-order feature values, determine whether the absolute value of the first-order row feature value is not less than a preset first threshold, and / or whether the absolute value of the first-order column feature value is not less than a preset second threshold; If yes, then it is determined to be an edge pixel; When combining second-order feature values, it is determined whether the absolute value of the first-order row feature value is not less than a preset first threshold and whether the absolute value of the second-order row feature value is not greater than a preset third threshold, and is then determined to be a row edge pixel; it is determined whether the absolute value of the first-order column feature value is not less than a preset second threshold and whether the absolute value of the second-order column feature value is not greater than a preset fourth threshold, and is then determined to be a column edge pixel; if both row edge pixel and / or column edge pixel are satisfied, then it is determined to be an edge pixel.
20. The image processing system according to claim 19, characterized in that, The compensation processing module is used to perform a preset compensation operation on the edge pixels within each grayscale channel: If the image to be processed is an RGB color image, the grayscale compensation value is calculated independently in the R channel, G channel and B channel respectively, and the output grayscale value is obtained by subtracting the grayscale compensation value from the input grayscale value. If the image to be processed is a single-channel grayscale image, the compensation operation is performed directly on the edge pixels of that channel; if the single-channel grayscale image is converted from an RGB color image, the edge pixel positions can be mapped to the original RGB color image, and the compensation operation is performed on each of the three channels respectively.