Nine-point median filtering algorithm with low hardware resources

By using median filtering sliding window and column sorting methods in the nine-point median filtering algorithm, the problem of excessive comparison times in the existing technology is solved, and the hardware resources are saved and the number of comparisons is reduced.

CN120017013AInactive Publication Date: 2025-05-16CANXIN SEMICON (CHENGDU) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510209477.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-25
Publication Date
2025-05-16
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, the 3x3 median filtering algorithm is compared too many times in hardware implementation, resulting in wasted hardware resources.

Method used

The nine-point median filtering algorithm with low hardware resources is adopted, and the working principle and column sorting method of the median filtering sliding window reduces the number of comparisons. The specific steps include putting the first two column sorting operations into the previous cycle. The current cycle only needs to be arranged 3-values ​​once, and the number of sorting comparisons is reduced according to the data characteristics during the calculation process.

Benefits of technology

Reducing the original 21 comparisons to 10 pair-by-two comparisons significantly saves hardware comparator resources and is suitable for hardware implementations with high area requirements in ASIC chips.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120017013A_ABST
    Figure CN120017013A_ABST
Patent Text Reader

Abstract

The invention discloses a nine-point median filtering algorithm with low hardware resources, and belongs to the technical field of filters, the nine-point median filtering algorithm utilizes the working principle of a median filtering sliding window and adopts a column sorting mode, sorting operation of the first two columns is put into a previous period, and only three-value arrangement needs to be carried out once in the current period; reducing the sorting comparison quantity according to the data characteristics in the calculation process; comparing the possible median values; and finally, comparing to obtain a data median according to the sorting relationship of the remaining data. According to the method, the data in each column are sorted through the column sorting method, comparison and analysis are carried out through the arrangement mode of the data during follow-up processing, the median is finally obtained, 10 times of pairwise comparison are needed in total by adopting the method, hardware overhead is greatly saved, and the method is suitable for implementation of hardware with the extremely high area requirement in an ASIC (Application Specific Integrated Circuit) chip.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of filters, and in particular relates to a nine-point median filtering algorithm with low hardware resources. Background Art

[0002] At present, the main mainstream practices of 3x3 median filtering are as follows:

[0003] Directly using bubble sort, since nine numbers will be compared in sequence, the first one will be compared with the remaining 8 numbers, the second one will be compared with the remaining 7, and so on, the final number of pairwise comparisons is (8+7+6…+1) = (8+1)*8 / 2 = 36 times. The median sorting implemented by this algorithm requires 36 comparators, which is obviously not suitable for hardware implementation.

[0004] The improved FPGA median filtering algorithm is as follows:

[0005] a. Count the three numbers in each row or column and find the maximum, middle and minimum values. Figure 1 For example, assuming that the statistics are in the row direction, the first row value after statistics becomes A1_max, A1_med, A1_min, and the second and third rows are the same. Each row requires at least 3 comparisons to obtain the maximum value, the middle value, and the minimum value, a total of 9 comparisons. The truth table of the three-value comparison is shown in Table 1.

[0006] b. Compare the three groups of 3 maximum values, middle values, and minimum values ​​again to obtain the minimum value A_max_min of the maximum value group, the middle value A_med_med of the middle value group, and the maximum value A_min_max of the minimum value group. In this step, each comparison of 3 data requires 3 comparisons, a total of 9 comparisons

[0007] c. Finally, compare the remaining three values, and the middle value is the required 9-point median. Finally, 3 pairwise comparisons are required.

[0008] From the above steps, it can be seen that the improved FPGA filtering algorithm requires a total of 9+9+3 = 21 comparisons. Compared with bubble sort, this algorithm reduces the number of comparisons and saves hardware resources. However, it is still not the optimal solution.

[0009] Table 1 is the truth table of three-value comparison:

[0010] Summary of the invention

[0011] The purpose of the present invention is to provide a nine-point median filter algorithm with low hardware resources, focusing on reducing the number of comparisons of the hardware median filter algorithm, thereby reducing the overhead of hardware comparator resources. Through this solution, the original 21 comparisons are reduced to 10 pairwise comparisons. The number of hardware comparators is reduced, the hardware area is saved, and the problems raised in the above background technology can be solved.

[0012] To achieve the above-mentioned purpose, the present invention provides the following technical solutions: a nine-point median filtering algorithm with low hardware resources, which utilizes the working principle of median filtering sliding window and adopts a column sorting method, placing the sorting operations of the first two columns into the previous cycle, and only needing to perform a three-value arrangement once in the current cycle; then reducing the number of sorting comparisons according to data characteristics during the calculation process; then comparing possible medians; and finally obtaining the median of the data through comparison through the sorting relationship of the remaining data.

[0013] Preferably, the working principle of the median filter sliding window is used, and the column sorting method is adopted, the sorting operation of the first two columns is placed in the previous cycle, and only one three-value arrangement is required in the current cycle, specifically including:

[0014] Using the working principle of median filtering sliding window, when a new sequence comes in, you only need to sort the new sequence; while the old sequence will continue to retain the column order that has been calculated during the previous calculation; the new sequence calculation process requires three pairwise comparisons.

[0015] Preferably, reducing the number of sorting and comparison according to data characteristics during the calculation process specifically includes:

[0016] Currently, three columns have been stored and the data is in order in the column direction. When comparing again, it is only necessary to compare the median polarities of the three columns in the window two by two. This process requires three two-by-two comparisons.

[0017] Preferably, the comparing possible medians specifically includes:

[0018] Remove the median and minimum value in the smallest median sequence and retain the maximum value; remove the median and maximum value in the largest median sequence and retain the minimum value; compare the retained values ​​with the medians of all retained column data in pairs; this process also requires three pairwise comparisons.

[0019] Preferably, the step of comparing and obtaining the median of the data by sorting the remaining data specifically includes:

[0020] According to the ranking relationship of the remaining data, the median of the data is obtained through one comparison.

[0021] Compared with the prior art, the present invention has the following beneficial effects:

[0022] The present invention sorts the data in each column by a column sorting method. In subsequent processing, the arrangement of the data is used for comparison and analysis to finally obtain the median. With this method, a total of 10 pairwise comparisons are required. This method greatly saves hardware overhead and is suitable for hardware implementation in ASIC chips with extremely high area requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 The block diagram is counted in the row direction for the improved FPGA median filtering algorithm.

[0024] Figure 2 This is a working timing diagram of a nine-point median filtering algorithm with low hardware resources according to the present invention.

[0025] Figure 3 The present invention is a method flow chart of a nine-point median filtering algorithm with low hardware resources. DETAILED DESCRIPTION

[0026] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] The present invention firstly utilizes the working principle of median filter sliding window and adopts the column sorting method to put the sorting operation of the first two columns into the previous cycle, and only needs to perform three-value arrangement once in the current cycle. Figure 2 As shown, assume that the nine points of the last operation are the windows where B4_max, B4_med, and B4_min are located. When the next operation is performed, the window removes the B4 column and introduces B11, B12, and B13. Since B3_max, B3_med, B3_min and B2_max, B2_med, and B2_min have been sorted in the previous window calculation. Therefore, in the current calculation, only B11, B12, and B13 need to be sorted. The number of pairwise comparisons required for this calculation is 3 times. Similarly, when a new sequence comes in, only the new sequence needs to be sorted. The old sequence will continue to retain the column order that has been calculated in the previous calculation.

[0028] Secondly, the present invention will use data characteristics to reduce the number of sorting and comparisons during the calculation process. For example, three columns have been stored, and the data are B3_max, B3_med, B3_min, B2_max, B2_med, B2_min and B1_max, B1_med, B1_min. Since there is already a data order in the column direction, when comparing again, B3_med, B2_med, and B1_med can be used for comparison. At this time, three pairwise comparisons are performed. Assume that the comparison result is B3_med>B2_med>B1_med. At this time, it can be judged by logic that the data that may be smaller than B1_med are B3_min and B2_min. The data that is definitely smaller than B1_med is B1_min, so B1_med can only be ranked below the 4th place (arranged from small to large) in the 9-point sequence, and it cannot be the median, so the possibility that B1_med and B1_min are the median can be ruled out. Similarly, to determine the possibility that B3_med is the median, the data that may be larger than B3_med are B2_max and B1_max, and the data that must be larger than B3_med is B3_max. Then B3_med must be ranked above the 6th place. Therefore, excluding B3_med can also exclude B3_max.

[0029] After using the above two analysis methods, the median values ​​in the current data may be B2_min, B2_med, B2_max, B3_min, and B1_max. At this time, the corresponding relationship between B2_med, B3_min, and B1_max can be compared. This step will also use 3 comparisons. The following relationship may exist:

[0030] 1. If B3_min>B2_med>B1_max, then there are 4 numbers larger than B2_med: B2_max, B3_min, B3_med, and B3_max, and there are 4 numbers smaller than B2_med: B2_min, B1_min, B1_med, and B1_max. Then the median is B2_med. Similarly, the case of B1_max>B2_med>B3_min can be deduced.

[0031] 2. If B1_max>B3_min>B2_med, there are 5 data points larger than B2_med, and B2_med is not the median, so further analysis is needed. Similarly, the situation of B3_min>B1_max>B2_med is the same.

[0032] 3. If B2_med>B1_max>B3_min, there are 5 data points smaller than B2_med, and B2_med is not the median, so further analysis is needed. Similarly, the situation of B2_med>B3_min>B1_max is the same.

[0033] In the above steps, there may be four cases where the median cannot be determined immediately. However, because the order of the remaining data is known, the median of the data can be compared once. If B1_max>B3_min>B2_med, the data larger than B2_med may be B3_min, B1_max, B2_max, B3_med, B3_max. Since B1_max, B3_med, and B3_max are known conditions, the median is the smaller number of B3_min or B2_max. The other three possibilities can be derived in the same way.

[0034] From the above analysis, we can see that using this method, the number of comparisons required will become 3+3+3+1 = 10, and a total of 10 comparisons can get the median output.

[0035] like Figure 3 As shown, this method reduces the number of times used and saves hardware overhead. The steps of median filtering using this solution are as follows:

[0036] 1. Discard the leftmost column of the previous comparison data in the sliding window, such as B4_max, B4_med, and B4_min in the figure;

[0037] 2. Compare the new data B11, B12, and B13 in pairs, and assign the corresponding maximum value to B1_max, the median value to B1_med, and the minimum value to B1_min;

[0038] 3. Compare the median polarities of the three columns in the window, i.e., B1_med, B2_med, and B3_med. Assume that the result obtained in this implementation example is B1_med <B2_med<B3_med;

[0039] 4. Remove the median and minimum value in the smallest median sequence, and retain the maximum value. For example, in the above embodiment, the retained data is B1_max, and the discarded data are B1_min and B1_med;

[0040] 5. Remove the median and maximum value in the largest median sequence, and retain the minimum value; for example, in the above embodiment, the retained data is B3_min, and the discarded data are B3_med and B3_max;

[0041] 6. Compare the retained data pairwise with the median values of all the retained column data. In the above-mentioned embodiment, the data to be compared are B3_min, B2_med, and B1_max;

[0042] 7. Judge the comparison results:

[0043] a. If the comparison results are B3_min < B2_med < B1_max or B3_min > B2_med > B1_max, then the median value can be determined as B2_med, and the comparison ends.

[0044] b. If the comparison results are B3_min < B1_max < B2_med or B1_max < B3_min < B2_med, then take the median value of the comparison results and compare it with B2_min again. The larger value in the results of the second comparison is the median value at 9 o'clock.

[0045] c. If the comparison results are B2_med < B3_min < B1_max or B2_med < B1_max < B3_min, then take the median value of the comparison results and compare it with B2_max again. The smaller value in the results of the second comparison is the median value at 9 o'clock.

[0046] In the present invention, through the column sorting method, each data in each column is sorted. During subsequent processing, the arrangement of the data is used for comparative analysis, and finally the median value is obtained. Using this method, a total of 10 pairwise comparisons are required. This method greatly saves the hardware overhead and is suitable for hardware implementation with extremely high area requirements in ASIC chips.

[0047] Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments once they know the basic creative concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments and all changes and modifications falling within the scope of the present invention.

[0048] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these changes and modifications.

Claims

1. A nine-point median filtering algorithm with low hardware resources, characterized in that: The nine-point median filter algorithm uses the working principle of the median filter sliding window and adopts the column sorting method. The sorting operation of the first two columns is placed in the previous cycle, and only one 3-value arrangement is required in the current cycle; then, the number of sorting comparisons is reduced according to the data characteristics during the calculation process; then, the possible medians are compared; finally, the median of the data is obtained by comparison through the sorting relationship of the remaining data.

2. The nine-point median filtering algorithm with low hardware resources according to claim 1 is characterized in that: The working principle of the median filter sliding window is used, and the column sorting method is adopted to put the sorting operation of the first two columns into the previous cycle. Only one three-value arrangement is required in the current cycle, which specifically includes: Using the working principle of median filtering sliding window, when a new sequence comes in, you only need to sort the new sequence; while the old sequence will continue to retain the column order that has been calculated during the previous calculation; the new sequence calculation process requires three pairwise comparisons.

3. The nine-point median filtering algorithm with low hardware resources according to claim 2 is characterized in that: The method of reducing the number of sorting and comparison according to data characteristics during the calculation process specifically includes: Currently, three columns have been stored and the data is in order in the column direction. When comparing again, it is only necessary to compare the median polarities of the three columns in the window two by two. This process requires three two-by-two comparisons.

4. The nine-point median filtering algorithm with low hardware resources according to claim 3 is characterized in that: The comparison of possible median values ​​specifically includes: Remove the median and minimum value in the smallest median sequence and retain the maximum value; remove the median and maximum value in the largest median sequence and retain the minimum value; compare the retained values ​​with the medians of all retained column data in pairs; this process also requires three pairwise comparisons.

5. The nine-point median filtering algorithm with low hardware resources according to claim 4 is characterized in that: The comparison and obtaining of the median of the data by sorting the remaining data specifically includes: According to the ranking relationship of the remaining data, the median of the data is obtained through one comparison.

Citation Information

Patent Citations

  • Improved adaptive median filtering method based on FPGA

    CN117788259A

  • Data processor, data processing method, image processor and image processing method

    JP2003296730A

  • Data processor

    JP2004220094A

  • Single-stage hardware sorting blocks and associated multiway merge sorting networks

    US11360740B1

  • Max, min determination of a two-dimensional sliding window of digital data

    US20030212652A1