On discrete triangles characterization

On discrete triangles characterization

Computer Vision and Image Understanding 90 (2003) 169–189 www.elsevier.com/locate/cviu On discrete triangles characterization  unic*,1 Jovisa Z Co...

451KB Sizes 3 Downloads 85 Views

Computer Vision and Image Understanding 90 (2003) 169–189 www.elsevier.com/locate/cviu

On discrete triangles characterization  unic*,1 Jovisa Z Computer Science Department, Cardiff University, QueenÕs Buildings, Newport Road, P.O. Box 916, Cardiff CF24 3XF, UK Received 20 August 2001; accepted 21 November 2002

Abstract For a given real triangle T its discretization on a discrete point set S consists of points from S which fall into T . If the number of such points is finite the obtained discretization of T will be called discrete triangle. In this paper we show that all discrete triangles from a fixed discretizing set are determined uniquely by their 10 discrete moments which have the order up to 3. Of a particular interest is the case when S is the integer grid, i.e., S ¼ Z2 . The discretization of a real triangle on Z2 is called digital triangle. It turns out that the proposed characterization preserves a coding of digital triangles from an integer grid of a given size, say m  m; within an Oðlog mÞ amount of memory space per coded digital triangle. That is the theoretical minimum. A possible extension of the proposed coding scheme for digital triangles to the coding digital convex k-gons and arbitrary digital convex shapes is discussed, as well.  2003 Elsevier Science (USA). All rights reserved. Keywords: Digital triangle; Digital shape; Coding; Moments; Discrete moments

1. Introduction In the area of computer image analysis, real objects are replaced with their discretizations, i.e., they are represented by finite number point sets which are obtained by some discretizing process. Due to the applied digitization there is always an inherent loss of information and consequently, it can happen that different real objects have

*

E-mail address: [email protected]. The author is also with the Mathematical Institute of Serbian Academy of Sciences and Arts, Belgrade. 1

1077-3142/03/$ - see front matter  2003 Elsevier Science (USA). All rights reserved. doi:10.1016/S1077-3142(03)00007-9

170

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

the same (or isometric) digitizations, but also that isometric objects have non-isometric digitizations (see Fig. 1). So, the representing real objects by their corresponding discrete sets (pictures) opens new problems. Some of them are: recognition of the original object from the corresponded discrete data, objects classification based on their discrete images, estimation of relevant parameters (size, position, orientation, etc.) of original objects, but also, the efficient storage and encoding of such discrete data— which is the main subject of this manuscript. So called digital objects are mostly studied in literature. Digital objects are results of the discretization of real objects on the integer grid Z2 . However, the discretization can be made by using another ‘‘discretizing’’ sets than it is Z2 (Fig. 1). Let us mention a few other examples of discrete presentation of real objects: images on a hexagonal grid, radar images, images made on sets of statistically distributed points, and so on. This manuscript deals with the encoding of discrete objects which are a result of a discretization of planar regions by applying the discretization scheme which defines the discretization of a given real region as the set of all points from discretizing set which fall into the discretized region. The most of our attention is given to the characterization of discrete triangles (the discretization of real triangles) but an extension to the characterization of digitized convex shapes is given, as well. Objects discretized on the integer grid are mostly studied in literature. It can be said that the problems related to digital straight line segments are solved completely. If a digital straight line segment is given, then it is known how to reconstruct all preimages of it (i.e., all line segments whose digitalizations coincide with the given digital line segment) [3,18], the number of digital straight lines on a squared integer grid is well estimated [13], several coding schemes for digital straight line segments are already known [2,3,16,19,25], etc. Another digital objects are also investigated: recognition problem for the digital circles [4,10,20] and digital squares [5,21] are solved,

Fig. 1. Discretizations of isometric shapes A (points labeled by a) and B (points labeled by b) on three different discretizing sets are shown. In all cases, the discretizations of A and B are non-isometric, but discretizations of A coincide with the discretizations of the given ellipse E.

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

171

digitized circular arcs are considered in [24], efficient coding problem for digital ellipses is considered in [26] while a common coding scheme for different families of digital curve segments including the family of digital polynomial segments is given in [25], etc. We conclude this overview of related literature by mentioning the well-known Freeman (8-chain) code for the encoding of boundaries of digital regions—[6], and two efficient algorithms for decomposition of digital curves into maximal digital straight line segments—[15,23]. The paper is organized as follows. Section 2 contains basic definitions and denotations. Section 3 is related to the characterization of discrete triangles. The main result of the paper, which shows that there are no two different discrete triangles (on the same discretizing set) with the same corresponding discrete moments having the order up to 3, is proved there. In Section 4 we give some performance analysis of the proposed characterization if the discretization is made on a squared integer grid of a given size, but also, a possibility (based on the results obtained here) for the encoding digital convex shapes is discussed. Section 5 contains concluding remarks.

2. Definitions and denotations In this section we list the basic definitions and denotations which will be used in the manuscript. The discretizing set will be denoted by S. A point is called integer point if its coordinates are integers. Set of all integer points is denoted as Z2 . The set consisting of all integer points whose coordinates are non-negative and less than a given number m is called m  m integer grid. For2 2 mally, the m  m integer grid equals Z2 \ ½0; m 1 ¼ f0; 1; 2; . . . ; m 1g . For a given planar region X its discretization on S consists of all points from S which fall into X (see Fig. 1 for some examples), it will be denoted as DðX Þ, and formally defined as DðX Þ ¼ fðx; yÞ j ðx; yÞ 2 X \ Sg: If X is a real triangle T its discretization on S is called discrete triangle and denoted by DðT Þ: We say a discrete triangle is the result of the discretization of a real triangle by using the discretization set S (see Fig. 2). By a digital shape we mean the discretization of a real shape on Z2 , or more formally, a digital shape DðX Þ is the set consisting of all integer points which fall into the real shape X : DðX Þ ¼ fði; jÞ j ði; jÞ 2 X ; i; j are integersg ¼ fði; jÞ j ði; jÞ 2 X \ Z2 g: The digitization of a real convex shape is called digital convex shape, while a digitization of a convex n-gon is called digital convex n-gon. Particularly, a digitization of a real triangle T will be called as digital triangle and denoted as DðT Þ. Through the manuscript only discrete shapes which consist of a finite number of points will be considered.

172

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

Fig. 2. (a) Discretizations of non-isometric triangles MðABCÞ and MðPQRÞ are identical and they consist of 12 numbered points. (b) During the discretization process the vertices of discretized real triangle are usually unknown. We can only manipulate with the obtained discrete set (i.e., discrete triangle).

The discrete moment lp;q ðX Þ of a finite number point set X is defined as X lp;q ðX Þ ¼ xp  y q : ðx;yÞ2X

The moment lp;q ðX Þ has the order p þ q: Through the paper a unique characterization and coding will have the same meaning: if CðAÞ and CðBÞ are codes of the objects A and B, respectively, then CðAÞ ¼ CðBÞ () A ¼ B:

ð1Þ

We shall say that a continuous function z ¼ f ðx; yÞ separates sets A and B if the sign of f ðx; yÞ in the points from A differs from the sign of f ðx; yÞ in the points from B. Precisely, it is either A  fðx; yÞjf ðx; yÞ > 0g and or A  fðx; yÞjf ðx; yÞ < 0g

and

B  fðx; yÞjf ðx; yÞ < 0g;

B  fðx; yÞjf ðx; yÞ > 0g:

Some examples are given in Fig. 3.

3. Characterization of discrete triangles As it is mentioned, different real triangles may have the same discretizations. Real triangles MðABCÞ and MðPQRÞ from Fig. 2(a) have the same discretization which is displayed separately on Fig. 2(b). More over, there is a continuum of real triangles with the same discretization. Consequently, it is not possible to use a real triangle for

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

173

Fig. 3. (a) Function z ¼ c  x þ d  y þ e separates the sets A (points labeled by a) and B (points labeled by b). The function z ¼ ðx f Þ2 þ ðy gÞ2 h also separates A and B. But, the function z ¼ ðc  x þ d  y þ eÞ  ððx f Þ2 þ ðy gÞ2 hÞ does not separate A and B. (b) The function z ¼ f ðx; yÞ does not separate the sets A (points labeled by a) and B (points labeled by b). The function z ¼ gðx; yÞ also does not separate A and B. But the function z ¼ f ðx; yÞ  gðx; yÞ separates A and B.

the unique characterization of its discretization—see (1). By the way, if we have a discrete triangle, the ‘‘original triangle’’ is usually unknown and depending on S; it can be difficult to reconstruct a real triangle whose discretization coincide with the given discrete set. On the other side, the memorizing all points which belong to a given discrete triangle can require a big amount of memory space, which in addition makes a difficult data manipulation—just as an example, the answering a very simple question: Are two given discrete triangles equal or not? cannot be easily answered because of its high time complexity. We will show here that any discrete triangle is determined uniquely by the corresponding discrete moments having the order up to 3. In this way a discrete triangle which can be consisting of an arbitrarily large number of points can be represented uniquely by 10 numbers. Such a characterization is simple and fast independently on the used discretizing set. We start with the following theorem. Theorem 3.1. Let A1 and A2 be finite number point sets. If there exists a function of the form X f ðx; yÞ ¼ ap;q  xp  y q ; where p; q 2 f0; 1; . . . ; kg; ð2Þ pþq 6 k

which separates A1 n A2 and A2 n A1 then lp;q ðA1 Þ ¼ lp;q ðA2 Þ for all non-negative integers p, q, with p þ q 6 k, is equivalent to A1 ¼ A 2 :

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

174

Proof. If A1 ¼ A2 then the corresponding discrete moments are equal obviously. What we have to prove is: The equalities of the corresponded moments of the order up to k preserve A1 ¼ A2 . We prove this by a contradiction. Let X X xp  y q ¼ lp;q ðA1 Þ ¼ lp;q ðA2 Þ ¼ xp  y q ðx;yÞ2A1

ðx;yÞ2A2

hold for all non-negative integers p and q satisfying p þ q 6 k; and for some different finite sets A1 and A2 : Since A1 6¼ A2 we can assume A1 n A2 is non-empty, else we can start with the non-empty A2 n A1 . Further, because there exists a function f ðx; yÞ of the form (2) X f ðx; yÞ ¼ ap;q  xp  y q ; pþq 6 k

which separates A1 n A2 and A2 n A1 ; we can assume f ðx; yÞ > 0 for ðx; yÞ 2 A1 n A2 ; and f ðx; yÞ < 0 for ðx; yÞ 2 A2 n A1 : Then, we have ! X X X p q 0< f ðx; yÞ ¼ ap;q  x  y ðx;yÞ2A1 nA2

¼

X

X

pþq 6 k

ðx;yÞ2A1 nA2



¼

¼

p

ap;q  x  y

X

pþq 6 k

ðx;yÞ2A1 \A2

X

ap;q 

q

ap;q  x  y

X

x y

X

X

q

!

p

x y

q



ðx;yÞ2A2

X

ðx;yÞ2A2 nA1

pþq 6 k

The contradiction 0 < 0

! p

ap;q  x  y

q

X

X

pþq 6 k

ðx;yÞ2A1 \A2

! p

ap;q  x  y

q

q

! p

ðx;yÞ2A1

X

pþq 6 k

þ

p

pþq 6 k

ap;q 

!

!

X

pþq 6 k

¼

ðx;yÞ2A1 nA2

X

X

ap;q 

pþq 6 k

ðx;yÞ2A1 \A2

X

X

ap;q 

pþq 6 k

¼

! p

q

p

q

x y

! x y

ðx;yÞ2A1 \A2

X

f ðx; yÞ 6 0:

ðx;yÞ2A2 nA1

finishes the proof.



Now, we can prove the main result of the paper. Theorem 3.2. Let a discretizing set S be given. Then, any discrete triangle DðT Þ from S is uniquely determined by 10 discrete moments lp;q ðDðT ÞÞ;

where p þ q 6 3; and p; q are non-negative integers:

Proof. We will use the previous theorem specifying that k ¼ 3 and A1 and A2 are discrete triangles DðMðABCÞÞ and DðMðPQRÞÞ. Thanks to a finite cardinality of discrete triangles (there is a continuum of their preimages), we can assume that real

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

175

triangles MðABCÞ and MðPQRÞ are chosen such that there are no points from the discretizing set S which belong to their boundaries, and also, we can assume: MðABCÞ and MðPQRÞ do not have a common vertex, their edges are not mutually parallel (or collinear) and there is no a vertex of one triangle which belong to an edge of the second one. Else, by infinitensimal movements of the vertices of MðABCÞ and MðPQRÞ we can obtain real triangles which satisfy the previous assumptions, and whose digitizations coincide with the given discrete triangles. So, we have to prove that for any choice of MðABCÞ and MðPQRÞ (under the above assumptions) there is a function f ðx; yÞ which is of the form (2), i.e., f ðx; yÞ ¼ P p a  x  y q ; and which separates the set differences DðMðABCÞÞn p;q pþq 6 3 DðMðPQRÞÞ and DðMðPQRÞÞ n DðMðABCÞÞ. We fix the triangle MðABCÞ and distinguish all eight essentially different situations depending on the choice of MðPQRÞ: Such situations are illustrated by Figs. 4–11. The boundary of the triangle MðPQRÞ is drown by dashed lines. In the capture of any figure, a function f ðx; yÞ which separates DðMðABCÞÞ n DðMðPQRÞÞ and DðMðPQRÞÞ n DðMðABCÞÞ is described. Let us prove briefly that all possible cases are covered by Figs. 4–11. Easily, if we consider the set-intersection MðABCÞ \ MðPQRÞ the number of its edges can be 6, 5, 4, or 3 (as considered by the items (i)–(iv), respectively). (i) If MðABCÞ \ MðPQRÞ has six edges, the possible situations correspond to Figs. 4 and 5. Precisely, let V1 ; V2 ; V3 ; V4 ; V5 ; and V6 be vertices of MðABCÞ \ MðPQRÞ. Then we have two essentially different possibilities: (a) The edges ½V1 V2 , ½V3 V4 and ½V5 V6 belong to the boundary of MðABCÞ while the edges ½V2 V3 , ½V4 V5 ; and ½V6 V1 belong to the boundary of MðPQRÞ. This situation is presented in Fig. 4. A possibility for the required separating function is the

Fig. 4. f ðx; yÞ ¼ ðdy þ ex þ f Þ  ðgy þ hx þ kÞ  ðly þ rx þ sÞ is a separating function for DðMðABCÞÞn DðMðPQRÞÞ (points labeled by a belong to the gray area), and DðMðPQRÞÞ n DðMðABCÞÞ (points labeled by b belong to the white area).

176

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

Fig. 5. f ðx; yÞ ¼ ðdy þ ex þ f Þ  ðgy þ hx þ kÞ is a separating function for DðMðABCÞÞ n DðMðPQRÞÞ (points labeled by a belong to the gray area), and DðMðPQRÞÞ n DðMðABCÞÞ (points labeled by b belong to the white area).

Fig. 6. f ðx; yÞ ¼ ðdy þ ex þ f Þ  ðgy þ hx þ kÞ is a separating function for DðMðABCÞÞ n DðMðPQRÞÞ (points labeled by a belong to the white area), and DðMðPQRÞÞ n DðMðABCÞÞ (points labeled by b belong to the gray area).

product of the linear functions which are defined by the straight lines determined by the edges of MðABCÞ—of course, another possibility for the separating function is the product of linear equalities satisfied by the straight lines determined by the edges of MðPQRÞ. (b) Two consecutive edges of MðABCÞ \ MðPQRÞ; let say, ½V1 V2 and ½V2 V3 belong to the boundary of MðABCÞ. Then we have two analog possibilities:

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

177

Fig. 7. f ðx; yÞ ¼ dy þ ex þ f is a separating function for DðMðABCÞÞ n DðMðPQRÞÞ (points labeled by a belong to the white area), and DðMðPQRÞÞ n DðMðABCÞÞ (points labeled by b belong to the gray area).

Fig. 8. f ðx; yÞ ¼ ðdy þ ex þ f Þ  ðgy þ hx þ kÞ is a separating function for DðMðABCÞÞ n DðMðPQRÞÞ (points labeled by a belong to the gray area), and DðMðPQRÞÞ n DðMðABCÞÞ (points labeled by b belong to the white area).



½V1 V2 , ½V2 V3 and ½V5 V6 belong to the boundary of MðABCÞ (presented in Fig. 5 if V1 ; V2 ; V3 ; V4 ; V5 ; and V6 are listed counterclockwise, the points A and Q coincide with V2 and V4 , respectively). One of the required separating functions can be defined as the product of linear equalities of straight lines defined by ½V1 V3

and ½V5 V6 .

178

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

Fig. 9. f ðx; yÞ ¼ dy þ ex þ f is a separating function for DðMðABCÞÞ n DðMðPQRÞÞ (points labeled by a belong to the white area), and DðMðPQRÞÞ n DðMðABCÞÞ (points labeled by b belong to the gray area).

Fig. 10. f ðx; yÞ ¼ dy þ ex þ f is a separating function for DðMðABCÞÞ n DðMðPQRÞÞ (points labeled by a belong to the white area), and DðMðPQRÞÞ n DðMðABCÞÞ (points labeled by b belong to the gray area).



½V1 V2 , ½V2 V3 , and ½V4 V5 belong to the boundary of MðABCÞ then a separating function for DðMðABCÞÞ n DðMðPQRÞÞ and DðMðPQRÞÞ n DðMðABCÞÞ is the product of linear equalities of straight lines determined by V1 V3 and V4 V5 . This case is analogous to the previous one. Since it is not possible that three consecutive edges, let say ½V1 V2 , ½V2 V3 , and ½V3 V4

belong to the boundary of MðABCÞ and ½V4 V5 , ½V5 V6 , and ½V6 V1 belong to the boundary of MðPQRÞ the situations presented in Figs. 4 and 5 cover all possibilities if MðABCÞ \ MðPQRÞ has six edges.

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

179

Fig. 11. f ðx; yÞ ¼ dy þ ex þ f is a separating function for DðMðABCÞÞ n DðMðPQRÞÞ (points labeled by a belong to the white area), and DðMðPQRÞÞ n DðMðABCÞÞ (points labeled by b belong to the gray area).

(ii) If MðABCÞ \ MðPQRÞ has five edges we recognize two possibilities corresponded to Figs. 6 and 7—it can be proved analogously to the item (i). The required separating functions are given it the captures of Figs. 6 and 7. (iii) If MðABCÞ \ MðPQRÞ has four edges, we recognize three essentially different situations corresponded to Figs. 8–10—it also can be proved analogously to (i). The separating functions are in captures of the figures. (iv) if T \ T1 has three vertices we have only one non-trivial situation presented in Fig. 11. Since the existence of a function of the form (2), which separates the set differences of two arbitrarily given different discrete triangles DðMðABCÞÞ and DðMðPQRÞÞ is shown in all possible situations, the statement ðDðMðABCÞÞ ¼ DðMðPQRÞÞÞ () ðlp;q ðDðMðABCÞÞÞ ¼ lp;q ðDðMðPQRÞÞÞ follows due to Theorem 3.1.

for all p; q with 0 6 p þ q 6 3Þ



4. Discretization on an m · m integer grid In this section we consider the discretization on an m  m integer grid. That is the most practical situation because it is corresponded to frequently used digital (binary) pictures made by standard devices as they are digital cameras and scanners, for example. Since the integer grid is a regular grid a more detailed efficiency analysis can be made than in the general case. Also, some comparisons with existing procedures for the digital shape (boundary based) representations can be done.

180

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

Through this section we will assume that all appearing points have non-negative coordinates—i.e., the origin is placed in the left lower corner of the considered digital picture. This section has three subsections. In Section 4.1 we discuss the efficiency of the proposed discrete triangle characterization in the case of discretization on an m  m integer grid. In Section 4.2, we consider the impact of the position of the coded digital triangle to the number of required bits. Section 4.3 is related to an extension of the results to the encoding of digital convex shapes. 4.1. Digital triangles encoding As it is mentioned, we use a digital triangle instead of a discrete triangle if the discretization is made on the integer grid, and use the notation DðX Þ for digital objects instead of a more general D(X). In this section we analyze the storage complexity if the proposed characterization (coding scheme) is used for digital triangles from an m  m integer grid. It turns out that this coding scheme requires the asymptotically minimal possible number of bits per coded digital triangle. Theorem 4.1. The proposed coding scheme enables a coding of digital triangles presented on an m  m integer grid within an amount of Oðlog mÞ bits per coded digital triangle. That is the asymptotic minimum. Proof. Let DðT Þ be a digital triangle from the m  m integer grid. We have easily X X X lp;q ðDðT ÞÞ ¼ ip  jq 6 ip  jq 6 ðm 1Þpþq 6 ðm 1Þpþqþ2 : ði;jÞ2DðT Þ

0 6 i;j 6 m 1

0 6 i;j 6 m 1

Since 10 moments having the order up to 3 (i.e., p þ q 6 3) are enough for the 5 characterization of DðT Þ it follows that 10  logðm 1Þ ¼ Oðlog mÞ bits per coded digital triangle are sufficient for the proposed encoding. On the other side, since any of m2 pixels (from the same grid) can be the digitization of a suitable chosen continuous triangle with a sufficiently small edges, it follows that dlog m2 e ¼ Oðlog mÞ is a lower bound for the number of bits (per coded digital triangle) sufficient for the coding. Since our scheme reaches this minimum the statement is proved.  Further, let us assume that D1 ðSÞ is a digital binary picture of a region S for the resolution r1 ¼ 1; i.e., one pixel per unit, and let D2 ðSÞ be the digital binary picture of the same region for a resolution r2 ; i.e., with r2 pixels per unit. Then D2 ðSÞ ¼ D1 ðr2  SÞ; where r2  S is the dilation of S by factor r2 : More precisely, for a real number r and a set S; the set r  S is defined to be r  S ¼ fðr  x; r  yÞjðx; yÞ 2 Sg:

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

181

So, it can be concluded that the study of a real object S on pictures with increasing resolutions can be transformed to the study of the dilated object r  S on the integer grid [11,12]. Of course, the situation when r ! 1 corresponds to an unbounded resolution increase. Generally speaking, a higher resolution enables an image analysis with a higher precision while a lower resolution enables a faster computation and data manipulation. The choice of resolution should be a good compromise between those criteria. For a practical purpose we give an equivalent formulation of the previous theorem as a remark. Remark 4.1. If a discrete triangle is displyed on a digital picture of a given resolution r (i.e., there are r pixels per measure unit) then Oðlog rÞ bits are sufficient for the storage of its code. Of course, an amount of Oðlog rÞ bits per coded digital triangle is much better than Oðr2  log rÞ bits necessary for the storage of all  ðarea of T Þ  r2 ¼ Oðr2 Þ pixels belonging to DðT Þ; but also, better than the storage of the Freeman (8-chain) code. Namely, it is straightforward that  ðperimeter of T Þ  r ¼ OðrÞ is the best estimate for the storage complexity of the Freeman code of the boundary of digital triangle DðT Þ. Let us mention here that the Freeman coding is the most used code for boundaries of digital shapes. The coding is simple and fast but also preserves a fast reconstruction of the coded shape from the given code. We give an example in order to illustrate the code length of the code proposed here. The Freeman code is used for a comparison because of its simplicity and frequent use. pffiffiffiffiffi If the triangle T with vertices ðp=3; ln 3Þ; ð4; 3Þ; and ð 30; 1:5Þ is presented on digital pictures having resolutions r ¼ 1, r ¼ 100, and r ¼ 1000, then the code of DðT Þ presented here and the size of the Freeman code of the boundary of DðT Þ are listed below. Applied resolution r

The proposed code l0;0 ; l1;0 ; l0;1 ; l2;0 ; l1;1 ; l0;2 ; l3;0 ; l2;1 ; l1;2 ; l0;3

Freeman code length

1

3, 11, 7, 41, 26, 17, 155, 98, 64, 43

6

100

36185, 12693880, 6752390, 4759918368, 2420790884, 884 1320567596, 1876452768418, 917747474042, 482006394242, 270164847422

1000

3618988, 12695921747, 6753765392, 47607829872317, 24213564268683, 13209707547320 187683603193555619, 91798157355252605, 48217079605184691, 27028463512434674

8858

From the presented data it can be seen that for a relatively small resolution r ¼ 1, i.e., one pixel is the measure unit, 76 bits are enough for the code proposed here (19 characters from the set f0; 1; 2; . . . ; 9g should be stored) while 18 bits

182

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

(for the storage of 6 characters from f0; 1; 2; . . . ; 7g) are sufficient for the Freeman coding (i.e., 8-chain coding). The situation is changing if the resolution increase. For example, if r ¼ 100, i.e., there are 100 pixels per measure unit, 396 bits are enough for the proposed code (99 characters from f0; 1; 2; . . . ; 9g) while the Freeman code consisting of 884 characters from f0; 1; 2; . . . ; 7g requires 2652 bits. If r ¼ 1000 the amounts of bits are are 556 and 35432, respectively. Let us conclude this section mentioning that an Oðlog mÞ coding scheme for digital triangles from an m  m integer grid can be derived from already known algorithms for the decomposition of digitized curves into maximal digital straight line segments [15,23]. By using those algorithms the boundary of any digital triangle can be decomposed into (at most) three digital straight line segments. After that, any already existing Oðlog mÞ coding scheme for straight line segments [2,16] enables an optimal coding of digital triangles from an m  m integer grid. If such a coding is applied then the coded digital triangle can be reconstructed from its code easily. The algorithms for the reconstruction of digital straight line segments from the codes presented in [2,16] are already known. It is worth to mention here that an algorithm for a reconstruction of digital triangles from their codes proposed here is not developed yet. A fast approximation algorithm is straightforward and it is enabled by solving a system of the equations which are the connection between a given real triangle and corresponding real moments. On the other side, the proposed coding by moments is more robust with respect to a noise (it takes into account all points—not only the boundary points) and it can be applied independently on which discretization set is used. 4.2. Position of coded digital triangles In this section we will consider the impact of the position of a coded digital triangle to the number of bits required for the storage of 10 moments which are proposed for the coding. Since in this section we consider digital triangles from a given m  m integer grid, the following question seems to be natural: For a large m and affi small digital triangle pffiffiffi (let say all edges of an ‘‘original’’ triangle are shorter than m) which is placed far from the origin (let say all vertices of an ‘‘original’’ triangle have the coordinates bigger than m2=3 ) is it much more efficient to translate the given discrete triangle closer to the ! origin (for the vector ð m2=3 ; m2=3 Þ) , do encoding, and make a new code consisting of the translation vector and of the code of the translated triangle? It will be turn out that the answer is negative, i.e., such a modification of the coding scheme could not lead to an essential decrease of the number of required bits. Namely, if it is noted that the discrete moment lp;q ðDðT ÞÞ equals the number of integer points inside of the 3D-body BðT ; p; qÞ ¼ fðx; y; zÞ j ðx; yÞ 2 T ; z 6 xp  y q g then it is obvious that the cardinality of BðT ; p; qÞ \ Z3 ; i.e., the size of lp;q ðDðT ÞÞ depends on the area of T ; on p and q; but also on the position of T with respect to the

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

183

origin. Roughly speaking, if the coded object is closer to the origin, the moments are smaller. So, if we want to reduce the number of bits necessary for a coding of some digital triangle, the following scenario seems to be natural: (1) translate it by some vector ~ v, (2) do coding of the translated digital triangle, (3) the obtained code and the translation vector ~ v make a new, hopefully, shorter code. Of course, we can allow only translation for a vector with integer coordinates. Let us consider the equations which are satisfied by discrete moments of digital 0 triangle DðT Þ and moments !of a digital triangle DðT Þ obtained from DðT Þ by the translation for a vector ða; bÞ having integer coordinates. l0;0 ðDðT 0 ÞÞ ¼ l0;0 ðDðT ÞÞ; l1;0 ðDðT 0 ÞÞ ¼ l1;0 ðDðT ÞÞ þ a  l0;0 ðDðT ÞÞ; l0;1 ðDðT 0 ÞÞ ¼ l0;1 ðDðT ÞÞ þ b  l0;0 ðDðT ÞÞ; l2;0 ðDðT 0 ÞÞ ¼ l2;0 ðDðT ÞÞ þ 2a  l1;0 ðDðT ÞÞ þ a2  l0;0 ðT Þ; l1;1 ðDðT 0 ÞÞ ¼ l1;1 ðDðT ÞÞ þ a  l0;1 ðDðT ÞÞ þ b  l1;0 ðDðT ÞÞ þ a  b  l0;0 ðDðT ÞÞ; l0;2 ðDðT 0 ÞÞ ¼ l0;2 ðDðT ÞÞ þ 2b  l0;1 ðDðT ÞÞ þ b2  l0;0 ðDðT ÞÞ; l3;0 ðDðT 0 ÞÞ ¼ l3;0 ðDðT ÞÞ þ 3a  l2;0 ðDðT ÞÞ þ 3a2  l1;0 ðDðT ÞÞ þ a3  l0;0 ðDðT ÞÞ; l2;1 ðDðT 0 ÞÞ ¼ l2;1 ðDðT ÞÞ þ b  l2;0 ðDðT ÞÞ þ 2a  l1;1 ðDðT ÞÞ þ 2a  b  l1;0 ðDðT ÞÞ þ a2  l0;1 ðDðT ÞÞ þ b  a2  l0;0 ðDðT ÞÞ; l1;2 ðDðT 0 ÞÞ ¼ l1;2 ðDðT ÞÞ þ a  l0;2 ðDðT ÞÞ þ 2b  l1;1 ðDðT ÞÞ þ 2a  b  l0;1 ðDðT ÞÞ þ b2  l1;0 ðDðT ÞÞ þ a  b2  l0;0 ðDðT ÞÞ; l0;3 ðDðT 0 ÞÞ ¼ l0;3 ðDðT ÞÞ þ 3b  l0;2 ðDðT ÞÞ þ 3b2  l0;1 ðDðT ÞÞ þ b3  l0;0 ðDðT ÞÞ: Since the order of magnitude of the number of bits necessary for the proposed coding of DðT 0 Þ equals the logarithm of the largest summand appearing on the right sides of 10 equalities given above, we can conclude that this number is upper bounded by   O maxflog l3;0 ðDðT ÞÞ;log l2;1 ðDðT ÞÞ;log l1;2 ðDðT ÞÞ;log l0;3 ðDðT ÞÞ;log a;log bg : ð3Þ We give a remark which follows from the previous discussion. Remark 4.2. The asymptotic estimate (3) for the number of bits sufficient for the storage of 10 discrete moments proposed for the coding of a digital triangle shows that the translation of a digital triangle for a vector with integer coordinates does not lead to a significant improvement of the required bit rate, since this vector has to be memorized, as well. pffiffiffiffiffi If we again consider the triangle with vertices ðp=3; ln 3Þ; ð4; 3Þ; and ð 30; 1:5Þ on a picture having the resolution r ¼ 1000 then after the translation for ! ð 1047; 1098Þ (the direction to the origin), the translated digital triangle has the code

184

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

3618988; 8906841311; 2780116568; 24989736950591; 7362660143781; 2741505155240; 75745936536012167; 21059761011480413; 7479990615490731; 3152139649723202; ! noticing that ð 1047; 1098Þ should be added to the code, as well. Comparing to the previously listed example it can be seen that the code lengths are almost equal. Let us mention that in the most standard image processing tasks, real objects are translated in such a way that the origin coincides with their so-called gravity center which is calculated as RR

R R x dx dy y dx dy X R RX R R ; dx dy dx dy X X for a real shape X ; or, in a digital case as ! P P ði;jÞ2DðX Þ i ði;jÞ2DðX Þ j P ;P : ði;jÞ2DðX Þ 1 ði;jÞ2DðX Þ 1 Moments of so positioned shape are called central moments. But, a usage of central moments is not convenient for us because they are not always integers. 4.3. Further application Since the shape triangulation is one of common procedures in many computer vision and image processing tasks it can be concluded that an efficient digital triangle coding scheme can be applied to the encoding of more general shapes. In this section we will analyze the efficiency of the encoding digital convex shapes by using the digital triangles coding scheme established in this paper and compare it with the efficiency of another coding scheme which naturally follows from known results. Again, a digital convex shape means the digitization of a real convex shape. As it is mentioned, if we want to encode a digital convex shape by using the previously described coding scheme for digital triangles, it is enough to make a partition of the coded digital convex shape into digital triangles, and after that apply the coding scheme to the obtained digital triangles. Since a digital convex polygon can be partitioned into digital triangles in many different ways, we have to fix a partitioning procedure. The following one seems to be very natural (see Fig. 12) and easily applicable not only in digital case. Procedure 1 (Decomposition into digital triangles). (i) For a given digital convex shape DðSÞ determine the convex hull CH ðDðSÞÞ; and list the vertices of it in the counterclockwise order A0 ; A1 ; A2 ; . . . ; AnðDðSÞÞ ¼ A0 ; where A0 is the right outermost vertex of CH ðSÞ among those with the minimal y-coordinate. The number of vertices of CH ðDðSÞÞ is denoted as nðDðSÞÞ.

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

185

Fig. 12. Digital convex shape is portioned into seven digital triangles. The points belonging to the same triangle are labeled by the same number.



(ii) Let DððA0 Aiþ1 Aiþ2 Þ Þ be the digital set obtained from the digital triangle DðMðA0 Aiþ1 Aiþ2 ÞÞ by excluding the integer points lying on the (closed) edge  ½A0 Aiþ1 : Obviously, DððA0 Aiþ1 Aiþ2 Þ Þ is also a digital triangle whose ‘‘preimage’’ can be obtained from the triangle A0 Aiþ1 Aiþ2 by a translation (for a small enough vector) of the edge ½A0 Aiþ1 in the direction to the the point Aiþ2 . Then DðSÞ can be represented as the set-union of the following non-overlapping digital triangles: DðMðA0 A1 A2 ÞÞ

and

DððA0 Aiþ1 Aiþ2 Þ Þ

for i ¼ 1; . . . ; nðDðSÞÞ 3:

The size of the code of DðSÞ (consisting of codes of digital triangles obtained by previously described procedure) obviously depends on the number of vertices of CH ðDðSÞÞ. If there are no assumptions about the convex shape S; whose digitization is presented on an m  m integer grid, then the best possible upper bound for the number of vertices of CH ðDðSÞÞ is [1]   12 ffiffiffiffiffiffiffiffiffiffiffi  m2=3 þ O m1=3  log m p ð4Þ 3 4  p2 (there is also a digital convex shape whose convex hull has such a number of vertices).

186

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

The previous discussion and Theorem 4.1 give the following statement. Theorem 4.2. The coding scheme proposed here enables the encoding of digital convex shapes from an m  m integer grid within an   O m2=3  log m amount of bits per coded digital convex shape. Another possibility to decompose a digital convex shape into digital triangles can be based on known algorithms [15,23] for partitioning a digitized curve into maximal digital straight line segments. If any of such algorithms is applied to the boundary of digital convex shape, and the triangulation is made based on this decomposition, the number of obtained digital triangles is not bigger than the number of digital triangles obtained by Procedure 1, and it is not difficult to construct a digital convex shape such that the number of vertices of its convex hull is strictly less then the number of maximal digital straight line segments which make its boundary. But, if N ðmÞ denotes the maximum number of digital straight line segments which make a boundary of a digital convex shape from an m  m integer grid, it is not known yet what is the order of magnitude of N ðmÞ. What can be said is that the order of magnitude of N ðmÞ could not be essentially smaller than m2=3 = log m. Namely, if N ðmÞ has the order of magnitude less than m2=3 = log m, then it would be possible to encode digital convex shapes from an m  m integer grid with the number of bits whose order of magnitude is strictly less than m2=3 —but this contradicts to (4) which easily gives that the number of digital convex shapes is bigger than 12 ffi  m2=3 þ Oðm1=3  log mÞ ffiffiffiffiffiffiffiffiffiffi p 3 2 4  p2 : In any case, it can be concluded that the storage complexity for codes of digital convex shapes from an m  m integer grid is OðN ðmÞ  log mÞ bits per coded digital convex shape, under assumption that the triangulation is made by decomposing the digital shape boundaries into maximal straight line segments. A better upper bound (than Oðm2=3  log mÞ) easily holds for the number of bits required for the coding digital shapes which are digitizations of real k-gons if assume that k is essentially less than m2=3 . Precisely, any digital sets which is a digitization of a real convex k-gon on the m  m integer grid can be coded by Oðk  log mÞ bits. It is important to mention here that if the Procedure 1 is applied for the decomposition of a digital convex shape which is the result of a digitization of a given real k-gon, then the number of bits required for such an encoding can be estimated as 2

Oðk  ðlog mÞ Þ: Namely, an Oðlog nÞ upper bound for the number of vertices of the convex hull of a digital straight line segment consisting of n points, follows easily from the

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

187

characterization of digital straight line segments by, so-called, adjacent pairs, established in [16]. So, the number of vertices of the convex hull of a digital convex k-gon S from an m  m integer grid is upper bounded by Oðk  log mÞ; which estimates the number of digital triangles obtained by applying Procedure 1 to DðSÞÞ; as well. Finally, the statement follows by Theorem 4.1. Let us conclude this section noticing that the problem of the optimal coding of digital convex shapes from an m  m grid still remains unsolved. Namely, it is known [8] that such an optimal coding requires at most Oðm2=3 Þ bits per coded digital convex shape and that is the best possible estimate. But such a coding scheme is still unknown. As it is stated by Theorem 4.1 the coding scheme proposed here requires Oðm2=3  log mÞ bits per coded digital convex shape. That is, in an asymptotic sense, the same amount as in the case of the coding ‘‘vertex-by-vertex,’’ i.e., by the storage of all vertices of the convex hull of the considered digital convex shape. It is easy to see that the coding scheme presented here is more robust because it is not based on the boundary points only.

5. Conclusion Real moments are already used as a good descriptors of shapes [7,17]. In this paper we shown that ten discrete moments having the order up to 3 are sufficient for a unique characterization (coding) of the discrete triangles. The method can be applied to different discretizing sets. It is only required that the discrete objects have a finite cardinality, which is not a restriction in practical applications. If digital triangles from an m  m integer grid are considered then the proposed encoding is asymptotically optimal with respect to the used memory space. A number of papers were devoted to developing fast algorithms of moment computation for 2D objects [9,14]. Also, a general approach for moment calculation for polygons and line segments is given in [22]. If there are no assumptions about the discretizing set a performance analysis of the code length is not given. Such a general estimate is not possible because it depends on many factors as they are: topology of discretizing set (for example, how many points are collinear), diameter of it, are the coordinates integers or not, etc. In any case, 10 numbers (which are discrete moments) are always enough for an unique matching of a discrete triangle which can consist of an arbitrarily large number of points. The method is modified and applied to the encoding of digital convex shapes. A particular attention is given to the coding of digitized real convex k-gons. A performance analysis is done and the results are compared with performances of a possible coding scheme which comes from a decomposition of the boundary of the coded digital convex shape into maximal digital straight line segments. The coding scheme for discrete shapes from an arbitrary discretizing set (different from Z2 ) is not discussed because of its simplicity. It also assumes that a given discrete shape have to be partitioned into discrete triangles (for example Procedure 1) and after that the coding procedure should be applied to the obtained discrete triangles.

188

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

Acknowledgments The author would like to thank the referees for their helpful comments and suggestions which led to an essential improvement of the manuscript. References  unic, On the maximal number of edges of digital convex polygons included into an [1] D.M. Acketa, J. Z ðm; mÞ-grid, J. Combinat. Theory A 69 (1995) 358–368. [2] L. Dorst, A.W.M. Smeulders, Discrete representation of straight lines, IEEE Trans. Pattern Anal. Machine Intell. 6 (1984) 450–463. [3] L. Dorst, A.W.M. Smeulders, Discrete straight line segments: parameters, primitives and properties, in: P. Bhattacharya, A. Rosenfeld (Eds.), Vision Geometry, Contemporary Mathematics, vol. 119, American Mathematical Society, Providence, RJ, 1991, pp. 45–62. [4] S. Fisk, Separating point sets by circles, and the recognition of digital disks, IEEE Trans. Pattern Anal. Machine Intell. 6 (1984) 554–556. [5] S. Forchammer, C.E. Kim, Digital squares, in: Proc. 9th IEEE Int. Conf. on Pattern Recognition, vol. 2, 1988, pp. 672–674. [6] H. Freeman, Boundary encoding and processing, in: B.S. Lipkin, A. Rosenfeld (Eds.), Picture Processing and Psyhopictorics, Academic Press, New York, 1970, pp. 391–402. [7] M. Hu, Visual pattern recognition by moment invariants, IRE Trans. Inform. Theory 8 (1962) 179–187.  unic, On the number of digital convex polygons inscribed into an ðm; mÞ[8] A. Ivic, J. Koplowitz, J. Z grid, IEEE Trans. Inform. Theory 40 (1994) 1681–1686. [9] X.Y. Jiang, H. Bunke, Simple and fast computation of moments, Pattern Recognition 24 (1991) 801–806. [10] C.E. Kim, Digital circles, IEEE Trans. Pattern Anal. Machine Intell. 6 (1984) 372–374.  unic, Digital approximation of moments of convex regions, Graphical Models Image [11] R. Klette, J. Z Process. 61 (1999) 274–298.  unic, Multigrid convergence of calculated features in image analysis, J. Math. Imaging [12] R. Klette, J. Z Vision 13 (2000) 173–191. [13] J. Koplowitz, M. Lindenbaum, A. Bruckstein, On the number of digital straight lines on a squared grid, IEEE Trans. Inform. Theory 15 (1993) 949–953. [14] J.-G. Leu, Computing a shapeÕs moments from its boundary, Pattern Recognition 24 (1991) 949–957. [15] M. Lindenbaum, A. Bruckstein, On recursive, OðN Þ partitioning of a digitized curve into digital straight segments, IEEE Trans. Pattern Anal. Machine Intell. 15 (1993) 949–953. [16] M. Lindenbaum, J. Koplowitz, A new parametrization of digital straight lines, IEEE Trans. Pattern Anal. Machine Intell. 13 (1991) 847–852. [17] A.G. Mamistvalov, n-Dimensional moment invariants and conceptual mathematical theory of recognition n-dimensional solids, IEEE Trans. Pattern Anal. Machine Intell. 20 (1998) 819–831. [18] M.D. McIlroy, A note on discrete representation of lines, AT&T Tech. J. 64 (1984) 481–490.  unic, A new characterization of digital lines by least square fits, [19] R.A. Melter, I. Stojmenovic, J. Z Pattern Recognition Lett. 14 (1993) 83–88. [20] A. Nakamura, K. Aizawa, Digital circles, Comput. Vision Graphics Image Process. 26 (1984) 242–255. [21] A. Nakamura, K. Aizawa, Digital squares, Comput. Vision Graphics Image Process. 49 (1990) 357–368. [22] M.H. Singer, A general approach to moment calculation for polygons and line segments, Pattern Recognition 26 (1993) 1019–1028. [23] A.W.M. Smeulders, L. Dorst, Decomposition of discrete curves into piecewise straight segments in linear time, in: P. Bhattacharya, A. Rosenfeld (Eds.), Vision Geometry, Contemporary Mathematics, vol. 119, American Mathematical Society, Providence, RJ, 1991, pp. 169–195.

J. Z unic / Computer Vision and Image Understanding 90 (2003) 169–189

189

[24] M. Worring, A.W.M. Smeulders, Digitized circular arcs: characterization and parameter estimation, IEEE Trans. Pattern Anal. Machine Intell. 17 (1995) 587–598.  unic, D.M. Acketa, A general coding scheme for families of digital curve segments, Graphical [25] J. Z Models Image Process. 60 (1998) 437–460.  unic, N. Sladoje, Efficiency of characterizing ellipses and ellipsoids by discrete moments, IEEE [26] J. Z Trans. Pattern Anal. Machine Intell. 22 (2000) 407–414.