Image edge compensation processing method and system
Patent Information
- Application Number
- CN202511887863.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-15
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2045-12-15
AI Technical Summary
[0002]在数字图像处理与显示过程中,由于采样、量化、压缩或显示设备本身的限制,图像中的边缘区域容易出现锯齿、色边、亮度不均或过渡生硬等问题,影响视觉体验
第一,实现了对边缘方向的精细化区分。传统方法通常只能粗略判断边缘的大致方向,本发明通过计算,将边缘方向精确划分到多个不同的角度区域,从而能够更细致地识别边缘的具体走向。
Smart Images

Figure CN121728229B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image edge processing technology, and particularly relates to an image edge compensation processing method and system. Background Technology
[0002] In digital image processing and display, due to limitations in sampling, quantization, compression, or the display device itself, edge areas in images are prone to problems such as jagged edges, color fringing, uneven brightness, or abrupt transitions, affecting the visual experience. Especially in high-contrast edge areas, such as the transition from white to black areas, traditional image processing techniques may not be able to adapt to different edge directions for fine brightness compensation, resulting in unsmooth and unnatural edge contours.
[0003] Existing technologies employ various edge detection and enhancement methods, such as using operators like Sobel, Prewitt, and Canny for edge detection followed by filtering or sharpening. However, these methods often focus on edge localization and enhancement, lacking effective solutions for adaptive compensation processing based on the directional characteristics of different edges to improve visual transitions. Most methods apply a uniform processing strategy to all edges or pixels, failing to adequately consider the impact of edge direction on the compensation strategy. This can lead to poor edge transition improvement in certain directions or even introduce new visual defects.
[0004] Based on this, the present invention designs an image edge compensation processing method and system. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention discloses an image edge compensation processing method and system.
[0006] An image edge compensation processing method includes the following steps: S1: Receive an input image to be processed, the image to be processed containing at least one grayscale channel, wherein each pixel has a grayscale value to characterize the brightness information of the pixel; S2: Construct a set of first-order differential convolution kernels, including a first weight matrix for row-direction edge detection and a second weight matrix for column-direction edge detection; S3: For each grayscale channel of the image to be processed, perform the following operations on each target pixel in 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 row neighborhood window matches the first weight matrix, and the size of the column neighborhood window matches the second weight matrix; multiply each weight value in the first weight matrix by the grayscale value of the corresponding pixel in the row neighborhood window and sum them to obtain the first-order row feature value of the target pixel; multiply each weight value in the second weight matrix by the grayscale value of the corresponding pixel in the column neighborhood window and sum them to obtain the first-order column feature value of the target pixel; sum the squares of the row feature value and the squares of the column feature value to obtain the composite feature value of the target pixel; S4: For each target pixel within a grayscale channel, edge detection is performed using the composite feature value. The edge detection includes: If the absolute value of the composite feature value is not less than the preset composite feature value threshold, then the pixel is determined to be an edge pixel in the grayscale channel. Otherwise, the pixel is determined to be a non-edge pixel; S5: For a target pixel that is determined to be an edge pixel, the angular region where it is located is further determined. The angular region is divided in the following way: the display area is divided into eight fan-shaped angular regions, and each edge pixel is mapped to the corresponding angular region according to its directional features. S6: Perform a preset compensation operation on the grayscale value of the edge pixels in each grayscale channel to improve the brightness transition effect between edge pixels and adjacent pixels. This compensation operation is adjusted according to the angle region to which the target edge pixel belongs. S7: Outputs an optimized image based on the pixel grayscale values after compensation processing of all grayscale channels.
[0007] In the above method, 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. The second weight matrix is a first-order differential convolution kernel in 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.
[0008] In the above method, 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, 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.
[0009] In the above method, the angle region is set as multiple evenly divided sector regions.
[0010] In the above method, the angle region includes eight fan-shaped angle regions defined based on two preset tangent feature value thresholds, specifically including: The two preset tangent feature thresholds include an upper tangent feature threshold and a lower tangent feature threshold, wherein the upper tangent feature threshold is greater than 0, and the lower tangent feature threshold is greater than 0 and less than the upper tangent feature threshold; Divide the column direction feature value of the target edge pixel by its row direction feature value to obtain the tangent feature value of the target edge pixel; Based on the sign of the row direction feature values and column direction feature values of the target edge pixels, as well as the comparison results of the absolute value of the tangent feature value with the upper and lower tangent feature thresholds, the angular region is determined, including setting the following conditions: Condition 1: Determine whether the row direction feature value of the target edge pixels is greater than zero; Condition 2: Determine whether the row direction feature value of the target edge pixels is less than zero; Condition 3: Determine whether the column direction feature value of the target edge pixels is greater than zero; Condition 4: Determine whether the column direction feature value of the target edge pixels is less than zero; Condition 5: Determine whether the absolute value of the tangent feature value of the target edge pixel is less than the lower tangent feature value threshold; Condition 6: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the lower tangent feature value threshold and less than the upper tangent feature value threshold; Condition 7: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the upper tangent feature value threshold; If conditions one, three, and five or conditions one, four, and five are met, then the target edge pixel is located in angle region one; If conditions one, three, and six are met, then the target edge pixels are located in angle region two. If conditions one, three, and seven or conditions two, three, and seven are met, then the target edge pixel is located in angle region three. If conditions two, three, and six are met, then the target edge pixels are located in angle region four. If conditions two, three, and five or conditions two, four, and five are met, then the target edge pixel is located in angle region five. If conditions two, four, and six are met, then the target edge pixels are located in angle region six. If conditions one, four, and seven or conditions two, four, and seven are met, then the target edge pixel is located in angle region seven. If conditions one, four, and six are met, then the target edge pixels are located in angle region eight.
[0011] In the above method, the calculation of the preset composite feature value threshold includes: Calculate the theoretical maximum value of the composite feature value, which is the calculation result when the row feature value and the column feature value take the first and second values, respectively; The preset composite feature value threshold is greater than 0 and less than the theoretical maximum value of the composite feature value.
[0012] In the above method, the preset compensation operation 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 angle region compensation weight: The angle region compensation weight is a compensation coefficient, the value of 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 current channel when the image transitions from a completely white image to a completely black image in the angle region where the current target edge pixel is located". (3) Calculate the eigenvalue weights: The eigenvalue weight is equal to the ratio of the composite eigenvalue to the theoretical maximum value of the composite eigenvalue, where the theoretical maximum value of the composite eigenvalue is the calculation result when the row eigenvalue and column eigenvalue take the first and second values respectively; (4) The gray level compensation value is the product of the gray level ratio in step (1), the angle region compensation weight in step (2), and the feature value weight in step (3).
[0013] In the above method, 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.
[0014] In the above method, 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.
[0015] The present invention also discloses an image edge compensation processing system for performing the above method, comprising: An image receiving module is used to receive the input image to be processed; The kernel construction module is used to construct groups of differential convolution kernels; 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. Angle region calculation module, used to calculate the angle region where edge pixels are located; The edge detection module is used to perform edge detection on target pixels within each grayscale channel; The compensation processing module is used to perform preset compensation operations on edge pixels in each grayscale channel; The image output module is used to output an optimized image based on the compensated pixel grayscale values of all grayscale channels.
[0016] In the above system, 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.
[0017] In the above system, 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.
[0018] In the above system, 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, including: The row neighborhood window and column neighborhood window of the target pixel are determined. The first weight matrix is multiplied and summed with the grayscale values of the pixels in the row neighborhood window to obtain the row feature value. The second weight matrix is multiplied and summed with the grayscale values of the pixels in the column neighborhood window to obtain the column feature value. The composite eigenvalue is obtained by summing the squares of the row eigenvalues and the squares of the column eigenvalues.
[0019] In the above system, the edge detection module is used to perform edge detection on the target pixels within each grayscale channel: The edge determination includes: If the absolute value of the composite feature value is not less than the preset composite feature value threshold, then the pixel is determined to be an edge pixel in the grayscale channel. Otherwise, the pixel is determined to be a non-edge pixel.
[0020] In the above system, the angle region calculation module calculates the angle region of the edge pixels, including: The display area will be divided into eight equally angular sector regions. Two preset tangent feature value thresholds are set, including an upper tangent feature threshold and a lower tangent feature threshold. The upper tangent feature threshold is greater than 0, and the lower tangent feature threshold is greater than 0 and less than the upper tangent feature threshold. Divide the column direction feature value of the target edge pixel by its row direction feature value to obtain the tangent feature value of the target edge pixel; Based on the sign of the row direction feature values and column direction feature values of the target edge pixels, as well as the comparison results of the absolute value of the tangent feature value with the upper and lower tangent feature thresholds, the angular region is determined, including setting the following conditions: Condition 1: Determine whether the row direction feature value of the target edge pixels is greater than zero; Condition 2: Determine whether the row direction feature value of the target edge pixels is less than zero; Condition 3: Determine whether the column direction feature value of the target edge pixels is greater than zero; Condition 4: Determine whether the column direction feature value of the target edge pixels is less than zero; Condition 5: Determine whether the absolute value of the tangent feature value of the target edge pixel is less than the lower tangent feature value threshold; Condition 6: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the lower tangent feature value threshold and less than the upper tangent feature value threshold; Condition 7: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the upper tangent feature value threshold; If conditions one, three, and five or conditions one, four, and five are met, then the target edge pixel is located in angle region one; If conditions one, three, and six are met, then the target edge pixels are located in angle region two. If conditions one, three, and seven or conditions two, three, and seven are met, then the target edge pixel is located in angle region three. If conditions two, three, and six are met, then the target edge pixels are located in angle region four. If conditions two, three, and five or conditions two, four, and five are met, then the target edge pixel is located in angle region five. If conditions two, four, and six are met, then the target edge pixels are located in angle region six. If conditions one, four, and seven or conditions two, four, and seven are met, then the target edge pixel is located in angle region seven. If conditions one, four, and six are met, then the target edge pixels are located in angle region eight.
[0021] In the above system, 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.
[0022] The beneficial effects of this invention are as follows: First, it achieves a finer distinction of edge direction. Traditional methods can usually only roughly determine the general direction of an edge. This invention, through calculation, precisely divides the edge direction into multiple different angular regions, thereby enabling a more detailed identification of the specific direction of the edge.
[0023] Secondly, adaptive compensation for different edge directions is achieved. Based on the above-mentioned fine direction distinction, the present invention sets independent compensation parameters for different angle regions. This enables the system to apply the most appropriate compensation amount according to the specific direction of the edge, thereby effectively improving the brightness transition effect of the edges in various directions and improving the overall image clarity and naturalness. Attached Figure Description
[0024] Figure 1 This is a flowchart illustrating an image edge compensation processing method disclosed in this invention. Figure 2 This is a schematic diagram illustrating the allocation of edge pixels to corresponding angle regions in an image edge compensation processing method disclosed in this invention.
[0025] Figure 3 This is a schematic diagram of the first-order differential convolution kernel in the H direction in an image edge compensation processing method disclosed in this invention; Figure 4 This is a schematic diagram of the first-order differential convolution kernel in the V direction in an image edge compensation processing method disclosed in this invention; Figure 5 This is a schematic diagram of direction detection in an image edge compensation processing method disclosed in this invention; Detailed Implementation To facilitate understanding of this application and to make the aforementioned objectives, features, and advantages of this application more apparent, a detailed description of specific embodiments of this application is provided below in conjunction with the accompanying drawings. Numerous specific details are set forth in the following description to provide a thorough understanding of this application, and preferred embodiments are shown in the accompanying drawings. However, this application can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the disclosure of this application. This application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified. In the description of this application, "several" means at least one, such as one, two, etc., unless otherwise explicitly specified. It should be noted that when an element is referred to as being "fixed to" another element, it can be directly attached to the other element or there may be an intervening element. When an element is referred to as being "connected to" another element, it can be directly connected to the other element or there may be an intervening element. The terms "vertical," "horizontal," "left," "right," and similar expressions used herein are for illustrative purposes only and do not represent the only possible implementations. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is only for describing particular implementations and is not intended to limit the scope of this application. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0026] See attached document Figures 1-5 An image edge compensation processing method includes the following steps: The system receives an input image to be processed, which contains at least one grayscale channel, wherein each pixel has a grayscale value to characterize the brightness information of the pixel; the image data can be a single-channel grayscale image or a multi-channel color image, and in the case of a color image, each color channel is treated as an independent grayscale channel for processing. Construct a set of first-order differential convolution kernels, including a first weight matrix for row-direction edge detection and a second weight matrix for column-direction edge detection; For each grayscale channel of the image to be processed, the following operations are performed on each target pixel in that channel: A first-order row neighborhood window and a first-order column neighborhood window are determined for the target pixel, wherein the size of the row neighborhood window matches the size of the first weight matrix, and the size of the column neighborhood window matches the size of the second weight matrix; each weight value in the first weight matrix is multiplied by the grayscale value of the corresponding pixel within the row neighborhood window, and then summed to obtain the first-order row feature value of the target pixel; each weight value in the second weight matrix is multiplied by the grayscale value of the corresponding pixel within the column neighborhood window, and then summed to obtain the first-order column feature value of the target pixel; the squares of the row feature value and the squares of the column feature value are summed to obtain the composite feature value of the target pixel; this composite feature value comprehensively reflects the gradient intensity of the pixel in both the row and column directions. For each target pixel within a grayscale channel, edge detection is performed using the composite feature value. The edge detection includes: If the absolute value of the composite feature value is not less than the preset composite feature value threshold, then the pixel is determined to be an edge pixel in the grayscale channel. Otherwise, the pixel is determined to be a non-edge pixel; For target pixels identified as edge pixels, the angular region in which they are located is further determined. The angular region is divided in the following way: the display area is divided into multiple fan-shaped angular regions, and each edge pixel is mapped to the corresponding angular region according to its directional features. This division further classifies the edges according to the pixel gradient direction, which is convenient for subsequent differentiation processing. A preset compensation operation is performed on the grayscale value of the edge pixels in each grayscale channel to improve the brightness transition effect between edge pixels and adjacent pixels. This compensation operation is adjusted according to the angle region to which the target edge pixel belongs. Through compensation, the brightness jump and color distortion at the edge can be reduced, and the subjective quality of the image can be improved. Based on the compensated pixel grayscale values of all grayscale channels, an optimized image is generated and output. The output image has smoother edge transitions and a more natural visual effect while maintaining the original content.
[0027] In one feasible embodiment, the first weight matrix is an m-by-n 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 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. This symmetrical negative-positive distribution structure can effectively extract grayscale changes in the horizontal direction. The first value is defined as the sum of all weights in the right column of the first weight matrix multiplied by the maximum grayscale value of the grayscale channel. The maximum grayscale value is the theoretical maximum value of the pixel grayscale value in that grayscale channel, determined by the image quantization bit depth, specifically 2. n -1, where n is the number of bits for image quantization. For example, in an eight-bit image, the theoretical maximum value of grayscale is 255, so the first value can be expressed as 255×(A+B+C+D+E+F). The first value represents the theoretical maximum value of the row feature value, which can be calculated from a reference image with alternating black and white and a white middle column. like Figure 3 As shown, when the second row and third column of the first weight matrix are aligned with the target pixel, the rest of the matrix corresponds to the neighborhood window of the target pixel. The weight values A, B, C, D, E, F and their symmetrical negative values -A, -B, -C, -E, -F correspond to pixels within the neighborhood window. In practice, the weight values can be designed in the form of 2^n (n ranges from 0 to 6). The larger the weight value, the higher the edge detection accuracy. It is worth noting that the weight values B, D, F, and their symmetrical negative values closer to the target pixel are usually set to be greater than the weight values A, C, E, and their symmetrical negative values on either side. This design stems from the spatial correlation of neighboring pixels—neighboring points closer to the target pixel contribute more significantly to edge detection.
[0028] Similarly, the second weight matrix is a differential convolution kernel with rows j and columns 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 matrix is zero. The specific structure is as follows: Figure 4 As shown in the diagram, the matrix has row ((j+1) / 2) as its middle row, where all weights are zero. The rows above and below the middle row are symmetrically distributed, with all weights of the upper rows being negative and all weights of the lower rows being positive. Furthermore, the absolute values of the weights of the rows above and below the symmetrical positions are equal.
[0029] The second value is defined as the sum of the products of all weights in the lower row of the second weight matrix and the maximum gray level value. For example... Figure 4As shown, when the second row and second column of the matrix are aligned with the target pixel, the weight values G, H, and I, and their symmetric negative values -G, -H, and -I, correspond to the pixels in the neighborhood window, respectively. Taking an 8-bit image as an example, the second value is 255×(G+H+I), representing the theoretical maximum value of the column feature value.
[0030] The theoretical maximum value of the composite feature value can be derived from the first and second values. This value comprehensively reflects the brightness gradient features of the target pixel in the row and column directions.
[0031] 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. Edge detection and compensation are performed independently for each channel, and the results are finally merged to achieve comprehensive edge processing of the color image.
[0032] In one feasible embodiment, the angle region is set as multiple evenly divided sector regions. By performing independent edge compensation on the sector regions where the edge pixels are located, the compensation effect can be optimized.
[0033] In one feasible embodiment, the number of angular regions is set to eight. The division of the angular regions is based on two preset tangent feature value thresholds, and edge pixels are assigned to the corresponding eight angular regions, specifically including: The two preset tangent feature thresholds include an upper tangent feature threshold and a lower tangent feature threshold, wherein the upper tangent feature threshold is greater than 0, and the lower tangent feature threshold is greater than 0 and less than the upper tangent feature threshold; Divide the column direction feature value of the target edge pixel by its row direction feature value to obtain the tangent feature value of the target edge pixel; Based on the sign of the row direction feature values and column direction feature values of the target edge pixels, as well as the comparison results of the absolute value of the tangent feature value with the upper and lower tangent feature thresholds, the angular region is determined, including setting the following conditions: Condition 1: Determine whether the row direction feature value of the target edge pixels is greater than zero; Condition 2: Determine whether the row direction feature value of the target edge pixels is less than zero; Condition 3: Determine whether the column direction feature value of the target edge pixels is greater than zero; Condition 4: Determine whether the column direction feature value of the target edge pixels is less than zero; Condition 5: Determine whether the absolute value of the tangent feature value of the target edge pixel is less than the lower tangent feature value threshold; Condition 6: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the lower tangent feature value threshold and less than the upper tangent feature value threshold; Condition 7: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the upper tangent feature value threshold; like Figure 5 As shown, the display area is divided into a circle, and the angular region is divided with the center of the circle as the origin of the coordinate system. If the target edge pixel satisfies conditions one, three, and five or conditions one, four, and five at the same time, it is located in the first or fourth quadrant, and its tangent value is lower than the lower tangent feature value threshold, then the target edge pixel is located in angular region one. If the target edge pixel satisfies conditions one, three, and six, then it is located in the first quadrant, and its tangent feature value is between two preset tangent feature value thresholds, then the target edge pixel is located in angle region two. Similarly, if the target edge pixels satisfy conditions one, three, and seven or conditions two, three, and seven, then the target edge pixels are located in angle region three. If the target edge pixels satisfy conditions two, three, and six, then the target edge pixels are located in angle region four. If the target edge pixel satisfies conditions two, three, and five or conditions two, four, and five, then the target edge pixel is located in angle region five. If the target edge pixels satisfy conditions two, four, and six, then the target edge pixels are located in angle region six. If the target edge pixel satisfies conditions one, four, and seven or conditions two, four, and seven, then the target edge pixel is located in angle region seven. If the target edge pixels satisfy conditions one, four, and six, then the target edge pixels are located in angle region eight.
[0034] This judgment mechanism combines direction and proportion information to accurately divide edge pixels into one of eight angular regions. Furthermore, by using a preset threshold for angular division, it can reduce the computational load on the display chip.
[0035] In one feasible embodiment, the calculation of the preset composite feature value threshold includes: Calculate the theoretical maximum value of the composite feature value, which is the calculation result when the row feature value and the column feature value take the first and second values, respectively; In practical implementation, the preset composite feature value threshold should be greater than zero and not exceed the theoretical maximum value of the composite feature value. This can be achieved by setting a coefficient no greater than 1 multiplied by the theoretical maximum value. The preset composite feature value threshold directly determines the strictness of edge detection: the higher the value, the stricter the edge detection standard and the higher the display accuracy, but at the same time, it will increase the computational load of the display chip; when the value is low, although the computational load is reduced, the accuracy of edge detection will decrease accordingly. Therefore, it is necessary to make targeted adjustments according to the actual edge display requirements of the product.
[0036] In one feasible embodiment, the preset compensation operation 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; this ratio normalizes the brightness information of the pixel; (2) Calculate the angle region compensation weight: The angle region compensation weight is a compensation coefficient, the value of 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 current channel when the image transitions from a completely white image to a completely black image in the angle region where the current target edge pixel is located". This weight reflects the color deviation of the angle region under the ideal edge, and at the same time, it performs accurate compensation based on the angle region where the edge pixel is located, thereby improving the effect of image edge compensation. (3) Calculate the eigenvalue weights: The eigenvalue weight is equal to the ratio of the composite eigenvalue to the theoretical maximum value of the composite eigenvalue, where the theoretical maximum value of the composite eigenvalue is the calculated result when the row eigenvalue and column eigenvalue take the first and second values respectively; this weight is proportional to the edge strength. (4) The grayscale compensation value is the product of the grayscale ratio in step (1), the angle region compensation weight in step (2), and the feature value weight in step (3). This compensation value integrates the brightness, direction, and intensity information of the edge.
[0037] 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 then recombined into pixel values of the RGB color image to obtain the optimized RGB color image. The compositing process must maintain pixel coordinate alignment and ensure that the numerical values remain within valid ranges.
[0038] 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 require compensation, independent preset grayscale compensation operations are performed in the R, G, and B channels respectively. This method ensures that the edge compensation of each color channel is independent of each other, avoiding interference between channels.
[0039] The present invention also discloses an image edge compensation processing system for performing the above method, comprising: The image receiving module is used to receive the input image to be processed; this module supports multiple image formats and resolutions for input. The kernel construction module is used to construct a group of differential convolution kernels; it can adaptively adjust the kernel parameters according to image characteristics. 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; this module efficiently implements neighborhood operations and convolution operations. The angle region calculation module is used to calculate the angle region where the edge pixels are located; this module classifies angles based on gradient direction and magnitude. The edge detection module is used to perform edge detection on target pixels within each grayscale channel; this module determines edges based on thresholds and generates a binary edge map. The compensation processing module is used to perform preset compensation operations on edge pixels within each grayscale channel; this module adjusts the compensation strategy by region to achieve adaptive edge enhancement. The image output module outputs an optimized image based on the compensated pixel grayscale values of all grayscale channels. The output image has better visual quality and edge continuity.
[0040] In one feasible embodiment, the image to be processed includes at least one grayscale channel, where each pixel in the grayscale channel has a grayscale value, which is used to characterize the brightness information of the pixel. The system is compatible with both grayscale and color image processing.
[0041] In one feasible embodiment, 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 convolution kernel can be customized and extended according to actual application requirements.
[0042] In one feasible embodiment, the feature value calculation module is used to perform a feature value calculation operation on each target pixel in each grayscale channel of the image to be processed, including: The row neighborhood window and column neighborhood window of the target pixel are determined. The first weight matrix is multiplied and summed with the grayscale values of the pixels in the row neighborhood window to obtain the row feature value. The second weight matrix is multiplied and summed with the grayscale values of the pixels in the column neighborhood window to obtain the column feature value. The composite eigenvalue is obtained by summing the squares of the row eigenvalues and the squares of the column eigenvalues. This calculation makes full use of local gradient information.
[0043] In one feasible embodiment, the edge determination module is used to perform edge determination for target pixels within each grayscale channel: The edge determination includes: If the absolute value of the composite feature value is not less than the preset composite feature value threshold, then the pixel is determined to be an edge pixel in the grayscale channel. Otherwise, the pixel is determined to be a non-edge pixel, and this binarization judgment simplifies the subsequent processing steps.
[0044] In one feasible embodiment, the angle region calculation module calculates the angle region of the edge pixels, including: The display area will be divided into eight equally angular sector regions. Two preset tangent feature value thresholds are set, including an upper tangent feature threshold and a lower tangent feature threshold. The upper tangent feature threshold is greater than 0, and the lower tangent feature threshold is greater than 0 and less than the upper tangent feature threshold. Divide the column direction feature value of the target edge pixel by its row direction feature value to obtain the tangent feature value of the target edge pixel; Based on the sign of the row direction feature values and column direction feature values of the target edge pixels, as well as the comparison results of the absolute value of the tangent feature value with the upper and lower tangent feature thresholds, the angular region is determined, including setting the following conditions: Condition 1: Determine whether the row direction feature value of the target edge pixels is greater than zero; Condition 2: Determine whether the row direction feature value of the target edge pixels is less than zero; Condition 3: Determine whether the column direction feature value of the target edge pixels is greater than zero; Condition 4: Determine whether the column direction feature value of the target edge pixels is less than zero; Condition 5: Determine whether the absolute value of the tangent feature value of the target edge pixel is less than the lower tangent feature value threshold; Condition 6: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the lower tangent feature value threshold and less than the upper tangent feature value threshold; Condition 7: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the upper tangent feature value threshold; If conditions one, three, and five or conditions one, four, and five are met, then the target edge pixel is located in angle region one; If conditions one, three, and six are met, then the target edge pixels are located in angle region two. If conditions one, three, and seven or conditions two, three, and seven are met, then the target edge pixel is located in angle region three. If conditions two, three, and six are met, then the target edge pixels are located in angle region four. If conditions two, three, and five or conditions two, four, and five are met, then the target edge pixel is located in angle region five. If conditions two, four, and six are met, then the target edge pixels are located in angle region six. If conditions one, four, and seven or conditions two, four, and seven are met, then the target edge pixel is located in angle region seven. If conditions one, four, and six are met, then the target edge pixels are located in angle region eight.
[0045] 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, 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.
[0046] 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, which contains at least one grayscale channel, wherein each pixel has a grayscale value to characterize the brightness information of the pixel. Construct a set of first-order differential convolution kernels, including a first weight matrix for row-direction edge detection and a second weight matrix for column-direction edge detection; For each grayscale channel of the image to be processed, the following operations are performed on each target pixel in 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 row neighborhood window matches the first weight matrix, and the size of the column neighborhood window matches the second weight matrix; multiply each weight value in the first weight matrix by the grayscale value of the corresponding pixel in the 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 column neighborhood window and summing the results. The composite feature value of the target pixel is obtained by summing the squares of the row feature values and the squares of the column feature values. For each target pixel within a grayscale channel, edge detection is performed using the composite feature value. The edge detection includes: If the absolute value of the composite feature value is not less than the preset composite feature value threshold, then the pixel is determined to be an edge pixel in the grayscale channel. Otherwise, the pixel is determined to be a non-edge pixel; For a target pixel that is determined to be an edge pixel, its angular region is further determined. The angular region is divided in the following way: the display area is divided into multiple angular regions, and each edge pixel is mapped to the corresponding angular region according to its directional features. A preset compensation operation is performed on the grayscale value of the edge pixels in each grayscale channel to improve the brightness transition effect between edge pixels and adjacent pixels. This compensation operation is adjusted according to the angle region to which the target edge pixel belongs. Based on the compensated pixel grayscale values of all grayscale channels, an optimized image is generated and output. The preset compensation operation includes the following steps: (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 angle region compensation weight: The angle region compensation weight is a compensation coefficient, 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 current channel when transitioning from a pure white image to a pure black image. (3) Calculate the eigenvalue weights: The eigenvalue weight is equal to the ratio of the composite eigenvalue to the theoretical maximum value of the composite eigenvalue, where the theoretical maximum value of the composite eigenvalue is the calculation result when the row eigenvalue and column eigenvalue take the first and second values respectively; (4) The gray level compensation value is the product of the gray level ratio in step (1), the angle region compensation weight in step (2), and the feature value weight in step (3).
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. The second weight matrix is a first-order differential convolution kernel in 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.
3. The method according to claim 1, 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.
4. The method according to claim 1, characterized in that, The angle region is set as multiple evenly divided sector regions.
5. The method according to claim 1, characterized in that, The number of angular regions is set to eight. The division of the angular regions is based on two preset tangent feature value thresholds, and edge pixels are assigned to the corresponding eight angular regions, specifically including: The two preset tangent feature thresholds include an upper tangent feature threshold and a lower tangent feature threshold, wherein the upper tangent feature threshold is greater than 0, and the lower tangent feature threshold is greater than 0 and less than the upper tangent feature threshold; Divide the column direction feature value of the target edge pixel by its row direction feature value to obtain the tangent feature value of the target edge pixel; Based on the sign of the row direction feature values and column direction feature values of the target edge pixels, as well as the comparison results of the absolute value of the tangent feature value with the upper and lower tangent feature thresholds, the angular region is determined, including setting the following conditions: Condition 1: Determine whether the row direction feature value of the target edge pixels is greater than zero; Condition 2: Determine whether the row direction feature value of the target edge pixels is less than zero; Condition 3: Determine whether the column direction feature value of the target edge pixels is greater than zero; Condition 4: Determine whether the column direction feature value of the target edge pixels is less than zero; Condition 5: Determine whether the absolute value of the tangent feature value of the target edge pixel is less than the lower tangent feature value threshold; Condition 6: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the lower tangent feature value threshold and less than the upper tangent feature value threshold; Condition 7: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the upper tangent feature value threshold; If conditions one, three, and five or conditions one, four, and five are met, then the target edge pixel is located in angle region one; If conditions one, three, and six are met, then the target edge pixels are located in angle region two. If conditions one, three, and seven or conditions two, three, and seven are met, then the target edge pixel is located in angle region three. If conditions two, three, and six are met, then the target edge pixels are located in angle region four. If conditions two, three, and five or conditions two, four, and five are met, then the target edge pixel is located in angle region five. If conditions two, four, and six are met, then the target edge pixels are located in angle region six. If conditions one, four, and seven or conditions two, four, and seven are met, then the target edge pixel is located in angle region seven. If conditions one, four, and six are met, then the target edge pixels are located in angle region eight.
6. The method according to claim 2, characterized in that, The calculation of the preset composite feature value threshold includes: Calculate the theoretical maximum value of the composite feature value, which is the calculation result when the row feature value and the column feature value take the first and second values, respectively; The preset composite feature value threshold is greater than 0 and less than the theoretical maximum value of the composite feature value.
7. The method according to claim 6, 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.
8. The method according to claim 1, characterized in that, Perform a preset compensation operation on the grayscale values of edge pixels within each grayscale channel, including: 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, perform compensation operation directly on the edge pixels of that channel; if the single-channel grayscale image is converted from an RGB color image, map the edge pixel positions to the original RGB color image and perform compensation operation on each of the three channels respectively.
9. An image edge compensation processing system, characterized in that, For performing the method according to any one of claims 1-8, comprising: An image receiving module is used to receive the input image to be processed; The kernel construction module is used to construct groups of differential convolution kernels; 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. Angle region calculation module, used to calculate the angle region where edge pixels are located; The edge detection module is used to perform edge detection on target pixels within each grayscale channel; The compensation processing module is used to perform preset compensation operations on edge pixels in each grayscale channel; The image output module is used to output an optimized image based on the compensated pixel grayscale values of all grayscale channels.
10. The image edge compensation processing system according to claim 9, 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.
11. The image edge compensation processing system according to claim 9, characterized in that, The differential convolution kernel group includes a first weight matrix for row direction detection and a second weight matrix for column direction detection.
12. The image edge compensation processing system according to claim 9, 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, including: The row neighborhood window and column neighborhood window of the target pixel are determined. The first weight matrix is multiplied and summed with the grayscale values of the pixels in the row neighborhood window to obtain the row feature value. The second weight matrix is multiplied and summed with the grayscale values of the pixels in the column neighborhood window to obtain the column feature value. The composite eigenvalue is obtained by summing the squares of the row eigenvalues and the squares of the column eigenvalues.
13. The image edge compensation processing system according to claim 9, characterized in that, The edge detection module is used to perform edge detection for target pixels within each grayscale channel: The edge determination includes: If the absolute value of the composite feature value is not less than the preset composite feature value threshold, then the pixel is determined to be an edge pixel in the grayscale channel. Otherwise, the pixel is determined to be a non-edge pixel.
14. The image edge compensation processing system according to claim 9, characterized in that, The angle region calculation module calculates the angle region of the edge pixels, including: The display area will be divided into eight equally angular sector regions. Two preset tangent feature value thresholds are set, including an upper tangent feature threshold and a lower tangent feature threshold. The upper tangent feature threshold is greater than 0, and the lower tangent feature threshold is greater than 0 and less than the upper tangent feature threshold. Divide the column direction feature value of the target edge pixel by its row direction feature value to obtain the tangent feature value of the target edge pixel; Based on the sign of the row direction feature values and column direction feature values of the target edge pixels, as well as the comparison results of the absolute value of the tangent feature value with the upper and lower tangent feature thresholds, the angular region is determined, including setting the following conditions: Condition 1: Determine whether the row direction feature value of the target edge pixels is greater than zero; Condition 2: Determine whether the row direction feature value of the target edge pixels is less than zero; Condition 3: Determine whether the column direction feature value of the target edge pixels is greater than zero; Condition 4: Determine whether the column direction feature value of the target edge pixels is less than zero; Condition 5: Determine whether the absolute value of the tangent feature value of the target edge pixel is less than the lower tangent feature value threshold; Condition 6: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the lower tangent feature value threshold and less than the upper tangent feature value threshold; Condition 7: Determine whether the absolute value of the tangent feature value of the target edge pixel is greater than the upper tangent feature value threshold; If conditions one, three, and five or conditions one, four, and five are met, then the target edge pixel is located in angle region one; If conditions one, three, and six are met, then the target edge pixels are located in angle region two. If conditions one, three, and seven or conditions two, three, and seven are met, then the target edge pixel is located in angle region three. If conditions two, three, and six are met, then the target edge pixels are located in angle region four. If conditions two, three, and five or conditions two, four, and five are met, then the target edge pixel is located in angle region five. If conditions two, four, and six are met, then the target edge pixels are located in angle region six. If conditions one, four, and seven or conditions two, four, and seven are met, then the target edge pixel is located in angle region seven. If conditions one, four, and six are met, then the target edge pixels are located in angle region eight.
15. The image edge compensation processing system according to claim 9, 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, perform compensation operation directly on the edge pixels of that channel; if the single-channel grayscale image is converted from an RGB color image, map the edge pixel positions to the original RGB color image and perform compensation operation on each of the three channels respectively.
Citation Information
Patent Citations
R angle compensation method and storage device
CN109345995A
Image display processing method and device
CN116860143A
