When are two weighted-order statistic filters identical?

1 downloads 0 Views 607KB Size Report
There is a finite number of different Weighted Order Statistic (WOS) filters of a fixed length N. However, even for relatively small values of N, one cannot ...
Proc. of SPIE Vol. 2180, Nonlinear Image Processing V, ed. E R Dougherty, J T Astola, H G Longbotham (May 1994) Copyright SPIE

When

are two Weighted

Order

Statistic

J. Astola, F. Cheikh-Alaya

Filters

Identical?

and M. Gabbouj

Signal Processing Laboratory, Tampere University of Technology P.O. Box 553, FIN-33101 Tampere, Finland

ABSTRACT There is a finite number of different Weighted Order Statistic (WOS) filters of a fixed length N. However, even for relatively small values of N, one cannot immediately see if two given WOS filters are the same by simply looking at the weights and the thresholds. This problem is addressed in this paper. We define two WOS filters to be equivalent (the same) if they produce the same output for arbitrary inputs. We shall show that the solution requires the use of Integer Linear Programming (ILP) and next develop a hierarchical heuristical procedure which may provide a much quicker solution to the given problem. The hierarchy starts with simple checks and proceeds to more and more complicated tests. The procedure is exited as soon as a definite conclusion is reached.

1

Introduction

The first use of the Standard Median(SM) was to smooth statistical data [l]. Given a set X = (Xl, X2, . . . , Xzk+i) of samples, the output of the Standard Median filter can be defined as follows: Xzk+i) = (L + 1)‘th largest sample of &, Y = MED(X1,X~,..., where Ic > 0 integer, and N = 2k + 1 is commonly referred to as the filter window width. Due to their smoothing and edge-preserving characteristics, median filters have received considerable attention in the field of digital signal processing leading to a generalization of the median filter by Justusson [2] and Brownrigg [3], who introduced the Weighted Median (WM) filter with integer weights. Weighted medians were extended to Weighted Order Statistics (WOS) filters by simply allowing the threshold to vary. The most important development is the area of WOS filtering is perhaps the existence of several optimization algorithms which allow the designer to pick the best WOS filter among the class of WOS according to some error criteria. However, most of these optimization algorithms yield solutions with non-integer weights. This has partially led to the work in [4] where we showed the existence of an integer-valued equivalent WOS filter for any real-weights WOS filter. A procedure is given there to perform the transformation and, therefore, we assume in the sequel integer-valued weights. However, even for integer-valued weights, it is often a non-trivial problem to decide whether two WM filters, or in general two WOS filters, are the same. Prasad and Lee [5] h ave eluded to this problem but did not give a complete solution. This is the problem we shall investigate in this paper. The paper is organized as follows. In the next section, the equivalence of two Weighted Order Statistic (WOS) filters is defined and some relevant properties of Weighted Median WM filters are reported. In Section 3, we derive a complete solution to the equivalence problem. In particular, we show that Integer Linear Programming (ILP) can be used to check whether two WOS filters are equivalent. We also show that the equivalence problem is as complex as the ILP (NP complete). This has prompted us to develop in Section 4 some heuristics, based on the properties in Section 2, to solve this problem in special cases. Some examples are given at the end of the section. Section 5 contains some conclusions.

2 2.1

Definitions

and properties

Definitions

The Weighted Median (WM) filt er can be defined in two different but equivalent ways. The most commonly used one assumes positive integer weights with odd sum.

45

Dejinition

1:

For a discrete-time continuous-valued

input vector X,

x=(Lx2,...JN),

the output Y of the W M filter of span N associated with the integer weights w=(Kw2,...,wN)

is given by Y = MED{ wr oXr,I”&oXz where MED{.}

,..., WNoXN

},

d enotes the median operation and o denotes duplication nox

= x,...,x. n times

This filtering procedure can be stated as follows: sort the samples inside the filter window, duplicate each sample Xi to the number of the corresponding weight VVi and choose the median value from the expanded list. Remark: An equivalent definition for weighted median filters with positive real-valued weights exists. Interested readers are referred to [4].

Weighted Order statistics are a generalization of weighted medians and can be defined as follows. 2: The output Y of the weighted order statistic filter with weights W and threshold T (denoted as (IV, T))

Definition

is given by Y =T’thlargestvalueoftheset{

W~OX~,W~OX~,...,WNOXN},

The equivalence of two W M or WOS filters can be defined in two ways, one in the multilevel domain, Definition 3; and the other in the binary domain, Definition 4. The two definitions are equivalent since WOS filters obey the threshold decomposition and the stacking properties and are hence stack filters [6]. Definition

3:

(~1,~2,~‘~,~N),

Two weighted order statistics (@,T) and (v, S), are equivalent if for all multi-valued vectors X = we have Yi = Yz, where Yi and Yz are the outputs of (lV, T) and (v, S), respectively.

In the binary domain, the above definition is equivalent to:

4: Two WOS filters (Q’, T) and (V, S), are equivalent if for all binary vectors X,

Dejnition

~wix,>T~~~X~>S. i=l

2.2

Some Properties

i=l

of Weighted Medians

In this section, we shall only list three simple properties, and yet, powerful, of W M filters which will be used in the heuristics developed in Section 4. Notation:

The following notation will be used: W and 1 denote two general positive integer-valued weight vectors. The nth smallest weight in W is denoted by IV(,), n = 1,2, . . ., N, such that W(r) 5 W(z) < * *. 5 W(N). XN)’ denotes a binary column vector. x=(x1,x2,*“, 1: Consider

Property

i = l,..., o-l&

46

two W M filters defined by W = (WI, W2, . . . , WN) and 11 = (VI, V2,. . . , VN). If Wi = crFs:,for

N, where CYis a positive real number, then JJ and v define equivalent W M where cy = gcd(Wr, wz, . . . , WN), define equivalent filters.

filters.

In particular

W and

Property 2 [5]: The W M filter associated with the weight vector W, is a Standard Median (SM) if and only if the sum of the k + 1 smallest weights exceeds the sum of the k largest weights.

Consider two weighted median filters WMl and WM2 with weight vectors.? and v, respectively. If Property 3: WM2 is known to be equivalent to some WM3 with weight vector c and there exist positive real numbers m and q such that, for all i E {1,2,. . . , N}, Wi = -mK + qUi holds; then WMl # WM2. Note that the above property is a generalization of Property

4 in [5] when WM3 is a standard median.

4: [5] The W M

filters associated with weight vectors W and v are equivalent if W = m v + Q, such that I&i] 2 m, where m > 0 integer and Q = (Q, Q2,. . . , QN) is an integer-valued vector.

Property

x:1

3

Equivalence

of two Weighted

4 is given as follows.

For binary inputs, an equivalent definition to Definition Definition

5: Two Weighted Order Statistics, WOSl

Medians

= (PJ, T) and WO&

iff(X1,X2,...,XN)=g(X1,Xa,...,XN)

= (v, S), are equivalent

forallX=(Xi,X2,...,XN)1XiE{0,1};

where 1, ifWIX1+WzXZ+...+WNXN

>T

(1)

f(Xl,X2,-,XN)=

otherwise;

0,

and

1,ifKxl+h/2x2+...+vNxN>s

(2)

g(xl,x2,-,xN)=

0, This can be expressed also in the form of WOSl that:

otherwise. # WOS2

if and only if there exists X = (Xl, X2, .

wlx,+w2x2+...+wNxN

,

XN) such

T

(4

and &XI

+

+. . . + VNXN

EJ2

Theorem: One can say whether two weighted order statistic filters WOSl by solving the two optimization problems:

minimize :

WlXl

subject to :

VlXl

< S.

= (VJ’, T) and WOS2 = (If, S) are the same

+ W2X2 + . . . + WNXN

(5) +

E!x2

+

. . .

+ Klx71 2 S, Xi E (0, l},

and

47

minimize : subject to : Proof: &‘)

&XI

+ V2X2 + . . . + VNXN

(6) w1x1+

w2x2

+

. . . +

WNXN

2

T,

Xi

E

{O,l}.

Suppose WOSl # WOS2 then there exists either: E (0, l}N such that: --W X(l) < T and --V X(l) >- S,

or -Xc2) E (0, l}N such that: --V Xc21 < S and --W Xc2) 1 T, implying that either any solution x*

of (5) satisfies:

or any solution X* of (6) satisfies:

On the other hand, let Xc’) be a solution of (5) and Xc2) be a solution of (6). If either W X (l) < T or --V Xc21 < S then WOSl # WOS2. Thismeans that the complexityf deciding whether two WOS filters are equivalent is at most the complexity of the optimization problems (5) and (6). On the other hand, suppose that we have a method which can determine whether (1) and (2) are the same and also, if not, it gives a solution of (3) and (4). We intend to show that with this information we can find a solution to (5). This means that the complexity of deciding whether two WOS filters are the same and finding vectors for which they differ is at least as complex as (5), which for arbitrary weights is known to be NP complete. Suppose that we want to solve (5). Let us form a sequence of problems of the type (WOS1 = WOS,?). Denote Let us suppose that c w = Kaam and consider the equivalence problem of (lV, Y) and (1, S), where 1 5 Y < Y,,,. the method deciding the equivalence of WOS filters gives the answer in the following vector: p(Y) = (Ziy), Zr)), where

z$y)=

1, if (W, Y) = (V, 8 0,

otherwise,

and

z2

(Y) =

1, 0,

if there exists X such that W X < Y and v X 2 S otherwise.

Now, if Yopt is the solution of (5) we can say that: p(Y) = (L*)> ( w h ere * can be 0 or 1) implies Yopt 5 Y, (4 (ii) p(Y) = (0, l), implies Yopt < Y, (iii) p(Y) = (0,O) implies Yopt 2 Y. Obviously, armed with the information given by (i)-( iii ) we can use a bisection algorithm YA,,) steps.

48

and solve (5) in O(log,

4

Solving

the Equivalence

Problem

using

Heuristics

In this section, we present seven elementary procedures (which are efficient in several cases) to solve the equivalence problem of two WM filters. These procedures are listed below according to the increasing complexity required for their implementation. Here, we assume that: WMl and WM2 are weighted median filters associated with the integer weight vectors W and v. The width of the filter window is N = 2k + 1, where k > 0 integer. The sum of the weights is odd. We use the procedure sort(z) to sort a given vector X in ascending order. Heuristic 1 (Procedure Identical) Here we check if the two vectors W and v are the same. procedure Identical begin OK = true RATIO1 = WJVl

For i=2 to N do begin RATIOi = Wi/G RATIOi # RATIO1 then OK = false if OK = true then WMI is equivalent to WM2

if

else GOT0 end

Heuristic 2

2 (Procedure Standard-Median) Heuristic Here we verify if one or both of the weighted medians are standard medians using Property The following procedure checks if a given vector corresponds to a standard median. procedure SM(&) begin OK

t.

= true

sort(x) sum1 = 0 sum2 = 0

for for

i=l to k+l do sum1 = sum1 + X(i) i=k+2 to N do sum2 = sum2 + X(i) if sum1 2 sum2 then OK=false sum = sum1 + sum2

end The main procedure of Heuristic procedure Standard-Median begin fW.Y)

2 is listed below.

A=OK Wsum = sum Tl = (Wsum + 1)/2

SMW B = OK Vsum = sum T2 = (Vsum + 1)/2

if NOT(A OR B) then WMI is equivalent to WM2 else if ((NOT A AND B) OR (A AND NOT B) then else GOT0 Heuristic 3

and both of them are SM. WMl

is not equivalent to WM2

end Heuristic 3 (Procedure Negative-Product) This heuristic checks if the two WM satisfy the conditions of Property 3. If so, they are not equivalent. procedure Negative-Product

49

begin OK

= true,

A = true

i=2 Repeat if(((wi = Wr)AND(Vi # Vl))OR((Wi then OK = false ; A = false else if (K # VI) then A = false else i = i + 1 until (((OK AND A)=false)

# Wl)AND(K

= VI)))

if (OK OR A )=false then Goto heuristic 4. if (OK OR A )=true then begin m =

WI-Wi-1 Vi-1-Vi

if m is integer then q=

W~+mV~;

begin OK

=true

for i=2 to N if Wi + rnK # q then go to Heuristic 4 end else if m-l is integer then begin q = VI + m- ’ WI for i=2 to N if V; + mm1 Wi # q then go to Heuristic 4 end if OK = true then WM1 # WM: end end Heuristic 4 (Procedure Positive-Product) According to Property 4, we can say that two WMs are equivalent if Wi = rnVi + Qi, where m > 0 integer and &i = (QI, Q2, . . . , QN), with Qi integer for all i E {1,2,. . . , N}. We are looking for m > 1 because if m=l, then the unique solution to CE, I&ii < m is Q = (O,O, . . . ,O); thus, W = 1, which can be detected by Heuristic 1. Procedure Positive-Product begin m = int(Wsum/Vsum); { w h ere int(z) is the integer part of the real z} ifm>l then begin Label 1: for i = 1 to N do Qi = JWi - rnVil

then WM1 ifCE,Qi 1 then Goto Label 1 else Goto Heuristic 5 end end Heuristic 5 (Largest-weights-sum) Here we compute the minimum sum of the largest weights Wi which exceeds the threshold T, then check if the sum of the corresponding E’s is less than the threshold S. If yes, then WM1 # WM 2; else, repeat the procedure with the x’s and the corresponding Wi’s. If there is still no conclusion, go to Heuristic 6. Procedure Largest-weights-sum begin i=

N;Wsum=O;Vsum=O

Repeat Wsum

50

= Wsum

+ WC; Vsum

= Vsum

+ vi

i&l until Wsum 2 Tl if Vsum < T2 then WA41 # WM2 else begin i=N;Wsum=O;Vsum=O

Repeat Wsum = Wsum + Wi; Vsum = Vsum i=i-1 until Vsum 2 T2 if Wsum < Tl then WMl # WM2

else Goto end

+ Vi

Heuristic 6

end Heuristic 6 (Procedure Ratios) Here we sort the ratios, RATIOi = (Wi/E), and if RATIO(k+l) _> 1, we take the sum of the weights in W corresponding to the nr largest ratios, which exceeds the threshold Tl, and check if the sum of the nr corresponding weights in 1 exceeds the threshold T2. If yes, then we can not conclude; else, WMl # WM2 . Otherwise, if RATIO b+l) < 1, then take the sum of the weights in v corresponding to the ni smallest ratios, which exceeds the thresh01 6 T2, and check if the sum of the nr corresponding weights in W exceeds the threshold Tl. If yes, then we can not conclude; else, WM1

# WM2

.

Procedure Ratios begin sort(RATI0) and re-order ,I&’and v accordingly if RATIOck+l) 2 1 then begin i= N; repeat Wsum = Wsum + W(i) * the elements in & and v are re-ordered according to the order in RATIO* i=i-1

until

NWsum 2 Tl if eIs5j=i+l v(j) < 7’2 then

WMl

# WM2

Goto Heuristic 7 end else begin i=l repeat Vsum

= Vsum

+ V(d)

i=i+l Vsum 2 T2 until then if xi=: W(j) < Tl else Goto Heuristic 7 end

WM1

# WM2

end Heuristic 7 (Procedure Recursive-search) Here, we try to find a subset of {1,2,.+., N} which contains the indices of the smallest weights Wi whose sum exceeds the threshold Tl. Then with some permutations we try to find a new subset for which the sum of the weights Wi exceeds the threshold Tl while the sum of the weights K is less then the threshold T2. If not successful, replace W by y and Tl by T2 and repeat the above procedure. Let M = {1,2,..., N}, where N = 2k + 1. Sort W in ascending order and re-order y accordingly. Procedure 7 Recurcive-search begin Wsum=O;i=l;Vsum=O

repeat Wsum Vsum

= Wsum + Wj = Vsum + vi

51

i=i+l until Wsum 2 Tl nr=i-1 Let L = {1,2,..*, 121) and M = M - L WMl Label 2: if Vsum < T2 then is not equivalent to WM2. begin else sort(Vi) and re-order Wi accordingly, i E L if there exists Vj < Vk = msz(E), i E L, and j E M then begin L = L - {k} + {j} Wsum = Wsum - Wk + Wj Vsum = Vsum - Vk + Vj M = M - {j}

Label 3: if Vsum < T2 then WMI is not equivalent to WM2 end else begin if there exists 1 E L, WI = min(Wi), f or which Wsum - Tl 2 Wi holds, i E L then begin L = L - {I} Wsum = Wsum - Wl Vsum = Vsum - V$

Goto Label 3 End else Goto Label 2 end end end

4.1

Examples:

Seven examples are provided in this section. Examples l-7 are solved by Heuristics 1-7, respectively; while, all seven heuristics fail to yield a definite conclusion for example 8. Note that the seven heuristics follow a hierarchy of increasing computational complexity. Furthermore, the example given to illustrate a particular heuristic fails to be solved by the previous heuristics, e.g. example 4 cannot be solved by Heuristics l-3. Heuristic 1 w,

= (3,3,9,3,3)

IL1 = (1>1,3,1,1> VV, = oKi,

where a = 3 and hence WMI

= WM2.

Heuristic 2 W, = W&45) X2 = (5,6,7,8,9> v2 corresponds to a Standard Median; while W2 does not; hence WMl Heuristic 3 W, = (4,5,% 7>9), &

52

= (18,15,12,9,3).

# WM2.

Since E = -3 Wi + 30, for i E {1,2,. . . ,5}, WM1 # WM2. Heuristic 4 w, &

= (2, I, 4,3,5)>

= (21,10,37,32,51), 6

&

= IO&+&,

I&ii < 10, where -Q = (l,O, -3,2,1).

i=l

Therefore, WM1

= WM2.

Heuristic 5 b& = (20,24,25,27,43),

where Tl = 70,

KS = (44,26,23,27,45),

where TZ = 83.

Since the sum of the two largest weights in W exceeds Tl; while the sum of the two corresponding weights in 1 does not exceed T2, WM1 # WM2. Heuristic 6 &

= (5,7,3,2,

Is

S), where TI = 12,

= (1,5,2,3,4),

RATIO

where T-J = 8,

= (5,1.4,1.5,0.66,1.5).

Since the sum of the three weights in W corresponding to the the three largest ratios exceeds Tl; while, the sum of the corresponding weights in y does not exceed TX, WM1 # WM2. Heuristic 7 I&

= (20,24,26,35,36,39,45),

I& = (40,50,50,62,65,40,

where TI = 113,

loo), where Tz = 204.

It is straight forward to verify that none of the previous heuristics (Heuristics l-6) yields a definite solution to this example. Furthermore, one can check that Heuristic 7 can successfully solve this problem. It actually makes one swap inside Label 2 and one “trimming” inside label 3 and concludes that WM1 # WM2. The following example goes through all these heuristics and the problem is still not solved. IV, = (5,7,9,21,45,59,61),

where TI = 104,

&

where T2 = 109.

= (6,8,12,20,47,62,62),

53

5

Conclusion

Several authors have been reporting “optimal” weighted order statistic filters under some error criterion in their papers. Especially, when these optimal weights are real-valued, it is a non-trivial problem to verify if two of them are equivalent. This is the problem we tried to solve in this paper. Although our results are derived for integer-valued weights, some can easily be extended to real-valued weights. Keep in mind that each real-valued weight WOS filter is equivalent to an integer-valued weight WOS filter. In this paper, we showed that the equivalence problem of two WOS filters requires the use of integer linear programming. This being an NP complete problem, we developed several heuristics which can solve this problem efficiently in many special cases. Current research aims at developing more sophisticated, and yet efficient, heuristics. One approach in this direction is based on a sensitivity analysis of the weights. The results shall be reported elsewhere.

References [l] J.W. Tukey,“Nonlinear

(Nonsuperposable)

[2] B.I. Justusson, “Median filtering: Ed., Springer-Verlag, 1981.

methods for smoothing data”, Cong. Rec. EASCON’74,

statistical properties,”

Two Dimensional

[3] D.R.K. Brownrigg, “The weighted median filter,” Communications 1984. [4] J. Nieweglowski, M. Gabbouj, and Y. Neuvo, “Weighted Processing, Vol. 39, No. 2, 1994. [5] M.K. Prasad and Y.H. Lee, “Weighted median filters: Circuits and Systems, 1989, pp. 425-428. [6] P.D. Wendt, E.J. Coyle and N.C. Gallagher, Jr.,“Stack ASSP-34, No. 4, pp. 898-911, August 1986.

54

Digital

of the ACM,

Signal Processing

p. 673, 1974. II, T.S. Huang,

Vol. 27, No. 8, pp. 807-818, August

medians- positive Boolean functions conversion,“Signal generation and properties,” filters,” IEEE

Trans.

Proc.

of IEEE

Int.

Symp.

ACOUS., Speech, Signal Proc.,

on

Vol.