# A New Efﬁcient 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 ﬁtting rectangular boxes and cubes given as a set of voxels in a threedimensional voxel space. This extends our work on ﬁtting 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 ﬁrst 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 ﬁtting results, even if the boxes are heavily distorted for example by cutting-off vertices.

II. F ITTING U SING N ORMALIZATION At ﬁrst we give a short summary of the general principle of our ﬁtting 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 ﬁtting (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 ﬁtting methods try to solve the problem ||f (O) − f (P (θ))||2 −→ min (1)

I. I NTRODUCTION In [6] we introduced a new ﬁtting procedure for rectangles and squares. In contrast to other authors the objects to be ﬁtted 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 sufﬁcient 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 ﬁtting procedures for three-dimensional objects. In this paper we present a procedure for ﬁtting 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 ﬁt (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 ﬁtting 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.