A New Efficient Algorithm for Fitting Rectangular Boxes and Cubes in 3D

Frank Ditrich, Herbert Suesse and Klaus Voss
Friedrich-Schiller-University Jena, Department of Computer Science

Ernst-Abbe-Platz 2 D-07737 Jena, Germany

Abstract- In this paper, we introduce a new approach for fitting rectangular boxes and cubes given as a set of voxels in a threedimensional voxel space. This extends our work on fitting rectangles and squares described in [6] to three dimensions. It is also based on our normalization method published in [4] and [5]. Here we also encounter the problem of normalizing the rotation as it is necessary for rectangles and squares, but here we have two degenerate cases to handle. The first one are cubes, the second one are rectangular boxes with two edges of equal length and the length of the third edge different from them. Our method delivers good fitting results, even if the boxes are heavily distorted for example by cutting-off vertices.

II. F ITTING U SING N ORMALIZATION At first we give a short summary of the general principle of our fitting method. We have a class T of transformations where each t ∈ T is described by n parameters ξ1 , . . . , ξn . We have also a class of primitives P (θ), these are the theoretical shapes used for fitting (e.g. rectangles, circles, cubes etc.). Each primitive is described by m parameters θ1 , . . . , θm . If we are given an object O, we derive a tuple of features f (O) = (f1 , f2 , f3 , . . . ). At this point some fitting methods try to solve the problem ||f (O) − f (P (θ))||2 −→ min (1)

I. I NTRODUCTION In [6] we introduced a new fitting procedure for rectangles and squares. In contrast to other authors the objects to be fitted are described as a point set inside a closed region (whereas often objects are represented by points lying on their contour). Furthermore, it uses the method of simultanouosly normalizing the transformation and the shape of the object using area moments as features, as it can be found in [4] and [5]. We used moments up to fourth order for the optimization of the shape and to handle the degenerate case where the rectangle becomes a square. In this case, the second order moments are not sufficient to properly normalize the rotation. Advantages of this method are the reduced numerical effort for the optimization process and the invariance with respect to the transformation group. Since there are many techniques (e. g. computer tomography) which deliver three-dimensional data as output it is also of interest to develop fitting procedures for three-dimensional objects. In this paper we present a procedure for fitting rectangular boxes (and handling the corresponding degenerate cases) which are described by a set of voxels in a voxel space representing the object as a solid and not only forming its boundary.

by searching the m-dimensional space Θ of all primitives. In our approach, we choose an appropriate canonical frame for the class of primitives we fit (e.g. a unit square for the class of all squares with respect to the similarity transformation group) and normalize the object to that frame. Suppose we also normalize the optimal primitive P (θ∗ ) with the same transformation, we have to solve the optimization problem ||f (O ) − f (P (θ∗ ))||2 −→ min (2)

It has the effective dimension m − n. Examples with effective dimension 0 can be found in [4], whereas in [5] examples with dimension 1 are given. At the end we get the optimal fitting primitive P (θ∗ ) by applying the inverse of the normalization transformation to the solution of the optimization process. III. F ITTING R ECTANGULAR B OXES In this paper we use as transformations the group of similarity transformations. A similarity transformation in three dimensions can be described by seven parameters (three for the translational part, three for the rotational part and one for the isotrope scaling). Rectangular boxes can be described by nine parameters (six for the motion and three for the side lengths). As a canonical frame we choose a centered, axis-parallel rectangular box with volume 1, which can be described by two parameters for two of its side lengths. So here we have an example where the optimization problem has effective dimension 2.

This research was supported by DAKO GmbH, Jena.

0-7803-9134-9/05/$20.00 ©2005 IEEE

using  R12 R22 R32 R13 R23  R33  µq = 200 µq = 020 µq = 002 µq = 400 µq = 040 µq = 004 µq = 220 µq = 202 µq = 022 To determine a and b we have to solve the following optimization problem: f (a. since u and −u are both eigenvectors there are eight possible rotations... D. we have m110 = m101 = m011 = 0. up to fourth order (p + q + r = 4).c+f +k . If we describe the rotation by R11 R =  R21 R31 (here det(R) = 1 holds). Suppose we have a centered axis-parallel rectangular box with side lengths a.. b < ∞. Translation As a first step. . The normalization process is done in the following steps: A. The inertial ellipsoid axes are the eigenvectors of the inertial matrix m200 I =  m110 m101  m110 m020 m011  m101 m011  . In [2] an heuristic method is given to select one of this eight tiltings. . Then the following moments can be expressed in terms of a and b (all moments of third order vanish): a2 12 b2 12 1 12a2 b2 a4 80 b4 80 1 80a4 b4 a2 b2 144 1 144b2 1 144a2 It is real and symmectric and has three real eigenvalues and three eigenvectors which are pairwise perpendicular. Rotation For the normalization of the rotation we rotate the object so that the axes of its inertial ellipsoid coincide with the coordinate axes.f ≤q 0≤h. ty .b+e+i. The scaling factor α is α= 3 From now on we use the central moments mpqr = µpqr and we have m100 = m010 = m001 = 0. (x + y + z)n = 0≤a. c e+f f i+k i+k f a b c d e h i k · R11 R12 R13 R21 R22 R23 R31 R32 R33 · .As features we use here the volume moments mpqr = object xp y q z r dxdydz mpqr = 0≤a.i.k≤r a+b+c=p d+e+f =q h+i+k=r a+b+c b+c · . Canonical frame parameters To determine the two remaining parameters. C..b. m000 The moments are transformed by the relationship mpqr = αp+q+r+3 mpqr .e. k ma+d+h.b. After that.− m000 m000 m000 . tz ) = − m100 m010 m001 . This is of evidence if for example the normalized objects shall be compared through some features.c≤n a+b+c=n (a + b + c)! a b c x y z a! b! c! a+b+c b+c b+c a b c x y z c = 0≤a. b and c and volume 1 (abc = 1).c≤p 0≤d. we normalize the translation T and get (tx . Scaling Now we normalize the size by an isotrope scaling S so that m000 = 1. B. So we choose simply one of the eight possibilities.− . we use some higher order moments which have nontrivial values. b+c d+e+f e+f h+i+k · .c≤n a+b+c=n (see [3]) the moments have to be transformed in the following way: . Here an ambiguity is introduced. b) = (m200 − µq )2 + (m020 − µq )2 + 200 020 (m002 − µq )2 + (m400 − µq )2 + 002 400 (m040 − µq )2 + (m004 − µq )2 + 040 004 (m220 − µq )2 + (m202 − µq )2 + 220 202 (m022 − µq )2 022 −→ min subject to 0 < a.b. but since we deal only with rectangular boxes this is uncritical for us. m002 1 .

using fourth order moments only. ry . In Fig. But as for rectangles. In the diagrams we have r1 on the x-axis and r2 on the y-axis. we use one direction from the inertia matrix and the fourth order moments for the remaining directions. λ2 . rz = rx + π j : i. The fitting quality q shown in the figure is the arithmetic means of the distances between the corners of the original and the fitted box (q = 1 means 1 voxel). rz ) + µ004 (rx . set all the voxels inside the box and then fit a box using our algorithm with each of the three rotation normalization methods to determine the regions where they are applicable. • If one ratio is nearby 1 and the other is clearly different from 1 we should take one direction from the inertia matrix and use fourth order moments to get the two others as described in case 2 above. rz rx ry Fig. rz ) −→ min to get the proper rotation parameters for R = Rz · Ry · Rx . and λ3 be the eigenvalues of the inertia matrix with λ1 ≥ λ2 ≥ λ3 λ2 and consider their ratios r1 = | λ1 | and r2 = | λ3 |. First we check if the ratios lie in region I and if so. In this case. Upper images: 0 ≤ q <= 1 (method works well). B. To find the right rotation parameters we use the fact that for a cube centered about the origin the term µ400 + µ040 + µ004 reaches its minimum if the cube is positioned axis-parallel (this is the position of our canonical frame). both ranging from 0 to 1. there are also cases were the above given normalization of the rotation fails. j. Otherwise we check if the ratios lie in the regions marked with II and if so. So we perform an 2 2 optimization µ400 (rx . ry . Evaluation of the fitting quality q dependent on the ratios r1 and r2 for the three methods for rotation normalization. These ratios λ2 are invariant to similarity transformations and can be used to distinguish between the three cases for rotation normalization: • If both ratios are nearby 1. j ∈ Z} and 2 2 {ry = π i. rz run from 0 to 1). taking one direction from the inertia matrix and normalizing the other two by fourth order moments. The inertial ellipsoid can degenerate to a sphere or to an ellipsoid with two axes of equal length. H ANDLING S PECIAL C ASES A. 1 the minima of this term are shown dependent on the three rotation angles rx . we use fourth order moments for a proper normalization of the rotation. From left to right: Using the inertia matrix. ry . rz ) + µ040 (rx . The minima of µ400 (rx . rz ) + µ040 (rx . ry . 3. Fig. Inertial ellipsoid has rotational symmetry In the second case where two axes of the inertial ellipsoid are of equal length and the third is different from them we take the direction of this different axis and map it to the x-axis as a first normalization step. ry . to compute the remaining rotation parameter. A D ECISION C RITERION To complete our fitting algorithm we need a criterion when to use which of the above described methods. Here we also use the fourth order moments and perform the optimization µ040 (rx ) + µ004 (rx ) −→ min So with two properly chosen values ε1 and ε2 the decision is made as shown in Fig.If we have a solution we can easily calculate the corners of the fitted canonical frame and apply the inverse transform (S · R · T )−1 = T −1 · R−1 · S −1 to get the optimal fitted rectangular box for our object. j ∈ Z}. rz ) (rx . The normalization is completed by finding a proper rotation about this x-axis. ry . 2. then the object seems to be a cube and we should use the fitting using fourth order moments only. ry . rz ) + µ004 (rx . 1. π k) : i. ry . which are described in the following. rz used to rotate the axis-parallel cube about the axes with Rz · Ry · Rx : These are the grid points {( π i. IV. In both cases additional procedures are necessary. k ∈ Z} and the two 2 2 2 sets of lines {ry = π i. . Fig. Inertial ellipsoid becomes a sphere One possible degeneration of the inertial ellipsoid is the sphere. • In all other cases we use the inertia matrix. 2 shows the fitting quality for each of the three rotation normalization methods. It is computed in the following way: We randomly create boxes of volume 503 inside a 200x200x200 voxel space. In all other cases we use only the inertia matrix for rotation normalization. π j. lower images: 1 < q (method should not be used in this range). V. Let λ1 . rz = −rx + π j : i. we use only the fourth order moments.

4 Fig. IEEE Trans. Massachusetts. Fitting quality for boxes with volume 503 and a sphere with radius 15 removed at a corner. 6. L. pp. Here we used 50 samples per volume/radius combination. pp. ”A New Efficient Algorithm for Fitting of Rectangles and Squares”. Pattern Recognition. R EFERENCES [1] S. 4. VI. 1994. volume moments as object features. ”Concrete Mathematics”. Addison-Wesley.5 and ε2 = 0. [2] J. [5] K. Cho and H. Fig. 80-83. 5. 646-651. pp. pp. ”Normalization and Shape Recognition of Three-Dimensional Objects by 3D Moments”. ”Orthogonal Distance Fitting of Implicit Curves and Surfaces”. M. Voss. Graham. Warnecke. Suesse. W. S. IEEE Trans. .58 voxels. Knuth and O. we get a fitting quality as shown in Fig. The regions for the three rotation normalization methods. 2. even if there are major regions missing from the object.75. Ahn. PAMI 19 (1997). [6] H. IEEE International Conference on Image Processing 2001 (ICIP’01). PAMI 21 (1999). Suesse and K. Greece. Suesse. E. 26 (1993). 667-681. Reading. Its an application of our fitting principle (see [4]. S UMMARY We presented a new solution for fitting rectangular boxes and cubes with their interior represented by a set of voxels. 3. Vol. Voss and H. For this example we achieved a fitting quality q of 0. Galvez and M. PAMI 24 (2002). For example. IEEE Trans. After extensive experiments we propose to set ε1 = 0. ”Invariant Fitting of Planar Objects by Primitives”. D.-J. [4] K. The average fitting quality for different values of the box volume and the sphere radius is shown in Fig. We also showed how arising degeneracies can be successfully handled using fourth order moments. No. A box with a sphere of voxels removed from one of its corners and the fitted box. 0 1 r1 0 1 r2 0 Fig. Canton. Rauh. Patashnik. Proc. J.1 II ε1 I ε1 40000 Volume 120000 200000 ε2 III II ε2 q 8 4 0 8 4 0 1 20 16 12 Radius Fig. The average achieved fitting quality q for boxes with given volume (from 40000 to 200000 voxels) and spheres with given radius (ranging from 4 to 20) removed from one box corner. 4. if we have boxes with a volume of 503 and we remove all voxels inside a sphere with radius 10 centered at one corner. [3] R. pp. ”A New One-Parametric Fitting Method for Planar Objects”. 5. Voss and H. Vol. 809-812. H. Thessaloniki. 620-638. 5. We achieved very good fitting results. [5]) using a simultanouos normalization of object transformation and object shape and working with area resp.

Sign up to vote on this title
UsefulNot useful