Image sharpening and black and white edge elimination method and system
By constructing a filtering window and using multiple directional filters, obtaining the maximum and minimum filtering results, dividing the pixel area, and calculating the center brightness after eliminating the black and white edges, the problem of black and white edges after image sharpening is solved, and the black and white edges are eliminated without reducing the clarity.
Patent Information
- Application Number
- CN202210870789.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-22
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-07-22
AI Technical Summary
In the prior art, black and white edges are easily generated after image sharpening, resulting in insufficient image clarity or over-sharpening of edges.
By constructing a filtering window, using multiple directional filters for filtering, obtaining the maximum and minimum filtering results, dividing the pixel area, calculating the center brightness after eliminating the black and white edges, setting the brightness of the center pixel point, and limiting the range of pixel brightness changes before and after sharpening.
Without reducing the overall clarity of the image, the black and white edges at the edges after sharpening are effectively eliminated, maintaining the clarity of the image.
Smart Images

Figure CN115187486B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to image processing, in particular to an image sharpening and black and white edge elimination method. Background Art
[0002] Due to the limitations of the image capture device's inherent performance or after image noise reduction and other algorithmic processing, the image's edge contours, detailed textures, etc. often appear blurry, requiring image sharpening to improve their clarity. Image sharpening is generally performed on the brightness map, increasing the image's brightness jump portion to make the image clearer. Typically, image sharpening uses a high-pass filter, or the original brightness map minus the low-pass filter result of the original brightness map, to extract the image's high-frequency information, and then superimposes the high-frequency information with the original image to obtain a clearer image. However, when superimposing the high-frequency information with the original image, if the sharpening intensity is too low, the sharpened image will not be clear enough. If the sharpening intensity is too high, it can easily lead to over-sharpening of the image at the edges, resulting in black and white edges in the image. Summary of the Invention
[0003] In order to solve the technical problems in the prior art that the sharpened image is either not clear enough or is easily over-sharpened at the edges, resulting in black and white edges on the image, the present invention provides a method and system for removing black and white edges from image sharpening. The specific technical solutions are as follows:
[0004] In one aspect, a method for image sharpening and black and white edge removal is provided, comprising:
[0005] Get the original brightness image;
[0006] Take the current pixel of the original brightness image as the center pixel and build a filtering window;
[0007] Using multiple directional filters, filtering the filtering window to obtain multiple filtering results;
[0008] According to the plurality of filtering results, a maximum filtering result and a minimum filtering result are obtained;
[0009] Dividing the pixel points of the filtering window into a first pixel area, a second pixel area, and a third pixel area according to the filter direction corresponding to the maximum filtering result;
[0010] Obtaining the sharpened brightness of the center pixel of the filter window after sharpening;
[0011] Calculate the center brightness after black and white edges are eliminated according to the maximum filtering result, the minimum filtering result, the first pixel area, the second pixel area, the third pixel area, and the sharpened brightness;
[0012] The brightness of the central pixel is set according to the central brightness after the black and white edges are eliminated.
[0013] In this technical solution, after the original image is sharpened, Figure 1 The filtering results of the pixel blocks are obtained, and according to the filtering results, the brightness of the pixels in the range centered on it is checked, and the pixels of the window are divided based on these pixels, thereby limiting the range of pixel brightness changes before and after sharpening, so that the sharpening fully considers the local information of the image and eliminates the black and white edges that appear at the edges after sharpening, thereby eliminating the black and white edges caused by image sharpening without reducing the overall clarity of the image.
[0014] Preferably, the calculating of the center brightness after the black and white edges are eliminated specifically includes:
[0015] Obtaining a corresponding edge probability prediction according to the maximum filtering result and the minimum filtering result;
[0016] Calculating the average brightness of the first pixel area, the second pixel area, and the third pixel area respectively to obtain a first average brightness, a second average brightness, and a third average brightness;
[0017] Calculate a sharpening threshold according to the first average brightness, the second average brightness, and the third average brightness;
[0018] Calculating the pre-center point brightness according to the sharpening threshold, the sharpening brightness, and the edge probability prediction;
[0019] The center brightness after the black and white edges are eliminated is calculated according to the sharpening brightness and the pre-center point brightness.
[0020] Further preferably, when the maximum filtering result is greater than or equal to 0, calculating the sharpening threshold according to the first average brightness, the second average brightness, and the third average brightness specifically includes:
[0021] Obtaining a maximum average brightness based on the first average brightness, the second average brightness, and the third average brightness; pixels in the filtering window with a brightness lower than that of a central pixel in the filtering window are not included in the calculation of the first average brightness, the second average brightness, and the third average brightness;
[0022] The sharpening threshold is calculated according to the maximum average brightness and the positive black and white edge intensity threshold.
[0023] Further preferably, when the maximum filtering result is greater than or equal to 0, calculating the center brightness after the black and white edges are eliminated specifically includes:
[0024] The pre-center point brightness and the sharpened brightness are compared, and the smaller one is taken as the center brightness after the black and white edges are eliminated.
[0025] Further preferably, when the maximum filtering result is less than 0, calculating the center brightness after the black and white edges are eliminated specifically includes:
[0026] Obtaining a minimum average brightness based on the first average brightness, the second average brightness, and the third average brightness; pixels in the filtering window with a brightness greater than that of a central pixel in the filtering window are not included in the calculation of the first average brightness, the second average brightness, and the third average brightness;
[0027] Calculating a sharpening threshold according to the minimum average brightness and the negative black and white edge intensity threshold;
[0028] Further preferably, when the maximum filtering result is less than 0, calculating the center brightness after the black and white edges are eliminated specifically includes:
[0029] The pre-center point brightness and the sharpened brightness are compared, and the larger one is taken as the center brightness after the black and white edges are eliminated.
[0030] Further preferably, the pre-center point brightness = (the sharpening brightness + (the sharpening threshold - the sharpening brightness) × the edge probability prediction).
[0031] Further preferably, the edge probability prediction=1-(the minimum filtering result+noise influence coefficient) / (the maximum filtering result+noise influence coefficient).
[0032] Further preferably, the size of the filtering window is 3x3 or 5x5.
[0033] Preferably, the number of the directional filters is one of 4, 6, and 8.
[0034] On the other hand, a system for image sharpening and black and white edge removal is provided, comprising:
[0035] The original acquisition module is used to obtain the original brightness image;
[0036] A filtering module is configured to construct a filtering window using the current pixel of the original brightness image as the center pixel, and filter the filtering window using multiple directional filters to obtain multiple filtering results; thereby obtaining a maximum filtering result and a minimum filtering result based on the multiple filtering results;
[0037] A region division module, configured to divide the pixels of the filtering window into a first pixel region, a second pixel region, and a third pixel region according to a filter direction corresponding to the maximum filtering result;
[0038] A sharpening acquisition module is used to obtain a sharpened brightness map and obtain the corresponding sharpened brightness of the central pixel point of the filter window after sharpening;
[0039] An edge probability prediction module, configured to obtain a corresponding edge probability prediction based on the maximum filtering result and the minimum filtering result;
[0040] a sharpening threshold calculation module, configured to respectively calculate the average brightness of the first pixel area, the second pixel area, and the third pixel area to obtain a first average brightness, a second average brightness, and a third average brightness, and calculate a sharpening threshold based on the first average brightness, the second average brightness, and the third average brightness;
[0041] The pre-center point calculation module is used to calculate the pre-center point brightness based on the sharpening threshold, the sharpening brightness, and the edge probability prediction; and calculate the center brightness after the black and white edges are eliminated based on the sharpening brightness and the pre-center point brightness; thereby setting the brightness of the center pixel point based on the center brightness after the black and white edges are eliminated.
[0042] In this technical solution, after the original image is sharpened, Figure 1 The filtering results of the pixel blocks are obtained, and according to the filtering results, the brightness of the pixels in the range centered on it is checked, and the pixels of the window are divided based on these pixels, thereby limiting the range of pixel brightness changes before and after sharpening, so that the sharpening fully considers the local information of the image and eliminates the black and white edges that appear at the edges after sharpening, thereby eliminating the black and white edges caused by image sharpening without reducing the overall clarity of the image.
[0043] Preferably, the sharpening threshold calculation module includes a positive filtering calculation submodule, which is used to obtain the maximum average brightness according to the first average brightness, the second average brightness, and the third average brightness when the maximum filtering result is greater than or equal to 0; pixels in the filtering window with a brightness less than that of a central pixel of the filtering window are not involved in the calculation of the first average brightness, the second average brightness, and the third average brightness, and the sharpening threshold is calculated according to the maximum average brightness and a positive black and white edge intensity threshold;
[0044] The pre-center point calculation module includes a positive filtering brightness calculation submodule. When the maximum filtering result is greater than or equal to 0, the pre-center point brightness and the sharpening brightness are compared, and the smaller one is taken as the center brightness after the black and white edges are eliminated.
[0045] Preferably, the sharpening threshold calculation module includes a negative filtering calculation submodule, which is used to obtain the minimum average brightness according to the first average brightness, the second average brightness, and the third average brightness when the maximum filtering result is less than 0; in the filtering window, pixels with a brightness greater than the brightness of the center pixel of the filtering window are not involved in the calculation of the first average brightness, the second average brightness, and the third average brightness; and calculate the sharpening threshold according to the minimum average brightness and the negative black and white edge intensity threshold;
[0046] The pre-center point calculation module includes a negative filtering brightness calculation submodule. When the maximum filtering result is less than 0, the pre-center point brightness and the sharpening brightness are compared, and the larger one is taken as the center brightness after the black and white edges are eliminated.
[0047] The technical effect of the present invention is as follows: based on the filtering result of the current pixel window of the calculated original brightness image, the center pixel is first calculated as the edge probability prediction, and then the pixels of the window are divided. The range of pixel brightness change before and after sharpening is limited by the calculated pre-center brightness, so that the sharpening fully considers the local information of the image and eliminates the black and white edges that appear at the edge after sharpening, thereby achieving the elimination of the black and white edges caused by image sharpening without significantly reducing the overall clarity of the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0049] Figure 1 Schematic diagram of the process of a method for image sharpening and eliminating black and white edges according to embodiment 1 of the present invention;
[0050] Figure 2 This is a schematic diagram of region division in Example 1 of a method for image sharpening and eliminating black and white edges of the present invention;
[0051] Figure 3 This is a flow chart of S7 of Example 2 of a method for image sharpening and eliminating black and white edges of the present invention;
[0052] Figure 4 This is a flow chart of S7 of Example 3 of a method for image sharpening and eliminating black and white edges of the present invention;
[0053] Figure 5 This is a schematic diagram of a specific flow chart of a third embodiment of a method for image sharpening and eliminating black and white edges according to the present invention;
[0054] Figure 6This is a diagram showing an ideal situation with no black or white edges after sharpening;
[0055] Figure 7 This is a schematic diagram of the actual black and white edges after sharpening;
[0056] Figure 8 is the original brightness image without sharpening;
[0057] Figure 9 is the sharpened brightness map after sharpening;
[0058] Figure 10 This is the result of the sharpened image after the black and white edges are eliminated. DETAILED DESCRIPTION
[0059] In the following description, specific details such as specific system structures and technologies are provided for illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obstructing the description of the present application with unnecessary details.
[0060] It will be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections.
[0061] To simplify the drawings, only the parts relevant to the present invention are schematically depicted in each figure; they do not represent the actual structure of the product. Furthermore, to simplify the drawings and facilitate understanding, in some figures, only one component with the same structure or function is schematically depicted or labeled. As used herein, "one" refers not only to "only one" but also to "more than one."
[0062] It should be further understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0063] In addition, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0064] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the specific embodiments of the present invention will be described below with reference to the accompanying drawings. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings and other embodiments can be obtained based on these drawings without inventive work.
[0065] Example 1:
[0066] This embodiment provides a method for image sharpening and black and white edge removal, including:
[0067] S1: Get the original brightness image;
[0068] S2: Take the current pixel of the original brightness image as the center pixel and build a filtering window;
[0069] S3: Filtering the filtering window using multiple directional filters to obtain multiple filtering results;
[0070] S4: Obtaining a maximum filtering result and a minimum filtering result according to the multiple filtering results;
[0071] S5: Dividing the pixels of the filtering window into a first pixel area, a second pixel area, and a third pixel area according to the filter direction corresponding to the maximum filtering result;
[0072] S6: Obtain the central pixel point of the filter window and the corresponding sharpened brightness after sharpening;
[0073] S7: Calculating the center brightness after black and white edges are eliminated based on the maximum filtering result, the minimum filtering result, the first pixel area, the second pixel area, the third pixel area, and the sharpened brightness;
[0074] S8: Setting the brightness of the central pixel according to the central brightness after the black and white edges are eliminated.
[0075] like Figure 1 As shown in the figure, image sharpening is generally performed on the brightness map, and the image is made clearer by increasing the brightness jump part of the image. Usually, image sharpening uses a high-pass filter, or uses the original brightness map minus the low-pass filter result of the original brightness map to extract the high-frequency information of the image, and then superimposes the high-frequency information with the original image to obtain a clearer image. However, when superimposing the high-frequency information with the original image, if the sharpening strength is too low, the image after sharpening will not be clear enough. If the sharpening strength is too high, it will easily lead to over-sharpening at the edges of the image, and black and white edges will appear in the image, such as Figure 6 As shown, curve a is the one-dimensional cross-section of the edge of the brightness transition, and curve b is the result of a without black and white edges after sharpening under ideal conditions. Figure 7 As shown, a is the one-dimensional cross-section of the edge where the brightness value transitions, and c is the result of a being sharpened and having black and white edges.
[0076] Therefore, in this embodiment, after the original image is sharpened, the original image is sharpened. Figure 1 The filtering results of the pixel blocks are obtained, and according to the filtering results, the brightness of the pixels in the range centered on it is checked, and the pixels of the window are divided based on these pixels, thereby limiting the range of pixel brightness changes before and after sharpening, so that the sharpening fully considers the local information of the image and eliminates the black and white edges that appear at the edges after sharpening, thereby eliminating the black and white edges caused by image sharpening without reducing the overall clarity of the image. Figure 8 、 9 As shown in 10, you can see Figure 9 Black and white edges appear in the image. Figure 10 It can be seen that the image clarity has not decreased significantly, but the black and white edges have been eliminated.
[0077] Preferably, the size of the filtering window is 3x3 or 5x5. It can also be any other singular window in plural form, that is, as long as a clear central pixel point can be found.
[0078] Preferably, the number of directional filters is one of 4, 6, and 8. Taking 4 filtering directions as an example, the directions are 0, 45, 90, and 135 degrees, respectively. The specific directions can be adjusted according to actual conditions, as long as they are evenly distributed within a range and meet the partitioning requirements of the filtering window.
[0079] Example 2:
[0080] like Figure 1 、 3 As shown, this embodiment provides a method for image sharpening and eliminating black and white edges, including:
[0081] S1: Get the original brightness image;
[0082] S2: Take the current pixel of the original brightness image as the center pixel and build a filtering window;
[0083] S3: Filtering the filtering window using multiple directional filters to obtain multiple filtering results;
[0084] S4: Obtaining a maximum filtering result and a minimum filtering result according to the multiple filtering results;
[0085] S5: Dividing the pixels of the filtering window into a first pixel area, a second pixel area, and a third pixel area according to the filter direction corresponding to the maximum filtering result;
[0086] S6: Obtain the central pixel point of the filter window and the corresponding sharpened brightness after sharpening;
[0087] S7-1: Obtaining a corresponding edge probability prediction based on the maximum filtering result and the minimum filtering result;
[0088] S7-2: Calculate the average brightness of the first pixel area, the second pixel area, and the third pixel area respectively to obtain a first average brightness, a second average brightness, and a third average brightness;
[0089] S7-3: Calculating a sharpening threshold according to the first average brightness, the second average brightness, and the third average brightness;
[0090] S7-4: Calculating the pre-center point brightness according to the sharpening threshold, the sharpening brightness, and the edge probability prediction;
[0091] S7-5: Calculating the center brightness after black and white edges are eliminated based on the sharpening brightness and the pre-center brightness;
[0092] S8: Setting the brightness of the central pixel according to the central brightness after the black and white edges are eliminated.
[0093] In this embodiment, take the use of four filters and a window size of 3x3 as an example: in S2, a 3x3 window is constructed for each pixel in the image, and then in S3, four filters (filter directions are 0 / 45 / 90 / 135 degrees) are used to filter the 3x3 window respectively. The result with the largest absolute value among the four filtering results (filterOut1, filterOut2, filterOut3, filterOut4) is recorded as filterOut, and the filter direction corresponding to filterOut is recorded as filterOrien. Then in S5, the 3x3 window of the original brightness image is divided into 3 regions according to filterOrien. Figure 2 The left and right sides respectively show how the original brightness image is divided in the 3x3 window when filterOrien is in the 0 degree and 45 degree directions.
[0094] Then, the sharpened brightness of the corresponding central pixel is obtained in S6 and recorded as ySharpen.
[0095] Then, in S7-1, the maximum value of filterOut1, filterOut2, filterOut3, and filterOut4 is taken as filterOutMax and the minimum value is taken as filterOutMin. Combined with the noise influence coefficient k, the edge probability prediction is calculated and recorded as edgePro. Generally speaking, the higher the overall noise level of the image, the larger the k value. At the same time, further preferably, the edge probability prediction = 1-(the minimum filtering result + the noise influence coefficient) / (the maximum filtering result + the noise influence coefficient), that is:
[0096] edgePro=1-(filterOutMin+k) / (filterOutMax+k)
[0097] Then, in S7-2, the sum of the brightness values of the pixels in the three areas is recorded as pixelSum1, pixelSum2, and pixelSum3, and the number of these pixels is recorded as pixelNum1, pixelNum2, and pixelNum3. Calculate pixelAve1 = pixelSum1 / pixelNum1, pixelAve2 = pixelSum2 / pixelNum2, and pixelAve3 = pixelSum3 / pixelNum3. The maximum value of pixelAve1, pixelAve2, and pixelAve3 is recorded as pixelAround.
[0098] In S7-3, the sharpening threshold is recorded as yThr, and is calculated in combination with the black and white edge intensity threshold unevenGain. More specifically:
[0099] yThr=pixelAround*unevenGain
[0100] Then, in S7-4, further preferably, the pre-center point brightness=(the sharpening brightness+(the sharpening threshold-the sharpening brightness)×the edge probability prediction), that is:
[0101] (ySharpen+(yThr-ySharpen)*edgePro)
[0102] The pre-center point brightness is calculated and then combined with the sharpening brightness to obtain the brightness of the center pixel point actually set.
[0103] Example 3:
[0104] like Figure 1 、 3 As shown in , 4, and 5, this embodiment provides an image sharpening method for eliminating black and white edges, including:
[0105] S1: Get the original brightness image;
[0106] S2: Take the current pixel of the original brightness image as the center pixel and build a filtering window;
[0107] S3: Filtering the filtering window using multiple directional filters to obtain multiple filtering results;
[0108] S4: Obtaining a maximum filtering result and a minimum filtering result according to the multiple filtering results;
[0109] S5: Dividing the pixels of the filtering window into a first pixel area, a second pixel area, and a third pixel area according to the filter direction corresponding to the maximum filtering result;
[0110] S6: Obtain the central pixel point of the filter window and the corresponding sharpened brightness after sharpening;
[0111] S7-1: Obtaining a corresponding edge probability prediction based on the maximum filtering result and the minimum filtering result;
[0112] S7-2: Calculate the average brightness of the first pixel area, the second pixel area, and the third pixel area respectively to obtain a first average brightness, a second average brightness, and a third average brightness;
[0113] When the maximum filtering result is greater than or equal to 0, pixels in the filtering window with a brightness lower than that of a central pixel in the filtering window are not included in the calculation of the first average brightness, the second average brightness, and the third average brightness;
[0114] When the maximum filtering result is less than 0, pixels in the filtering window with a brightness greater than that of a central pixel in the filtering window are not included in the calculation of the first average brightness, the second average brightness, and the third average brightness;
[0115] S7-3-1: When the maximum filtering result is greater than or equal to 0, obtain the maximum average brightness according to the first average brightness, the second average brightness, and the third average brightness;
[0116] S7-3-2: When the maximum filtering result is greater than or equal to 0, calculate a sharpening threshold according to the maximum average brightness and the positive black and white edge intensity threshold;
[0117] S7-3-3: When the maximum filtering result is less than 0, obtain the minimum average brightness according to the first average brightness, the second average brightness, and the third average brightness;
[0118] S7-3-4: When the maximum filtering result is less than 0, calculate the sharpening threshold according to the minimum average brightness and the negative black and white edge intensity threshold;
[0119] S7-4: Calculating the pre-center point brightness according to the sharpening threshold, the sharpening brightness, and the edge probability prediction;
[0120] S7-5-1: When the maximum filtering result is greater than or equal to 0, compare the pre-center point brightness and the sharpened brightness, and take the smaller one as the center brightness after the black and white edges are eliminated;
[0121] S7-5-2: When the maximum filtering result is less than 0, compare the pre-center point brightness and the sharpened brightness, and take the larger one as the center brightness after the black and white edges are eliminated.
[0122] S8: Setting the brightness of the central pixel according to the central brightness after the black and white edges are eliminated.
[0123] In this embodiment, take the use of four filters and a window size of 3x3 as an example: in S2, a 3x3 window is constructed for each pixel in the image, and then in S3, four filters (filter directions are 0 / 45 / 90 / 135 degrees) are used to filter the 3x3 window respectively. The result with the largest absolute value among the four filtering results (filterOut1, filterOut2, filterOut3, filterOut4) is recorded as filterOut, and the filter direction corresponding to filterOut is recorded as filterOrien. Then in S5, the 3x3 window of the original brightness image is divided into 3 regions according to filterOrien. Figure 2 The left and right sides respectively show how the original brightness image is divided in the 3x3 window when filterOrien is in the 0 degree and 45 degree directions.
[0124] Then, the sharpened brightness of the corresponding central pixel is obtained in S6 and recorded as ySharpen.
[0125] Then, in S7-1, the maximum value of filterOut1, filterOut2, filterOut3, and filterOut4 is taken as filterOutMax and the minimum value is taken as filterOutMin. Combined with the noise influence coefficient k, the edge probability prediction is calculated and recorded as edgePro. Generally speaking, the higher the overall noise level of the image, the larger the k value. At the same time, further preferably, the edge probability prediction = 1-(the minimum filtering result + the noise influence coefficient) / (the maximum filtering result + the noise influence coefficient), that is:
[0126] edgePro=1-(filterOutMin+k) / (filterOutMax+k)
[0127] Then, in S7-2, when filterOut >= 0, search for pixels in each of the three regions whose brightness is not less than the brightness of the center point. Record the sum of these brightness values as pixelSum1, pixelSum2, and pixelSum3, and the number of these pixels as pixelNum1, pixelNum2, and pixelNum3. Calculate pixelAve1 = pixelSum1 / pixelNum1, pixelAve2 = pixelSum2 / pixelNum2, and pixelAve3 = pixelSum3 / pixelNum3. When pixelNum = 0, the region is not included in the calculation. Take the maximum value of pixelAve1, pixelAve2, and pixelAve3 and record it as pixelAround.
[0128] If filterOut < 0, find pixels in each of the three regions whose brightness is no greater than the brightness of the center point. Record the sum of these brightness values as pixelSum1, pixelSum2, and pixelSum3, and the number of these pixels as pixelNum1, pixelNum2, and pixelNum3. Calculate pixelAve1 = pixelSum1 / pixelNum1, pixelAve2 = pixelSum2 / pixelNum2, and pixelAve3 = pixelSum3 / pixelNum3. If pixelNum = 0, the region is not included in the calculation. Take the minimum value of pixelAve1, pixelAve2, and pixelAve3 as pixelAround.
[0129] At the same time, in the setting of the black and white edge intensity threshold, the positive black and white edge intensity threshold unevenGainPos in the positive state and the negative black and white edge intensity threshold unevenGainNeg in the negative state are set respectively. Generally, the former takes a value greater than or equal to 1, and the latter takes a value less than or equal to 1.
[0130] The sharpening threshold is recorded as yThr, and is calculated in combination with the black and white edge intensity thresholds unevenGainPos and unevenGainNeg. More specifically, when filterOut>=0, the sharpening threshold is set:
[0131] yThr=pixelAround*unevenGainPos
[0132] When filterOut<0, set the sharpening threshold:
[0133] yThr=pixelAround*unevenGainNeg
[0134] Then, in S7-4, further preferably, the pre-center point brightness=(the sharpening brightness+(the sharpening threshold-the sharpening brightness)×the edge probability prediction), that is:
[0135] (ySharpen+(yThr-ySharpen)*edgePro)
[0136] Thus the pre-center point brightness is calculated;
[0137] When filterOut>=0, the smaller value ySharpenNew of the pre-center brightness and ySharpen is taken as the center brightness value after sharpening and eliminating black and white edges.
[0138] When filterOut<0, the larger value ySharpenNew of the pre-center brightness and ySharpen is taken as the center brightness value after sharpening the black and white edges.
[0139] Example 4:
[0140] This embodiment provides an image sharpening and black and white edge removal system, comprising:
[0141] The original acquisition module is used to obtain the original brightness image;
[0142] A filtering module is configured to construct a filtering window using the current pixel of the original brightness image as the center pixel, and filter the filtering window using multiple directional filters to obtain multiple filtering results; thereby obtaining a maximum filtering result and a minimum filtering result based on the multiple filtering results;
[0143] A region division module, configured to divide the pixels of the filtering window into a first pixel region, a second pixel region, and a third pixel region according to a filter direction corresponding to the maximum filtering result;
[0144] A sharpening acquisition module is used to obtain a sharpened brightness map and obtain the corresponding sharpened brightness of the central pixel point of the filter window after sharpening;
[0145] An edge probability prediction module, configured to obtain a corresponding edge probability prediction based on the maximum filtering result and the minimum filtering result;
[0146] a sharpening threshold calculation module, configured to respectively calculate the average brightness of the first pixel area, the second pixel area, and the third pixel area to obtain a first average brightness, a second average brightness, and a third average brightness, and calculate a sharpening threshold based on the first average brightness, the second average brightness, and the third average brightness;
[0147] The pre-center point calculation module is used to calculate the pre-center point brightness based on the sharpening threshold, the sharpening brightness, and the edge probability prediction; and calculate the center brightness after the black and white edges are eliminated based on the sharpening brightness and the pre-center point brightness; thereby setting the brightness of the center pixel point based on the center brightness after the black and white edges are eliminated.
[0148] Image sharpening generally operates on the luminance map, increasing the image's brightness transitions to create a clearer image. Typically, image sharpening uses a high-pass filter, or a method that subtracts a low-pass filter from the original luminance map, to extract the image's high-frequency information. This high-frequency information is then superimposed on the original image to create a clearer image. However, if the sharpening strength is too low when superimposing the high-frequency information, the sharpened image will lack clarity. If the sharpening strength is too high, the image may be oversharpened at the edges, resulting in black and white edges.
[0149] Therefore, in this embodiment, after the original image is sharpened, Figure 1 The filtering results of the pixel blocks are obtained, and according to the filtering results, the brightness of the pixels in the range centered on it is checked, and the pixels of the window are divided based on these pixels, thereby limiting the range of pixel brightness changes before and after sharpening, so that the sharpening fully considers the local information of the image and eliminates the black and white edges that appear at the edges after sharpening, thereby eliminating the black and white edges caused by image sharpening without reducing the overall clarity of the image. Figure 8 、 9 As shown in 10, you can see Figure 9 Black and white edges appear in the image. Figure 10 It can be seen that the image clarity has not decreased significantly, but the black and white edges have been eliminated.
[0150] Preferably, the size of the filtering window is 3x3 or 5x5. It can also be any other singular window in plural form, that is, as long as a clear central pixel point can be found.
[0151] Preferably, the number of directional filters is one of 4, 6, and 8. Taking 4 filtering directions as an example, the directions are 0, 45, 90, and 135 degrees, respectively. The specific directions can be adjusted according to actual conditions, as long as they are evenly distributed within a range and meet the partitioning requirements of the filtering window.
[0152] In this embodiment, four filters with a window size of 3x3 are used as an example: for each pixel in the image, a 3x3 window is constructed, and then four filters (filter directions are 0 / 45 / 90 / 135 degrees) are used to filter the 3x3 window respectively. The result with the largest absolute value among the four filtering results (filterOut1, filterOut2, filterOut3, filterOut4) is recorded as filterOut, and the filter direction corresponding to filterOut is recorded as filterOrien. Then, the 3x3 window of the original brightness image is divided into three regions according to filterOrien. Figure 2 The left and right sides respectively show how the original brightness image is divided in the 3x3 window when filterOrien is in the 0 degree and 45 degree directions.
[0153] Then get the sharpened brightness of the corresponding center pixel, recorded as ySharpen.
[0154] Then, the maximum value of filterOut1, filterOut2, filterOut3, and filterOut4 is recorded as filterOutMax and the minimum value is recorded as filterOutMin. Combined with the noise influence coefficient k, the edge probability prediction is calculated and recorded as edgePro. Generally speaking, the higher the overall noise level of the image, the larger the k value. At the same time, further preferably, the edge probability prediction = 1-(the minimum filtering result + the noise influence coefficient) / (the maximum filtering result + the noise influence coefficient), that is:
[0155] edgePro=1-(filterOutMin+k) / (filterOutMax+k)
[0156] Then record the sum of the brightness values of the pixels in the three areas as pixelSum1, pixelSum2, and pixelSum3, and record the number of these pixels as pixelNum1, pixelNum2, and pixelNum3. Calculate pixelAve1 = pixelSum1 / pixelNum1, pixelAve2 = pixelSum2 / pixelNum2, and pixelAve3 = pixelSum3 / pixelNum3. Take the maximum value of pixelAve1, pixelAve2, and pixelAve3 and record it as pixelAround.
[0157] The sharpening threshold is recorded as yThr, and the specific calculation is performed in combination with the black and white edge intensity threshold unevenGain. More specifically:
[0158] yThr=pixelAround*unevenGain
[0159] Further preferably, the pre-center point brightness=(the sharpening brightness+(the sharpening threshold-the sharpening brightness)×the edge probability prediction), that is:
[0160] (ySharpen+(yThr-ySharpen)*edgePro)
[0161] The pre-center point brightness is calculated and then combined with the sharpening brightness to obtain the brightness of the center pixel point actually set.
[0162] Example 5:
[0163] This embodiment provides an image sharpening and black and white edge removal system. Based on Embodiment 4, the sharpening threshold calculation module includes a positive filtering calculation submodule for obtaining a maximum average brightness based on the first average brightness, the second average brightness, and the third average brightness when the maximum filtering result is greater than or equal to 0; pixels in the filtering window with a brightness less than that of a central pixel of the filtering window are not included in the calculation of the first average brightness, the second average brightness, and the third average brightness; and a sharpening threshold is calculated based on the maximum average brightness and a positive black and white edge intensity threshold.
[0164] The pre-center point calculation module includes a positive filtering brightness calculation submodule. When the maximum filtering result is greater than or equal to 0, the pre-center point brightness and the sharpening brightness are compared, and the smaller one is taken as the center brightness after the black and white edges are eliminated.
[0165] The sharpening threshold calculation module includes a negative filtering calculation submodule, which is used to obtain a minimum average brightness based on the first average brightness, the second average brightness, and the third average brightness when the maximum filtering result is less than 0; pixels in the filtering window with a brightness greater than the brightness of the center pixel of the filtering window are not involved in the calculation of the first average brightness, the second average brightness, and the third average brightness; and calculate a sharpening threshold based on the minimum average brightness and a negative black and white edge intensity threshold;
[0166] The pre-center point calculation module includes a negative filtering brightness calculation submodule. When the maximum filtering result is less than 0, the pre-center point brightness and the sharpening brightness are compared, and the larger one is taken as the center brightness after the black and white edges are eliminated.
[0167] In this embodiment, take the use of four filters and a window size of 3x3 as an example: for each pixel in the image, a 3x3 window is constructed, and then four filters (filter directions are 0 / 45 / 90 / 135 degrees) are used to filter the 3x3 window respectively. The result with the largest absolute value among the four filtering results (filterOut1, filterOut2, filterOut3, filterOut4) is recorded as filterOut, and the filter direction corresponding to filterOut is recorded as filterOrien. According to filterOrien, the 3x3 window of the original brightness image is divided into 3 areas. Figure 2 The left and right sides respectively show how the original brightness image is divided in the 3x3 window when filterOrien is in the 0 degree and 45 degree directions.
[0168] Then get the sharpened brightness of the corresponding center pixel, recorded as ySharpen.
[0169] Then, the maximum value of filterOut1, filterOut2, filterOut3, and filterOut4 is recorded as filterOutMax and the minimum value is recorded as filterOutMin. Combined with the noise influence coefficient k, the edge probability prediction is calculated and recorded as edgePro. Generally speaking, the higher the overall noise level of the image, the larger the k value. At the same time, further preferably, the edge probability prediction = 1-(the minimum filtering result + the noise influence coefficient) / (the maximum filtering result + the noise influence coefficient), that is:
[0170] edgePro=1-(filterOutMin+k) / (filterOutMax+k)
[0171] Then, when filterOut >= 0, find pixels in each of the three regions whose brightness is not less than the brightness of the center point. Record the sum of these brightness values as pixelSum1, pixelSum2, and pixelSum3, and the number of these pixels as pixelNum1, pixelNum2, and pixelNum3. Calculate pixelAve1 = pixelSum1 / pixelNum1, pixelAve2 = pixelSum2 / pixelNum2, and pixelAve3 = pixelSum3 / pixelNum3. When pixelNum = 0, the region is not included in the calculation. Take the maximum of pixelAve1, pixelAve2, and pixelAve3 as pixelAround.
[0172] If filterOut < 0, find pixels in each of the three regions whose brightness is no greater than the brightness of the center point. Record the sum of these brightness values as pixelSum1, pixelSum2, and pixelSum3, and the number of these pixels as pixelNum1, pixelNum2, and pixelNum3. Calculate pixelAve1 = pixelSum1 / pixelNum1, pixelAve2 = pixelSum2 / pixelNum2, and pixelAve3 = pixelSum3 / pixelNum3. If pixelNum = 0, the region is not included in the calculation. Take the minimum value of pixelAve1, pixelAve2, and pixelAve3 as pixelAround.
[0173] At the same time, in the setting of the black and white edge intensity threshold, the positive black and white edge intensity threshold unevenGainPos in the positive state and the negative black and white edge intensity threshold unevenGainNeg in the negative state are set respectively. Generally, the former takes a value greater than or equal to 1, and the latter takes a value less than or equal to 1.
[0174] The sharpening threshold is recorded as yThr, and is calculated in combination with the black and white edge intensity thresholds unevenGainPos and unevenGainNeg. More specifically, when filterOut>=0, the sharpening threshold is set:
[0175] yThr=pixelAround*unevenGainPos
[0176] When filterOut<0, set the sharpening threshold:
[0177] yThr=pixelAround*unevenGainNeg
[0178] Further preferably, the pre-center point brightness=(the sharpening brightness+(the sharpening threshold-the sharpening brightness)×the edge probability prediction), that is:
[0179] (ySaroen+(yThr-ySharpen)*edgePro)
[0180] Thus the pre-center point brightness is calculated;
[0181] When filterOut>=0, the smaller value ySharpenNew of the pre-center brightness and ySharpen is taken as the center brightness value after sharpening and eliminating black and white edges.
[0182] When filterOut<0, the larger value ySharpenNew of the pre-center brightness and ySharpen is taken as the center brightness value after sharpening the black and white edges.
[0183] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0184] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.
Claims
1. A method for image sharpening and black and white edge elimination, characterized in that: include: Get the original brightness image; Take the current pixel of the original brightness image as the center pixel and build a filtering window; Using multiple directional filters, filtering the filtering window to obtain multiple filtering results; According to the plurality of filtering results, a maximum filtering result and a minimum filtering result are obtained; Dividing the pixel points of the filtering window into a first pixel area, a second pixel area, and a third pixel area according to the filter direction corresponding to the maximum filtering result; Obtaining the sharpened brightness of the center pixel of the filter window after sharpening; Calculate the center brightness after black and white edges are eliminated according to the maximum filtering result, the minimum filtering result, the first pixel area, the second pixel area, the third pixel area, and the sharpened brightness; Setting the brightness of the central pixel point according to the central brightness after the black and white edges are eliminated; The method further comprises calculating the center brightness after eliminating the black and white edges based on the maximum filtering result, the minimum filtering result, the first pixel area, the second pixel area, the third pixel area, and the sharpened brightness. Obtaining a corresponding edge probability prediction according to the maximum filtering result and the minimum filtering result; Calculating the average brightness of the first pixel area, the second pixel area, and the third pixel area respectively to obtain a first average brightness, a second average brightness, and a third average brightness; Calculate a sharpening threshold according to the first average brightness, the second average brightness, and the third average brightness; Calculating the pre-center point brightness according to the sharpening threshold, the sharpening brightness, and the edge probability prediction; The center brightness after the black and white edges are eliminated is calculated according to the sharpening brightness and the pre-center point brightness.
2. The method for image sharpening and black and white edge elimination according to claim 1, characterized in that: When the maximum filtering result is greater than or equal to 0, calculating the sharpening threshold according to the first average brightness, the second average brightness, and the third average brightness specifically includes: Obtaining a maximum average brightness based on the first average brightness, the second average brightness, and the third average brightness; pixels in the filtering window with a brightness lower than that of a central pixel in the filtering window are not included in the calculation of the first average brightness, the second average brightness, and the third average brightness; The sharpening threshold is calculated according to the maximum average brightness and the positive black and white edge intensity threshold.
3. The method for image sharpening and black and white edge elimination according to claim 2, characterized in that: When the maximum filtering result is greater than or equal to 0, calculating the center brightness after the black and white edges are eliminated specifically includes: The pre-center point brightness and the sharpened brightness are compared, and the smaller one is taken as the center brightness after the black and white edges are eliminated.
4. The method for image sharpening and black and white edge elimination according to claim 1, characterized in that: When the maximum filtering result is less than 0, calculating the center brightness after the black and white edges are eliminated specifically includes: Obtaining a minimum average brightness based on the first average brightness, the second average brightness, and the third average brightness; pixels in the filtering window with a brightness greater than that of a central pixel in the filtering window are not included in the calculation of the first average brightness, the second average brightness, and the third average brightness; The sharpening threshold is calculated according to the minimum average brightness and the negative black and white edge intensity threshold.
5. The method for image sharpening and black and white edge elimination according to claim 4, characterized in that: When the maximum filtering result is less than 0, calculating the center brightness after eliminating the black and white edges specifically includes: The pre-center point brightness and the sharpened brightness are compared, and the larger one is taken as the center brightness after the black and white edges are eliminated.
6. The method for image sharpening and black and white edge elimination according to claim 2 or 4, characterized in that: The pre-center point brightness = (the sharpening brightness + (the sharpening threshold - the sharpening brightness) × the edge probability prediction); The edge probability prediction=1-(the absolute value of the minimum filtering result+the noise influence coefficient) / (the absolute value of the maximum filtering result+the noise influence coefficient).
7. An image sharpening and black and white edge elimination system, characterized in that: include: The original acquisition module is used to obtain the original brightness image; A filtering module is configured to construct a filtering window using the current pixel of the original brightness image as the center pixel, and filter the filtering window using multiple directional filters to obtain multiple filtering results; thereby obtaining a maximum filtering result and a minimum filtering result based on the multiple filtering results; A region division module, configured to divide the pixels of the filtering window into a first pixel region, a second pixel region, and a third pixel region according to a filter direction corresponding to the maximum filtering result; A sharpening acquisition module is used to obtain a sharpened brightness map and obtain the corresponding sharpened brightness of the central pixel point of the filter window after sharpening; An edge probability prediction module, configured to obtain a corresponding edge probability prediction based on the maximum filtering result and the minimum filtering result; a sharpening threshold calculation module, configured to respectively calculate the average brightness of the first pixel area, the second pixel area, and the third pixel area to obtain a first average brightness, a second average brightness, and a third average brightness, and calculate a sharpening threshold based on the first average brightness, the second average brightness, and the third average brightness; The pre-center point calculation module is used to calculate the pre-center point brightness based on the sharpening threshold, the sharpening brightness, and the edge probability prediction; and calculate the center brightness after the black and white edges are eliminated based on the sharpening brightness and the pre-center point brightness; thereby setting the brightness of the center pixel point based on the center brightness after the black and white edges are eliminated.
8. The image sharpening and black and white edge removal system according to claim 7, characterized in that: The sharpening threshold calculation module includes a positive filtering calculation submodule, which is used to obtain the maximum average brightness according to the first average brightness, the second average brightness, and the third average brightness when the maximum filtering result is greater than or equal to 0; In the filtering window, pixels with brightness less than that of a central pixel of the filtering window are not involved in calculating the first average brightness, the second average brightness, and the third average brightness, and a sharpening threshold is calculated based on the maximum average brightness and a positive black and white edge intensity threshold; The pre-center point calculation module includes a positive filtering brightness calculation submodule. When the maximum filtering result is greater than or equal to 0, the pre-center point brightness and the sharpening brightness are compared, and the smaller one is taken as the center brightness after the black and white edges are eliminated.
9. The image sharpening and black and white edge removal system according to claim 7, characterized in that: The sharpening threshold calculation module includes a negative filtering calculation submodule, which is used to obtain the minimum average brightness according to the first average brightness, the second average brightness, and the third average brightness when the maximum filtering result is less than 0; In the filtering window, pixels with brightness greater than that of the central pixel of the filtering window are not included in the calculation of the first average brightness, the second average brightness, and the third average brightness; a sharpening threshold is calculated based on the minimum average brightness and the negative black and white edge intensity threshold; The pre-center point calculation module includes a negative filtering brightness calculation submodule. When the maximum filtering result is less than 0, the pre-center point brightness and the sharpening brightness are compared, and the larger one is taken as the center brightness after the black and white edges are eliminated.
Citation Information
Patent Citations
Image sharpening method and device
CN113643190A
Image processing method and device for black edge optimization, equipment and storage medium
CN114187204A