Image median filtering method, electronic equipment and storage medium

By scanning and obtaining the measurement values ​​of non-flat points in the neighborhood window and combining the point selection method to perform median filtering, the problem of poor effect of median filtering in complex images is solved, and the high-frequency details of the image are better preserved.

CN120707444APending Publication Date: 2025-09-26HUNAN GOKE MICROELECTRONICS CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510890946.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-30
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

Median filtering is less effective when processing complex images with sharp edges and many details, resulting in blurred image features and destruction of details.

Method used

By scanning the central pixel point in the neighborhood window, the measurement value of the non-flat point (such as edge point and corner point) is obtained, and the corresponding point selection method is selected according to the measurement value to perform median filtering. The results of different types of median filtering are fused to obtain the filtered central pixel point.

Benefits of technology

It effectively preserves the high-frequency details of complex images, improves the effect of median filtering in complex images, adaptively processes edges and corners, and reduces image feature blur.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120707444A_ABST
    Figure CN120707444A_ABST
Patent Text Reader

Abstract

The invention discloses an image median filtering method, electronic equipment and a storage medium, and the method comprises the steps: scanning a central pixel point in a neighborhood window to each direction of the neighborhood window, so as to obtain a measurement value when the central pixel point is a non-flat point; and carrying out median filtering processing by adopting a point selection mode corresponding to the non-flat points according to the metric value to obtain a filtered central pixel point. The technical problems that complex images with many details are included, and the median filtering effect is poor are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of digital image processing, and in particular to an image median filtering method, electronic equipment, and storage medium. Background Art

[0002] Median filtering is a nonlinear smoothing technique that replaces the value of a pixel in a digital image or sequence with the median of all the values ​​in its neighborhood, bringing the surrounding pixel values ​​closer to the true value and eliminating isolated noise points. This method is effective in suppressing noise, especially salt and pepper noise and impulse noise.

[0003] In addition, median filtering can well preserve the edge information of images or signals. This is because the median value in the pixel neighborhood is selected to replace the central pixel value, and edge pixels usually occupy the majority in the neighborhood, so the edge position is not easily blurred. It is simple to implement, consumes less hardware, and runs fast.

[0004] However, median filtering will cause a certain degree of blur when processing details such as edges and textures, especially when there are sharp edges and details in the image, which will cause these features to be blurred, thereby changing the original features of the image, especially the grayscale values ​​of pixels that are not contaminated by noise, which will destroy the image details to a certain extent.

[0005] That is, for complex images containing many points, lines, and sharp corners, the effect of median filtering is relatively poor. Summary of the Invention

[0006] The present invention provides an image median filtering method, electronic equipment and storage medium, aiming to solve the technical problem of poor median filtering effect for complex images with many details.

[0007] This application provides a median filtering method for an image, comprising the following steps: Scanning the center pixel point in the neighborhood window in all directions to the neighborhood window to obtain a metric value when the center pixel point is a non-flat point; According to the metric value, median filtering is performed using a point selection method corresponding to the non-flat point to obtain a filtered central pixel point.

[0008] Optionally, performing median filtering based on the metric value and adopting a point selection method corresponding to the non-flat point to obtain a filtered central pixel point includes: Obtaining a first median filtering result of the central pixel point in the neighborhood window under the point selection method corresponding to the non-flat point and a second median filtering result when the central pixel point is a flat point; The first median filtering result and the second median filtering result are fused according to the metric value to obtain a filtered central pixel point.

[0009] Optionally, when the non-flat point includes a corner point, obtaining a first median filtering result of the central pixel point in the neighborhood window in a point selection method corresponding to the non-flat point includes: Comparing the central pixel point in the neighborhood window with each of the neighborhood pixel points relative to the central pixel point to obtain first comparison results; Determine the identification value corresponding to each pixel point according to each first comparison result, and obtain the sum of the identification values ​​corresponding to the pixel points in each area divided in the horizontal direction and the vertical direction based on the central pixel point, with the central pixel point as the central point; Comparing the median of the sum of the identification values ​​corresponding to the pixels in each area with the reference value associated with the central pixel to obtain a second comparison result; The target point of the neighborhood window is determined according to the second comparison result, and a median filtering calculation is performed according to the target point to obtain a third median filtering result, wherein the first median filtering result includes the third median filtering result.

[0010] Optionally, determining the target point of the neighborhood window according to the second comparison result includes: When the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixels in each area is equal to the reference value related to the central pixel, the target point in the neighborhood window is the central pixel; When the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixels in each area is greater than the reference value associated with the central pixel, the target selected point in the neighborhood window is a neighborhood pixel in the area corresponding to the sum of the identification values ​​being less than the reference value associated with the central pixel; When the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixel points in each area is less than the reference value related to the central pixel point, the target selection point in the neighborhood window is the neighborhood pixel point in the area corresponding to the sum of the identification values ​​greater than the reference value related to the central pixel point.

[0011] Optionally, when the non-flat point includes an edge point, obtaining a first median filtering result of the central pixel point in the neighborhood window under the point selection method corresponding to the non-flat point includes: Obtaining an edge angle obtained during scanning, where the edge angle is the angle between the corner point and the vertical direction; Determine the target point within the neighborhood window according to the size of the edge angle; Perform median filtering calculation according to the target selected point to obtain a fourth median filtering result, and the first median filtering result includes the fourth median filtering result.

[0012] Optionally, the first median filtering result includes a third median filtering result under a point selection method corresponding to a corner point and a fourth median filtering result under a point selection method corresponding to an edge point; and fusing the first median filtering result and the second median filtering result according to the metric value to obtain a filtered center pixel point includes: The second median filtering result, the third median filtering result, and the fourth median filtering result are fused according to the metric value at the edge point and the metric value at the corner point to obtain a filtered central pixel point.

[0013] Optionally, fusing the second median filtering result, the third median filtering result, and the fourth median filtering result according to the metric value at the edge point and the metric value at the corner point to obtain a filtered center pixel point includes: Perform linear interpolation based on the second median filtering result, the third median filtering result, and the metric value at the corner point to determine a non-edge median filtering result; Linear interpolation is performed based on the non-edge median filtering result, the fourth median filtering result, and the metric value at the edge point to obtain a filtered central pixel point.

[0014] The present application also provides an electronic device, comprising: A scanning module, configured to scan from a central pixel point in a neighborhood window to all directions of the neighborhood window to obtain a metric value when the central pixel point is a non-flat point; The filtering processing module is used to perform median filtering processing according to the measurement value and adopt the point selection method corresponding to the non-flat point to obtain a filtered central pixel point.

[0015] The present application also provides an electronic device, comprising: at least one processor; and A memory communicatively connected to the at least one processor, the memory storing a computer program executable by the at least one processor, the computer program being executed by the at least one processor so as to enable the at least one processor to perform the median filtering method for an image as described above.

[0016] The present application also provides a computer-readable storage medium, wherein the storage medium is used to store a computer program, and the computer program is used to enable a computer to execute the median filtering method for an image as described above.

[0017] The embodiment of the present application scans the center pixel point in the neighborhood window in all directions to the neighborhood window to obtain the measurement value when the center pixel point is a non-flat point, such as an edge point and / or a corner point; according to the measurement value, the point selection method corresponding to the target type is used to perform median filtering to obtain the filtered center pixel point. Therefore, when the center pixel point is subjected to median filtering, it is based on the corresponding measurement value when the center point is a non-flat point, such as an edge point and / or a corner point, in the neighborhood window where the center point is located, combined with its corresponding point selection method. The situation that the pixel point subjected to median filtering is an edge point and / or a corner point when in a complex image is taken into account, and median filtering is adaptively performed according to its corresponding point selection method. The filtered center pixel point finally obtained can better retain high-frequency details, such as edge texture, and can adapt to the texture details of complex images. The median filtering effect is better, thus solving the technical problem that the median filtering effect is poor for complex images with many details. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0019] Figure 1 1 is a flow chart of a median filtering method for an image according to an embodiment of the present invention; Figure 2 A schematic diagram of feature point classification in the related art involved in an embodiment of the present invention; Figure 3 Schematic diagram of target point selection within a neighborhood window when the central pixel point is calculated as a flat point in an embodiment of the present invention; Figure 4 Schematic diagram of selecting a target point in a neighborhood window when calculating a central pixel point as a corner point in an embodiment of the present invention; Figure 5 Schematic diagram of target point selection within a neighborhood window when calculating a central pixel point as an edge point in an embodiment of the present invention; Figure 6 This is a schematic structural diagram of an electronic device according to an embodiment of the present invention; Figure 7 Schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0020] In order to help those skilled in the art better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of this application.

[0021] It should be noted that when an element is referred to as being “fixed on” or “set on” another element, it can be directly on the other element or indirectly set on the other element; when an element is referred to as being “connected to” another element, it can be directly connected to the other element or indirectly connected to the other element.

[0022] It should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on this application.

[0023] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of technical features indicated. Thus, a feature specified as "first" or "second" may explicitly or implicitly include one or more of such features. Throughout the description of this application, "plurality" or "several" means two or more, unless otherwise specifically defined.

[0024] It should be noted that the structures, proportions, sizes, etc. illustrated in the drawings of this specification are only used to match the contents disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the conditions under which this application can be implemented. Therefore, they have no substantive technical significance. Any structural modification, change in proportional relationship or adjustment of size should still fall within the scope of the technical content disclosed in this application without affecting the efficacy and purpose that can be achieved by this application.

[0025] In order to solve the technical problem of poor median filtering effect for complex images with many details, the present application provides an image median filtering method, electronic device and storage medium. The following first introduces the image median filtering method provided by the present application.

[0026] like Figure 1 As shown, an embodiment of the present invention provides a median filtering method for an image, comprising: Step S110, scanning the direction from the central pixel point in the neighborhood window to the neighborhood window to obtain a metric value when the central pixel point is a non-flat point; Step S120 : performing median filtering according to the metric value and the point selection method corresponding to the non-flat point to obtain a filtered central pixel point.

[0027] In this embodiment, when performing median filtering on the central pixel point, the median filtering is performed based on the corresponding metric value when the central point is a non-flat point in the neighborhood window, such as an edge point and / or a corner point, combined with its corresponding point selection method. The situation where the pixel point of the median filter is an edge point and / or a corner point when in a complex image is taken into consideration, and the median filtering is adaptively performed according to its corresponding point selection method. The filtered central pixel point finally obtained can better retain high-frequency details, such as edge texture, and can adapt to the texture details of complex images. The median filtering effect is better, thereby solving the technical problem of poor median filtering effect for complex images with many details.

[0028] The median filtering scheme in this solution describes the process of performing median filtering on a single central pixel in image data. For image data or digital sequences, this median filtering scheme is executed cyclically. For example, the neighborhood window can be used as a single sliding window. After the median filtering process is completed for the central pixel in a sliding window, the next sliding window is moved to, and the median filtering process is completed for the central pixel in all sliding windows.

[0029] In step S110, a feature point detection algorithm may be used to scan the neighborhood window from the central pixel in each direction to the neighborhood window, record the gradient transformation of the grayscale value when the pixel moves in each direction, and then output a metric value when the central pixel is a non-flat point, such as an edge point or a corner point. The feature point detection algorithm may be, for example, a Harris feature point detection algorithm.

[0030] It should be noted that when using the Harris feature point detection algorithm, related technologies usually use a combination of gradient transformation and thresholds to determine whether the detected feature point is a corner point or an edge point. If the gradient of a pixel point in the window varies by more than a certain threshold in all directions, the point is considered a corner point; if the gradient of a pixel point varies by more than a certain threshold in one direction, the point is considered an edge point; if the gradient of a pixel point varies very little in all directions, the point is considered a flat point.

[0031] In contrast, when the present application scans the direction from the central pixel point in the neighborhood window to the neighborhood window, it does not output the determination result of whether the central pixel point is a flat point, corner point or edge point. Instead, it records the grayscale transformation parameters from the central pixel point in the neighborhood window to the neighborhood window in all directions, and then determines and outputs the measurement value when the central pixel point is a non-flat point based on the grayscale transformation parameters. The measurement value can be understood as the probability statistical value when the central pixel point is a (different) non-flat point.

[0032] In some examples, the non-flat point includes at least one of a corner point and an edge point.

[0033] The following example illustrates the process of using the Harris feature point detection algorithm to record the grayscale transformation parameters from the central pixel to the neighborhood window in all directions, and then outputting the measurement value when the central pixel is a non-flat point.

[0034] When Harris feature point detection algorithm is used for calculation, the neighborhood window will be centered along the center pixel. (i.e. horizontal direction) and The image is moved slightly in the vertical direction and its grayscale changes are detected.

[0035] For small movements , its grayscale changes It can be expressed by the autocorrelation function expression:

[0036] in, is the grayscale value of the neighborhood pixel, The center pixel neighborhood. is a weight function, which can generally be represented by a constant or a Gaussian function.

[0037] We can further use Taylor's formula to expand the above autocorrelation function expression, omitting the high-order terms to obtain:

[0038] in and Along and Partial derivatives in the direction.

[0039] Will Converted to quadratic form, we have:

[0040] The symmetric matrix Expressed as:

[0041] Related technologies usually define the corner response function (CRF), which is the following formula:

[0042] in Usually the empirical value constant is 0.4~0.6, and The matrices These two eigenvalues ​​reflect the intensity of the grayscale change when each pixel moves slightly in the directions perpendicular to each other, that is, the grayscale transformation parameters mentioned above.

[0043] Please continue to see Figure 2 , in related technologies, the above and , distinguish the central pixel as a flat point, edge point, or corner point. If the eigenvalue and If both are small, it is a flat point, that is, the grayscale changes slowly in all directions; if the eigenvalue and If the eigenvalues ​​are large, the central pixel is a corner point, that is, the grayscale changes rapidly in all directions; if the eigenvalues and One large and one small are edge points, that is, the grayscale changes rapidly in a certain direction.

[0044] During the actual R&D and design process, the inventors of this application discovered that the choice of k value in the corner point response function has a great influence on the final detection result. Therefore, based on the grayscale transformation parameters, the center pixel point in the current neighborhood window is used as the measurement value of the non-flat point of the corner point and edge point.

[0045] For example, the above metric value may be:

[0046] in, and Respectively represent the measurement values ​​of the current center pixel as a corner point and an edge point (i.e., a non-flat point), is the larger of the two eigenvalues ​​(i.e., grayscale transformation parameters), is the smaller of the two eigenvalues, and are the configured smoothing parameters respectively.

[0047] It should be noted that by expressing the result of feature point detection with the metric value at the non-flat point, the influence of the selection of the k value on the final detection result can be avoided, thereby indirectly improving the accuracy of the median filter.

[0048] When executing the above step S120, different from the original point selection method for flat points, the present application utilizes a point selection method unique to non-flat points, which can be combined with the metric values ​​corresponding to the non-flat points to perform fusion median filtering. This takes into account the situation where the pixel points of the median filter are edge points and / or corner points when in a complex image, and adaptively performs median filtering according to its corresponding point selection method. The resulting filtered center pixel point can better retain high-frequency details, such as edge texture, and can adapt to the texture details of complex images. The median filtering effect is better, thus solving the technical problem of poor median filtering effect for complex images with many details.

[0049] In some examples, step S120 may include: Step S121, obtaining a first median filtering result of the central pixel point in the neighborhood window in the point selection method corresponding to the non-flat point and a second median filtering result when the central pixel point is a flat point; Step S122: Fusing the first median filtering result and the second median filtering result according to the metric value to obtain a filtered central pixel point.

[0050] The second median filtering result obtained when the center point is taken as the flat point may be performed with reference to related technologies, or may also be performed with reference to the following solution.

[0051] Please see Figure 3 , Figure 3 This is a schematic diagram of point selection using a 3*3 neighborhood as an example when the center pixel is used as a flat point. The 3*3 neighborhood window includes the center pixel, which is the noisy pixel to be processed, that is, the position where the black border is filled with blue in the figure.

[0052] In addition, neighborhood pixels are set around the central pixel. For this neighborhood window, referring to the original median filtering method of flat points, the central pixel and the neighborhood pixels in the up, down, left and right directions relative to the central pixel will be selected to calculate the median to implement median filtering and obtain the second median filtering result.

[0053] The method for selecting the non-flat points can be determined according to the type and characteristics of the non-flat points. For details, please refer to the subsequent embodiments.

[0054] In this example, based on the median filtering processing performed on the metric value combined with the point selection method corresponding to the non-flat point, a second median filtering result when the center pixel point is a flat point can be obtained, and the first median filtering result and the second median filtering result can be fused using the metric value, for example, linear interpolation is performed to obtain the filtered center pixel point.

[0055] In summary, this example classifies central pixels into flat points and non-flat points, and uses the metric probability value of non-flat points as a weight for fusion, which can better preserve high-frequency details.

[0056] It should be noted that, when the non-flat point includes the corner point, the process of obtaining the first median filtering result of the central pixel point in the neighborhood window under the point selection method corresponding to the non-flat point in the above step S121 may include: Step S211, comparing the central pixel point in the neighborhood window with the neighboring pixel points relative to the central pixel point to obtain first comparison results; Step S212: determining an identification value corresponding to each pixel point based on each first comparison result, and obtaining the sum of the identification values ​​corresponding to the pixel points in each area divided in the horizontal direction and the vertical direction based on the central pixel point as the central point; Step S213, comparing the median of the sum of the identification values ​​corresponding to the pixels in each area with the reference value associated with the central pixel to obtain a second comparison result; Step S214: determine the target point of the neighborhood window according to the second comparison result, and perform median filtering calculation according to the target point to obtain the third median filtering result, wherein the first median filtering result includes the third median filtering result.

[0057] This implementation provides a method for selecting corner points when non-flat points are used. This method takes into account the characteristic of corner points being located at the intersection of two or more edges. Therefore, within the neighborhood window, the algorithm prioritizes selecting pixel regions at the intersection of window edges for sum calculation and comparison of identification values. Furthermore, by comparing the sum of the identification values ​​of the comparison results with a reference value associated with the center pixel, the differences between pixels in different edge exchange regions and the center pixel are considered, resulting in a third median filtering result that is more appropriate for the corner point.

[0058] Please see Figure 4 , we take the target point selection method when the neighborhood window is 3*3 in size and the center pixel is a corner point as an example. First, we can compare the grayscale values ​​of each neighborhood pixel with the center pixel in the neighborhood window to obtain the comparison result.

[0059] When the comparison result is that the neighborhood pixel value is less than the center pixel value, the identification value can be configured as 0; when the comparison result is that the neighborhood pixel value is equal to the center pixel value, the identification value can be configured as 1; when the comparison result is that the neighborhood pixel value is greater than the center pixel value, the identification value can be configured as 2.

[0060] For example, Figure 4The grayscale values ​​of the left side (L), top side (T), bottom side (B), and upper left side (LT) of the central pixel (C) are all smaller than the grayscale value of the central pixel, so the identification value is 0.

[0061] The grayscale values ​​of the lower left (LB), right (R), upper right (TR), and lower right (BR) sides of the central pixel are all smaller than the grayscale value of the central pixel, so the identification value is 2. Similarly, after the central pixel is compared with itself, its identification value is configured as 1. In other examples, other identification values ​​can also be set, and those skilled in the art can set them according to actual needs. For example, in other examples, the identification value is centered when the value is equal, the identification value is maximized when the value is greater, and the identification value is minimized when the value is less than.

[0062] exist Figure 4 In the neighborhood window shown, four regions are formed by dividing the central pixel point C into four regions in the horizontal and vertical directions. The identification values ​​of each region can be added together to obtain the sum of the identification values ​​corresponding to each region.

[0063] For example Figure 4 The diagram on the upper right shows the neighboring pixels of the corresponding positions involved when the pixels of each area are added together, and the reference Figure 4 By adding the identification values ​​on the lower left side, we can get Figure 4 The sum of the identification values ​​of each area on the lower right side.

[0064] For example, if the left horizontal direction is taken as 0 degrees for statistics, the sum of the identification values ​​of the area at 45 degrees from the center point is 1, the sum of the identification values ​​of the area at 135 degrees from the center point is 5, and the sum of the identification values ​​of the area at 225 degrees from the center point is 3. The value of the central area where the central pixel is located is 4 times the value of the central pixel compared with itself, that is, the sum of the identification values ​​is 4.

[0065] Furthermore, several points in the 3*3 neighborhood window can be selected as target points according to the median of the sum of the five identification values, and then the median filtering result (i.e., the third median filtering result) when the mean of the grayscale values ​​of the target points is calculated as the corner point is output.

[0066] Optionally, when selecting a target point based on the median of the sum of the five identification values, a reference value associated with the center pixel point can be used for comparison to obtain a second comparison result. In some examples, the reference value associated with the center pixel point can be the sum of the identification values ​​of the center area, that is, the reference value is 4.

[0067] When the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixels in each area is equal to the reference value related to the central pixel, the target point in the neighborhood window is the central pixel.

[0068] When the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixel points in each area is greater than the reference value related to the central pixel point, the target selection point in the neighborhood window is the neighborhood pixel point in the area corresponding to when the sum of the identification values ​​is less than the reference value related to the central pixel point.

[0069] When the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixel points in each area is less than the reference value related to the central pixel point, the target selection point in the neighborhood window is the neighborhood pixel point in the area corresponding to the sum of the identification values ​​greater than the reference value related to the central pixel point.

[0070] Corresponding to Figure 4 In, at this time Figure 4 The median of the sum of the five identification values ​​is 4, which satisfies the condition that the median of the sum of the identification values ​​is equal to the reference value related to the central pixel point. Therefore, the target selection point is still the central pixel point.

[0071] Assuming that the median of the sum of the identification values ​​is greater than the reference value related to the central pixel point, the target point is the area where the sum of the identification values ​​is 1 and 3, and the average grayscale value in the two areas 1 and 3 can be calculated as the third median filtering result.

[0072] Similarly, assuming that the median of the sum of the identification values ​​is less than the reference value related to the central pixel point, the target selection point is the neighborhood pixel point involved in the area where the sum of the identification values ​​is 5, and the average grayscale value in these two areas is calculated as the third median filtering result.

[0073] It should be noted that, in the case where the non-flat point includes the edge point, the process of obtaining the first median filtering result of the central pixel point in the neighborhood window under the point selection method corresponding to the non-flat point in the above step S121 may include: Step S311, obtaining an edge angle obtained during scanning, where the edge angle is the angle between the corner point and the vertical direction; Step S312, determining a target point within the neighborhood window according to the size of the edge angle; Step S313: Perform median filtering calculation according to the target selected point to obtain the fourth median filtering result, where the first median filtering result includes the fourth median filtering result.

[0074] It should be noted that when the central pixel point is an edge point, the process parameters of the aforementioned scanning process, such as , obtaining the edge angle. Because different edge angles correspond to different arrangements within the neighborhood window, the target point within the neighborhood window can be determined based on the size of the edge angle. Specifically, the direction or arrangement position of the edge point within the neighborhood window is determined based on the size of the edge angle, and the pixel point corresponding to the edge direction / arrangement position within the neighborhood window is used as the target point to perform median filtering calculations.

[0075] In addition, since different edge angles will affect the actual pixel presentation effect, different numbers of target points can be selected corresponding to different edge angles. For example, for certain edge angle ranges, three pixel points in the neighborhood window can be selected as target points, and for certain edge angle ranges, five pixel points in the neighborhood window can be selected as target points.

[0076] Please see Figure 5 The following example still uses the neighborhood window of 3*3 size and the target point selection method within the neighborhood window under different edge angles, where the edge angle is .

[0077] When the edge angle is (0, 10) or (170, 180) (in degrees), the edge direction of the neighborhood area is vertical or approximately vertical, so the center pixel of the neighborhood window and the neighborhood pixels above and below the center pixel can be selected as the three target points.

[0078] When the edge angle is (10, 35), the edge direction of the neighborhood area is slightly tilted, so the center pixel of the neighborhood window and the neighborhood pixels above, below, to the upper right, and to the lower left relative to the center pixel can be selected as the five target points.

[0079] When the edge angle is [35, 55], the edge direction of the neighborhood area is tilted to the right, so the center pixel of the neighborhood window and the upper right and lower left neighborhood pixels relative to the center pixel can be selected as the three target points.

[0080] When the edge angle is (55, 80), the edge direction of the neighborhood area tilts from the right and tends to the horizontal state, so the center pixel point of the neighborhood window and the neighborhood pixels to the left, lower left, lower right, and upper right of the center pixel point can be selected as the five target points.

[0081] When the edge angle is [80, 100], the edge direction of the neighborhood area is horizontal or approximately horizontal, so the center pixel of the neighborhood window and the neighborhood pixels on the left and right sides relative to the center pixel can be selected as the three target points.

[0082] When the edge angle is (100, 125), the edge direction of the neighborhood area is slightly tilted to the left, so the center pixel of the neighborhood window and the neighborhood pixels on the left, right, upper left and lower right relative to the center pixel can be selected as the five target points.

[0083] When the edge angle is [125, 145], the edge direction of the neighborhood area is tilted to the left, so the center pixel of the neighborhood window and the neighborhood pixels to the upper left and lower right of the center pixel can be selected as the three target points.

[0084] When the edge angle is (145, 170), the edge direction of the neighborhood area tends to be vertical, and the center pixel of the neighborhood window and the neighborhood pixels above, below, upper left, and lower right relative to the center pixel can be selected as five target points.

[0085] Of course, when the angle is equal to 0 degrees, 10 degrees or 180 degrees, the method of selecting the target point in the closest arbitrary interval can also be used.

[0086] In this embodiment, by distinguishing the size of the edge angle, appropriate points are selected for median filtering processing, taking into account the different edge distributions of the neighborhood window when the central pixel point is used as the edge point, thereby being able to output a fourth median filtering result that is more suitable for the edge point.

[0087] On the basis of the above embodiment, according to the case where the first median filtering result includes the third median filtering result under the point selection method corresponding to the corner point and the fourth median filtering result under the point selection method corresponding to the edge point, and correspondingly, the metric value of the non-flat point includes the metric value corresponding to the corner point and the metric value corresponding to the edge point, then the first median filtering result and the second median filtering result are fused according to the metric values ​​to obtain the filtered center pixel point, including: The second median filtering result, the third median filtering result, and the fourth median filtering result are fused according to the metric value at the edge point and the metric value at the corner point to obtain a filtered central pixel point.

[0088] For the above fusion process, flat points, corner points and edge points can be fused once, or two of them can be fused first to obtain an intermediate filtering result, and then the intermediate filtering result can be fused with another one to obtain the final median filtering result.

[0089] Exemplarily, linear interpolation can be performed based on the second median filtering result, the fourth median filtering result and the measurement value at the edge point to determine the non-corner point median filtering result; then linear interpolation can be performed based on the non-corner point median filtering result, the third median filtering result and the measurement value at the corner point to obtain the filtered center pixel point.

[0090] Exemplarily, linear interpolation can be performed based on the second median filtering result, the third median filtering result and the measurement value at the corner point to determine the non-edge median filtering result; and then linear interpolation can be performed based on the non-edge median filtering result, the fourth median filtering result and the measurement value at the edge point to obtain the filtered center pixel point.

[0091] The above measurement value when combining the above corner points and edge points and When marking, the following formula is used:

[0092] in is the result of directional median filtering, that is, the filtered center pixel point of the final output. 、 and The median filtering results are divided into those when the central pixel is a flat point, a corner point, and an edge point. is the non-edge median filtering result.

[0093] It can be seen from the above formula that the three medians are fused according to the metric values ​​at the edge point and the metric values ​​at the corner point. If the metric value at the edge point is larger, the fusion result will refer more to the fourth median filtering result at the edge point. If the metric value at the corner point is larger, the fusion result will refer more to the third median filtering result at the corner point. If the metric value at the edge point and the metric value at the corner point are both small, the fusion result will refer more to the second median filtering result.

[0094] In summary, the above-mentioned linear interpolation method is used for fusion, and the fusion is combined with the weights of different selected points according to the classification situation, which can achieve the effect of better retaining high-frequency details.

[0095] See Figure 6 , in an electronic device for which protection is sought in this solution, comprising: A scanning module 610 is configured to scan from a central pixel point in a neighborhood window to all directions of the neighborhood window to obtain a metric value when the central pixel point is a non-flat point; The filtering processing module 620 is configured to perform median filtering according to the metric value and the point selection method corresponding to the non-flat point to obtain a filtered central pixel point.

[0096] Optionally, the filtering processing module 620 includes: An acquiring unit, configured to acquire a first median filtering result of the central pixel point in the neighborhood window in the point selection method corresponding to the non-flat point and a second median filtering result when the central pixel point is a flat point; A fusion unit is used to fuse the first median filtering result and the second median filtering result according to the metric value to obtain a filtered central pixel point.

[0097] Optionally, when the non-flat point includes a corner point, the acquiring unit includes: a comparing subunit, configured to compare the central pixel point within the neighborhood window with the neighboring pixel points relative to the central pixel point to obtain first comparison results; a determination subunit, configured to determine an identification value corresponding to each pixel point according to each first comparison result, and obtain, with the central pixel point as the center point, a sum of the identification values ​​corresponding to the pixel points in each area divided in the horizontal direction and the vertical direction based on the central point; The comparison subunit is further configured to compare a median of the sum of the identification values ​​corresponding to the pixels in each area with a reference value associated with the central pixel to obtain a second comparison result; The determination subunit is also used to determine the target point of the neighborhood window according to the second comparison result, and perform median filtering calculation based on the target point to obtain a third median filtering result, and the first median filtering result includes the third median filtering result.

[0098] Optionally, a determination subunit is used to, when the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixels in each area is equal to the reference value related to the center pixel point, the target selection point in the neighborhood window is the center pixel point; when the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixels in each area is greater than the reference value related to the center pixel point, the target selection point in the neighborhood window is the neighborhood pixel point in the area corresponding to when the sum of the identification values ​​is less than the reference value related to the center pixel point; when the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixels in each area is less than the reference value related to the center pixel point, the target selection point in the neighborhood window is the neighborhood pixel point in the area corresponding to when the sum of the identification values ​​is greater than the reference value related to the center pixel point.

[0099] Optionally, in the case where the non-flat points include edge points, the acquisition subunit is also used to obtain the edge angle obtained during scanning, where the edge angle is the angle between the corner point and the vertical direction; based on the size of the edge angle, the target selection point within the neighborhood window is determined; and median filtering calculation is performed based on the target selection point to obtain a fourth median filtering result, where the first median filtering result includes the fourth median filtering result.

[0100] Optionally, the first median filtering result includes the third median filtering result under the point selection method corresponding to the corner point and the fourth median filtering result under the point selection method corresponding to the edge point; the fusion subunit is also used to fuse the second median filtering result, the third median filtering result and the fourth median filtering result according to the measurement value at the edge point and the measurement value at the corner point to obtain the filtered center pixel point.

[0101] Optionally, the fusion subunit is also used to perform linear interpolation based on the second median filtering result, the third median filtering result and the measurement value at the corner point to determine the non-edge median filtering result; and perform linear interpolation based on the non-edge median filtering result, the fourth median filtering result and the measurement value at the edge point to obtain the filtered center pixel point.

[0102] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps of the image median filtering method disclosed in any of the aforementioned embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0103] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create an image processing channel between the electronic device 20 and the external device. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0104] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon may include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.

[0105] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, so as to enable the processor 21 to operate and process data 223 in the memory 22. The operating system 221 may be Windows Server, NetWare, Unix, Linux, etc. In addition to including a computer program capable of performing the image median filtering method performed by the electronic device 20 as disclosed in any of the aforementioned embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.

[0106] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0107] Furthermore, this application also discloses a computer-readable storage medium and a computer program product for storing a computer program. When executed by a processor, the computer program and / or computer program product implements the aforementioned image median filtering method. The specific steps of this method can be found in the corresponding contents disclosed in the aforementioned embodiments and will not be further described here.

[0108] It should be understood that the use of "method," "device," "unit," and / or "module" in this application is merely a method for distinguishing different components, elements, parts, portions, or assemblies at different levels. However, if other words can achieve the same purpose, they can be replaced by other expressions.

[0109] As used in this application and the claims, unless the context clearly indicates an exception, the terms "a," "an," "an," and / or "the" are not intended to refer to the singular and may include the plural, unless the context clearly indicates otherwise. Generally speaking, the terms "comprises" and "include" only indicate the inclusion of the steps and elements specifically identified, and these steps and elements do not constitute an exclusive list. A method or apparatus may also include other steps or elements. The phrase "comprises a..." does not preclude the presence of additional identical elements in the process, method, product, or apparatus that includes the elements.

[0110] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the quantity of the technical features indicated. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include one or more of the features. If a flow chart is used in this application, the flow chart is used to illustrate the operations performed by the system according to the embodiments of the application. It should be understood that the previous or subsequent operations are not necessarily performed in exact order. Instead, the steps can be processed in reverse order or simultaneously. At the same time, other operations can be added to these processes, or one or more operations can be removed from these processes.

[0111] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A median filtering method for an image, characterized in that: The steps include: Scanning the center pixel point in the neighborhood window in all directions to the neighborhood window to obtain a metric value when the center pixel point is a non-flat point; According to the metric value, median filtering is performed using a point selection method corresponding to the non-flat point to obtain a filtered central pixel point.

2. The method according to claim 1, characterized in that The step of performing median filtering based on the metric value and selecting a point corresponding to the non-flat point to obtain a filtered central pixel point includes: Obtaining a first median filtering result of the central pixel point in the neighborhood window under the point selection method corresponding to the non-flat point and a second median filtering result when the central pixel point is a flat point; The first median filtering result and the second median filtering result are fused according to the metric value to obtain a filtered central pixel point.

3. The method according to claim 2, characterized in that In the case where the non-flat point includes a corner point, obtaining a first median filtering result of the central pixel point in the neighborhood window in the point selection method corresponding to the non-flat point includes: Comparing the central pixel point in the neighborhood window with each of the neighborhood pixel points relative to the central pixel point to obtain first comparison results; Determine the identification value corresponding to each pixel point according to each first comparison result, and obtain the sum of the identification values ​​corresponding to the pixel points in each area divided in the horizontal direction and the vertical direction based on the central pixel point, with the central pixel point as the central point; Comparing the median of the sum of the identification values ​​corresponding to the pixels in each area with the reference value associated with the central pixel to obtain a second comparison result; The target point of the neighborhood window is determined according to the second comparison result, and a median filtering calculation is performed according to the target point to obtain a third median filtering result, wherein the first median filtering result includes the third median filtering result.

4. The method according to claim 3, characterized in that Determining the target point of the neighborhood window according to the second comparison result includes: When the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixels in each area is equal to the reference value related to the central pixel, the target point in the neighborhood window is the central pixel; When the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixels in each area is greater than the reference value associated with the central pixel, the target selected point in the neighborhood window is a neighborhood pixel in the area corresponding to the sum of the identification values ​​being less than the reference value associated with the central pixel; When the second comparison result indicates that the median of the sum of the identification values ​​corresponding to the pixel points in each area is less than the reference value related to the central pixel point, the target selection point in the neighborhood window is the neighborhood pixel point in the area corresponding to the sum of the identification values ​​greater than the reference value related to the central pixel point.

5. The method according to claim 2, characterized in that In the case where the non-flat point includes an edge point, obtaining a first median filtering result of the central pixel point in the neighborhood window in the point selection method corresponding to the non-flat point includes: Obtaining an edge angle obtained during scanning, where the edge angle is the angle between the corner point and the vertical direction; Determine the target point within the neighborhood window according to the size of the edge angle; Perform median filtering calculation according to the target selected point to obtain a fourth median filtering result, and the first median filtering result includes the fourth median filtering result.

6. The method according to claim 2, characterized in that The first median filtering result includes a third median filtering result obtained under a point selection method corresponding to a corner point and a fourth median filtering result obtained under a point selection method corresponding to an edge point; The fusing the first median filtering result and the second median filtering result according to the metric value to obtain a filtered central pixel point includes: The second median filtering result, the third median filtering result, and the fourth median filtering result are fused according to the metric value at the edge point and the metric value at the corner point to obtain a filtered central pixel point.

7. The method according to claim 6, characterized in that The step of fusing the second median filtering result, the third median filtering result, and the fourth median filtering result according to the metric value at the edge point and the metric value at the corner point to obtain a filtered center pixel point includes: Perform linear interpolation based on the second median filtering result, the third median filtering result, and the metric value at the corner point to determine a non-edge median filtering result; Linear interpolation is performed based on the non-edge median filtering result, the fourth median filtering result, and the metric value at the edge point to obtain a filtered central pixel point.

8. An electronic device, characterized in that: include: A scanning module, configured to scan from a central pixel point in a neighborhood window to all directions of the neighborhood window to obtain a metric value when the central pixel point is a non-flat point; The filtering processing module is used to perform median filtering processing according to the measurement value and adopt the point selection method corresponding to the non-flat point to obtain a filtered central pixel point.

9. An electronic device, characterized in that: include: at least one processor; as well as A memory communicatively connected to the at least one processor, the memory storing a computer program executable by the at least one processor, the computer program being executed by the at least one processor so as to enable the at least one processor to perform the median filtering method for an image as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The storage medium is used to store a computer program, and the computer program is used to enable a computer to execute the median filtering method for an image according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • An edge protection denoising method

    CN109377450A

  • Image processing method and device, storage medium and computer device

    CN109767408A

  • CT image denoising method based on self-adaptive median filtering

    CN113313641A

  • Edge perception guide filtering method fusing superpixel and window offset

    CN114219740A

  • Image processing method and device, equipment and storage medium

    CN117952855A