• No results found

Steering using a Separable Basis Set

GLT^{t,r,a) = and

Chapter 4 Optimisation

4.5 Steering using a Separable Basis Set

The previous section showed th a t separable filtering has significant computational advantages. This section dem onstrates th a t it is possible to construct the oriented derivative of a filter from a basis set of purely separable filters (and again, from equation (4.17) this is also true for the responses). Additionally, some new expressions are derived for the weights and the separable filters required, w ithout using singular value decomposition or m atrix methods [FreemanQl]. Instead, in order to determine which separable basis filter responses are required to construct an oriented derivative filter, we use the directional derivative [Barr96]:

D f{ p) ü ^' 7f { p) - ü (4.18)

where D is the derivative operator acting on the circularly symmetric function f{p) , at a location p , in the direction given by the unit vector ïï and V is the gradient operator. It is im portant th a t f{p) is circularly symmetric since we are rotating the derivatives of this function, not the function itself. The unit vector ü can be expressed in terms of an orientation 6 with respect to the x-axis of the Cartesian coordinate system:

where i and j are unit vectors in the x and y coordinate axes directions. It is also useful at this point to define a unit vector orthogonal to ü {6) :

u^{9) = —i sind + j cos 6 (4.20)

We now have the m athem atical apparatus to determine the first order derivative of a function in any direction, expressed purely as a scalar sum of derivatives in the i and j directions. For example, the first order derivative of the Gaussian 0{x,y) in the direction

u{6) is given by:

DG{x,y)u{e) =WG{x,y)-u{6) i \ \ (i cos6 + jsm6^ (4.21) dG{x,y) Ç , dG{x,y) V * “r J dx dy dx dy

This shows th a t the first order x-derivative, rotated clockwise by an amount 6 , can be expressed as a weighted sum of the first order x and y derivatives, i.e:

DG(x,y)u =Gl(x,y)

= kfi^{x,v) + k^G^(x,y) (4.22)

where = cos 6 and = sin 9. An example of steering this derivative through

45degrees is shown in figure 4.2. For higher order filters the situation is more complicated and the benefits of using a separable basis set become clearer.

F ig u re 4.2 F ro m a linear co m b in atio n of th e tw o, first o rd e r, se p arab le G au ssian d eriv a tiv e s a n d {left+center) th e first o rd er d eriv a tiv e of a G au ssian ta k e n a t an y o rie n ta tio n can be sy n th e sise d , {right)

Steering Higher Order Derivatives

We can substitute the directional derivative back into equation (4.18) to obtain higher order directional derivatives, th a t is, we can define a new function/'(p) = V/(p) • ü thus:

D J ( p ) u = V ( / \ p ) ) - ü

= V ( V / ( p ) - 5 ) - û (4.23)

We can continue in this manner for arbitrarily high orders of differentiation by successive substitution. This enables us to calculate an oriented derivative of any order. For example, the second order derivative of Gaussian G{x,y) in the direction u{9) is given by:

%/)ü = V (V G(z, %/). ü (^ )). Ü

substituting our result from (4.22) for the term in brackets and staying in simplified derivative notation gives:

Dg G(z, y)ü = V cos g + Gy sin g ) . E

= (Gg^ cos 0 + sin 6>) + j ( g ^ c o s 9 + G^^ sin 6>jj • (z cos 6> + j sin (9) = Gg^ cos^ 9 + Gyj. sin 0 cos 0 cos 9 sin 9 + G^^ sin^ 9

since the order of performing partial differentiation does not m atter, i.e. , we can write:

= G.2x

^\^2x +^2^2y (4.24)

where cos 9 and = sin 0 . This expresses the second derivative of a Gaussian

rotated though an arbitrary angle in terms of a linear superposition of three separable Gaussian derivatives (figure 4.3). A complete set of steering functions for the separable basis filters of up to third order is given in Appendix D.

F ig u re 4.3 F ro m a linear co m b in atio n of th e th re e , se p arab le G au ssian d eriv a tiv e s a n d

{ to p ro w) th e second o rd er d eriv a tiv e of a G au ssian G j^ ta k e n a t a n y o rie n ta tio n can be sy n th e sise d ( b o t t o m ) . A ny of th e filters in th e to p row can be sy n th e siz ed a t an y o rie n ta tio n u sin g a co m b in atio n of itself and its neighbors.

Crossed D erivatives

Crossed derivatives such as G^{x,y) contain derivatives in both orthogonal

directions and so require the use of both orthogonal directional derivatives u{6) and u^{9). The calculation proceeds similarly to th a t of higher order derivatives, although now the correct directional vector must be used. For example, if we wish to calculate the oriented version of Gj^{x,y) we use:

D {DG{x, y)ü) = V ( V G{x, y) • ü{9)) ■

Again, we can substitute for the term in brackets on the right hand side with the result obtained in equation (4.22), thus:

D [ D G { x , y)u)u^ = V (cos{9)Gj. + sin{9)Gy ) • u_^

= {G^^c o s 9 + Gyj.sin 0 j + j (g^ c o s 9 + G^^sin 0 jj • z sin 9 + jcos 9^ = —G^^sin 9cos 9Gy^sin^ 9 + (7^ cos^ 9 + G^^sin 9cos 9

again, since G ^ = G y^, we can write:

D(DG(x,y)ü)ü^ = G l

- + (*1 “ *^2) ® ! 0 + (4.25)

where = cos 9 and = si n 9 .

We notice th a t the same second-order basis derivatives are required to generate the oriented responses to both G^{x,y) and G^^{x,y) ^ w ith only a change in the relative weightings of the basis elements. It is easy to observe th a t for a derivative of total order D, all of the separable derivatives of th a t order are required to generate an oriented response, th a t is:

(4.26)

For example, steering the third order Gaussian derivative G^^{x,y) requires a weighted addition of all the separable filters , G^.^^ (x, y) and (x, y) . These separable basis filters and an oriented filter synthesised from them are shown in figure 4.4. A complete set of steering functions for the separable basis filters is given in Appendix D.

G. i x ■10 G 2xy ■2yx

F ig u re 4.4 F ro m a linear co m b in atio n of th e four, th ird o rd er, se p arab le G au ssian d eriv a tiv e s {top 2 rows) th e th ird ord er d eriv a tiv e of a G uassian (e.g. G.^^ ) ta k e n a t a n y o rie n ta tio n can be sy n th e sise d {bottom). A ny of th e filters in th e to p rows can be sy n th esized a t a n y o rie n ta tio n using a co m b in atio n of itself a n d its neighbours.

We are now able to generate any of the oriented spatial filters used by the model from a weighted sum of filters in the basis set. From the linearity of the convolution operation shown in equation (4.17) we can also synthesise the responses to these filters. We can calculate the reduction in the number of operations by employing this separable basis set filtering scheme. By using separable convolution to generate the basis set of responses we decrease the number of operations considerably, from using m ultiplication’s to 2 n, where n is the filter size.

Filter Order Normal Convolution Basis Generation Separable Basis Generation Steering 1 6656 277 24 13 2 9985 416 36 19 3 13313 555 48 25 4 16641 693 60 31 5 19969 832 72 38 6 23297 971 84 44 Total 89861 3744 326 170 Percentage of Normal 100.00 4.17 0.36 0.19

T a b le 4.4 M illions o f o p e ra tio n s req u ired to g e n e ra te th e resp o n ses for 24 o rie n ta tio n s on a 512x512 im age u sing filters of size 23x23. T h e ste e rin g (lin e ar re c o m b in a tio n of basis filters) o p e ra tio n s m u st b e ad d e d to th e basis se t g e n e ra tio n o p era tio n s. T h u s th e to ta l n u m b e r of o p e ra tio n s for se p a ra b le basis g e n e ra tio n & ste e rin g is 3 2 6 + 1 7 0 = 4 9 6 (0.55% ), alm o st 200 tim e s fa ste r th a n n o rm a l co nvolution.

We can estimate the increased efficiency of using the steering algorithm in the McGM. Table 4.4 shows the number of operations required by the standard convolution method, the two basis set generation methods and the steering algorithm. These results show th a t the separable steering method devised here can produce all the filters required by the McGM and will cut down the processing by at least a two orders of magnitude. The implementation of this scheme is explored in C hapter 5.