CN111953318A - Median filtering method and device adaptive to pipeline architecture and filter - Google Patents

Median filtering method and device adaptive to pipeline architecture and filter Download PDF

Info

Publication number
CN111953318A
CN111953318A CN202010597238.2A CN202010597238A CN111953318A CN 111953318 A CN111953318 A CN 111953318A CN 202010597238 A CN202010597238 A CN 202010597238A CN 111953318 A CN111953318 A CN 111953318A
Authority
CN
China
Prior art keywords
numerical
subsequence
median
value
values
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010597238.2A
Other languages
Chinese (zh)
Other versions
CN111953318B (en
Inventor
徐峰
王利明
李自明
邵猛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Dingjiukang Technology Co ltd
Original Assignee
Shanghai Dingjiukang Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Dingjiukang Technology Co ltd filed Critical Shanghai Dingjiukang Technology Co ltd
Priority to CN202010597238.2A priority Critical patent/CN111953318B/en
Publication of CN111953318A publication Critical patent/CN111953318A/en
Application granted granted Critical
Publication of CN111953318B publication Critical patent/CN111953318B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H21/00Adaptive networks
    • H03H21/0012Digital adaptive filters
    • H03H21/0025Particular filtering methods
    • H03H21/0029Particular filtering methods based on statistics
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H17/00Networks using digital techniques
    • H03H17/02Frequency selective networks
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H17/00Networks using digital techniques
    • H03H17/02Frequency selective networks
    • H03H17/0202Two or more dimensional filters; Filters for complex signals
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H17/00Networks using digital techniques
    • H03H17/02Frequency selective networks
    • H03H17/0211Frequency selective networks using specific transformation algorithms, e.g. WALSH functions, Fermat transforms, Mersenne transforms, polynomial transforms, Hilbert transforms
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H17/00Networks using digital techniques
    • H03H17/02Frequency selective networks
    • H03H17/0223Computation saving measures; Accelerating measures
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H17/00Networks using digital techniques
    • H03H17/02Frequency selective networks
    • H03H17/04Recursive filters
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H21/00Adaptive networks
    • H03H21/0012Digital adaptive filters
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H21/00Adaptive networks
    • H03H21/0012Digital adaptive filters
    • H03H21/0043Adaptive algorithms
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H17/00Networks using digital techniques
    • H03H17/02Frequency selective networks
    • H03H17/0202Two or more dimensional filters; Filters for complex signals
    • H03H2017/0207Median filters
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H17/00Networks using digital techniques
    • H03H17/02Frequency selective networks
    • H03H2017/0298DSP implementation
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H21/00Adaptive networks
    • H03H21/0012Digital adaptive filters
    • H03H2021/007Computation saving measures; Accelerating measures
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03HIMPEDANCE NETWORKS, e.g. RESONANT CIRCUITS; RESONATORS
    • H03H21/00Adaptive networks
    • H03H21/0012Digital adaptive filters
    • H03H2021/0085Applications
    • H03H2021/0094Interference Cancelling

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Computer Hardware Design (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • General Physics & Mathematics (AREA)
  • Pure & Applied Mathematics (AREA)
  • Algebra (AREA)
  • Probability & Statistics with Applications (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses a median filtering method, a median filtering device and a median filtering filter adaptive to a pipeline architecture, wherein the median filtering method comprises the following steps of S101: receiving a sequence of values; s102: forming a first numerical subsequence according to a filtering window, and finding a numerical median value in the first numerical subsequence; s103: arranging according to the numerical sequence, sliding the filtering window, and changing a first numerical subsequence in the first sequence window into a second numerical subsequence after moving the filtering window into and out of a numerical value; s104: will shift into the valueThe shifted numerical value is compared with the numerical median in the first numerical subsequence, and logical operation is performed according to the comparison result to obtain the numerical median in the second numerical subsequence; s105: sliding a filtering window, and circulating the steps S103 to S104 until the numerical sequence filtering is finished; s106: and sequentially storing the numerical median values, and outputting a numerical median sequence. This applicationThe filtering algorithm in the method has a simple logic structure, avoids maintaining a complex data structure, has low dependency on data in a circulating body, and is convenient for pipelining and parallelization so as to realize the effect of improving the quick calculation.

Description

Median filtering method and device adaptive to pipeline architecture and filter
Technical Field
The invention relates to the technical field of data filtering processing, in particular to a median filtering method and device adaptive to a pipeline architecture and a filter.
Background
The median filtering is a nonlinear signal processing technology which is based on the ordering statistical theory and can effectively inhibit noise, and the basic principle of the median filtering is to replace the value of one point in a numerical value sequence (one-dimensional) or a digital image (two-dimensional) by the median of all point values in a neighborhood of the point.
The median filtering algorithm is widely applied to the fields of signal processing, image processing, automatic control and the like, and is used for extracting signal baselines or eliminating isolated noise points. For example, in cardiac signal processing, a median filtering algorithm is often used to extract a baseline and then subtract the baseline from the original signal, which is referred to as "divide the baseline". Compared with other filtering algorithms, the median filtering has better anti-interference performance on noise and mutation due to the characteristic of 'sequential selection', so that the median filtering is widely applied.
However, also due to the "in-order picking" feature, the median filtering algorithm has a larger computational load compared to the general linear filtering algorithm, especially when the filtering window length is large. If the data in the sliding window with the length of n is completely reordered each time, and the sorting algorithm adopts a heap sorting or merging sorting algorithm, the algorithm complexity is O (nlog)2(n))。
Most algorithms reduce repeated sequencing operation by using a median result of previous operation, a numerical value in a window and a numerical value moved in and out at this time, so that higher operation speed is obtained. The most common method is the MoveSort method, which maintains an array of sorted data, moves in a new data each time an old data is moved out, finds out the position of the new data through binary search, moves all the affected data to maintain the sorting after the new data is inserted, and finally maintains an array of data indexes. Although the algorithm complexity of binary search is O (log)2(n)), but the algorithm complexity of the data movement and the data index maintenance is O (n), so the algorithm of MoveSort is complexThe degree of impurity is O (n). The binary search is difficult to streamline due to data dependence, and the total addition of the three steps has a large operation amount. Still other algorithms, such as the Heapsort et al method, achieve algorithm complexity that is theoretically less than O (n) by building and maintaining more complex data structures (e.g., a sort tree) to achieve fast lookups. However, because the single calculation amount is large, the advantage of the algorithm can be shown only when the window length is large, for example, n > 300. However, a window length n < 300 is sufficient in many algorithm applications.
Disclosure of Invention
The embodiment of the application provides a median filtering method, a median filtering device and a median filtering filter which are adaptive to a pipeline architecture, and solves the problem that in the prior art, due to the fact that strong data dependence exists in front and back operations of methods such as sorting and the like, the calculation efficiency is low. The simple algorithm logic is utilized, the complex data structure is prevented from being maintained, the data dependency in a circulating body is reduced, so that the algorithm can be fully pipelined and parallelized, the parallelism of each module in the pipeline architecture is fully utilized, the advantages of the pipeline architecture are exerted, and the effect of quick calculation is achieved.
A first aspect of the present application provides a median filtering method adapted to a pipeline architecture, including:
s101: receiving a set of numerical sequences to be filtered;
s102: according to a filtering window with a preset size of n, obtaining a corresponding number of numerical values from the numerical value sequence to form a first numerical value subsequence x0,x1,...,xn-1And finding the median m of the values from said first subsequence of values0
S103: sliding the filtering window according to the arrangement of the numerical value sequence to shift the filtering window into a numerical value xnAnd shifting out a value x0Then, a first numerical subsequence x in the filtering window0,x1,...,xn-1Into a second numerical subsequence x1,x2,...,xn
S104: will shift into the valuexnShifting out the value x0And the median value m of the values in the first numerical subsequence0Comparing, and performing logic operation according to the comparison result to obtain the numerical median m in the second numerical subsequence1(ii) a The method for performing logic operation according to the comparison result comprises the following steps:
when x isn==m0||(xn<m0&&x0<m0)||(xn>m0&&x0>m0) Then, the numerical median m in the second numerical subsequence is obtained1=m0
When x isn>m0&&x0≤m0While, traverse x1To xnSearch for x1To xnMiddle ratio m0The largest minimum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0The number of large numbers, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is m1=m0Otherwise, the median value is m1=mt;
When x isn<m0&&x0≥m0While, traverse x1To xnSearch for x1To xnMiddle ratio m0The smallest maximum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0The number of small numbers, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is m1=m0Otherwise, obtaining the numerical median value m1=mt;
S105: sliding the filtering window, taking the second numerical value subsequence as a first numerical value subsequence of a next round of numerical value subsequence to be processed, taking the next round of numerical value subsequence to be processed as the second numerical value subsequence, and circulating the steps S103-S104 until the filtering of the numerical value sequence is finished;
s106: and sequentially storing the numerical median values output by the filtering window every time, and outputting a numerical median sequence.
A second aspect of the present application provides an adaptive pipeline-structured median filtering apparatus, which employs the adaptive pipeline-structured median filtering method according to the first aspect, and the apparatus includes: the device comprises a receiving module, an initialization module, an acquisition module, a processing module, a circulation module and an output module;
the receiving module is configured to receive a set of sequences of values to be filtered;
the initialization module is configured to obtain a corresponding number of values from the value sequence according to a filtering window with a preset size n to form a first value subsequence x0,x1,...,xn-1And finding the median m of the values from said first subsequence of values0
The acquisition module is configured to slide the filter window into a value x according to the arrangement of the value sequencenAnd shifting out a value x0Then, a first numerical subsequence x in the filtering window0,x1,...,xn-1Into a second numerical subsequence x1,x2,...,xn
The processing module is configured to move into a value xnShifting out the value x0And the median value m of the values in the first numerical subsequence0Comparing, and performing logic operation according to the comparison result to obtain the numerical median m in the second numerical subsequence1(ii) a The method for performing logic operation according to the comparison result comprises the following steps:
when x isn==m0||(xn<m0&&x0<m0)||(xn>m0&&x0>m0) Then, the numerical median m in the second numerical subsequence is obtained1=m0
When x isn>m0&&x0≤m0While, traverse x1To xnSearch for x1To xnMiddle ratio m0The largest minimum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0Of a large numberThe number, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is m1=m0Otherwise, the median value is m1=mt;
When x isn<m0&&x0≥m0While, traverse x1To xnSearch for x1To xnMiddle ratio m0The smallest maximum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0The number of small numbers, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is m1=m0Otherwise, obtaining the numerical median value m1=mt;
The circulation module is configured to slide the filtering window, take the second numerical value subsequence as a first numerical value subsequence of a next round of numerical value subsequences to be processed, take the next round of numerical value subsequences to be processed as the second numerical value subsequence, and circulate the acquisition module and the processing module until the filtering of the numerical value sequences is finished;
the output module is configured to sequentially store the numerical median values output by the filtering window each time, and output a numerical median sequence.
A third aspect of the present application provides a filter comprising a median filtering apparatus of an adaptive pipeline architecture as described above.
A fourth aspect of the present application provides a computer electronics product comprising a memory and a processor; the memory is used for storing program codes; the processor is configured to call the program code to perform the pipeline architecture compliant median filtering method according to any of the first or second embodiments.
A fifth aspect of the present application provides a computer-readable storage medium comprising program code including instructions for performing some or all of the steps of the pipeline architecture compliant median filtering method as described in any of the first or second embodiments.
The median filtering method and device adaptive to the pipeline architecture provided in the embodiment of the present application have at least the following technical effects:
1. the filtering algorithm implemented in the application is simple in logic, and complex data structures are prevented from being maintained; the data dependency in the filtering algorithm loop body is low, so that the algorithm can be fully pipelined and parallelized after being realized, the advantages of a pipeline architecture are fully exerted, the parallelism of each module unit in the pipeline architecture processor is conveniently and fully utilized, and the effect of quick calculation is realized.
2. The filtering algorithm implemented in the application is used for processing the data in three conditions, wherein the first condition is not required to be calculated, the result is directly obtained, and the occurrence probability is 50%; the algorithm complexity of the second case and the third case is O (n), and the occurrence probability is 25%. Since no calculation is needed in case one, the amount of calculation is greatly reduced.
3. When the filtering algorithm realized in the application carries out numerical filtering, for the second and third conditions, only the numerical subsequence needs to be compared in sequence, and a great deal of strong data dependency based on the search tree algorithm is avoided, so that the filtering algorithm can be highly streamlined.
4. In the filtering algorithm loop bodies S103-S104 realized in the application, no sorting is performed, so that a data structure similar to a sorting array and an index array does not need to be maintained, and the calculation amount is reduced; the present algorithm also does not maintain a search tree and index array-like data structure.
5. The filtering algorithm implemented in the present application can meet the requirements for filters in most signal processing scenarios, and thus is very practical and very suitable for pipeline architecture processors.
Drawings
Fig. 1 is a flowchart of a median filtering method for adapting to a pipeline architecture according to an embodiment of the present application;
FIG. 2 is a diagram illustrating a numerical sequence of a median filtering method according to an embodiment of the present application;
FIG. 3 is a diagram illustrating the positions of median values in a sorted sequence according to an embodiment of the present application;
FIG. 4 is a diagram illustrating the positions of k bit values in a sorted sequence according to an embodiment of the present application;
fig. 5 is a block diagram of a median filtering apparatus adapted to a pipeline architecture according to a second embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and/or groups thereof.
The technical scheme is described in detail in the following with reference to the figures and the specific embodiments of the specification.
Example one
Referring to fig. 1, the present embodiment provides a median filtering method for pipeline architecture, which includes the following steps.
S101: a set of sequences of values to be filtered is received.
In one embodiment, the signal processing is performed by receiving an analog signal to be processed in the transmission layer, and then converting the analog signal into a digital signal to form a set of numerical sequences. In another embodiment, a set of digital signals is directly accepted. In this embodiment, a group of numerical sequences to be processed is directly received during filtering.
S102: filtering window of preset size nThe numerical value sequence is used for obtaining the numerical values of the corresponding number to form a first numerical value subsequence x0,x1,…,xn-1And finding the value median m of the values from the first numerical subsequence0
This step S102 is a filter initialization operation of the present algorithm.
In one embodiment, the values in the first subsequence of values are ordered from small to large, such that the median value of the values in the first subsequence of values is taken as the median value of the values. The value x in the first numerical subsequence may be permuted0,x1,…,xn-1In order from small to large, the value m0In the middle of the ordered sequence, (n-1)/2 numbers are present on the left side and (n-1)/2 numbers are present on the right side. In the present embodiment, n is an odd number.
In another embodiment, all the values in the filtering window are initialized to 0 at the beginning, at this time, the median value of the values in the filtering window is 0, then the following steps S103 to S104 are used to perform n times of loop processing, one value is shifted in each loop to perform filtering, and after n times of movement are finished, the output result is x at this time0,x1,…,xn-1The initialization operation of median filtering is completed.
S103: sliding the filtering window in accordance with the arrangement of the value sequence to shift it into a value xnAnd shifting out a value x0Then, the first numerical subsequence x in the filtering window0,x1,…,xn-1Into a second numerical subsequence x1,x2,…,xn
In one embodiment, the filter window is slid over the sequence of values, i.e. by specifying the start position of the sub-sequence. Referring to FIG. 2, after processing the first subsequence of values x0,x1,…,xn-1Then, the window is slid one bit, x, to the right1As starting position of the subsequence, x0The window is moved out from the left side, and xnThe window is moved in from the right.
In another embodiment, the filtering window is fixed and the sub-sequence is updated by filling the values of the second sub-sequence of values into the window in turn.
S104: will shift into the value xnShifting out the value x0With the median value m of the values in the first subsequence of values0Comparing, performing logic operation according to the comparison result to obtain the numerical median m in the second numerical subsequence1
Will shift into the value xnShifting out the value x0With the median value m of the values in the first subsequence of values0In comparison, it can be understood that the filtering operation in this embodiment is implemented based on the effective filtering processing performed in the filtering window and based on the previous effective filtering operation, so as to improve the operation rate and simplify the operation logic.
The logic operation method based on the comparison result includes the following cases.
Case (1) when xn==m0||(xn<m0&&x0<m0)||(xn>m0&&x0>m0) Then, the numerical median m in the second numerical subsequence is obtained1=m0
It is understood that the median value of values in the second subsequence of values is equal to the median value of values in the first subsequence of values, or if the value of values in the second subsequence of values is less than the median value of values in the first subsequence of values and the value of values in the first subsequence of values is less than the median value of values in the first subsequence of values, or if the value of values in the second subsequence of values is greater than the median value of values in the first subsequence of values and the value of values in the first subsequence of values is greater than the median value of values in the first subsequence of values.
If xn<m0And x0<m0I.e. the values shifted out are m in FIG. 30On the left side of (c), the number of moves is also m0Left side of, does not affect m0At the numerical comparison position of the second numerical subsequence, m0Still the numerical median value, i.e. m1=m0. Similarly, if xn>m0And x0>m0I.e. byThe value removed is in m0Right side of (c), the number of moves in is also m0Right side of, does not affect m0At the numerical comparison position of the second numerical subsequence, m0Still the numerical median value, i.e. m1=m0. If xn==m0I.e. the value of the move and m0Equal, also does not affect m0At the numerical comparison position of the second numerical subsequence, m0Still the numerical median value, i.e. m1=m0
In this case, the results are obtained directly without further calculations. Depending on the specific application scenario. The input sequence may or may not have statistical regularity, and in a general statistical sense, the probability of occurrence of case (1) is 50%.
Case (2) when xn>m0&&x0≤m0While, traverse x1To xnSearch for x1To xnMiddle ratio m0The largest minimum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0The number of large numbers, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is m1=m0Otherwise, the median value is m1=mt。
It can be understood that when the shifted-in value is greater than the median value of the values in the first subsequence of values and the shifted-out value is less than or equal to the median value of the values in the first subsequence of values, the median value of the values in the second subsequence of values is obtained according to the logic algorithm in the present embodiment.
Further, if xn>m0And x0≤m0I.e. shifting out a value of m which is equal to or less than the median value of the values in the first subsequence of values0Is shifted into a value greater than the median m of the values in the first subsequence of values0The number of (2). If the equality of the values is not taken into account, the new median m1Must be x1To xnMiddle ratio m0The largest minimum number, denoted mt, is m1=mt. However, considering that there may be instances where the values are equal, x is recorded1To xnMiddle ratio m0The number of large numbers is cn. If cn < (n-1)/2, m in FIG. 3 is illustrated0Must also be equal to m on the right hand side of0So that the median value is constant, i.e. m1=m0
In a general statistical sense, the probability of occurrence of case (2) is 25%, for x1To xnThese n numbers are searched in one pass, and 2 comparisons and 1 accumulation operation are performed for each number.
Case (3) when xn<m0&&x0≥m0Go through x1To xnSearch for x1To xnMiddle ratio m0The smallest maximum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0The number of small numbers, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is m1=m0Otherwise, obtaining the numerical median value m1=mt。
It can be understood that when the shifted-in value is smaller than the median value of the first subsequence of numerical values and the shifted-out value is greater than or equal to the median value of the first subsequence of numerical values, the median value of numerical values in the second subsequence of numerical values is obtained according to the logic algorithm in the embodiment.
Further, if xn<m0And x0≥m0I.e. shifting out a value equal to or greater than the median value m of the values in the first subsequence of values0Is shifted into a value smaller than the median m of the values in the first subsequence of values0The number of (2). If the equality of the values is not taken into account, the new median m1Must be x1To xnMiddle ratio m0The smallest maximum number, denoted mt, is m1=mt. However, considering that there may be instances where the values are equal, x is recorded1To xnMiddle ratio m0The number of small numbers is cn. If cn < (n-1)/2, m in FIG. 3 is illustrated0Must also be equal to m on the left side of0So that the median value is constant, i.e. m1=m0
In a general statistical sense, the situation(3) The probability of occurrence of (2) is 25%. In this embodiment, for x1To xnThese n numbers are searched in one pass, and 2 comparisons and 1 accumulation operation are performed for each number.
Since the probabilities of the cases (1), (2), and (3) are 50%, 25%, and 25%, respectively, on average, the algorithm in this embodiment only needs to perform n/2 cycles for a single filtering, and the algorithm complexity is o (n), and in this embodiment, each cycle includes 2 comparisons and 1 accumulation operation.
Because the algorithm only carries out one time of deterministic sequential search, strong data dependency in a plurality of search tree-based algorithms is avoided, and the algorithm can be highly streamlined.
S105: and sliding a filtering window, taking the second numerical value subsequence as a first numerical value subsequence of the next round of numerical value subsequence to be processed, taking the next round of numerical value subsequence to be processed as a second numerical value subsequence, and circulating the steps S103-S104 until the filtering of the numerical value sequence is finished.
S106: and sequentially storing the numerical median values output by the filtering window each time, and outputting a numerical median sequence.
The median is the value at the middle position after the numerical subsequence is sorted. A filtering method for extracting an arbitrary designated position is derived from this embodiment, as shown in fig. 4, if a number of k-th positions is taken from small to large, which is called k-bit value filtering, then the median filtering is a special case when k is (n-1)/2. The method comprises the following steps.
S201: a set of sequences of values to be filtered is received.
S202: according to a filtering window with a preset size of n, obtaining a corresponding number of numerical values from the numerical value sequence to form a first numerical value subsequence x0,x1,…,xn-1(ii) a And finding the number m of the numerical values which is ordered from small to large as the k-th position from the first numerical value subsequence0
For example, for a first numerical subsequence x0,x1,…,xn-1The numerical values in (1) are sorted, and the number m of the k-th position in the sorted numerical values is found00
S203: sliding the filtering window in accordance with the arrangement of the value sequence to shift it into a value xnAnd shifting out a value x0Then, the first numerical subsequence x in the filtering window0,x1,…,xn-1Into a second numerical subsequence x1,x2,…,xn
S204: will shift into the value xnShifting out the value x0And the k bit value m in the first numerical value subsequence0Comparing, performing logic operation according to the comparison result to obtain the k bit value m in the second numerical subsequence1
The method for performing logic operation according to the comparison result comprises the following steps:
case 1: when x isn==m0||(xn<m0&&x0<m0)||(xn>m0&&x0>m0) Then, k bit value m in the second numerical subsequence is obtained1=m0
Case 2: when x isn>m0&&x0≤m0Go through x1To xnSearch for x1To xnMiddle to middle ratio0A maximum minimum number mt and search for x simultaneously1To xnBim0The number of large numbers cn; when cn < (n-k), the value k in the second numerical subsequence is found to be the bit value m1=m0Otherwise, the k bit value is m1= mt。
Case 3: when x isn<m0&&x0≥m0Go through x1To xnSearch for x1To xnIn (1) to m0A minimum maximum number mt; and search for x simultaneously1To xnMiddle to middle ratio0The number of small numbers cn; when cn < (k-1), the k bit value in the second numerical subsequence is found to be m1=m0Otherwise, the k bit value is m1=mt。
S205: and sliding a filtering window, taking the second numerical value subsequence as a first numerical value subsequence of the next round of numerical value subsequence to be processed, taking the next round of numerical value subsequence to be processed as a second numerical value subsequence, and circulating the steps S203-S204 until the filtering of the numerical value sequence is finished.
S206: and sequentially storing the k bit values output by the sliding filtering window each time, and outputting a k bit value sequence.
Another filtering method can be derived from this embodiment, for example, the median filtering when n is an even number is defined as the n/2 th number or the n/2+1 th number arranged from small to large, and the filtering method according to the k-bit value is naturally extended to the case when n is an even number.
In addition, in some application scenarios, the condition that the numerical values in the input sequence are equal may not be considered, or the result of approximate median filtering may be accepted, so that the counting and judgment of cn in the algorithm may be eliminated, thereby further improving the operation speed.
Example two
Referring to fig. 5, the present embodiment provides an adaptive pipeline structured median filtering apparatus, which employs the adaptive pipeline structured median filtering method according to the first embodiment, and the apparatus includes: the device comprises a receiving module 101, an initialization module 102, an acquisition module 103, a processing module 104, a circulation module 105 and an output module 105.
The receiving module 101 is configured to receive a set of sequences of values to be filtered.
The initialization module 102 is configured to obtain a corresponding number of values from the value sequence according to a filter window with a preset size n, to form a first value subsequence x0,x1,…,xn-1And finding the value median m of the values from the first numerical subsequence0
The acquisition module 103 is configured to slide the filtering window in the order of the sequence of values into a value xnAnd shifting out a value x0Then, a first numerical subsequence x in the filtering window0,x1,…,xn-1Into a second numerical subsequence x1,x2,…,xn
The processing module 104 is configuredIs set to move into the value xnShifting out the value x0And the median value m of the values in the first numerical subsequence0Comparing, and performing logic operation according to the comparison result to obtain the numerical median m in the second numerical subsequence1(ii) a The method for performing logic operation according to the comparison result comprises the following steps:
when x isn==m0||(xn<m0&&x0<m0)||(xn>m0&&x0>m0) Then, the numerical median m in the second numerical subsequence is obtained1=m0
When x isn>m0&&x0≤m0Go through x1To xnSearch for x1To xnMiddle to middle ratio0A maximum minimum number mt and search for x simultaneously1To xnMiddle to middle ratio0The number of large numbers cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is m1=m0Otherwise, the median value is m1=mt;
When x isn<m0&&x0≥m0Go through x1To xnSearch for x1To xnMiddle to middle ratio0A minimum maximum number mt, and searching for x at the same time1To xn, the ratio m0The number of small numbers cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is m1=m0Otherwise, obtaining the numerical median value m1=mt。
The loop module 105 is configured to slide the filtering window, take the second numerical subsequence as a first numerical subsequence of a next round of numerical subsequences to be processed, take the next round of numerical subsequences to be processed as a second numerical subsequence, and loop the obtaining module and the processing module until the filtering of the numerical sequence is finished;
the output module 106 is configured to sequentially store the numerical median values output each time by the filtering window, and output a numerical median sequence.
EXAMPLE III
This embodiment provides a filter including a median filtering apparatus adapted to a pipeline architecture as in embodiment 2.
In one application embodiment, the filter uses TMS320C67XX series DSP chip of TI company to implement the algorithm in the embodiment for processing median filtering of floating point (float) type precision data. The DSP chip is a single-core processor and at least comprises an acquisition unit, a comparison unit and a calculation unit, wherein the acquisition unit acquires a numerical value, the comparison unit compares floating point numbers, and the calculation unit performs addition and subtraction arithmetic operations.
In the embodiment, the performance that only 1 clk is needed for each cycle on average can be achieved by realizing on a chip and optimizing codes, and n/2 cycles are executed by filtering on average once. After many experiments, for a filter with length n being 152, the embodiment needs only 118 clk to run the filtering average once. However, the existing HeapSort algorithm is implemented on the same chip and is fully optimized by codes, and 192 clk are needed for one-time filtering by the HeapSort algorithm when the length n of the filter is 152. And after the MoveSort algorithm with the same algorithm complexity of o (n) is implemented on the same chip and is fully optimized by codes, 445 clk are needed for filtering at one time by using the MoveSort algorithm when the length n of the filter is 152.
Different from the MoveSort algorithm, the algorithm does not perform sequencing in the operation process, so that a data structure such as a sequencing array and an index array is not required to be maintained, and the algorithm is far superior to the calculation amount of the MoveSort. Unlike the Heapsort algorithm, the algorithm does not maintain data structures such as search trees and index arrays. The algorithm only performs comparison and counting operations and executes deterministic slave x1To xnAnd (5) searching once. Although the algorithm complexity of the Heapsort algorithm is better, the algorithm is superior to the speed of the Heapsort algorithm in the range of n < 300 from the operating result of implementation and code optimization on a TMS320C67XX type DSP chip. And n < 300 already meets the requirements for a median filter in most signal processing scenarios. The algorithm of the invention is therefore very practical and very adaptable to pipeliningA processor is configured.
Example four
The embodiment provides a computer electronic product, which comprises a memory and a processor; the memory is used for storing program codes; the processor is configured to call program code to perform a median filtering method adapted to a pipeline architecture as in embodiment 1 or embodiment 2.
The present embodiment also provides a computer-readable storage medium including program code including instructions for performing some or all of the steps of the pipeline architecture adaptive median filtering method according to embodiment 1 or embodiment 2.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by instructions associated with hardware via a program, which may be stored in a computer-readable storage medium, and the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Additionally, some of the steps or functionality of the present invention may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various functions or steps. The method disclosed by the embodiment shown in the embodiment of the present specification can be applied to or realized by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present specification may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present specification may be embodied directly in a hardware decoding processor, or in a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The chip provided by the third application example is a computer-readable storage medium storing one or more programs that, when executed by an electronic system including a plurality of application programs, cause the electronic system to perform the method of the first embodiment. And will not be described in detail herein.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital versatile discs (dvd) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
In addition, some of the present invention can be applied as a computer program product, such as computer program instructions, which when executed by a computer, can invoke or provide the method and/or technical solution according to the present invention through the operation of the computer. Program instructions which invoke the methods of the present invention may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions. An embodiment according to the invention herein comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform a method and/or solution according to embodiments of the invention as described above.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (5)

1. A method for median filtering in an adaptive pipeline architecture, comprising:
s101: receiving a set of numerical sequences to be filtered;
s102: according to a filtering window with a preset size of n, obtaining a corresponding number of numerical values from the numerical value sequence to form a first numerical value subsequence x0,x1,…,xn-1And finding the median m of the values from said first subsequence of values0
S103: sliding the filtering window according to the arrangement of the numerical value sequence to shift the filtering window into a numerical value xnAnd shifting out a value x0Then, the filteringFirst subsequence of values x within a window0,x1,…,xn-1Into a second numerical subsequence x1,x2,…,xn
S104: will shift into the value xnShifting out the value x0And the median value m of the values in the first numerical subsequence0Comparing, and performing logic operation according to the comparison result to obtain the numerical median m in the second numerical subsequence1(ii) a The method for performing logic operation according to the comparison result comprises the following steps:
when x isn==m0||(xn<m0&&x0<m0)||(xn>m0&&x0>m0) Then, the numerical median m in the second numerical subsequence is obtained1=m0
When x isn>m0&&x0≤m0While, traverse x1To xnSearch for x1To xnMiddle ratio m0The largest minimum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0The number of large numbers, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is found to be m1=m0Otherwise, the median value is m1=mt;
When x isn<m0&&x0≥m0While, traverse x1To xnSearch for x1To xnMiddle ratio m0The smallest maximum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0The number of small numbers, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is found to be m1=m0Otherwise, obtaining the numerical median value m1=mt;
S105: sliding the filtering window, taking the second numerical value subsequence as a first numerical value subsequence of a next round of numerical value subsequence to be processed, taking the next round of numerical value subsequence to be processed as the second numerical value subsequence, and circulating the steps S103-S104 until the filtering of the numerical value sequence is finished;
s106: and sequentially storing the numerical median values output by the filtering window every time, and outputting a numerical median sequence.
2. An adaptive pipeline-architecture median filtering apparatus adopting the adaptive pipeline-architecture median filtering method according to any one of claim 1, the apparatus comprising: the device comprises a receiving module, an initialization module, an acquisition module, a processing module, a circulation module and an output module;
the receiving module is configured to receive a set of sequences of values to be filtered;
the initialization module is configured to obtain a corresponding number of values from the value sequence according to a filtering window with a preset size n to form a first value subsequence x0,x1,…,xn-1And finding the median m of the values from said first subsequence of values0
The acquisition module is configured to slide the filter window into a value x according to the arrangement of the value sequencenAnd shifting out a value x0Then, a first numerical subsequence x in the filtering window0,x1,…,xn-1Into a second numerical subsequence x1,x2,…,xn
The processing module is configured to move into a value xnShifting out the value x0And the median value m of the values in the first numerical subsequence0Comparing, and performing logic operation according to the comparison result to obtain the numerical median m in the second numerical subsequence1(ii) a The method for performing logic operation according to the comparison result comprises the following steps:
when x isn==m0||(xn<m0&&x0<m0)||(xn>m0&&x0>m0) Then, the numerical median m in the second numerical subsequence is obtained1=m0
When x isn>m0&&x0≤m0While, traverse x1To xnSearch for x1To xnMiddle ratio m0The largest minimum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0The number of large numbers, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is found to be m1=m0Otherwise, the median value is m1=mt;
When x isn<m0&&x0≥m0While, traverse x1To xnSearch for x1To xnMiddle ratio m0The smallest maximum number, denoted mt, is searched for x at the same time1To xnMiddle ratio m0The number of small numbers, denoted cn; when cn < (n-1)/2, the median value of the values in the second numerical subsequence is found to be m1=m0Otherwise, obtaining the numerical median value m1=mt;
The circulation module is configured to slide the filtering window, take the second numerical value subsequence as a first numerical value subsequence of a next round of numerical value subsequences to be processed, take the next round of numerical value subsequences to be processed as the second numerical value subsequence, and circulate the acquisition module and the processing module until the filtering of the numerical value sequences is finished;
the output module is configured to sequentially store the numerical median values output by the filtering window each time, and output a numerical median sequence.
3. A filter comprising the median filtering means of the adaptive pipeline architecture of claim 2.
4. A computer electronics product comprising a memory and a processor; the memory is used for storing program codes; the processor is configured to invoke the program code to perform the method of median filtering for an adaptive pipeline architecture of claim 1.
5. A computer-readable storage medium comprising program code including instructions for performing some or all of the steps of the adaptive pipeline architecture median filtering method of claim 1.
CN202010597238.2A 2020-06-28 2020-06-28 Median filtering method and device adaptive to pipeline architecture and filter Active CN111953318B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010597238.2A CN111953318B (en) 2020-06-28 2020-06-28 Median filtering method and device adaptive to pipeline architecture and filter

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010597238.2A CN111953318B (en) 2020-06-28 2020-06-28 Median filtering method and device adaptive to pipeline architecture and filter

Publications (2)

Publication Number Publication Date
CN111953318A true CN111953318A (en) 2020-11-17
CN111953318B CN111953318B (en) 2021-04-13

Family

ID=73337229

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010597238.2A Active CN111953318B (en) 2020-06-28 2020-06-28 Median filtering method and device adaptive to pipeline architecture and filter

Country Status (1)

Country Link
CN (1) CN111953318B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112669411A (en) * 2020-12-31 2021-04-16 一诺仪器(中国)有限公司 Trace smoothing method for vector network analyzer

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040230367A1 (en) * 2003-05-15 2004-11-18 Miller Gary P. Misfire detection system and method of median filtering
CN103312939A (en) * 2012-03-14 2013-09-18 富士通株式会社 Device and method for filtering mid value
CN108634935A (en) * 2018-05-09 2018-10-12 广东工业大学 The method, apparatus and equipment of signal base line drift correction
CN109767406A (en) * 2019-01-28 2019-05-17 中南林业科技大学 A kind of adaptive median filter denoising method applied to image procossing

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040230367A1 (en) * 2003-05-15 2004-11-18 Miller Gary P. Misfire detection system and method of median filtering
CN103312939A (en) * 2012-03-14 2013-09-18 富士通株式会社 Device and method for filtering mid value
CN108634935A (en) * 2018-05-09 2018-10-12 广东工业大学 The method, apparatus and equipment of signal base line drift correction
CN109767406A (en) * 2019-01-28 2019-05-17 中南林业科技大学 A kind of adaptive median filter denoising method applied to image procossing

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
TAKEAKI MATSUBARA,ETC: "A Low-Complexity and Low Power Median Filter Design", 《2010 INTERATIONAL SYMPOSIUM ON INTELLIGENT SIGNAL PROCESSING AD COMMUNICATION SYSTEMS (LSPACS 2010) 》 *
林清华 等: "新型快速中值滤波算法及在医学图像中的应用", 《计算机应用研究》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112669411A (en) * 2020-12-31 2021-04-16 一诺仪器(中国)有限公司 Trace smoothing method for vector network analyzer

Also Published As

Publication number Publication date
CN111953318B (en) 2021-04-13

Similar Documents

Publication Publication Date Title
US9098537B2 (en) Techniques for aligned run-length encoding
US10534576B2 (en) Optimization apparatus and control method thereof
US9952870B2 (en) Apparatus and method for bias-free branch prediction
US10908877B2 (en) Median value determination in a data processing system
CA2929403C (en) Multi-dimensional sliding window operation for a vector processor
Kung et al. Two-level pipelined systolic array for multidimensional convolution
CN111953318B (en) Median filtering method and device adaptive to pipeline architecture and filter
WO2018129930A1 (en) Fast fourier transform processing method and device, and computer storage medium
US20240126507A1 (en) Apparatus and method for processing floating-point numbers
CN114090954A (en) Integer matrix multiplication kernel optimization method based on FT-2000+
KR102569370B1 (en) Non-binary LDPC decoder check node and corresponding method
CN117396892A (en) Hardware perception neural network design
GB2581543A (en) Apparatus and method for processing floating-point numbers
WO2022191730A1 (en) Accelerated execution of convolution operation by convolutional neural network
CN111124358B (en) Operation method and device of sequence accumulator
US10761847B2 (en) Linear feedback shift register for a reconfigurable logic unit
Bevara et al. VLSI implementation of high throughput parallel pipeline median finder for IoT applications
CN113610221A (en) Variable expansion convolution operation hardware system based on FPGA
US20240086192A1 (en) Special-purpose digital-compute hardware for efficient element-wise aggregation, scaling and offset
CN116415103B (en) Data processing method, device, storage medium and electronic equipment
CN117370717B (en) Iterative optimization method for binary coordinate reduction
CN112330524B (en) Device and method for quickly realizing convolution in image tracking system
US20230361778A1 (en) Devices, systems, and methods for digital filtering
US11669725B1 (en) Systems and methods of buffering and accessing input data for convolution computations
Ursitti Computation of some transcendental integrals from path signatures

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant