10
Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses q Chin-Hsiung Wu a, * , Shi-Jinn Horng b , Yuh-Rau Wang c , Horng-Ren Tsai d a Department of Information Technology and Communication, Shih Chien University, Kaohsiung Campus, Kaohsiung, Taiwan, ROC b Department of Computer Science and Information Engineering, National Taiwan University of Science and Technology, Taipei, Taiwan c Department of Computer Science and Information Engineering, St. John’s University, Taipei, Taiwan d Department of Information Technology, Ling Tung University, Taiwan Available online 18 April 2006 Abstract Geometric algorithms play an important role in computer graphics and digital image analysis. This paper makes an improvement of computing geometric properties of labelled images using arrays with reconfigurable optical buses (AROB). For an N · N image, we first design two constant time algorithms for computing the leftmost one problem and for the component reallocation problem. Then, several geometric algorithms for the labelled images are derived. These include finding the border pixels, computing the perimeter and area, com- puting the convex hull, determining whether two figures are linearly separable, computing the smallest enclosing box, solving the nearest neighbor problems, and computing the width and diameter. The major contribution of this work is to design both time and cost optimal algorithms for these problems. To the best of our knowledge, the proposed algorithms are the first constant time algorithms for these problems on the labelled images. Ó 2006 Elsevier B.V. All rights reserved. Keywords: Geometric algorithm; Reconfigurable optical buses; Pattern recognition; Digital geometry; Image labelling 1. Introduction Digital geometry is the study of geometric properties of subsets of digital images. It is widely applied in many aspects such as computer graphics, computer vision, robot- ics, computational morphology, geographic information systems, and so on [7,15]. Given an N · N binary digitized image, where the black pixels are 1-valued and white pixels are 0-valued, computing the geometric properties of such an image also occurs normally in intermediate-level vision. These problems which arise from these areas are likely to come from real-time applications or situations in which the input consists of a amount of data. To compute these problems requires global propagation of data among differ- ent parts of the image. Parallel processing systems are clearly the best way to solve this kind of problems. Parallel algorithms for digital geometry problems have been proposed on various computation models. Given an N · N binary image on an N · N array of processors, each pixel is associated with a processor. Miller et al. [17] gave many h (N) time algorithms for digital geometry problems on the mesh-connected computer (MCC). Kumar et al. [12] gave several algorithms for digital geometry problems on the mesh with multiple broadcasting (MMB). Bokka et al. [5] gave several OðN 1 3 Þ time algorithms for digital geometry problems on the MMB. Djokic ´ et al. [7] gave many O (1) time algorithms for digital geometry problems on the scan model. Their algorithms are only used for unla- belled images. For labelled images, the time complexity of their solutions become O (log N). Recently, Lin et al. [15] gave several O (log N) time algorithms for digital geometry problems on the mesh with hybrid buses (MHB). 0141-9331/$ - see front matter Ó 2006 Elsevier B.V. All rights reserved. doi:10.1016/j.micpro.2006.03.003 q This work was partly supported by the National Science Council under contract No. NSC 92-2213-E-012-001 and NSC-94-2213-E-129-012. * Corresponding author. Tel.: +886 7 6678888; fax: +886 7 5850347. E-mail addresses: [email protected] (C.-H. Wu), horng@ mouse.ee.ntust.edu.tw (S.-J. Horng). www.elsevier.com/locate/micpro Microprocessors and Microsystems 30 (2006) 425–434

Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

Embed Size (px)

Citation preview

Page 1: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

www.elsevier.com/locate/micpro

Microprocessors and Microsystems 30 (2006) 425–434

Optimal geometric algorithms for digitized images on arrays withreconfigurable optical buses q

Chin-Hsiung Wu a,*, Shi-Jinn Horng b, Yuh-Rau Wang c, Horng-Ren Tsai d

a Department of Information Technology and Communication, Shih Chien University, Kaohsiung Campus, Kaohsiung, Taiwan, ROCb Department of Computer Science and Information Engineering, National Taiwan University of Science and Technology, Taipei, Taiwan

c Department of Computer Science and Information Engineering, St. John’s University, Taipei, Taiwand Department of Information Technology, Ling Tung University, Taiwan

Available online 18 April 2006

Abstract

Geometric algorithms play an important role in computer graphics and digital image analysis. This paper makes an improvement ofcomputing geometric properties of labelled images using arrays with reconfigurable optical buses (AROB). For an N · N image, we firstdesign two constant time algorithms for computing the leftmost one problem and for the component reallocation problem. Then, severalgeometric algorithms for the labelled images are derived. These include finding the border pixels, computing the perimeter and area, com-puting the convex hull, determining whether two figures are linearly separable, computing the smallest enclosing box, solving the nearestneighbor problems, and computing the width and diameter. The major contribution of this work is to design both time and cost optimalalgorithms for these problems. To the best of our knowledge, the proposed algorithms are the first constant time algorithms for theseproblems on the labelled images.� 2006 Elsevier B.V. All rights reserved.

Keywords: Geometric algorithm; Reconfigurable optical buses; Pattern recognition; Digital geometry; Image labelling

1. Introduction

Digital geometry is the study of geometric properties ofsubsets of digital images. It is widely applied in manyaspects such as computer graphics, computer vision, robot-ics, computational morphology, geographic informationsystems, and so on [7,15]. Given an N · N binary digitizedimage, where the black pixels are 1-valued and white pixelsare 0-valued, computing the geometric properties of suchan image also occurs normally in intermediate-level vision.These problems which arise from these areas are likely tocome from real-time applications or situations in whichthe input consists of a amount of data. To compute these

0141-9331/$ - see front matter � 2006 Elsevier B.V. All rights reserved.

doi:10.1016/j.micpro.2006.03.003

q This work was partly supported by the National Science Council undercontract No. NSC 92-2213-E-012-001 and NSC-94-2213-E-129-012.

* Corresponding author. Tel.: +886 7 6678888; fax: +886 7 5850347.E-mail addresses: [email protected] (C.-H. Wu), horng@

mouse.ee.ntust.edu.tw (S.-J. Horng).

problems requires global propagation of data among differ-ent parts of the image. Parallel processing systems areclearly the best way to solve this kind of problems.

Parallel algorithms for digital geometry problems havebeen proposed on various computation models. Given anN · N binary image on an N · N array of processors, eachpixel is associated with a processor. Miller et al. [17] gavemany h (N) time algorithms for digital geometry problemson the mesh-connected computer (MCC). Kumar et al.[12] gave several algorithms for digital geometry problemson the mesh with multiple broadcasting (MMB). Bokkaet al. [5] gave several OðN 1

3Þ time algorithms for digitalgeometry problems on the MMB. Djokic et al. [7] gavemany O (1) time algorithms for digital geometry problemson the scan model. Their algorithms are only used for unla-belled images. For labelled images, the time complexity oftheir solutions become O (log N). Recently, Lin et al. [15]gave several O (log N) time algorithms for digital geometryproblems on the mesh with hybrid buses (MHB).

Page 2: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

Fig. 1. (a) An LAROB of size N. (b) The switch states. (c) An example ofbus reconfiguration.

426 C.-H. Wu et al. / Microprocessors and Microsystems 30 (2006) 425–434

The MCC is useful for solving these problems becauseof its simplicity and regularity in architecture [12,15,17].Unfortunately, there are two drawbacks of the MCC: fixedarchitecture and long communication diameter and thesedegrade the performance of the proposed algorithms. Opti-cal interconnections may provide an ultimate solution tothis problems [11,13,24]. Unlike electronic buses on whichsignal propagation is bidirectional, optical buses are inher-ently unidirectional and have predictable delay of the sig-nal per unit length. Based on these two importantproperties, pipelined optical buses using division multiplex-ing (TDM) multiaccess methods have been proposed[11,13,21,24]. In a cycle time, the number of messages thatcan be transmitted by a pipelined optical bus is larger thanthat can be transmitted by an electrical bus. The array witha reconfigurable optical bus system is defined as an array ofprocessors connected to a reconfigurable optical bus systemwhose configuration can be dynamically changed by settingup the local switches of each processor, and messages canbe transmitted concurrently on a bus in a pipelined fashion.Recently, two related models have been proposed, namelythe array with reconfigurable optical buses (AROB) [22]and linear array with a reconfigurable pipelined bus system(LARPBS) [21]. Many algorithms have been proposed formodels with reconfigurable optical buses[22,23,25,27,26,28]. This indicates that these systems areefficient for parallel computations due to the high band-width and flexibility within a reconfigurable optical bussystem. Even though a real or a commercialized parallelcomputer based on such an architecture may not be avail-able in the near future, the algorithms on AROB are stilluseful, and can be implemented efficiently on other archi-tectures as well [21,22,25].

Usually, images may consist of several connected com-ponents on the background. In a binary image, the con-nected component is said to form a figure. In thefollowing, both component and figure will be used inter-changeably for the binary image. A labelled image is animage which is partitioned into several labelled compo-nents, where two pixels have the same label if and only ifthey are in the same component. In this paper, we are inter-ested in designing time and cost optimal algorithms for dig-ital geometry problems of labelled images on the AROB.We first label and count the connected components of animage, then solve several geometric problems for the imageand for each figure, which include connectivity, convexity,distance computing and the related problems. By integrat-ing the advantages of both optical transmission and elec-tronic computation, these problems can be solved in O (1)time on the AROB. In the sense of the product of timeand the number of processors used, our algorithms are timeand cost optimal. To the best of our knowledge, they arethe first constant time algorithms for these problems onthe labelled images.

The remainder of this paper is organized as follows. Wegive a brief introduction to the AROB computational mod-el in Section 2. Section 3 describes several basic operations

which will be used in the geometric algorithms proposed inthis paper. Sections 4–6 develop our geometric algorithms.Finally, some concluding remarks are included in the lastsection.

2. The computational model

The AROB model is essentially a mesh using the basicstructure of a classical reconfigurable network (RN) [3]and optical buses. The linear AROB (LAROB or 1-DAROB) extends the capabilities of the 1-D array processorswith pipelined buses (APPB) by permitting each processorto connect to the bus through a pair of switches. Each pro-cessor with a local memory is identified by a unique indexdenoted as Pi, 0 6 i < N, and each switch can be set toeither cross or straight by the local processor Pi for recon-figuration. These switches are called reconfigurable switch-es. When all switches are set to straight, the bus systemoperates as a regular optical bus. When both switches ofprocessor Pi, 1 6 i < N � 1, are set to cross, the LAROBwill be partitioned into two independent sub-buses fromprocessor Pi, where each of them forms an LAROB. Thatis, one consists of processors P0,P1, . . . ,Pi�1, and the otherconsists of processors Pi,Pi+1, . . . ,PN�1 whose leader pro-cessor is Pi (as shown in Fig. 1(c)). Each processor uses aset of control registers to store information needed to con-trol the transmission and reception of messages by thatprocessor. An example for an LAROB of size N is shownin Fig. 1(a). Two interesting switch configurations deriv-able from a processor of an LAROB are also shown inFig. 1(b).

In the AROB model, the synchronous communicationsare needed by time-division multiplexity scheme [24], andthe coincident pulse technique [13,24] is used for the

Page 3: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

C.-H. Wu et al. / Microprocessors and Microsystems 30 (2006) 425–434 427

address information. In order to ensure that all processorsin Fig. 1(a) can write their messages on the bus simulta-neously without collision, and to determine which slot touse, each processor contains a counter used for the timewaiting function, and the following collision-free conditionmust be satisfied:

do > bwcg;

where do is the optical distance between two adjacent pro-cessors (as shown in Fig. 1(a)), b is the maximum numberof binary bits in each message, w is the width of an opticalpulse used to represent one bit in each message (in sec-onds), and cg is the velocity of light in the waveguide. Thisis in contrast to the electronic bus, where the writing accessto the bus is mutually exclusive. Guo et al. [11] also showedthat when do approaches bwcg, the pipelined bus canaccommodate N messages in the same bus cycle due tothe property of pipelining, where N is the number of pro-cessors in the array.

A 2-D AROB of size M · N contains M · N processorsarranged in a 2-D grid. Each processor is identified by aunique 2-tuple index (i1,i0), 0 6 i1 < M, 0 6 i0 < N. Theprocessor with index (i1, i0) is denoted by P i1;i0 . Each pro-cessor has four I/O ports, denoted by �Sj, +Sj, 0 6 j < 2,to be connected with a reconfigurable optical bus system.The interconnection among the four ports of a processorcan be configured during the execution of algorithms.The extended AROB allows on-line switch setting whereprocessors can change configurations and delay switch set-ting during a bus cycle. For more details on the AROB, see[22]. An example of a 2-D 4 · 4 AROB and the 10 allowedswitch configurations are shown in Fig. 2.

The time complexity of an algorithm is measured interms of the number of bus cycles and the number of arith-metic operations. A petit cycle (s) is defined as the timeneeded for a pulse to traverse the optical distance betweentwo consecutive processors on the bus. A bus cycle (r) isdefined as the end-to-end propagation delay of the messag-es on the optical bus; i.e., the time needed to traversethrough the entire optical bus. Then the bus cycle

r = 2Ns, where N is the number of processors in the array.For a unit of time, assume each processor can either per-form arithmetic and logic operations or communicate withothers on a bus. Since the ratio r between the message pro-cessing time and a petit cycle is in the order of 103

[11,13,21,24], it implies that a bus cycle can be regarded

a b

Fig. 2. (a) A 4 · 4 AROB. (b) The allowed switch configurations.

as a constant time for systems of size O (r) (e.g., r = 103).In order for the message processing time to be of the sameorder of magnitude as the end-to-end communication time,the number of processors should satisfy N P r. However,for a bus cycle to be considered as one step and each steptakes O (1) time. This assumption for time complexity mea-sure has been adopted widely in the literature [11,21,23–25]. It allows multiple processors to broadcast data onthe different buses or to broadcast the same data on thesame bus simultaneously at a time unit, if there is nocollision.

3. Basic operations

In this section, several basic operations proposed on theAROB will be presented.

Lemma 1 [22]. Given N Boolean data each with either 0 or

1, the binary prefix sums of these N Boolean data can becomputed in O (1) time on a 1-D N AROB.

Lemma 2 [26]. Given N · N Boolean data each with either 0or 1, the binary prefix sums of these N2 Boolean data can be

computed in O (1) time on a 2-D N · N AROB.

Lemma 3 [23]. Given N (N · N) integers each of size

O (logN)-bit, these N (N2) integers can be sorted in O (1) time

on a 1-D N (2-D N · N) extended AROB.Based on Lemma 3, the algorithm proposed by Pavel

and Akl [23] can be easily modified to compute the mini-mum-finding problem. This leads to the followingcorollary.

Corollary 4. Given N (N · N) integers each of size

O (logN)-bit, the maximum/minimum of these N (N2) integers

can be found in O (1) time on a 1-D N (2-D N · N) extended

AROB.Consider an N · N AROB, each processor carrying at

most one packet. The partial permutation routing is thecommunication problem which requires to move the packetin each processor to its destination, each processor beingthe destination of at most one packet. A constant timealgorithm for this problem can be found in [23]. In partic-ular, they showed:

Lemma 5 [23]. On-line partial permutation routing can be

performed in O (1) time on a 2-D N · N AROB.

3.1. The leftmost one problem

Given a data matrix ai1;i0 , 0 6 i1, i0 < N, where ai1;i0 ¼ 0or 1, the leftmost one problem is to determine the position(index) of the leftmost 1, if any, in each row of the matrix,where the index of each data item is represented by rowmajor order. By the power of the reconfigurable opticalbus systems, this problem can be easily solved in constanttime. Initially, the data matrix ai1;i0 is stored in the localvariable a (i1, i0), 0 6 i1, i0 < N, of processor P i1;i0 . Finally,the result is stored in the local variable lm (i1,0) of proces-

Page 4: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

428 C.-H. Wu et al. / Microprocessors and Microsystems 30 (2006) 425–434

sor P i1;0. For the sake of completeness, the detailed algo-rithm for the leftmost one problem (LMOA) is listed asfollows.

1. For each row, establish the local optical bus connec-tions. That is, each processor P i1;i0 , 0 6 i1, i0 < N, estab-lishes the local connection {�S0, +S0} if the dataelement a (i1, i0) is equal to 0; disconnects it, otherwise.

2. Set the local index of each data element. That is, each pro-cessor P i1;i0 ; 0 6 i1; i0 < N , computes its own local indexl (i1, i0) for data element a (i1, i0), where l (i1, i0) = i1 · N + i0.

3. Any processor P i1;i0 , which carries a 1-pixel, writesl (i1, i0) to its �S0 port at the beginning of a bus cycle.Then processor P i1;0 receives l (i1, i0) and stores it in thelocal variable lm (i1,0).

Lemma 6. Given an N · N data matrix each with either 0 or1, the leftmost one problem can be solved in O (1) time on a 2-

D N · N AROB.

Proof. If there are n data items each having value 1 for theith1 row, then the optical bus for this row will be partitioned

into n + 1 optical segment buses. Only the leftmost proces-sor which has the data value 1 will be connected to the opti-cal bus where processor P i1;0 is connected. After Step 3,only the index of the leftmost one will be put to processorP i1;0 for each row. Steps 1–3 each take O (1) time. Hence,the time complexity of this algorithm is O (1). h

3.2. The component reallocation problem

Given a binary image B, pixel b (i1, i0), 0 6 i1, i0 < N, isstored in processor P i1;i0 . Assume that B contains m con-nected components, 0 6 m < N2, and each has a label dif-ferent from those of the other components. Thecomponent reallocation problem is to reallocate all of thecomponents properly according to their sizes. The detailedalgorithm for components reallocation problem (CRA) iscomposed by the following three steps.

1. Sort all black pixels using their labels as the primary keyand their indexes as the secondary key in snake-like row-major fashion by Lemma 3. After sorting, those blackpixels with the same label will be put together row byrow and the size of each component can be found asthe boundary pixels between any two components canbe identified easily.

2. Partition the AROB into several sub-AROBs properly,according to the size of each component, such that eachsub-AROB will contain a corresponding componentexactly.

3. Allocate all components to the corresponding sub-AROBs by Lemma 5.

An example is shown in Fig. 3, in this example we allo-cate components 0, 12, and 44 to sub-AROBs 0, 1, and 2,respectively.

Lemma 7. Given an N · N image which consists of several

connected components, the component reallocation algorithm

can be executed in O (1) time on a 2-D N · N extended

AROB.

4. The connectivity and its related problems

4.1. The image component labelling

The task of detecting and labelling the various connect-ed regions of a digital image is referred as component label-

ling. Connectivity among pixels can be defined in terms oftheir adjacencies. Two pixels b (x1,y1) and b (x2,y2) are saidto be 4-neighbor if |x1 � x2| + |y1 � y2| 6 1. Two pixelsb (x1,y1) and b (xk,yk) are said to be connected by a 4-pathif there exists a sequence of pixels (xt,yt), 2 6 t 6 k, suchthat each pair of pixels b (xt�1,yt�1) and b (xt,yt) are 4-neighbor and with the same intensity. A maximal connect-ed region of pixels is called a connected component (figurefor binary images). The image component labelling is toassign a unique label to each connected component in animage. Thus, in a labelled image, two pixels have the samelabel if and only if they are in the same connected compo-nent. A component is given a label corresponding to theleast (in row major order) identity index of the pixelbelonging to this component.

Given an N · N image on an N · N array of processors,the component labelling can be solved in O (1) time. Table1 compares our result with several others recently reportedin the literature. Compared it to those constant time algo-rithms listed in Table 1, our algorithm needs neither a spe-cial hardware like [9] nor extra N times processors like [2].

By exploiting the reconfigurability of the bus system ofthe reconfigurable mesh, Olariu et al. [20] proposed anO (log N) time algorithm for the component labelling prob-lem. The idea of their algorithm is to detect the inner andouter boundaries of each component, then uniquely labelall the connected ones surrounded by each of these bound-aries. To assure circular boundaries, they assume that theimage is magnified by a factor of two along each dimen-sion. Based on their approach and the power of opticalbus system, this problem can be solved in constant timeon an AROB. The algorithm consists of the following foursteps.

1. For each processor, detect whether it contains a bound-ary pixel, then establish the optical bus that will connectthe corresponding boundary processors.

2. For each boundary bus established above, elect a leaderwith the minimum index, then each leader identifies itsbus as internal or external.

3. For each leader of an internal bus, determine the corre-sponding external bus. Then those pixels or processorswithin these two buses become a component.

4. The leader of the corresponding external bus of a com-ponent broadcasts its index to each internal pixel ofthe component.

Page 5: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

a

b c

Fig. 3. An example of component reallocation. (a) An 8 · 8 binary image and its component labelling. (b) After Step 1. (c) The final result.

Table 1Summary of comparison results for component labelling algorithms

Reference Architecture Processors Time complexity

[19,18,14] Mesh, pyramid,polymorphic-torus

N · N O (N)

[12] MMB N · N O (N1/2)[6,4] EREW PARM,

scan model,N · N O (logN)

[20,10] Reconfigurable mesh, OMC[9] Mesh with

cross-bridge connectionN · N O (1)

[2] RN N · N · N O (1)This paper AROB N · N O (1)

C.-H. Wu et al. / Microprocessors and Microsystems 30 (2006) 425–434 429

Theorem 8. Given an N · N binary image stored in an N · N

AROB one pixel per processor, the component labelling

algorithm can be executed in O (1) time.

Proof. The time complexity of this algorithm is dominatedby the leader election operation in Step 2. For this step, wecan apply Corollary 4 to elect a leader with the minimumindex for each boundary bus in O (1) time using N · Nprocessors. h

4.2. Counting the connected components

The number of components of an image can be comput-ed by the following three steps. First, apply Theorem 8 toobtain all connected components of an image. Then, theleader processor P i1;i0 with the minimum index l of eachcomponent sets b (i1, i0) = 1, and other processors setb (i1, i0) = 0. Finally, apply Lemma 2 to sum up b (i1, i0),and the number of connected components can be obtained.Each of the above steps takes O (1) time. This leads to thefollowing theorem.

Theorem 9. Given an N · N image, the number of all

connected components can be computed in O (1) time on a2-D N · N AROB.

4.3. The border following

Define a border pixel as a pixel having at least one pixelof its 4-connected neighbors which has the different inten-sity as itself. Border following is the task of transforminga set of edge pixels into the perimeter of a connected com-ponent and at the same time establishing a unique label foreach component border.

Page 6: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

430 C.-H. Wu et al. / Microprocessors and Microsystems 30 (2006) 425–434

Consider an N · N image containing several connectedcomponents on an N · N AROB. The border followingproblem is to find the border pixels of each connected com-ponent. The algorithm for this problem consists of the fol-lowing two steps. First, we determine all connectedcomponents of an image and label a unique label for eachcomponent by Theorem 8. Then, each border pixel can befound by checking whether there is a pixel of its 4-neighborwith a different label. Each of the above steps takes O (1)time. This leads to the following theorem.

Theorem 10. Given an N · N image, the border following

problem can be solved in O (1) time on a 2-D N · N AROB.

The perimeter of a figure is the number of its black pix-els that have at least one white pixel in its neighborhood.The area of a figure is the number of pixels within the fig-ure. When the border pixels are found, the perimeter ofeach figure can be computed in the following two steps.First, sort the border pixels according to their labels. Then,for each label, compute the number of border pixels byLemma 2. Similarly, the area of a figure can be computedby Lemma 2. This leads to the following two corollaries.

Corollary 11. Given an N · N image, the perimeter of eachfigure can be computed in O (1) time on a 2-D N · N AROB.

Corollary 12. Given an N · N image, the area of each figure

can be computed in O (1) time on a 2-D N · N AROB.

5. The convexity and its related problems

The convex hull of a binary image B, denoted byCH (B), is the minimum convex set (polygon) enclosingall centers of black pixels. Every pixel of CH (B) is referredto an extreme pixel of B. A digital region or figure F is afinite set of black pixels. F is convex if and only if the con-vex hull CH (F) of F encloses no pixel of the complement ofF. The extreme pixels of F are the corners of the smallestconvex polygon enclosing F. A black pixel b (i1, i0) 2 F isan extreme pixel of F, if b (i1, i0) 62 CH (F � b (i1, i0)).

Given an N · N binary image on an N · N array of pro-cessors, the convexity problems can be solved in O (1) time.Table 2 compares our result with several others recentlyreported in the literature. It is shown that the algorithmsfor unlabelled image have less computational cost than

Table 2Summary of comparison results for convexity algorithms

Reference Architecture

[17] MCC[15] MHB[12] MMB[14,7] Polymorphic torus, scan model[10] OMC[17] MCC[20] Reconfigurable mesh[7] Scan modelThis paper AROB

those for labelled image. In this section, we will introducean improvement to computing the convexity for labelledimage.

5.1. Convex hull of a region

Given a binary image B on an AROB, pixel b (i1, i0),0 6 i1,i0 < N, is stored in processor P i1;i0 . Note that thereare OðN 2

3Þ extreme pixels in such an image [1]. Thus, manypixels in the interior can be eliminated before we locate theextreme pixels. The convex hull algorithm consists of threemajor steps. First, for each row, find the leftmost and right-most black pixels. Similarly, for each column, find the top-most and bottommost black pixels. After that, only pixelswhich are both leftmost (rightmost) in its row and eithertopmost or bottommost in its column are left as candidatesto be extreme pixels, and all others are eliminated. Thus,there are left at most 2N candidate pixels. Then, we parti-tion all candidate pixels into four groups according to theirpositions. Finally, find the extreme pixels from the candi-date pixels in each group separately. We use a criterionto check whether a candidate pixel b(i,j) is an extreme pixelin the upper-right convex hull or not: Find two other pixelsb (i 0, j 0) and b (i00, j00), where 0 6 j 0 < j < j00 < N, such that theangle formed by b (i 0, j 0), b(i,j) (resp. b (i, j), b (i00, j00)) and thenorth direction is minimum. Thus, b (i, j) is an extreme pixelof the upper-right convex hull if and only if b (i, j) is abovethe line segment bði0; j0Þ; bði00; j00Þ. By the same way, such cri-terion can be used to find the extreme pixels in the otherthree groups. For the sake of completeness, the detailedconvex hull algorithm (CHIA) is presented in thefollowing.

Procedure CHIA (B,ch);// b (i1, i0) is an extreme pixel if ch (i1, i0) = 1 after the

procedure. //

1. // Find the candidate pixels. //For each row, find theleftmost (rightmost) black pixel by Lemma 6. Similarly,for each column, find the topmost (bottommost) blackpixel. Then, processor P i1;i0 , 0 6 i1, i0 < N, setsch (i1, i0) = 1 if b (i1, i0) is a leftmost (rightmost) in itsrow and it is either a topmost or bottommost pixel inits column; ch (i1, i0) = 0, otherwise.

Image Processors Time complexity

Unlabelled N · N O (N)Unlabelled N · N O (logN)Unlabelled N · N O (N1/3)Unlabelled N · N O (1)Unlabelled N2 · N2 O (1)Labelled N · N O (N)Labelled N · N O (log2N)Labelled N · N O (logN)Labelled N · N O (1)

Page 7: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

C.-H. Wu et al. / Microprocessors and Microsystems 30 (2006) 425–434 431

2. // Partition the candidate pixels into four groups. //Apply Lemma 6 to find the leftmost (rightmost) blackpixel bl (i1, i0) (br (i1, i0)) for all rows of the image. Thenbl (i1, i0) (br (i1, i0)) is an extreme pixel. If more than onepixel is found, select a pixel with the smallest index. Sim-ilarly, find the topmost (bottommost) black pixelbt (i1, i0) (bb (i1, i0)) for all columns of the image. Thenbt (i1, i0) (bb (i1, i0)) is an extreme pixel again. Then, par-tition the 2-D AROB into four groups according tothe two line segments blði1; i0Þ; brði1; i0Þ andbtði1; i0Þ; bbði1; i0Þ.

3. // Find other extreme pixels from the candidate pixels inthe upper-right hull. //3.1. Processor P i1;i0 , 0 6 i1, i0 < N, broadcasts its index

(i1, i0) to i1-row and i0-column if it is a candidateextreme pixel and located above the line segmentblði1; i0Þ; brði1; i0Þ and right to the line segmentbtði1; i0Þ; bbði1; i0Þ.

3.2. Processor P i1;i0 , 0 6 i1,i0 < N, computes the angleformed by the two indices received previously an-d the north direction.

3.3. For each column, apply Corollary 4 to find the twominimal angles associated with two indices, oneleft to b (i1, i0), the other right to b (i1, i0), ifch (i1, i0) = 1; the found pixels then forms a refer-ence line segment.

3.4. Processor P i1;i0 , 0 6 i1, i0 < N, with ch (i1, i0) = 1,sets ch (i1, i0) = 0, if it is not above the line seg-ment found previously.

4. Find the extreme pixels of other three groups, similarlyto Step 3.

Theorem 13. Given an N · N image, the convex hull

algorithm can be executed in O (1) time on a 2-D N · N

AROB.

Proof. After Step 2, the convex hull will be restricted in theminimal rectangle covering the topmost, bottommost, left-most, and rightmost pixels of the image and these four pix-els are extreme pixels no doubt. Any pixel, which is abovethe line segment formed by its left and right pixels with theminimal angle respect to it, is an extreme pixel; otherwise, itis not. h

5.2. Convex hulls of multiple figures

In most applications, a binary image consists of severalfigures on the background. Thus, computing the convexhulls of all figures becomes more important in the realworld. The convex hulls of multiple figures problem is tocompute the convex hull of each figure simultaneously.Note that, the only pixels which can be extreme pixels ofa figure, are those on the border of the figure. The algo-rithm (CHMFA) for this problem consists of the followingfour steps.

1. Label all figures by Theorem 8.

2. Apply Theorem 10 to find the exterior border pixels ofeach figure as candidates to be extreme pixels.

3. Apply Lemma 7 to reallocate all figures. After that eachsub-AROB contains a figure.

4. Each sub-AROB performs Procedure CHIA based onthe original pixel’s index to find the extreme pixels ofeach figure, respectively.

Theorem 14. Given an N · N image stored in an N · N

AROB one pixel per processor, simultaneously for all

figures, the convex hull of each figure can be computed in

O (1) time.

Proof. Clearly, the algorithm is correct, since it is derivedfrom Theorems 8, 10, 13 and Lemmas 6, 7. The numberof figures on an N · N image is ranged from 0 to h (N2).Without loss of generality, we prove that Step 4 also takesconstant time through the following three cases:

Case 1: If there are O(1) figures, then each figure mayhave O (N2) pixels. The total number of candidates areO (N) by Lemma 6. Thus, Step 4 can be executed inO (1) time by Theorem 13.Case 2: If there are O (Nc) figures, 0 < c < 2, then eachfigure may have O (N2�2c) black pixels and O (N1�c) can-didates because there require O (Nc) white pixels to iso-late the O (Nc) figures. Thus, the total number ofcandidates are O (N) by Lemma 6. Therefore, Step 4can be executed in O (1) time by Theorem 13.Case 3: If there are O (N2) figures, then each figure mayhave O (1) black pixels as candidates. Each figure can befound in constant time sequentially. Thus, Step 4 can beexecuted in O (1) time. h

After computing the convex hull of each figure, we candetermine whether a figure F is convex or not. This prob-lem can be solved as follows. First, compute CH (F) inO (1) time by Theorem 14. Then, Each pixel in CH (F)that is not in F, writes a 1 in a local variable. Finally,sum up the local variables in O (1) time by Lemma 2. Ifthe sum is zero, then it is convex. This leads to the follow-ing corollary.

Corollary 15. Given an N · N image stored in an N · N

AROB one pixel per processor, simultaneously for all figures,

the task of deciding whether each figure is convex or not can

be solved in O (1) time.

A related problem concerns linearly separability. Twofigures F and F 0 are linearly separable if there exists astraight line that separates centers of black pixels in F fromthose of black pixels in F 0. Based on this fact, the linearlyseparability problem can be solved similarly to the taskof deciding whether a figure is convex or not.

Corollary 16. Given an N · N image stored in an N · N

AROB one pixel per processor, the task of deciding whether

two figures are linearly separable or not can be solved in O (1)time.

Page 8: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

432 C.-H. Wu et al. / Microprocessors and Microsystems 30 (2006) 425–434

5.3. The smallest enclosing box

The smallest enclosing box of a figure F is a rectangle ofthe least area containing it. If rectangles of zero area con-tain F then we want the smallest line segment containingF. Note that the area of a smallest rectangle is unique,and that a smallest enclosing box must contain an extremepixel of CH (F) on each side, and at least one side containstwo consecutive extreme pixels of CH (F). Based on thisfact, the smallest enclosing box algorithm consists of foursteps. First, compute CH (F) in O (1) time by Theorem14. Next, each sub-AROB sets each pair of consecutiveextreme pixels of CH (F) to be the base of a rectangle,and the extreme pixels of CH (F) lying on the other threesides can be found in O (1) time. Then, compute the areaof each of the rectangles found above by Corollary 12.Finally, find the rectangle with the minimum area as thesmallest enclosing box by Corollary 4.

Theorem 17. Given an N · N image stored in an N · N

AROB one pixel per processor, simultaneously for all figures,

the smallest enclosing box of each figure can be computed in

O (1) time.

6. The distance computation and its related problems

Table 3 compares our result of distance computationwith several others recently reported in the literature. It isshown that our result achieves time and cost optimal, com-pared with all the previously published results. In this sec-tion, we solve four problems related to computingdistances among image regions in O (1) time, namely thenearest neighbor black pixel problem, the nearest neighborfigure problem, the diameter and width of an image.

6.1. The nearest neighbor black pixel

Given a binary image B, pixel b (i1, i0), 0 6 i1, i0 < N, isstored in processor P i1;i0 . The nearest neighbor black pixelproblem is to find the nearest black pixel bði01; i00Þ for eachblack pixel b (i1, i0) according to some metrics. The familyof Lp metrics, 0 6 p 61, seem to be the most commonlyused. In these metrics the distance between two pixels(i1, i0) and ði01; i00Þ (denoted by d½ði1; i0Þ; ði01; i00Þ�) is given by

d½ði1; i0Þ; ði01; i00Þ� ¼ ½ji1 � i01jp þ ji0 � i00j

p�1=p:

In this paper, we use Euclidean distance L2 which is themost often used as a measure of distance.

Table 3Summary of comparison results for distance computing algorithms

Reference Architecture Processors Time complexity

[17] MCC N · N O (N)[12] MMB N · N O (N1/2)[8,10] Mesh with cross-bridge

connection, OMCN · N O (logN)

This paper AROB N · N O (1)

The nearest neighbor black pixel algorithm consists ofthree major steps. First, for each black pixel b (i1, i0),compute the nearest neighbor black pixel located atthe ith

1 row or the ith0 column. There are four candidates

in this step, denoted as e (i1, i0), w (i1, i0), s (i1, i0) andn (i1, i0) with respect to the directions east, west, southand north, respectively. The distance of this nearest neigh-bor located at the ith

1 row or the ith0 column is defined as

follows:

d1½ði1; i0Þ; ði01; i0Þ� ¼ minfji1 � i01j; for i1 6¼ i01g;

or d1½ði1; i0Þ; ði1; i00Þ� ¼ minfji0 � i00j; for i0 6¼ i00g:ð1Þ

Then, compute the nearest neighbor black pixel located inother place except the ith

1 row and the ith0 column for each

black pixel b (i1, i0). Since all the Lp metrics are monotone,the nearest neighbor of b (i1, i0) must be located at the win-dow whose bounds are e (i1, i0), w (i1, i0), s (i1, i0) and n (i1, i0)with respect to the directions east, west, south and north,respectively. The distance of this nearest neighbor blackpixel is defined as

d2½ði1; i0Þ; ði01; i00Þ� ¼ minf½ði1 � i01Þ2 þ ði0 � i00Þ

2�1=2;

for i1 6¼ i01g. ð2Þ

Finally, a black pixel with the minimum distance betweend1 and d2 will be the nearest neighbor black pixel of theblack pixel b (i1, i0).

Without loss of generality, if the distances of two nearestneighbor pixels are equal, then we choose the pixel with theminimum index. Based on the above properties, the nearestneighbor black pixel algorithm (NEAREST) is listed asfollows.

Procedure NEAREST(b, l);

1. // For each pixel b(i1, i0), find the nearest neighbor locat-ed at the ith

1 row or the ith0 column. //

1.1. Each processor P i1;i0 , 0 6 i1, i0 < N, carrying a w-hite pixel establishes the local connection {�S0,+S0}, {�S1, +S1}. That is, each row and columnbuses split into several subbuses whose end pro-cessor carries a black pixel.

1.2. For each row, each subbus can find the candidatee (i1, i0) of pixel b (i1, i0) as follows. Each processorcarrying a black pixel broadcasts its index ði01; i00Þby port +S0 along the established i0-dimensionsubbuses. If processor P i1;i0 receives it by port�S0 then put this index to the e (i1, i0); other-wise, the e (i1, i0) will be set to (+1, +1).The w (i1, i0), s (i1, i0) and n (i1, i0) can be ob-tained similarly.

1.3. Each processor computes the distance d1 accordingto Eq. (1).

2. // For each black pixel b (i1, i0), we use the white pixelsbði1; i00Þ of the ith

1 row to compute the nearest neighborlocated at the window according to Eq. (2). //

Page 9: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

C.-H. Wu et al. / Microprocessors and Microsystems 30 (2006) 425–434 433

2.1. For the right hand side ði00 > i0Þ, each processorP i1;i00

carrying a white pixel uses the eði1; i00Þ, wði1; i00Þ,sði1; i00Þ and nði1; i00Þ found above to computeminfd2½eði1; i00Þ; nði1; i00Þ�, d2½eði1; i00Þ, sði1; i00Þ�g. Thedistance for the left hand side can be computedsimilarly.

2.2. Each processor P i1;i0 carrying a black pixel com-putes the distance d2 (i.e. Eq. (2)) from the resu-lt of Step 2.1 at the ith

1 row by Corollary 4.

3. Each processor P i1;i0 carrying a black pixel computes

min{d1,d2}. Then, the nearest neighbor black pixel foreach black pixel b (i1, i0) can be easily obtained, and storeit in l (i1, i0).

Theorem 18. Given an N · N image stored in an N · N

AROB one pixel per processor, the nearest neighbor black

pixel algorithm can be executed in O (1) time.

6.2. The nearest neighbor figure

Assume that an image consists of several figures, andeach has a label different from those of the other figures.The goal of the nearest neighbor figure problem is to com-pute the nearest neighbor figure for each given figure. Tosolve this problem, our algorithm consists of three majorsteps. First, identify the border pixels for each figure byTheorem 10. Next, each processor with a border pixel com-putes the nearest neighbor border pixel with a different labelby Theorem 18. After that, the nearest neighbor figure ofeach border pixel is determined. Finally, the nearest neigh-bor figure of each figure can be determined by Corollary 4,simultaneously. This leads to the following theorem.

Theorem 19. Given an N · N image stored in an N · N AROB

one pixel per processor, simultaneously for all figures, the

nearest neighbor figure algorithm can be executed in O (1) time.

6.3. The width and diameter

The width of a figure F is the minimum distance betweenany two black pixels in the figure. The width computationis to find two black pixels from the figure F that are nearestapart from each other. It is well-known that the width isachieved by extreme pixels on the convex hull. Thus, thesetwo black pixels must be the extreme pixels of the figure F.Based on this fact, the width algorithm consists of threesteps. First, compute CH (F) in O (1) time by Theorem14. Next, each processor with an extreme pixel computesthe nearest neighbor extreme pixel carrying the same labelby Theorem 18. After that, the nearest neighbor extremepixel of each extreme pixel is determined. Finally, the widthof each figure can be determined by Corollary 4,simultaneously.

Theorem 20. Given an N · N image stored in an N · N

AROB one pixel per processor, simultaneously for all figures,

the width of each figure can be computed in O (1) time.

Similarly, the diameter of a figure F is the maximum dis-tance between any two black pixels in the figure. It is alsowell-known that the diameter is achieved by extreme pixelson the convex hull. Thus, the width algorithm can be mod-ified to compute the diameter of a figure F straightforward-ly. This leads to the following corollary.

Corollary 21. Given an N · N image stored in an N · N

AROB one pixel per processor, simultaneously for all figures,

the diameter of each figure can be computed in O (1) time.

7. Concluding remarks

In this paper, we first introduce two O (1) basic opera-tions: one for finding the leftmost one of an N · N datamatrix and the other for the component reallocation prob-lem. Then, these basic operations can be used to designconstant time algorithms for convexity problems. Further-more, we also propose several optimal algorithms for dig-ital geometry, which include computing the convex hull,computing the perimeter and width, computing smallestenclosing box, determining whether two figures are linearlyseparable, and solving the nearest neighbor problems. Inthe sense of the product of time and the number of proces-sors used, all of our algorithms are both time and costoptimal.

Acknowledgements

This work was partly supported by the National ScienceCouncil under contract No. NSC 92-2213-E-012-001 andNSC-94-2213-E-129-012.

References

[1] D.M. Acketa, J.D. Zunic, On the maximal number of edges of digitalconvex polygon included into a grid square, in: Proceedings of the 3rdCanadian Conf. Computational Geometry, 1991, pp. 215–218.

[2] H.M. Alnuweiri, Constant-time parallel algorithms for image labelingon a reconfigurable network of processors, IEEE Trans. Parall.Distrib. Syst. 5 (1993) 320–326.

[3] Y. Ben-Asher, D. Peleg, R. Ramaswami, A. Schuster, The power ofreconfiguration, J. Parall. Distrib. Comput. 13 (1991) 139–153.

[4] G.E. Blelloch, Scans as primitive parallel operations, IEEE Trans.Comput. 38 (1989) 1526–1538.

[5] V. Bokka, H. Gurla, S. Olariu, J.L. Schwing, I. Stojmenovic, Time-optimal digital geometry algorithms on meshes with multiple broad-casting, in: L.S. Davis et al. (Eds.), Parallel Image Analysis: Theoryand Applications, Series in Machine Perception and ArtificialIntelligence, 19, World Scientific, 1996.

[6] R. Cypher, J.L.C. Sanz, L. Snyder, An EREW PRAM algorithm forimage component labeling, IEEE Trans. Pattern Anal. Mach. Intell.11 (1989) 258–261.

[7] B. Djokic, J. Ruppert, I. Stojmenovic, Constant time digital geometryalgorithms on the scan model of parallel computation, Int. J. HighSpeed Comput. 6 (1994) 501–517.

[8] J. Elmesbahi, Nearest neighbor problems on a mesh-connectedcomputer, IEEE Trans. Syst. Man Cybernet. 20 (1990) 1199–1204.

[9] J. Elmesbahi, H(1) algorithm for image component labeling in a meshconnected computer, IEEE Trans. Systems, Man, Cybernet. 21 (1991)427–433.

Page 10: Optimal geometric algorithms for digitized images on arrays with reconfigurable optical buses

434 C.-H. Wu et al. / Microprocessors and Microsystems 30 (2006) 425–434

[10] M.M. Eshaghian, Parallel algorithms for image processing on OMC,IEEE Trans. Comput. 40 (1991) 827–833.

[11] Z. Guo, R.G. Melhem, R.W. Hall, D.M. Chiarulli, S.P. Levitan,Pipelined communications in optically interconnected arrays, J.Parall. Distrib. Comput. 12 (3) (1991) 269–282.

[12] V.K.P. Kumar, D.I. Reisis, Image computations on meshes withmultiple broadcast, IEEE Trans. Pattern Anal. Mach. Intell. 11(1989) 1194–1201.

[13] S.P. Levitan, D.M. Chiarulli, R.G. Melhem, Coincident pulsetechnique for multiprocessor interconnection structures, Appl. Opt.29 (14) (1990) 2024–2033.

[14] H. Li, M. Maresca, Polymorphic-torus network, IEEE Trans.Comput. 38 (1989) 1345–1351.

[15] R. Lin, S. Olariu, J.L. Schwing, B.F. Wang, The mesh with hybridbuses: an efficient parallel architecture for digital geometry, IEEETrans. Parall. Distrib. Syst. 10 (1999) 266–280.

[17] R. Miller, Q.F. Stout, Geometric algorithms for digitized pictures ona mesh-connected computer, IEEE Trans. Pattern Anal. Mach. Intell.7 (1985) 216–228.

[18] R. Miller, Q.F. Stout, Data movement techniques for the pyramidcomputers, SIAM J. Comput. 16 (1987) 38–60.

[19] D. Nassimi, S. Sahni, Finding connected components and connectedones on a mesh-connected parallel computers, SIAM J. Comput. 9(1980) 744–757.

[20] S. Olariu, J.L. Schwing, J. Zhang, Fast component labelling andconvex hull computation on reconfigurable meshes, Image Vis.Comput. 11 (1993) 447–455.

[21] Y. Pan, K. Li, Linear array with a reconfigurable pipelined bussystem – concepts and applications, Informat. Sci. 106 (3/4) (1998)237–258.

[22] S. Pavel, S.G. Akl, Matrix operations using arrays with reconfigu-rable optical buses, Parall. Algorithms Appl. 8 (1996) 223–242.

[23] S. Pavel, S.G. Akl, Integer sorting and routing in arrays withreconfigurable optical buses, Int. J. Foundat. Comput. Sci. 9 (1998)99–120.

[24] C. Qiao, R.G. Melhem, Time-division communications in multipro-cessor arrays, IEEE Trans. Comput. 42 (1993) 577–590.

[25] Y.R. Wang, S.J. Horng, C.H. Wu, Efficient algorithms for the allnearest neighbor and closest pair problems on the linear array with areconfigurable pipelined bus system, IEEE Trans. Parall. Distribut.Syst. 16 (3) (2005) 193–206.

[26] C.H. Wu, S.J. Horng, H.R. Tsai, Optimal parallel algorithms forcomputer vision problems, J. Parall. Distrib. Comput. 62 (6) (2002)1021–1041.

[27] C.H. Wu, S.J. Horng, Fast and scalable selection algorithms withapplications to median filtering, IEEE Trans. Parall. Distrib. Syst. 14(10) (2003) 983–992.

[28] C.H. Wu, S.J. Horng, Run-length chain coding and scalablecomputation of a shape’s moments using reconfigurable opticalbuses, IEEE Trans. Syst. Man Cybernet. Part B: Cybernet. 34 (2)(2004) 845–855.

Chin-Hsiung Wu received the BS degree fromChinese Naval Academy, the MS degree in infor-mation management from National DefenceManagement College, and the PhD degree inelectrical engineering from National TaiwanUniversity of Science and Technology, Taiwan, in1986, 1991, and 2000, respectively. Currently, he isa full professor in the Department of InformationTechnology & Communication at Shih ChienUniversity Kaohsiung Campus. His researchinterests include image processing, computervision, and parallel and distributed computing.

Shi-Jinn Horng received the BS degree in elec-tronic engineering from National Taiwan Insti-tute of Technology, the MS degree in informationengineering from National Central University,and the PhD degree in computer science fromNational Tsing Hua University in 1980, 1984, and1989, respectively. He has published more than100 research papers and received many awards.Currently, he is a full professor in the Departmentof Computer Science and Information Engineer-ing, National Taiwan University of Science and

Technology. His research interests include VLSI design, multiprocessing

systems, and parallel algorithms.

Yuh-Rau Wang is currently an associate professorand Department Chair of Computer Science andInformation Engineering at St. John’s University,Taipei, Taiwan. He received a PhD degree inelectrical engineering from National TaiwanUniversity of Science and Technology, Taipei,Taiwan. Dr. Wang’s research interests includeimage processing, computer vision, and parallelalgorithms.

Author-Horng-Ren Tsai received the BS, MS andPhD degrees in Electrical Engineering fromNational Taiwan Institute of Technology in 1990,1993 and 1997, respectively. Currently, he is anassociate professor in the Department of Infor-mation Technology at Ling Tung University,Taichung, Taiwan. His research interests includegraph theory, image processing, parallel archi-tectures and parallel algorithms.