Finding circular shapes in an image on a pyramid architecture

Finding circular shapes in an image on a pyramid architecture

Pattern Recognition Letters 13 (1992) 843-848 North-Holland Decemuer 1992 Finding circular shapes in an image on a pyramid architecture Alireza K a ...

554KB Sizes 0 Downloads 37 Views

Pattern Recognition Letters 13 (1992) 843-848 North-Holland

Decemuer 1992

Finding circular shapes in an image on a pyramid architecture Alireza K a v i a n p o u r a n d N a d e r B a g h e r z a d e h Department of Electrical and Computer Engineering, University of California, Irvine. CA 92717, USA

Received 24 December 1991 Revised 22 April 1992

Abstract Kavianpour, A. and N. Bagherzadeh, Finding circular shapes ;,n an image on a pyramid architecture, Pattern Recognition Letters 13 (1992) 843-848. The problem of finding circular shapes in an image using a pyramid architecture is considered. In this paper we have defined a new transformation that converts circles in an image to a family of straight lines allowing the problem to be converted to line detection which can be solved by Hough transform algorithms. Also, based on this new transformation we have developed two algorithms for circle detection using a pyramid architecture.

Keywords. Circle detection, Hough transform, image processing, parallel processing, pyramid architecture.

1. Introduction The detection of lines and curves in an image is a fundamental problem in image processing. The problem is often solved by Hough transform. The Hough transform algorithm was introduced by Paul Hough in a patent filed in 1962 (see Hough (1962)). Rosenfeld (1969) showed that it can be used to detect curves. Later Duda and Hart (1972) suggested that straight lines can be parameterized by the length 0 and orientation angle 0 of the normal vector to the line from the image origin. This relationship is given by 0 = x,cos 0 + y , s i n 0 where 0 is the length of the line segment from the origin perpendicular to the line, and 0 is the angle

Correspondence to: Dr. A. Kavianpour, P.O. Box 4580, Irvine, CA 92716, USA. e-mail: [email protected]

that the line makes with the positive x-axis, measured clockwise. For each point (xi, Ya) the equation O = xi*cos 0+Yi*sin 0 creates a set of sinusoidai curves on the (0, 0) plane as 0 varies from 0 to n. Curves corresponding to the set of collinear figure points will have a common point of intersection represented as (oi, Oi) which defines the line connecting them in the Cartesian coordinates. A point in the Cartesian plane corresponds to a sinusoidal curve in the parameter plane, and a point in the parameter plane corresponds to a straight line in the Cartesian plane. When it is not necessary to determine the lines exactly, we can specify the acceptable error resolution Oresand 0res. The parameter space 0 and 0 can be quantized into m 0-values 01,02, ...,0m and k 0-angles, 01, 02, ..., Ok with an accumulator array of size k , m in which each entry corresponds to a point defined by a pair of (Oi, 0i). A region is

0167-8655/92/$05.00 © 1992 m Elsevier Science Publishers B.V. All rights reserved

843

Volume 13, Number 12

PATTERN RECOGNITION LETTERS

treated as a two-dimensional array of accumulator cells. For each point (xi, Yi) in the Cartesian plane the (O, 0) of the cell selected by the curve with the relation O = xi * cos 0 + Yi * sin 0 is incremented. A given cell in the two-dimensional accumulator array eventually records the total number of curves intersecting at the point represented by a given (0, 0). After all the pixels have been treated, the parameter array is inspected to find those cells with the largest counts. Recently several efforts have been made to speed up the computation of Hough transform by utilizing parallelism. Kavianpour and Bagherzadeh (1991a, b) developed new and efficient algorithms on pyramid architectures for detecting curves using Hough transform. The application of Hough transform for circle detection in a digitized picture was considered by Duda and Hart (1972). In their algorithm a threedimensional array of accumulators was used. This array is indexed by three parameters specifying the location and size of a circle. This algorithm for real-time application is prohibitively time consuming. Detection of approximate circles was considered by Kimme et al. (1975). The procedure is an extension and improvement of the curve finding scheme described by Duda and Hart (1972). Casasent and grishnapuram (1987) have suggested a method which is based on the idea that a curve may be represented as a set of successive short line segments. For example, a circle can be represented by short straight line segments that are tangential to the circle at various points. This paper presents our effort in implementing an algorithm for detecting circles on a pyramid architecture. Section 2 describes a transformation which converts a circle to a line. Section 3 describes two algorith~ns for detecting circles, and finally in Section 4 we present the conclusion.

December 1992

xi

Co

Figure 1. The reflexive image c of point a with respect to point b. Definition 1. Points a and c on the line abc are called reflexive image of each other with respect to the reflection point b, if labl * Ibcl = 1. Figure 1 illustrates the reflexive image property between points a and c with respect to point b. In this figure, points a and c are X and 1/X distance apart from the reflection point respectively. Based on Definition 1, the reflexive property between two points which are reflexive image of each other, is symmetric with respect to the reflection point.

Definition 2. The reflexive image of a function C with respect to point b is another function C' such that for any point xi on C there is a reflexive image point x[ on C ' such that the relation Ibxtl,ibx;l= l is valid. Figure 1 illustrates the reflexive image of an arbitrary function C with respect to point b.

Definition 3. A pixel Pi is called a test pixel if it is selected as a reflection point of a binary image.

.j g:

a~=

IM

=

j

2, Transformation from circles to lines In this section, we will define a transformation that converts a circle to a line and hence facilitates circle detection algorithms. In the rest of this paper the notation [ox I denotes the absolute value of a line ox, i.e., the distance between points o and x.

844

Figure 2. The reflexiveimageof a circlewith respect to point b.

Volume 13, Number 12

PATTERN RECOGNITION LETTERS

Figure 3. Generalillustration of the reflexiveimage of a circle.

Theorem 1. The reflexive image o f a circle with respect to any point on the circle (i.e., the reflection point) is a straight line perpendicular to the line along the diameter passing through the reflection point. Proof. Figure 2 illustrates a circle of diameter lab[ = d. Given point b represents the reflection point, let x~ be a point on the circle such that angle /abxi=O where -n/2~<0~
(l/(d,cos O)).cos 0 = l / d .

December 1992

0~
Thus, the reflexive images of all points of a circle with respect to point b reside on a projection line X = l / d from point b. r-I The following corollary follows from Theorem 1.

Corollary 1. The reflexive image of a circle with respect to a reflection point that has an angle 0, 0 <~1t/2, with respect to the horizontal line passing through the center o f lhe circle is a straight line with an angle n/2 + 0 (see Figure 3).

3. Circle detection algorithm In this section circle detection on a pyramid architecture is considered. A pyramid computer with base size n is an SIMD machine that is constructed from ½ log n + 1 levels of a two-dimensional mesh connected processor array, where the Lth level,

Figure 4. A 4 by 4 base pyramid. 845

Volume 13, Number 12

PATTERN RECOGNITION LETTERS

(2) Edge detection: to represent solid objects by their edges. (3) Thinning: to reduce the edge width (from Step 2). The procedure for detecting circles has two steps. In step one, coordinates of reflexive images will be calculated. In step two, the Hough transform line detection algorithm will be applied. 3.1. General circle detection algorithm ( G C D A )

This algorithm describes a method for detecting circles of any size in a binary image. We assume processor p(O,i,j) at level zero (base) stores Pxo and py~j, the x and y coordinates of the pixel at its local memory. The four phases of the GCDA algorithm are described below. Phase one. Using the apex processor the coordinates of the reflection point, test pixel P0, will be broadcast to all processors at the base using the tree structure of the pyramid architecture. Phase two. In this phase each processor p(0, k, I) at the base computes the reflexive image coordinates of its pixel Pkl with respect to the reflection point PO where l<~k<<.n/4 L+t and 0~
and

cos 0 ffi (Px,, - Px,,)/Dkt.

rx,, = Px,~ - (cos O)/Dkl

= Px,, - (Px,, - Pxo)/D2l.

ry,, = py

=

-(sin O)/Dkt

- (Py,, - Pyo)/D

l,

December 1992

The value of Dkl is equal to: =

- px,)

+

-

After substitution we have the following: Px,,-Px~j rx,, = Px,, - (Px,, - Px,j)2 + (Py,, _py,j)2

and Py, i -Pyo rYA.,= PYo -- (Pxkt -- Pxo )2 Jr (PYk, -- PY0)2"

These coordinates constitute all the points that have to be checked for line detection. Phase three. Reflexive image coordinates with respect to pixei PO are moved up to the corresponding parent processors at level one and a new test pixel p~j is selected for repeating the algorithm at the base level. Phase four. In this phase the Hough transform line detection algorithm as described in our previous work (Kavianpour and Bagherzadeh (1991a)) will be applied to level-one processors of the pyramid. The only modification required is for each processor at level one to acquire four coordinates of its children, and the accumulator array must be changed accordingly to accommodate the extra entries for additional coordinate values. At the end of this phase the apex processor will have coordinates of the circle for test pixel P0' Phases one through four are repeated for all test pixels P0" Since Phase three is computed at the base level, operations of Phases three and four can continue in a pipeline fashion. The only common area of the pyramid is the tree structure utilization in both phases. However, computation of the reflexive image can be performed while Phase four is determining the line corresponding to the previous test pixel. 3.2. Specific circles detection algorithm ( S C D A )

I rid

x Figure 5. The reflexive image coordinates of pixel Pkl with respect to test pixelpq. 846

This algorithm describes a method for detecting circles of diameter d/for i = 1, 2,..., m in a binary image. We assume processor p(0, i , j ) at level zero (base) stores Px,j and py,j, the x and y coordinates of the pixel, and also it stores di, the diameter of the circle at its local memory. The SCDA algorithm has five phases as described below.

Volume 13, Number 12

PATTERN RECOGNITION LETTERS

December 1992

Phase one. Using the apex processor the coordinates of the reflection point, test pixel PO, will

Table 1 Execution times (in seconds) for GCDA and SCDA algorithms

be broadcast to all processors at the base using the tree structure of the pyramid architecture. Phase two. In this phase each processor p(0, i,j) at the base computes the distance of its pixel Pkt from test pixel Pij, by calculating D~.t. Phase three. Each processor compares the computed distance Dki with diameter di. Those processors that satisfy Dkl <<.di will calculate the reflexive image coordinates of their pixel Pkl with respect to the test pixei, p~y. Those processors that do not satisfy Dkt<<.di, will receive a new test pixel, rx~, and ryk~represent the coordinates of the reflexive image of the pixel Pkl and are calculated using the same equations as in Phase two of the GCDA algorithm (see Figure 5). These coordinates constitute all the points that have to be checked for line detection. Phase four. The coordinates of the reflexive images are moved up to the parent processors at level one and a new test pixel p:.~j is selected for repeating the algorithm at the base level. Phase five. In this phase the Hough line detection algorithm as described in our previous work (Kavianpour and Bagherzadeh (1991a)) will be applied to level one of the pyramid to detect lines that are at distance 1/di from the test pixel. At the end of this phase the apex processor will have the coordinates of the circle for the test pixei Pij. Phases one through five are repeated for all test pixels PU" Similar to the GCDA algorithm, SCDA allows for pipeline operations at each phase.

Image size

3.2.1. Algorithm GCDA complexity In this section, we describe the number of operations needed in different phases of the algorithm GCDA. In Phase one, the processor that holds the coordinates of the test pixel will distribute them to other processors at the base using the tree structure of the pyramid. The amount of time needed for this phase is 0 ( 2 log n). The constant 2 represents the number of times the tree must be traversed for each test pixel. In Phase two, the base processors perform two multiplications, one addition, two divisions, and six subtraction operations for a total of eleven operations per step. The time complexity of this step is O(1). Since Phase three involves one

8 by 8

16 by 16

GCDA

SCDA

11.5 25.5

8.1 18.5

transfer operation, assuming the transfer and arithmetic operation for b= I-log l/n] bits of data are equal, the time complexity is O(1). In Phase four the Hough transform will be applied. In the circle detection algorithm a line is specified exactly to be perpendicular to the diameter passing through the reflection point. In Kavianpour and Bagherzadeh (1991a), we showed the complexity of the Hough transform for line detection on a pyramid architecture to be O(log n). In general, for n test pixels the total time complexity is O(n log n). Thus, upon completion of the algorithm the apex processor will contain the coordinates of the detected circle.

3.2.2. Algorithm SCDA complexity Since in the SCDA algorithm only those processors that are located at distance Dkl<~di are needed to compute the reflexive image for a given test pixel, we can use the remaining processors to compute reflexive images for additional test pixels concurrently. This is different from the GCDA algorithm where all processors were only used for one test pixel at each iteration. Thus, if the diameter d~ is less than the diameter of level zero of the pyramid (dbase), then we can initiate concurrent transformations for other test pixels. Consequently, the time complexity is O((n/k) log n) where k=Ldbase/di] is the number of concurrent test pixels. Table 1 illustrates the computer simulation results for 8 by 8 and 16 by 16 binary images.

4. C o n c l u s i o n

This paper considers the problem of detecting circles in images using a pyramid architecture. In this paper we have defined a new transformation that converts circles in an image to a family of 847

Volume 13, Number 12

PATTERN RECOGNITION LETTERS

straight lines allowing t h e p r o b l e m to be c o n v e r t e d t o line detection which can be solved b y H o u g h t r a n s f o r m algorithms. Also, we have d e v e l o p e d t w o algorithms for circle detection o n a p y r a m i d architecture.

References

Casasent, D. and R. Krishnapuram (1987). Curve object location by Hough transformations and inversions. Pattern Recognition 20 (2), 181-188. Duda, R.O. and P.E. Hart (1972). Use of the Houg transforma-

848

December 1992

tion to detect lines and curves in pictures. Comm. A CM 15 (1), 11-15. Hough, P.V.C. (1962). A method and means for recognizing complex patterns. U.S. Patent 3,069,654, 1962. Kavianpour, A. and N. Bagherzadeh (1991a). Parallel Hough transform for image processing on a pyramid architecture. Proc. Int. Conf. on Parallel Processing, August 1991, 395-398. Kavianpour, A. and N. Bagherzadeh (1991b). Circle detection in black and white images. Patent pending UC Case No. 91-195-1. Kimme, C., D. Ballard and J. Skalansky (1975). Finding circles by an array of accumulators. Comm. A C M 18, 120-122. Rosenfeld, A. (1969). Picture Processing by Computer. Academic Press, New York.