non linear digital filters

Upload: prasannakumar7

Post on 03-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 non linear digital filters

    1/13

    Poularikas A. D. Nonlinear Digital Filtering

    The Handbook of Formulas and Tables for Signal Processing.

    Ed. Alexander D. PoularikasBoca Raton: CRC Press LLC,1999

    1999 by CRC Press LLC

  • 7/28/2019 non linear digital filters

    2/13

    1999 by C RC Press LLC

    41N onlinear D igitalFiltering41.1 Definitions

    41.2 Mean Filter

    41.3 Median Filter41.4 Trimmed Mean Filters

    41.5 L-Filters (Order Statistic Filters)

    41.6 Weighted Median Filters

    41.7 Ranked-Order Filter

    41.8 Separable Two-Dimensional Median Filters

    41.9 M-Filters

    41.10 R-Filters

    References

    41.1 Definitions

    41.1.1 One- and Two-Dimensional Signals

    f(t)=continuous, f(n)=discrete; f(x,y)=continuous, f(n,m)=discrete

    41.1.2 Filter Length

    N=2k+1, N= odd number, range of indices: i k,i k+ 1,,i + k

    41.1.3 Data Length

    x={x(1),,x(Nd)}

    41.2 Mean Filter

    41.2.1 Mean Filter

    Example

    x={4,14,18,40,10}. For k=1, N=21+1=3 and y(1)=4,

    y ik

    x i j

    j k

    k

    ( ) ( )=+

    +=12 1

  • 7/28/2019 non linear digital filters

    3/13 1999 by C RC Press LLC

    Note: 1. Mean filtering is a linear operation 2. Mean filter attenuates noise

    41.2.2 Mean Filter Algorithms

    Input: data x={x(1),,x(Nd)} Inputs: No of rows NR No of columns NC (image)

    moving window wN, N=2k+1 moving window wN=N=2k+1

    Output: y={y(1),,y(N)} Output: NRNC (image)

    for i = 1 to Nd for i=1 to NRset number at i for j=1 to NCSum=0 set window wN at (i,j)

    for every element x(m) of the Sum=0

    image inside the window wN for every element x(m,n) of the

    Sum=Sum+x(m) image inside wNend Sum=Sum+x(m,n)

    y(i)=Sum/N end

    end y(i,j)=Sum/N

    end

    end

    41.3 Median Filter

    41.3.1 Median Filter

    y(i)=MED{x(i2), x(i1), x(i), x(i+1), x(i+2)} i=3,4,,18 for data x={x(1),x(2),,x(20)}

    Example

    Let x={1,5,3,2,10,2} and k=1 then y(1)=1,y(2)=MED{1,5,3}=MED{1,3,5}=3,

    y ( 3 ) = M E D { 5 , 3 , 2} = M E D { 2 , 3 , 5} = 3 ,

    y(4)=MED{3,2,10}=MED{2,3,10}=3,y(4)=MED{3,2,10}=MED{2,3,10}=3,y(5)=MED{2,10,2}=MED

    {2,2,10}=2,y(6)=2. Hence, y={1,3,3,3,2,2}

    Note: a) the filter is nonlinear, b) attenuates noise to some degree c) does not attenuate noise well in

    the case of noisy ramp signal d) noisy step signal is rounded at the step e) eliminates impulse noise

    f) if impulse noise is close to an edge it may be removed but the edge moves toward the impulse (edge

    jitter).

    41.3.2 Median Filter Algorithms

    Inputs: data x={x(1),,x(Nd)} Inputs: No of rows NR No of columns NCmoving window wN, N=2k+1 moving window wN, N=2k+1

    Output: data y={y(1),,y(Nd)} Output: NRNC (image)

    for i=1 to Nd for i=1 to NRplace window wN at i for j=1 to NCstore the data inside the window wN in place window wN at (i,j)

    x={x(1),,x(N)} store image values inside wN

    find the median ofx, MED{x} x={x(1),,x(N)}y(i)=MED{x}; output find median of x, MED{x}

    end y(i,j)=MED{x}; output

    end

    end

    y x j y y y

    j

    ( ) ( ) ( ) , ( ) ( / )( ) , ( ) , ( )21

    32

    1

    34 14 18 12 3 1 3 14 18 40 24 4 68 5 10

    1

    1

    = + = + + = = + + = = ==

  • 7/28/2019 non linear digital filters

    4/13 1999 by C RC Press LLC

    41.4 Trimmed Mean Filters

    41.4.1 Motivation for Trimmed Mean Filters

    The idea of trimmed filters is to reject the most probable outliers some of the very small and the

    very large values.

    41.4.2 (r,s)-Fold Trimmed Mean Filters

    Short the samples in the window and omit r+s samples x(1),,x(r) and x(Ns+1),x(Ns+2)

    41.4.2.1 (r,s)-Fold Trimmed Mean Filters Algorithm

    Inputs: data x={x(1),,x(Nd)} Inputs: No of rows NR No of columns NC (image)

    moving window wN, N=2k+1, r and s moving window wN, N=2k+1, integer numbers

    integer numbers r,s

    Output: y(i) Output: NRNC (image)

    for i=1 to Nd for i=1 to NRplace window wN at i for j=1 to NCstore the values inside the window into place window wN at (i,j)

    x={x(1),x(2),,x(N)} store data inside window into

    sort x to x= x={x(1),,x(N)}

    Sum=0 sort x intox =

    for m=r+1 to Ns Sum=0Sum=Sum+ for m=r+s to Ns

    end Sum=Sum+

    y(i)=Sum/(Nrs); output end

    end y(i,j)=Sum/(Nrs); output

    end end

    Note:x(i)x(j) for all i

  • 7/28/2019 non linear digital filters

    5/13 1999 by C RC Press LLC

    41.4.4 -Trimmed Mean Filters

    If r = s then =j/N, 0 jN/2 is an integer, and the formula is

    41.4.5 -WinMean Filters (see 41.4.4)

    Note: a) (0,0)-fold trimmed, (0,0)-fold Winsorized, 0-trimmed, and 0-Winsorized mean filters are

    the same as the mean filter of the same window size; b) (k,k)-fold trimmed, (k,k)-fold Winsorized, 0.5-

    trimmed and 0.5-Winsorized mean filters are the same as the median filter of the same window size

    Example

    x=(4,14,18,40,10), N=5, x( )=(4,10,14,18,40) a) (2,1)-fold trimmed mean filter (14+18)/2=16, b) (1,2)-

    Winsorized mean filter (210+314)/5=12.4, c) 0.2-trimmed mean (14+18+40)/3=14, d) 0.2-Winsorized

    mean filter (210+14+218)/5=14

    41.4.6 Modified Trimmed Mean Filters

    A real valued constant q is first fixed and then all the samples in the range [x(k+1) q, x(k+1) + q] are

    averaged, and the results constitute the output

    Example

    x={4,14,18,40,10}, x( )={4,10,14,18,40}, a) for 0 q < 4 med is 14, b) for 4 q < 10, (10 + 14 +

    18)/3=14, c) for 10 q < 26, (4 + 10 + 14 + 18)/4=11.5, d) mean (4 + 10 + 14 + 18 + 40)/5=17.2

    41.4.6.1 Modified Trimmed Mean Algorithm

    Inputs: data x={x(1),,x(Nd)} Inputs: No of rows NR No of columns NC (image)

    moving window wN, N=2k+1 moving window wN, N=2k+1

    positive real number q positive real number q

    Output: y={y(1),,(Nd)} Output: NRNC (image)

    for i=1 to Nd for i=1 to NRplace window wN at i for j=1 to NCstore the values in the window in place window wN at (i,j)

    x={x(1),,x(N)} store the values inside the window wN in

    find the median x(k+1)

    ofx x={x(1),,x(N)}

    Sum1=0 find the median x(k+1) ofx

    Sum2=0 Sum1=0

    for m=1 to N Sum2=0

    if abs(x(m)x(k+1))q then for m=1 to N

    = = = +

    TrMean( ( )x { ( ), , )};( )x x N N N x

    d i

    i N

    N N

    11

    21

    K

    = = + +

    +

    = +

    WinMean( ( )x { ( ), , )}; ( ) ( ) ( )x x N N N x x N xd N ii N

    N N

    N N1

    11

    1

    K

    MTM x x N

    a x i

    a

    ax i x k q

    d

    i

    i

    N

    i

    i

    N i( ( )

    if

    otherwise

    x = = = +

    =

    =

    { ( ), , )}

    ( )

    ,( ) ( )

    11 1

    0

    1

    1

    K

  • 7/28/2019 non linear digital filters

    6/13 1999 by C RC Press LLC

    Sum1=Sum1+x(m) if abs(x(m)x(k+1))q then

    Sum2=Sum2+1 Sum1=Sum1+x(m)

    end Sum2=Sum2+1

    y(i)=Sum1/Sum2; output end

    end y(i,j)=Sum1/Sum2; output

    end end

    end

    41.4.7 Double Window Modified Trimmed Mean Filters

    The idea behind this filter is to suppress additive Gaussian noise with the large window and preserve

    the details by rejecting pixels that are far away from the median of the smaller window.

    41.4.7.1 Double Window Modified Trimmed Mean Filters Algorithm

    Inputs: data x={x(1),,x(Nd)} Inputs: No of rows NR No of columns NC (image)

    moving window wN, N=2k+1 moving window wN, N=2k+1moving window w1, M>N moving window w1, M>N

    positive real number q positive real number q

    Output: y={y(1),,y(Nd)} Output: NRNC (image)

    for i=1 to Nd for i=1 to NRplace window wN and w1 at i for j=1 to NCstore values inside wN in place windows wN and w1 at (i,j)

    x={x(1),,x(N)} store the values inside wN in x={x(1),,x(N)}

    find the median x(k+1) ofx find the median x(k+1) ofx

    sum1=0, sum2=0 sum1=0, sum2=0

    store values inside w1

    in store values inside w1

    in

    z={x(1),,x(M)} z={z(1),,z(M)}

    for m=1 to M for m=1 to M

    if abs(x(m)x(k+1))q then if abs(x(m)x(k+1))q then

    sum1=sum1+x(m) sum1=sum1+x(m)

    sum2=sum2+1 sum2=sum2+1

    end end

    y(i)=sum1/sum2 y(i,j)=sum1/sum2

    end end

    end end

    41.4.8 K-Nearest Neighbor Filter

    The output is given by the mean of K, 1KN, samples whose values are closest to the value of the

    central value x* inside the filter window.

    Example

    x={4,14,18,40,10}. Center sample is x*=18 a) for K=1, 18 (itself) is the closest sample to 18 and output

    is 18/1=18 b) for K=2, 18 and 14 must be used and the output is (18+14)/2=16 c) for K=3, 18, 14 and

    10 are closest and output is (18+14+10)/3=14.

    41.4.8.1 K-Nearest Neighbor Filter Algorithm

    Inputs: data x={x(1),,x(Nd)} Inputs: No of rows NR No of columns NC (image)

    moving window wN, N=2k+1 moving window wN, N=2k+1

    integer number K, 1KN integer number K, 1KN

  • 7/28/2019 non linear digital filters

    7/13 1999 by C RC Press LLC

    Output: y={y(1),,y(Nd)} Output: NRNC (image)

    for i=1 to Nd for i=1 to NRplace window wN at i for j=1 to NCstore values inside the window wN place windows wN at (i,j)

    and their differences from x* in store values inside wN

    and their differences

    z = from x* (pixel (i,j)) in

    sort z with respect to and store in z =

    t= sort z with respect to abs(x(i)x*), and store

    sum=0 the results in

    for m=1 to K t=

    sum=sum+x(m) sum=0

    end for m=1 to K

    y(i)=sum/K sum=sum+x(m)

    end endend y(i,j)=sum/K

    end

    end

    41.4.8.2 Modified K-Nearest Neighbor Filter

    If we change the rule for ai in 41.4.6 to

    If q is chosen to be twice the standard deviation of the noise, the filter is known as the sigma filter.

    41.5 L-Filters (Order Statistic Filters)

    41.5.1 Purpose of the Estimator

    L-filters are running estimators making a compromise between a pure nonlinear operation (ordering)

    and pure operation (weighting).

    41.5.2 L-Filters

    41.5.3 L-Filters Algorithms

    Inputs: data x={x(1),,x(Nd)} Inputs: No of rows NR No of columns NC (image)

    moving window wN, N=2k+1 moving window wN, N=2k+1

    weight vector a={a1,,aN} weight vector a={a1,,aN}Output: y={y(1),,y(Nd)} Output: NRNC (image)

    for i=1 to Nd for i=1 to NR

    {( ( ), ( ) ), ,( ( ), ( ) )}* *x x x x N x N x1 1 L

    x i x( ) *{( ( ), ( ) ), ,( ( ), ( ) )}* *x x x x N x N x1 1 L

    {( , ), ,( , )}

    ( ) ( )

    *

    ( ) ( )

    *x x x x x xN N1 1

    L

    {( , ), ,( , )}

    ( ) ( )

    *

    ( ) ( )

    *x x x x x xN N1 1

    L

    ax i x q

    i=

    1

    0

    if

    otherwise

    ( ) *

    L x x N a x ai i

    i

    N

    i

    i

    N

    ( ( ), , ); ) ,( )

    1 1

    1 1

    K ( a = == =

  • 7/28/2019 non linear digital filters

    8/13 1999 by C RC Press LLC

    place window wN at i for j=1 to NCstore the data inside the window place window wN at (i,j)

    wN in z={x(1),,x(N)} store values inside the window wN in

    sort z and store in the vector q z={x(1),,x(N)}

    q={x(1)

    ,,x(N)

    } sort z and store in q={x(1)

    ,,x(N)

    }

    sum=0 sum=0

    for m=1 to N for m=1 to N

    sum=sum+amx(m) sum=sum+amx(m)end end

    y(i)=sum; output y(i,j)=sum; output

    end end

    end end

    41.6 Weighted Median Filters

    41.6.1 Purpose

    With this filter we may emphasize the samples that for some reason are supposed to be more reliable,

    e.g., center sample x*, and the emphasis is obtained by weighing them more heavily.

    41.6.2 Repetition or Duplication Operator &

    3&x=x,x,x

    41.6.3 Multiset

    A multiset is a collection of objects, where the repetition of objects is permitted, e.g.,{3&2,1,2&4}={2,2,2,1,4,4}

    41.6.4 Weighted Median Filters

    WeightMed{x(1),,x(N);a}=Med{a1&x(1),,aN&x(N)}

    41.6.5 Weighted Median Algorithm

    Inputs: data x={x(1),,x(Nd)} Inputs: No of rows NR No of columns NC (image)

    moving window wN, N=2k+1 moving window wN, N=2k+1

    weight vector a={a1,,aN} weight vector a={a1,,aN}Output: y={y(1),,y(Nd)} Output: NRNC (image)

    halfsum= halfsum=

    for i=1 to Nd for i=1 to NRplace window wN at i for j=1 to NCstore values inside the window and weight place window wN and corresponding weighs in

    in z={(x1,a1),,(xN,aN)} z={(x1,a1),,(xN,aN)}

    sort z with respect to xis and store in q sort z with respect to xis and store in

    q={(x(1)a(1)),,(x(N),a(N))} q={(x(1),a(1)),,(x(N),a(N))}

    sum=0, m=1 sum=0, m=1

    repeat repeat

    sum=sum+a(m) sum=sum+a(m)m=m+1 m=m+1

    ai

    i

    N

    =

    1

    2 ai

    i

    N

    =

    1

    2

  • 7/28/2019 non linear digital filters

    9/13 1999 by C RC Press LLC

    until sumhalfsum until sumhalfsum

    y(i)=x(m1) y(i,j)=x(m1)end end

    end end

    Examplex={4,14,18,40,10}, a={0.05,0.1,0.15,0.1,0.05}. After ordering

    z={(4,0.05),(10,0.05),(14,0.1),(18,0.15),(40,0.1)}. Halfsum=(0.05+0.05+0.1+0.15+0.1)/2=0.225. But

    (0.05+0.05+0.1+0.15)=0.35>0.225 and the filter output is 18.

    41.7 Ranked-Order Filter

    41.7.1 Purpose

    These filters can be used in situations where the noise distribution is not symmetric, e.g., where there

    are more positive than negative impulses.

    41.7.2 Ranked-Order Filter

    RO(x(1),,x(N);r)=x(r), N=2k+1

    Note: When r=k+1 we obtain the median filter. If rk+1.

    Example

    If x={4,14,18,40,10} and the ordered x-ordered={4,10,14,18,40}. Here N=5=2k+1 and k=2. The rth

    ranked-order filter gives the outputs: 2 for r=1, 10 for r=2, 14 for r=3, 18 for r=4, and 40 for r=5.

    41.7.3 Ranked-Order Filter Algorithms

    Inputs: data x={x(1),,x(Nd)} Inputs: No. of rows NR No. of columns NC (image)

    moving window wN, N=2k+1 moving window wN, N=2k+1

    rank r rank r

    Output: y={y(1),,y(Nd)} Output: NRNC (image)

    for i=1 to Nd for i=1 to NRplace window wN at i for j=1 to NCstore the values in the window wN place window wN at (i,j)

    in z={x(1),,x(N)} store values inside the window wN in

    sort z to q={x(1),,x(N)} z={x(1),,x(N)}y(i)=x(r); output sort z to q={x(1),,x(N)}}

    end y(i,j)=x(r)end end

    end

    41.8 Separable Two-Dimensional Median Filters

    41.8.1 Purpose

    The filter has the same properties as the median filter but is much faster. It is accomplished by usingtwo successive one-dimensional median filters of window size M=2l+1 (MM=N), the first along the

    rows and the second one along the columns of the so-obtained image.

  • 7/28/2019 non linear digital filters

    10/13 1999 by C RC Press LLC

    41.8.2 Separable Two-Dimensional Median Filters

    Med{x(M,1),,x(M,M)}}

    41.8.3 Algorithm

    Inputs: No. of rows NR time No. of columns NC; (image)

    Moving horizontal window w1,M, M=2l+1

    Moving vertical window w2,M, M=2l+1

    Output: NRNC; (image)

    Median filter the image by using horizontal moving window w1,M for each row

    Store the resulting values as they are found in a column vector

    Median filter the column vector using vertical moving window w2,M

    41.9 M-Filters

    41.9.1 Purpose

    M-estimators are generalizations of maximum likelihood estimators

    41.9.2 M-Filters

    M(x(1),,x(Nd); ) =arg

    41.9.3 M-Filter by the Partial Derivative (with respect to ) of

    The estimate M(x(1),,x(Nd)) satisfies the equation

    41.9.4 Function in Use

    1. Skipped median,

    2. Andrews sine,

    3. Tukeys biweight,

    4. Standard M-filters,

    SepMed Med{Med{

    x x x M

    x x x M

    x M x M x M M

    x x M

    ( , ) ( , ) ( , )

    ( , ) ( , ) ( , )

    ( , ) ( , ) ( , )

    ( , ), , ( , )},

    1 1 1 2 1

    2 1 2 2 2

    1 2

    1 1 1

    L

    L

    M M M M

    L

    L L

    =

    min ( ( ) )

    = i

    N

    x i

    1

    ( ( ) )i

    N

    x i

    = =

    1

    0

    med r

    xx x r

    r x( )

    ( )sin( )

    =