A parallel implementation of the SCAN language

A parallel implementation of the SCAN language

Comput. Lang. Vol. 14, No. 4, pp. 239-254, 1989 Printed in Great Britain. All rights reserved A PARALLEL 0096-0551/89 $3.00+ 0.00 Copyright ~ 1989Pe...

801KB Sizes 17 Downloads 181 Views

Comput. Lang. Vol. 14, No. 4, pp. 239-254, 1989 Printed in Great Britain. All rights reserved

A PARALLEL

0096-0551/89 $3.00+ 0.00 Copyright ~ 1989PergamonPress plc

IMPLEMENTATION

OF

THE

SCAN

LANGUAGE* NIKOLAOS G. BOURBAKISl, CHRISTOSALEXOPOULOS2 and ALLEN KLINGER3 ~Department of ECE, SITE Machine Vision Lab, George Mason University, Fairfax, VA 22030, U.S.A. 2Department of Computer Engineering, University of Patras, 26500 Patras, Greece 3Department of Computer Science, University of California at Los Angeles, CA 90024, U.S.A. (Received 26 July 1988; revision received 30 March 1989)

A~tract--SCAN is a special purpose context-free language which describes and generates a wide range of array accessing algorithms from a short set of simple ones. These algorithms may represent scan techniques for image processing, but at the same time they stand as generic data accessing strategies. In this paper we present two schemes (one sequential and one parallel) which implementthe SCAN language and compare their memory requirements and execution time. Picture processing Scanning techniques Special purpose languages Parallel implementation

1. I N T R O D U C T I O N Images manipulated by digital computers are commonly stored as rectangular arrays of numeric values; the values are usually integers representing points on some grey scale and are, not uncommonly, simply Boolean values indicating the presence or absence of a picture element at that location in the image. Picture processing algorithms modify the digital image by changing the numeric values. Each pass of an algorithm usually processes all image elements sequentially, normally in "left-to-right" and " t o p - t o - b o t t o m " (raster scan) order. We call this linear scanning below. However, some algorithms are much more effective if other scan orders are used [1-4, 6, 7, 10, 11, 14, 22]. M a n y authors have found recursive scanning better than linear for object and symmetry detection, and there is a large literature on pyramid data structures [2, 4, 6, 8, 10, 11, 12, 14, 15]. Since there are (n x m)! scan orders for an n x m image, specifying a specific one seems an herculean task. However, this paper presents a new and simple notation (the S C A N language [5, 9, 20, 23]) to describe complex scans by hierarchies of simpler ones. The notation can be expressed by a trivial g r a m m a r and so is easy to parse. More important, constructed two algorithmic schemes, which when given a SCAN description, can efficiently construct the scan order. We compare these two algorithmic schemes (one sequential and one parallel) for m e m o r y space and execution speed, and conclude that the parallel algorithmic scheme is both more interesting and more useful. This paper is organized into six sections. In Section 2 we provide some interesting scan orders, and an example of an interesting image processing algorithm which requires a non-trivial scan order. In Section 3 we present the description of the S C A N language. In Section 4, two implementation schemes for the S C A N language are discussed and illustrative examples are provided. The complexity of the sequential and parallel algorithmic schemes is discussed in Section 5. The last section summarizes the overall presentation.

2. S C A N O R D E R

APPLICATIONS

This section describes several non-standard scan orders (scannings) used in image processing, with illustrations of their possible advantages. The purpose is to illustrate the development and utility of the S C A N language. *This work is part of the SCAN Research Project. CL 14 4--B

239

240

N1KOLAOS G. BOURBAKISet al.

"~7

/

(a) ;

//

"/"'-'/"

~-

"/

-"

P

1

2

5

6

.-

3

4

7

8

)

9

10

13

14

-~

11

12

15

16

:

16

15

14

13

I

5

4

3

12

"-" "-"J

6

1

2

11

~

7

8

9

10

1

2 5 6

4

3

8

7

1:3 14

9

10

16

12

11

(b)

(d) 1

2

3

4

5

6

7

8

9

10

11

12

13

14

1.5 16

/

]

--%.(c)

~-~

r I

~

'

4- -~'~1"-=

"1

15

Fig. 1. Graphical representation of four scan orders for an image P(4,4). (a) ZETA scan order; (b) SPIRAL-OUT scan order; (c) R I G H T - B R A C K E T scan order; (d) RASTER scan order.

2.1

Object detection [4, 8, 21]

Four different scan orders, ZETA, SPIRAL-OUT, R I G H T - B R A C K E T and RASTER are illustrated by Fig. 1. We postulate that the image is binary containing an object and an object detection algorithm is to be implemented. We initially assume that the object is located in nine different square regions of (n/2) × (n/2) size, where n x n is the size of the image, as shown in Fig. 2(a). We apply sequentially each scan order to these nine different cases in order to detect and scan completely the dark square regions, which contain the object. Figure 2(b) shows graphically an image P(n, n) scanned by the RASTER scan order, where the dark area is located at the northern part of the image. The RASTER order touches firstly the dark area after (n/4 + 1) steps and completes its scanning after (n/2) × ( n - 1/2) steps. The results of the above scanning processes showed that the ZETA and SPIRAL-OUT scan orders occupy the first place with a 55.5 coefficient of success, by finding the dark regions in less steps and scanning them completely in less number of steps as well. The R I G H T - B R A C K E T scan order was second with 52.2 and the traditional RASTER scanning was third with 43.0 coefficient of success.

2.2 Implementation of image pyramid data structures [8, 11, 19, 22] The pyramid data structure is suitable for containing (or representing) an image or images in a hierarchical mode for picture processing, such as edge detection, planning, orthogonal transformations, segmentation, etc. [8, 19]. In particular, an image P(n, n) can be expressed in a pyramidal form by applying recursively on its elements a transfer function (i.e. average) f(a, b, c, d) = a', where a, b, c, d, e, P~(n/2 i, n/2 i), pi represents the image transformed at the i-level of the pyramid, and a' eP i- i (n/2 i + i, n/2 i + 1) with 0 ~
A parallel implementation of the SCAN language

241

(a)

NW

NE

SE

N

SW

S

W ~

~ E

~CentraL

(b)

First touchpoint

\N

I

Last scannedpoint Fig. 2. Nine different locations of an object in an image area. The dark regions contain the object. (b) The northern dark region scanned by the RASTER scan order.

where Gn(L) represents the SCAN language [20]. Note that, the selection of different scan orders, which constitute a SCAN word, generate different versions of the exponential pyramid [23]. The elements of the pyramid are stored in consecutive memory locations of the PYRAMID array. Figure 4 shows graphically the structure of a one-dimensional pyramid (PYRAMID array) generated by the SCANPAV algorithm. The elements of the i-level of the exponential pyramid are ordered by the (L,a, ~ L2a2 =~... L~a~) scan orders. When the number of the pyramid levels is

l•'O bottom- up

/

(~ (n/2i)x (n/2 i } /

"" (n/2°)x (n/2 ° )

/ - -

9

Level- 0

~

Level-i- 1

"=

tevel-i

Level-(Log2(n))

Fig. 3. Pyramidal representation of an image P(n, n).

242

NIKOLAOS G. BOURBAKISet al.

,

I

-..lll...lllll--.ll Level-t: The elements of the picture after the G (wt) scanning

I ... I I1.-.1

Level-l: Elements ~ at the level-1 Level-(t-1): Average at the ( t - l ) level

Level-O: Top of the pyramid

Fig. 4. Graphical representation of the one-dimensional pyramid for the SCAN word L I a= # . . . # Lta t.

t = log2(n), then a i = 2, Vi, and the PYRAMID array contains (4n 2 - 1)/3 memory locations [8, 19], and the SCANPAV general algorithm becomes the same with the ZPAVER algorithm [1 I, 22], which generates the exponential pyramid of the average intensities of an image P(n, n) by using only the ZETA scan order. Figure 5 shows graphically the four levels pyramid of an image P(8, 8) by using the ZETA scan order. Thus, the implementation of the exponential pyramid of an image P(n, n) requires only an appropriate scan word-length log2(n) and the use of the SCANPAV algorithm, without to be necessary writing specific algorithms to do it. For better understanding, we provide an example of a pyramid generated by the C2 ~ R2 ~ X2 SCAN word using the SCANPAV algorithm, as illustrated in Fig. 6. The main advantages of the SCANPAV algorithm scheme are: (i) no recursive process is required for the appropriate reordering of the image elements; (ii) less memory space is used for the storage of the image pyramid elements; (iii) simpler implementation of any exponential pyramidal version of an image, note that the ZPAVER pyramid can be generated by the SCANPAV scheme using the SCAN word Z2 ~ Z2 ~ Z2; (iv) the P(n, n) image can be transformed into a flexible tree-structure, using the SCAN words, appropriate for further processing, such as Regular Decomposition, WH transformation, Symmetries detection [8, 11, 18]. 3. SCAN L A N G U A G E [9, 20, 23] In this section we describe briefly a specific SCAN alphabet, the syntax and semantics of the SCAN words and an illustrative example in order to explain the use of the SCAN words.

Algorithm S C A N P A V { Scan image 1). using a S C A N pattern w ~ G . ( L ) size,=

~ (a, az . . . ai)z -~- 1 i=1

Declare array P Y R A M I D (1..size) Input the n 2 image values from a ( w t ) scanning and store them into the n 2 first locations of P Y R A M I D : num_of_/ev,=length (w); / / d e f i n e number o f levels in pyramid// npnl'.=n2 / / n p n l : number of points at next level// last~ooint,=n 2; //points last element o¢ current level in P Y R A M I D / / first,=1 ; last,=a~; //first and last point first and last element of an image region respectively// k ==last_point; for 1 ,=num_of_lev d o w n t o 1 do [ num_of~ooints,=a~:

for point,=1 to num_of_points do [

average,=O;

for j,=first to last d o

] ]

]

average ,=average + P Y R A M I D ( j ) ; k ==last~point + 1 ; P Y R A M I D (k ),=average /num_of_points; first,=last + 1 ; last,=last ÷ num_of_points;

npnl:npnl/a 2 last_point,=last~point + npnl

A parallel implementation of the SCAN language

243

[El 81~ 82 8.% 84

p9~7o 67 ';I "-72

93"66

/

r~'~6

79~ 80

.--3,6

[~1 _ L 3 "~

.~

='8 ~19 ~ 0

/

9._ ;(o

,,o 2, 22 23 24

/

13 j 4

2~ 26 29 30

IL

11

12

13

16 27 28 ,51

52

i

~3

34 37 38 49

50153

55

36 39 40

51

52

41

42 45

46

57

,58 61

43

44 47

=1.8 59 60

54

55 56

63

62 64

Fig. 5. A four level pyramid for a picture P(8, 8) using the ZETA scan order.

3.1 A specific SCAN alphabet The SCAN alphabet used here consists of 15 SCAN items (or letters, or scan orders). Figure 7 provides graphically these items, where a scan order can be specified in a straightforward language with loops and tests. In the SCAN alphabet Z, each item is represented by a specific symbol as follows: E = [R, C, D, E, A, I, O, L, S, H, Y, W, Z, B, X] where R C D E A I O L S H Y

is is is is is is is is is is is

the the the the the the the the the the the

R A S T E R scan order C O N T I N U E D R A S T E R scan order D I A G O N A L scan order D I A G O N A L W I T H P A R A L L E L R E T U R N S scan order R I G H T O R T H O G O N A L scan order SPIRAL-IN scan order S P I R A L - O U T scan order C O N T I N U E D O R T H O G O N A L scan order V E R T I C A L S Y M M E T R I C BY ROWS scan order V E R T I C A L S Y M M E T R I C BY C O L U M N S scan order M A I N D I A G O N A L S Y M M E T R I C scan order

NIKOLAOS G. BOURBAKISet al.

244

80 ";81tpI 83, 182

64 ~

65

"67

66 / T6

/

0

2

3

I

/

~

/

70 /

~ 77

/ i

7 8 '"

68

/

/ /

, 71

72 •

" 79

,~ 6 9

/

J, 7 3

//

74 /

• 75

4

6

16

18

7

5

19

17

20

//

/

8

.10

,/

12

14

24

// 2:3

21

28

30

31

29

36

38

/ 39

37

44

46

47

45

/

26 J

11

9

15

13

:97

25

48

50

52

54

32

34

22

.

,= 51

49

'

55

53

//

35

53

/

4

/

/

56

58

59

57

/

60

62

40

42

63

61

43

41

/

Fig. 6. A t-pyramid of four levels for the image Ps, which was generated by the C2 ~ R2 ~ X2 SCAN word (or scan order). The numbers represent the consecutive numbering of the scanned cells.

W Z B X

is is is is

the the the the

D I A G O N A L S Y M M E T R I C BY S E C O N D A R Y L I N E S scan order Z E T A scan order R I G H T - B R A C K E T scan order XI scan order

3.2 Definition of the SCAN language The S C A N language was defined as a context-free language [9, 20]. DEFINITION: A S C A N word wt is a sequence of scan orders,

w t = L l a m# L2a2 ~ . . . # L t a t where, ai is a number power of two and (a~) is the number of the elements scanned by the L i s c a n order, 1 ~< i ~< t --- log2(n). Each S C A N item Li is the name of a basic scan order (for example X, D, or Z) followed by an integer number a~ which is a power of 2. The items in a S C A N word are separated by the punctuation m a r k " # " , which also plays the role of the connection operator between S C A N items. An example of a simple S C A N word is: R2 # C4 # X2. It is obvious that a simple g r a m m a r G can be written for the S C A N words [20].

A parallel implementation of the SCAN language

(b) Letter C

( a ) Letter R

245

(C) Letter D

;///



(d) Letter E

:

i

(e) Letter A

( f ) Letter I (spirat in)

---t-'I. I ,._c .~J, . ~ / /

. . ' ~ ' N' "N

(g) Letter 0

(h) Letter L

i ) Letter S r--F ~ - ~ F 7-I _r_ .....

"4-

k) L e t t e r Y

LetterH r-~

,

j

I I/

i

I

.

.

.

.

.

.

J

(I.) Letter W

~7.--2.-2

I

17 2 if,~

q

= L .

(j)

i

-~ ~

f

i~-~

P-1

l14

i It

I

'

o

n

[/

-"

~y I

f? ,;" 7 ej._z "

/

I

( m ) Letter Z

(n) Letter B

(0)

o

¢/IN~

/-~.

Letter X

f'

Z_/

-/ ¢-

.Z_./ -/ :

T2q

Fig. 7. Graphical representation of the SCAN letters.

A S C A N word can be described as a scanning pyramid. The first SCAN item (L, a0 describes the scan order to be used at the lowest level of the pyramid. The integer (at) describes the number of the image elements which are scanned by the L~ scan order. The second SCAN item (L, ~a~ ~) describes the first level of the pyramid above the image itself; the scan order (L~_ n) tells how to combine the blocks (image areas) scanned by the first (L~at) item. The integer (a,_ ~) describes the number, the scanning order and the location of these blocks in the image area. The remaining items (L~ai), i = (t - 2 ) , . . . , 1, are applied reptitiously by this way until a complete pyramid is built. The product [(a~)(a2)... (at)] = n of the powers of 2 must be the side length n of the original image.

246

NIKOLAOS G. BOURBAKIS e t al.

/

\

/

\ \ \ \ \ \ \

//

-

Si

II

/I / / i i

i

\

\

I

/I

\

\

I

I

\

i

//

/

Ii

i

Fig. 8. The S C A N pyramid for the R2 4~ C4 41=X2 word.

3.3 An illustrative example Considering the SCAN word w 3 R2 4t: C4 # X2. Figure 8 presents the SCAN pyramid structure for the above w3 SCAN word. In particular, the item R2 represents the RASTER scan order applied on the picture area in order to partition it in blocks, see the top of the pyramid. Moreover, the letter R defines the order by which these blocks of the image will be selected. The square of the coefficient 2 (of the R2 item), 2 2 = 4, indicates the number of these blocks at the original picture. In Fig. 8, the top level of the pyramid contains 22 = 4 blocks ordered by RASTER way. The second item C4, of the w3 word, represents the CONTINUED RASTER scan order, which is applied on each block previously defined by the R2 item. The C4 item partitions each block into more detailed sub-blocks. Moreover, the C letter defines the order of the sub-blocks in each block, see second level of the pyramid in Fig. 8. The square of the coefficient 4 (of the C4 item), 42 = 16, indicates the number of sub-blocks in each block. The last item X2 represents the XI scan =

---....

r"

0

64

64

" ""

80

" ' " 96

112

128

1 9 2 "'" 2 0 8

" "" 112

113

192

114

115

" ""

224

240

Fig. 9. The S C A N tree structure for the R2 # C4 ~ X2 word.

"'"

241

240

242

24:3

A parallel implementation of the SCAN language ~0 3 28 31 32 35 60 63 ~128 131 156 159 160 163 188 191

2 1 30 29 34 33 62 61 130 129 158 157 162 161 190 189

4 7 24 27 36 39 56 59 132 135 152 155 164 167 184 187

6 5 26 25 38 37 58 57 134 133 154 153 166 165 186 185

8 11 20 23 40 43 52 55 136 139 148 151 168 t71 180 183

10 9 22 21 42 41 54 53 138 137 150 149 170 169 182 181

12 15 16 19 44 47 48 51 140 143 144 147 172 175 176 179

14 - , 6 4 13 67 18 92 17 95 46 96 45 99 50 124 49 127 142 --,192 141 195 146 220 145 223 174 224 173 227 178 252 17"7 255

66 65 94 93 98 97 126 125 194 193 222 221 226 225 254 253

68 71 88 91 1O0 103 120 123 196 199 216 219 228 231 248 251

247

70 69 90 89

72 75 84 87

74 73 86 85

76 79 80 83

102 101 122 121 198 197 218 217 230 229 250 249

104 107 116 119 200 203 212 215 232 235 244 247

106 105 118 117 202 201 214 213 234 233 246 245

108 111 112 115 204 207 208 211 236 239 240 243

713 77 82 8'1 110 109 114 113 206 205 210 209 238 237 242 241

Fig. 10. The P(16 x 16) matrix ordered by the R2 ~ C4 ~ X2 word. order applied on each sub-block previously defined by the C4 item. In particular, the X letter orders the elements of each sub-block, see the lowest level of the pyramid. Note that, the elements of each sub-block are also elements of the original picture. The integer 2 indicates that, 22 = 4 elements are included in each sub-block. Finally, the elements of the image are ordered by the X scan order and the sequential orders, by which the X scan order is applied on the image sub-blocks and blocks defined hierarchically by the item of the SCAN word. An equivalent hierarchical representation of a SCAN word is the SCAN tree structure. The nodes of the SCAN tree represent the starting points (or drive points) from which the scan orders begin. In particular, for the previous example, the letter R uses 2 2 = 4 starting points (0, 64, 128, 192). These starting points represent also the upper-left point of each block generated by the R2 item, as shown in Fig. 10 with arrows. The second letter C uses 42 = 16 starting points for each block. The starting points, for the C4 item, are also the upper-left points of each sub-block. For example, the block 1 corresponds to the starting point 64 and contains 16 starting points ( 6 4 , 6 8 , 7 2 , 7 6 , 8 0 , 8 4 , 8 8 , 9 2 , 9 6 , 100, 104, 108, 112, 116, 120, 124), as shown in Fig. 10. Each of these 16 starting points corresponds to a sub-block of the pyramid structure. Finally, the last letter X uses the starting points of the sub-blocks in order to scan the elements of each sub-block. The SCAN tree structure for the above example is shown in Fig. 9. 4. I M P L E M E N T A T I O N

SCHEMES

In this section we present two implementation schemes for the SCAN language. The first scheme, called Sequential (or Nesting-Loops), uses each SCAN letter as a loop procedure and computes the trace by iterating itself at least once. The second scheme, called Parallel Expansion, generates each SCAN sequence according to a given combination of SCAN items, by using a number of expansion matrices [5]. 4.1

Sequential or Nesting-Loops scheme

The Nesting-Loops scheme embodies traditional ideas about how a 2-D array should be scanned. The algorithm, which implements the Nesting-loops scheme, receives as inputs: (i) the image region of k x k elements; (ii) the drive point dp of the image region; and (iii) the SCAN word w,. Then, it accesses the w t word from the left to right, which is similar to a top-down process shown in Fig. 11. In each step of this loop process, the corresponding image points are calculated and inserted in the S C AN tree structure, from the top to bottom as illustrated in Fig. 12. The output of the Sequential algorithm is a matrix of k x k elements, which its elements have been ordered by the w, word. Note that, the Nesting-loop scheme scans the elements of the output matrix directly as a "nesting-do-loop" procedure. The main part of the Nesting-loops algorithm is formulated as follows: "Given a starting (or drive) point v at a particular level j of the construction tree, then we apply the Lj scan order on the corresponding sub-region Pj(v)".

N[KOLAOS G. BOURBAKISe t aL

248

Algorithm of Nesting-Loop { procedure ScanRegion (M, dp); \\M: image region, dp: drive point\\ [Pop term Lia/ for current level; Compute set DP/ of drive points of current level j using a (L/a/); i f stack is empty \\drive points of DP/ are leaves\\ then \\scan them\\ insert DPi into output matrix else for v E DPi do \\scan region corresponding to v\\ ScanRegion (Pj(v), v ) ] ; ScanRegion(P, (1, 1)) \\scan the whole image P\\

}

Note that, the Nesting-loops algorithm requires i

I

1-Ia

j=l

calls of the scanning procedure Lj for the i-level, with the condition i/> 1 and aj/> 2. In particular, the pattern generated by the SCAN word R2 4# C4 4~ X2 using the sequential scheme (Fig. 11) requires: 4 calls for the RASTER procedure (R), 16 calls for the CONTINUED RASTER procedure (C), and 4 calls for the X procedure, in order to scan 256 picture elements. The Nesting-loops implementation scheme is characterized by its ability to insert 'drive' points directly into the output matrix, without the use of auxilliary storage. This means that, it requires a small storage space. The main cost, however, of the sequential scheme is the computational repetition of the same order applied at the same scanning level. 4.2 Parallel expansion scheme The parallel expansion scheme is based on a concept analogous to that of "windowing", by expanding matrices from the lower level into higher level ones. The principle of the parallel expansion scheme is directly derived by the expression of the product B ® A [20].

/

\

\

\

\ \ \

\

Do Loop for R2

"~"

1 1 D o Loop for C4 - -

L7;4]

ildrive ii points

(

Do Loop for X2

"i

/

i

/ /

Fig. 11. Graphical representation of the Nesting-Loops scheme for the SCAN word R2 4# C4 4# X2.

A parallel implementation of the SCAN language

249

P~(ori 6 ginalim . age) R

~

P

8(9,9)

P2(1'1)E

Fig. 12. The tree construction procedure for the SCAN order w~ = R2 ~ C4 ~ X2,

DEFINITION: Let Am, Br be two square matrices of sizes m × m and r x r respectively. Then the "expansion matrix" Erm is defined as:

Er~ = Br ® A m= ((A(i, j) + B(k, g))i,je[ml)k,qelrl, where the symbol ® represents the expansion operator. In order the generation of the E~m matrix to be understandable, a simple example is provided. Considering the w 3 = R2 4~ C4 # X2 word, then the matrix generated by the w3 word, by applying the parallel expansion scheme, is obtained by the following procedure: We take the item X2 of the w3 word. Then, the letter X generates the LS(X2) matrix by using the X scan order:

Then, we take the next item C4 generating the HS(C4) matrix:

HS(C4) =

0 7 8 15

1 6 9 14

2 5 10 13

3 4 11 12

At this point, we multiply the HS matrix by the integer (22). This integer is produced by using the square of the coefficient of the X2 item. Then, the new HS(C4) matrix is:

HS(C4)' =

0 28 32 60

4 8 12 24 20 16 36 40 44 56 52 48

Now, we "expand" the HS(C4)' matrix into E = HS ® LS, by "inserting" and "adding" the elements of the LS(X2) matrix into each e~jelement of the HS(C4)' matrix, by this way, we expand the % element into a "local" matrix: eiJ + 21] %+ 3 %+

1%+0

250

NIKOLAOSG. BOURBAKISet

al.

Thus, the E expand matrix for the above example is:

E = HS®LS =

0

2

4

6

8

10

12

14-

3

1

7

5

11

9

15

13

28

30

24

26

20

22

16

18

31

29

27

25

23

21

19

17

32

34

36

38

40

42

44

46

35

33

39

37

43

41

47

45

60

62

56

58

52

54

48

50

63

61

59

57

55

53

51

49

The same process is followed for SCAN words which contain more than three letters (or scan orders). Figure 13 shows graphically the generation of the expanded matrices in a binary tree structure. The parallel expansion algorithm requires as inputs: (i) the image region of k' x k' elements; and (ii) the wt SCAN word. It generates the expanded matrix ordered by the wt word. The algorithm for parallel expansion is: Algorithm of Parallel Expansion { LS = M (cr ( Liar)); //initialization// k = at;

for i = t - 1 downto 1 do [ HS=k2*M(a(Liai)); E = HS ® LS;\\compute the expansion matrix of LS into HS\\ k =k,ai; LS=E ] }

The above algorithm provides, through the LS matrix, the pattern corresponding to wt. At each iteration i, the E matrix contains ai*ki elements. After the construction of the loop, the value of ai will be a i = a] a2. • • at = n. The construction of the SCAN tree begins at the rightmost set of leaf-elements and progresses to the root. This means that the procedures, which implement the scan orders, are called once at each level, rather than once for each expansion. Considering the above word w3 = R2 ~ C4 4~ X2 and applying the parallel expansion scheme on it, only three calls are made, one at each level. The only shortcoming of the parallel expansion scheme is that, it requires a number of buffer matrices for enabling the successive expansions. On the other hand, the parallel expansion scheme allows

®



G 1

.

.

.

Gt

(a2...a,)~x[l-1 a,l

,,

(a3... at) 2 x[L2a 2]

Is /

{{a, a ~_l)z x [L~_2a,-2]

[ Ltat]

a2 x [L~_la~.,]

Fig. 13. The binary tree representation of the parallel expansion computation procedure.

A parallel implementationof the SCAN language LS

251

(E)+HS(R2) + E finat

Nestin9 - L o o p s 409q

ParaLLeL- expansion~ . . . ~

o o o o _J o

E

204~

LS(H8)+H8 (C4)+E

102,

LS (HS) --V-

I

I

2

3

~terations

Fig. 14. Memoryrequirementsvs iterations for the Nesting-loopsand Parallel-expansionschemes,for the R2 # C4 # H8 word. paralleism on its computation process. In addition, the expansions can be performed in parallel, once the initial expansion matrix is determined. 5. C O M P A R I S O N OF THE SCAN I M P L E M E N T A T I O N SCHEMES Both the implementation schemes of the SCAN language are characterized by trade-offs on memory requirements and execution time. However, an analysis of the complexity in terms of memory and time, of the underlying algorithms and real-time benchmarking tests, favors the parallel expansion implementation scheme [5]. Both algorithmic schemes were implemented in ADA and tested [17]. Some results, of the memory requirements, are given graphically in Figs 14 and 15. Through this graphical representation, the storage amount (array elements) is dynamically allocated at the successive steps of the parallel expansion algorithm. In particular, the parallel expansion scheme makes use of three arrays (LS, HS, E). On the other hand, the sequential algorithm operates on the output matrix exclusively. However, it would be hasty to assume that it means actually less storage space in overall. In fact, for long SCAN words, the parallel expansion scheme in average needs less storage space. In particular, the parallel scheme requires more memory space than the sequential scheme, but only at its final stage. In all the previous stages it requests less memory space.

252

NIKOLAOSG. BOURBAKISet

al.

LS

(E") + HS(R2) + E f i n a l

I

I I Nesting - Loops

I I

65536

o

ParaLLeL

:p

-

e x p a nsi on

o

o

_9° 0

E 32768

LS (E')+FIS ( C 4 ) + E "

\ r

16384 L S ( E )+HS(X 2)+E'

I I I

I I LSIY2)+HS(H8

I

-,,,

LS(Y2) _ _ &

L-- . . . . . I

l, I

J 2

3

Iterations Fig. 15. Memory requirements vs iterations for the Nesting-loops and Parallel-expansion schemes, for the R2 4~ C4 # X2 # H8 ~ Y2 word.

In addition, an execution speed comparison, between these two implementation schemes, was made. Figure 16 provides a graphical representation of the timing results for a sample of SCAN words. It is clear that the parallel expansion scheme requires less time for the implementation of the SCAN words. Finally, a general consideration of the complexity of the above implementation schemes has shown that, for a SCAN word wt = L]a, ~ L2a2 ~= • .. ~ Ltat they require: Parameters

Parallel expansion

Memory locations

~

a~ + ~

j=t-I

Arithmetic operations (a) Additions

j~ti=t

fi a~

Sequential

J

t j=ti=t

i=l

~ h a2k

i=lk=i i=lk=l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . t-I t i

(b) Multi/tions

E ~i + t - 1

)'~ l-I a2

i=l

i=Ik=l

t

I + ~ ]-I a2

t-I

Calls of procedures

i=lk=l

i

A parallel implementation of the SCAN language

253

350

500

*

ParaLLeL- expansion scheme

o

N e s t i n c j - Loops scheme

250 A

%

200

"150

100

50

' R2

C4 N2

04

i

D4 R 2 # D 2 Y 2 ~ C 4 0 4 # 1 4 R 2 # D 2 # I 2 02"~"H4~:I2 C4-~FI2 H4~=R2 C2#14 02'#'Y2#H2

Scan words

Fig. 16. Execution time for a sample of SCAN words. Dots indicate the execution time for the parallel scheme, and 'cycles' show the execution time for the nesting-loops scheme,

6. C O N C L U S I O N S In this paper, a context-free language, called S C A N , for sequential data accessing has been presented in brief. T w o algorithmic schemes, the " N e s t i n g - L o o p s " a n d the "Parallel E x p a n s i o n " , were also described a n d c o m p a r e d (in regards with m e m o r y space a n d execution speed) for the i m p l e m e n t a t i o n o f the S C A N language. T h e Parallel E x p a n s i o n scheme appears to be faster a n d requires less storage space, when storage is weighted by time. Extensions o f this work are: (i) a p p l i c a t i o n s of the S C A N language; (ii) a new e x p a n d e d version of the S C A N l a n g u a g e i n c l u d i n g new possible scan orders [12, 16, 18, 23]. Acknowledgement--The authors wish to express many thanks to the reviewer for his helpful suggestions on their work.

REFERENCES 1. 2. 3. 4. 5. 6. 7. 8. 9. 10, 11. 12. 13. 14. 15.

Kennedy, H. C, Selected Works o f Cuiseppe Peano. London: Allen & Unwin. Stevens, R. J. et al. Manipulation of multidimensional image data using the Peano scan. IEEE Trans. P A M I 5(5); 1983. Mandelbrot, B. Fractals Form, Chance and Dimension. San Francisco: W. H. Freeman. Bourbakis, N. G., Alexopoulos, C. and Serpanos, D. Efficientalgorithms for fast features detection in binary pictures. Int. Syrup. on Robotics and Automation, Switzerland, pp. 77-80; June 1983. Bourbakis, N. G., Klinger, A. and Lewis, C. An efficient implementation scheme for the SCAN language. IEEE Workshop on LFA Vienna, Austria, pp. 103-106; August 1987. Alexandrov, V., Gorsky, N. D. and Mysko, S. N. Recursive Pyramids and their use for image coding. Int. J. Pattern Recog. Lett.; September 1984. Yamashita, M. Parallel and sequential transformations on digital images. Int. J. Pattern Recog. 18(1); 1984. Bourbakis, N. G. Real time processing methods of structured images. Ph.D. thesis, University of Patras; 1982. Bourbakis, N. G. SCAN--A language for effective sequential accessing of 2-D arrays. IEEE Workshop on LFA, Singapore, pp. 52-58; 1986. Alexopoulos, C. and Bourbakis, N. G. Extraction and reconstruction of simple geometric features of a picture. Int. Symp. on M E C O , Athens, Greece, pp. 545-549; September 1983. Bourbakis, N. G. A scanning system and a Z image scanning technique for fast pyramid data structure. Int, Syrup. on MIC, Switzerland, pp. 156-159; March 1982. Bourbakis, N. G. and Alexopoulos, C. Picture data encryption using SCAN patterns. GMU-ECE-TR-1987. Submitted. Klinger, A. and Rhodes, M. L. Organization and access of image data by areas. IEEE Trans. P A M I 1(1): 50~0; 1979. Butz, A. R. Alternative algorithm for Hilbert's space-fillingcurve. IEEE Trans. Comput. 949 953; October 1968. Gagalowicz, A. and Dema, S. Sequential synthesis of natural textures. Int. J. C V G I P 30: 289--315: 1985.

254

NIKOLAOS G. BOURBAKISet al.

16. Bourbakis, N. G. Efficient storage and retrieval DB techniques using SCAN patterns. GMU-ECE-TR-1988. Submitted. 17. Russell, M. et al. Toward real-time performance benchmarks for ADA. Commun. A C M 29(8): 760-775; 1987. 18. Bourbakis, N. G. et al. An efficient tool for raster-to-vector data convesion: Geographical mapping. GMU-ECE-TR1988. 19. Tanimoto, S. and Klinger, A. Structured Computer Vision. New York: Academic Press; 1980. 20. Alexopoulos, C. and Bourbakis, N. G. A mathematical modeling of the SCAN language. J. ACM. Accepted for publication. 21. Bourbakis, N. G. and Park, S. Image preprocessing algorithms. GMU-ECE-TR-1986. 22. Bourbakis, N. G. and Klinger, A. A hierarchical picture coding scheme. Int. J. Pattern Recog. 22(3); 1989. 23. Alexo_poulos, C. A la_nguage for se_quential data accessin_g. Ph.D. thesis, University of Patras; 1989. About the Author--NIKOLAOS G. BOURBAKISreceived a B.S. in mathematics (1974) from the National University of Athens, and a Ph.D. in computer engineering (1982) from the University of Patras. He is an Assistant Professor at George Mason University in the Department of Computer Science and Engineering. His research interests are knowledge-driven vision system architecture, algorithms and languages for vision and knowledge creation, software environments, knowledge-based VLSI systems design, robotics, and text processing. He has published more than seventy-five articles in international journals and conferences, and he is the author of three books (in Greek). He is a guest editor for international journals related to AI, a reviewer for a number of international journals, and the principle investigator in several research projects. He is listed in the Congressional Who's Who in Computers, and was elected a senior member of the IEEE Computer Society in 1988. About the Author---CHRISTOSALEXOPOULOSwas born in Greece in 1952. He received a B.S. in mathematics from the University of Patras (1976), a D.E.A. of Mathematical Statistics from the Universit6 de Pierre et Marie Curie, Paris (1977), and a Ph.D. in Computer Sciences from the University of Patras (1989, advisor: Dr N. Bourbakis). His interests are in programming languages, DB technique, and data structures. About the Author--ALLAN KLINGER was born in New York City on April 2, 1937. He has received three degrees in Electrical Engineering: a B.E.E. from The Copper Union (1957), an M.S. from the California Institute of Technology (1958), and a Ph.D. from the University of California (1966). He is a Fellow of the Institute of Electrical and Electronic Engineers "for contributions to image analysis by means of computers", and a member of the American Association for Artificial Intelligence, the Pattern Recognition Society, and the IEEE Computer Society. Dr Klinger has ongoing research in computer vision, pattern analysis and machine intelligence, and human-computer interaction. His extensive record of publication in refereed journals, books, and proceedings includes over eighty-five items. He has chaired eleven Ph.D. committees at UCLA.