Full text
71 Chapter 4 Geometric Processing of Adaptive Triangular Meshes: Analysis Operations This chapter presents a set of geometric processing operations applicable to 21/2D adaptive triangular meshes. As it was indicated in chapter 3, these meshes must be projectable onto the reference plane, and they may approximate a digital image or any other kind of surface, such as terrain. Those meshes are simply referred to as triangular meshes throughout this chapter. These operations have been classified as analysis operations since they involve the extraction of information from adaptive triangular meshes. The extracted information can then be used to perform a description, interpretation or understanding of the adaptive triangular meshes in some way. Section 4.1 introduces the proposed analysis operations. Section 4.2 describes a set of preprocessing operations: geometric transformations, thresholding, quantization and algebraic operations, region-of-interest selection and tools for the generation of synthetic triangular meshes. Section 4.3 describes an edge detection technique. Section 4.4 presents a segmentation technique. Section 4.5 describes a set of operations for z0=
72 GEOMETRIC PROCESSING OF ADAPTIVE TRIANGULAR MESHES: ANALYSIS OPERATIONS feature extraction from binary triangular meshes. Section 4.6 presents a histogram generation algorithm from adaptive triangular meshes. Finally, the contents of this chapter are summarized in Section 4.7. 4.1 Introduction The interest of applying processing operations to digital images is twofold. On the one hand, image processing operations allow to improve the quality of the original images. On the other hand, those processing operations may simplify further computer vision tasks. In chapter 3, it was shown how to obtain 21/2D adaptive triangular meshes starting with digital images. The advantage of utilizing triangular meshes is that they allow to represent the information contained in digital images in a compact form, by removing redundant information. This chapter presents a set of techniques to perform typical image analysis operations upon 21/2D triangular meshes with two main purposes. First, by taking into account that the processed triangular meshes can represent any type of information, such as digital images or terrain surfaces, the typical operations applied in image processing upon gray level images can also be applied to triangular meshes in general. Additionally, by taking advantage that the processed triangular meshes are compact representations of digital images, the processing operations directly applied to those meshes can be more efficient than if they were applied to the original digital images. The classification of analysis operations utilized in this chapter is based on the classification made by Jain (1989) and Umbaugh (1998). In the next section, a set of techniques to perform image preprocessing operations upon 21/2D triangular meshes is described. 4.2 Preprocessing Operations upon 21/2D Triangular Meshes This section describes several image preprocessing operations applied to 21/2D triangular meshes. The described techniques allow the application of the following operations: geo-
GEOMETRIC TRANSFORMATIONS 73 metric transformations, thresholding, quantization, algebraic operations, selection of regions-of-interest and generation of synthetic triangular meshes. The next section presents the following geometric transformations: rotation, translation, shrinking, stretching, scaling and deformation. 4.2.1 Geometric Transformations The adaptive triangular meshes obtained with any of the two techniques proposed in Chapter 3 are representations of digital images at a higher level of abstraction. This may allow the application of many image processing operations more efficiently than if they were applied upon the individual pixels of the original images. For example, rotation, translation, scaling, shrinking, stretching and deformation operations are trivially implemented by applying geometric transformations to the 3D coordinates of the points that constitute the adaptive triangular meshes. Since those adaptive meshes contain a fraction of the original amount of pixels, these operations perform faster than their pixel-to-pixel counterparts. Figure 4.1(middle) shows an adaptive triangular mesh that will be used to illustrate the application of the proposed geometric transformations. This mesh was obtained by applying the algorithm described in Section 3.3.2. Figure 4.1. (left) Original range image with 40,000 pixels (200x200). (middle) Adaptive triangular mesh obtained with the algorithm described in Section 3.3.2 (1,634 sampled pixels). The proposed geometric transformations are applied upon this mesh. (right) Rendered adaptive triangular mesh.
74 GEOMETRIC PROCESSING OF ADAPTIVE TRIANGULAR MESHES: ANALYSIS OPERATIONS 4.2.1.1 Rotation and Translation of Triangular Meshes The rotation of a triangular mesh can be implemented by rotating every point of the mesh a previously defined angle. Hence, the new coordinates of the points of the given triangular mesh are computed as follows: (4.1) where is the specified rotation angle. Figure 4.2(left) shows the result obtained when a rotation of 45 degrees is applied to the triangular mesh shown in Figure 4.1(middle). The translation of a triangular mesh consists of the translation of the coordinates of its points: (4.2) where are the coordinates of the translated points and and are the specified translation factors. Figure 4.2(middle) shows the result obtained when a translation with and is applied to the points of an adaptive triangular mesh. Notice that the rotation and translation operations can also be combined as follows: (4.3) x y z, ,( ) x′y′z′, ,( ) x′xΦyΦsin+cos= y′xΦyΦcos+sin–= z′z= Φ x y z, ,( ) x′x Tx += y′y Ty += z′z= x′y′z′, ,( ) Tx Ty Tx70= Ty100 · = x′x Tx +( ) Φcos y Ty +( ) Φsin+= y′x Tx +( )–Φsin y Ty +( ) Φcos+= z′z=
GEOMETRIC TRANSFORMATIONS: ROTATION AND TRANSLATION 75 Figure 4.2(right) displays the final image after applying the same rotation and translation operations, Figure 4.2(left) and Figure 4.2(middle), but now combined into a single expression, by using Equation (4.3). When an approximating image is generated from the triangular mesh obtained after a translation or rotation, some problems may arise. For instance, if a translation is applied, the dimensions of the mesh bounding box remain constant. In this way, the obtained approximating image by applying the z-buffering process (Section 3.4.2) would no visualize the effect of the translation applied to the mesh. To avoid this problem, a visualization bounding box has been defined. This new bounding box contains both the mesh bounding box and the effects produced after processing that mesh. The minimum coordinates of the visualization bounding box are set to , while the maximum coordinates are defined according to the boundaries of the mesh. If any of the maximum coordinates are negative, they are translated back to the positive quadrant. A similar procedure is applied when the triangular mesh has been rotated. Figure 4.3 illustrates those problems. The pixels contained in the visualization bounding box that are located outside the limits of the resulting mesh are set to zero when they are visualized using the z-buffering technique presented in Section 3.4.2. Figure 4.2. Approximating images obtained after applying geometric transformations to the original triangular mesh. (left) Rotation. (middle) Translation. (right) Combined operations: rotation and translation. xmin ymin ,( ) 0 0,( )
76 GEOMETRIC PROCESSING OF ADAPTIVE TRIANGULAR MESHES: ANALYSIS OPERATIONS 4.2.1.2 Scaling, Shrinking and Stretching of Triangular Meshes The scaling operation applied to a given triangular mesh is defined as: (4.4) where and are the scale factors computed as: and ; where S is the scale factor specified by the user. Figure 4.4(left) displays the result obtained when a scale factor is applied to the triangular mesh shown in Figure 4.1(middle). Figure 4.3. Definition of the visualization bounding box: (top row) after applying mesh translation and (bottom row) after applying mesh rotation. Tx Ty X Y Ymax X Y translated mesh Xmax Xmin= 0 Ymin= 0 visualization bounding box X Y rotated mesh Φ X Yvisualization bounding box Xmax Ymax Xmin= 0 Ymin= 0 x′x Sx = y′y Sy = z′z= Sx Sy SxS Xmax 1+( ) 1–( ) Xmax ⁄= SyS Ymax 1+( ) 1–( ) Ymax ⁄= S2=
GEOMETRIC TRANSFORMATIONS: SCALING, SHRINKING AND STRETCHING 77 Additionally, shrinking and stretching operations can also be applied to the given triangular mesh if a new number of rows and columns is desired for the modified image. In this case, the coordinates of the mesh points are computed as follows: (4.5) where and are the shrinking or stretching factors computed as: and . and are the new number of columns and rows desired for the final image (shrunk or stretched image) respectively, and are the maximum coordinate values of the input triangular mesh. Figure 4.4(right) shows the result when the triangular mesh is scaled up to an image of 400x180 pixels (vertical stretching and horizontal shrinking). Figure 4.4. Approximating images obtained after applying: (left) scaling and (right) stretching and shrinking to the triangular mesh of Figure 4.1(middle). x′y′z′, ,( ) x′xSx ′= y′ySy ′= z′z= Sx ′ Sy ′ Sx ′Cnew 1–( ) Xmax ⁄= Sy ′Rnew 1–( ) Ymax ⁄= Cnew Rnew Xmax Ymax ,( )
78 GEOMETRIC PROCESSING OF ADAPTIVE TRIANGULAR MESHES: ANALYSIS OPERATIONS 4.2.1.3 Deformation of Triangular Meshes Besides the basic functions described above, any mathematical function can be applied to the points of the mesh in order to obtain other types of visual effects. For example, a possible deformation is the generation of an elliptical bounded mesh from a quadrilateral bounded mesh. This kind of geometric manipulation directly works upon the positions of the points, maintaining the topology of the original triangular mesh. The procedure applied to obtain the proposed deformation is the following. First, the x and y coordinates of the points of the original mesh are scaled and translated (Section 4.2.1.1 and Section 4.2.1.2) such that they are normalized into the interval . Then, the positions of the points of the elliptical bounded mesh are obtained from the points of the previous normalized mesh as: (4.6) where when either or , and when or ; is the angle of each normalized point with respect to the horizontal axis of a coordinate system located at the center of the normalized mesh, and are scalar factors used to generate a circular deformation ( ) or an elliptical deformation ( ). Two examples that illustrate the approximating images obtained after applying a circular deformation and an elliptical deformation are shown in Figure 4.6(bottom left) and Figure 4.6(bottom right) respectively. 4.2.1.4 Experimental Results The proposed geometric transformations have been tested upon various adaptive triangular meshes of different size. Those meshes are representations of digital images that have been obtained with the algorithm described in Section 3.3.2. The CPU times to perform these operations were measured and compared with the times to perform similar operations with 1– 1,[ ] x′kxrθcos= y′kyrθsin= z′z= r x= π4⁄–θ π 4⁄<≤ 3π4⁄ θ 5π4⁄<≤ r y= π4⁄ θ 3π4⁄<≤ 5π4⁄ θ 7π4⁄<≤ θ kx ky kxky = kxky ≠
GEOMETRIC TRANSFORMATIONS: DEFORMATION 79 CVIPtools, a conventional image processing software which is publicly available (Umbaugh, 1998). These CPU times were measured on a SGI Indigo II with a 175MHz R10000 processor. Figure 4.1(middle) and Figure 4.5(middle) show two examples of adaptive triangular meshes that contain 1,634 and 2,461 points respectively. Their corresponding RMS errors with respect to the original images, Figure 4.1(left) and Figure 4.5(left), are 9.92 and 7.26 respectively. The CPU times to perform the rotation operation upon the images displayed in Figure 4.1(left) and Figure 4.5(left) with CVIPtools were 0.33 sec. and 2.26 sec., while the same operation in the geometric domain took 0.0043 sec. and 0.0056 sec. respectively. The translation operation took 0.05 sec. and 0.34 sec. with CVIPtools and 0.0003 sec. and 0.0004 sec. with the proposed technique. Finally, the scaling operation took 0.11 sec. and 0.34 sec. with CVIPtools, while it took 0.0004 sec. and 0.0006 sec. with the proposed technique in the geometric domain. CVIPtools does not include any routines for producing deformations such as the circular and elliptical ones shown in Figure 4.6(bottom). Therefore, they should be implemented Figure 4.5. Triangular mesh utilized to perform the geometric transformation operations. (left) Original image with 262,144 pixels (512x512). (middle) Adaptive triangular mesh generated with the algorithm described in Section 3.3.2, which contains 2,461 sampled pixels. (right) Approximating image obtained from the previous mesh.
86 GEOMETRIC PROCESSING OF ADAPTIVE TRIANGULAR MESHES: ANALYSIS OPERATIONS Experimental results show that this thresholding operation may be more efficient in the geometric domain than in the image domain. The actual times depend on the number of triangles intersected by the dissection plane, which, in turn, depends on the contents of the image, the resolution of the triangular mesh (i.e., its approximation error) and the chosen threshold. Experiments have shown that, in general, an effective speed-up is guaranteed when the original images have more than a hundred times more pixels than points their corresponding triangular meshes have. This is the case of the examples shown in Figure 4.8 and Figure 4.9. Figure 4.9. (left column) Original images with 1,048,576 pixels (1024x1024, Lenna) and 262,144 pixels (512x512, pens). (middle column) Adaptive triangular meshes generated with the technique presented in Section 3.3.2: (top) 9,497 points (bottom) 1,354 points. (right column) Approximating images obtained through z-buffering (Section 3.4.2). RMS Error: (top) 10.8, (bottom) 6.8, considering 256 gray levels.
QUANTIZATION OF TRIANGULAR MESHES 87 The previous CPU times do not consider the image-to-mesh and mesh-to-image stages. The reason is that these stages must only be applied once. If many operations are performed (chained) in the geometric domain, the overhead of those two stages will become negligible. 4.2.3 Quantization of Triangular Meshes Triangular mesh quantization refers to the process of defining a set of possible z coordinate values that a point of a given 21/2D triangular mesh may take. This process consists of mapping predefined ranges of z values of the given triangular mesh to single z values. Within the image processing field, this operation is referred to as image quantization. The proposed quantization technique applies two main stages for mapping every predefined range of z values to a single z value. The first stage dissects the triangular mesh with as many horizontal planes as desired z values. Those planes are parallel to the xy reference plane of the given mesh and intersect the z axis at values that correspond to specified thresholds, Figure 4.11(left). Each parallel plane generates a mesh dissection, which is obtained Figure 4.10. CPU times for the thresholding operations, using both the proposed and conventional algorithms with different thresholds.
88 GEOMETRIC PROCESSING OF ADAPTIVE TRIANGULAR MESHES: ANALYSIS OPERATIONS by applying the dissection algorithm proposed in the thresholding operation described in Section 4.2.2. The range of z values comprised between two consecutive parallel dissection planes is mapped to a single z value that corresponds to coordinate , where is the height of the inferior dissection plane, Figure 4.11(right). Furthermore, each intersection point obtained after applying the mesh dissection process is unfolded into two points, by projecting every intersection point both upwards and downwards. Those points have the same coordinates as the intersection point, but different z coordinates: one of them is set to coordinate , where is the z coordinate of the inferior plane and the other is set to coordinate , where is the z coordinate of the superior plane. Figure 4.11(right) illustrates an example of this process. The second stage of the algorithm retriangulates the triangles that have been dissected with the previous process. In this stage, the final quantized triangular mesh is generated. Figure 4.12(middle) illustrates an example of the resulting triangular mesh after applying the second stage of the proposed algorithm. Both stages are described in more detail below. Figure 4.11. Illustration in the 2D space (zx plane) of the process of multiple dissection of a triangular mesh. (left) Parallel planes dissecting the given triangular mesh. (right) The range of z values comprised between two consecutive planes is projected to coordinate , where corresponds to the z height of the inferior plane. Furthermore, the intersection points are unfolded. z zinf 1+= zinf unfolding triangular mesh dissection planes range of z values z zinf 1+= zinf zsup range of z values Z XX Z z zinf 1+= zinf x y,( ) z zinf 1+= zinf z zsup 1+= zsup
QUANTIZATION OF TRIANGULAR MESHES 89 4.2.3.1 Multiple Dissection of a Triangular Mesh Given a triangular mesh M, a multiple dissection process is applied upon M. This process dissects the given mesh at as many horizontal planes as possible z values, nz, are desired for the final quantized mesh. Each mesh dissection is performed with a plane parallel to the xy reference plane of M, by using the dissection algorithm proposed for the thresholding operation (Section 4.2.2). These dissection planes intersect the z axis at a value defined as follows: (4.7) where and corresponds to the maximum value that can take the z coordinate of the mesh points. Considering that the given triangular mesh M represents, for example, an 8-bit gray level image, the maximum number of z values, nz, will be 256. The value of nz must be specified by the user. Figure 4.12. Illustration of the triangular mesh quantization process in the 3D space. (left) Inferior and superior plane dissecting a range of z values in the triangular mesh. The black triangles are labeled as dissected, while the others are labeled as non-dissected. (middle) Triangular mesh generated after applying the quantization process by using four dissection planes. (right) Approximating image obtained from the previous quantized triangular mesh (four z values are generated). superior dissection plane inferior dissection plane range of z values ziiZMAX 1+ nz ----------------------- 1–⋅= i0nz,[ ]∈ ZMAX
90 GEOMETRIC PROCESSING OF ADAPTIVE TRIANGULAR MESHES: ANALYSIS OPERATIONS Once the intersection values with the z axis, , for every dissection plane have been determined, the triangular mesh is dissected by using those planes one after the other. In Equation (4.7), the first plane intersecting the z axis at is not considered as a dissection plane, but as the first inferior dissection plane. When the following dissection plane is determined, it is considered as the superior dissection plane. That superior plane dissects the triangular mesh by applying the algorithm proposed in Section 4.2.2 (thresholding operation) in order to obtain the corresponding intersection points. In order to accelerate the next stage of the algorithm, only the triangles that are dissected by the superior plane are labeled as dissected, while the others are labeled as non-dissected. Figure 4.12(left) illustrates the previous steps. The range of z values comprised between the inferior and superior plane, , corresponds to the z coordinates that should be mapped to a single z value. Those values are finally set to . Finally, each intersection point is unfolded in two points by projecting it to and , while keeping the same x and y coordinates. When a new dissection plane is computed, the previous superior dissection plane is considered to be the inferior dissection plane, while the new dissection plane becomes the new superior dissection plane. The next stage of the algorithm triangulates the regions defined by the triangles labeled as dissected. 4.2.3.2 Triangular Mesh Generation Taking advantage that the points comprised between each pair of dissection planes are maintained, the retriangulation process is only applied to the dissected triangles, keeping the topology of the non-dissected triangles. This retriangulation process is applied as follows. Consider a triangle with vertices , which has been dissected by a horizontal plane. Furthermore, consider that points and are the intersection points zi z01–= z0z1 , )[ z z01+= z z01+= z z11+= tj v0v1v2 , ,{ } p0 p1
QUANTIZATION OF TRIANGULAR MESHES 91 corresponding to segments and respectively, such as illustrated in Figure 4.13(left). A hash table is generated in order to store and retrieve all the information about the intersection points. Hash tables are data structures that allow the storage of large amounts of records identifiable by a certain numeric or alphanumeric key, guaranteeing that records are retrieved in constant asymptotic time. In our case, the hash table is defined by a vector with B entries, where B is the prime number closest to the total number of triangles contained in the given mesh. In this way, the information associated with intersection point is stored at the entry determined by the following hash function: (4.8) where are the identifiers of the two vertices respectively. The intersection points stored at each entry of the hash table keep: (1) the identifiers, , of segment , (2) the coordinates of intersection point and (3) their opposite point identifiers corresponding to segment . Taking v0v1 ,{ } v0v2 ,{ } Figure 4.13. Illustration of the retriangulation process. (left) Triangle tj is dissected at points and by a horizontal plane. (right) Retriangulation of triangle tj when it is dissected by a superior dissection plane. p0 p1 v1 v2 v0 v1 v2 v0 p1 p0p’ 0 p’’ 0 p’ 1 p’’ 1 tj p0 h i0i1 ,()i0i1B1– 3 ------------ ⋅+ B⁄= i0i1 ,{ } v0v1 ,{ } i0i1 ,{ } v0v1 ,{ } x y z, ,( ) p0 i0i2 ,{ } v0v2 ,{ }
92 GEOMETRIC PROCESSING OF ADAPTIVE TRIANGULAR MESHES: ANALYSIS OPERATIONS advantage of the data kept in the hash table, it is very simple to determine the sequence of intersection points to be retriangulated. The triangulation process is applied by only retriangulating the dissected triangles. First of all, two new points are generated for every intersection point. Hence, the intersection points and in triangle generate four new points: and , which respectively lie at the inferior and superior dissection planes. Afterwards, two “vertical” triangles are generated from those new points: and , such as displayed in Figure 4.13(right). The previous process is applied for every dissected triangle. Once the mesh generation stage has been performed, a new dissection plane is computed and the previous two stages are performed again. This process concludes when all the dissection triangles have been retriangulated. The approximating image corresponding to the final triangular mesh is obtained by applying any of the image generation algorithms described in Section 3.4. An example that illustrates the approximating image obtained from the triangular mesh in Figure 4.12(middle) is shown in Figure 4.12(right). 4.2.3.3 Experimental Results This section presents experimental results obtained with the proposed quantization algorithm, which was tested upon various adaptive triangular meshes of different size. The utilized triangular meshes were generated with the algorithm described in Section 3.3.2. The CPU times were measured on a SGI Indigo II with a 175MHz R10000 processor. Figure 4.14(middle) shows an adaptive triangular mesh that represents a digital elevation map (DEM), which was generated by converting a DEM file to an 8-bit image and then by approximating it with a triangular mesh through the algorithm described in Section 3.3.2. Figure 4.15(left column) illustrates the triangular mesh obtained after applying the proposed quantization algorithm, considering 8 possible z coordinate values. The CPU time was 0.93 sec. For 32 possible z coordinate values, the CPU time was 6.65 sec. The corresponding triangular mesh is displayed in Figure 4.15(right column). In both cases, the p0 p1 tj p0 'p0 '',{ } p1 'p1 '',{ } p0 'p0 '' p1 ', ,{ } p1 'p0 '' p1 '', ,{ }
QUANTIZATION OF TRIANGULAR MESHES 93 approximating images generated from those meshes are shown in Figure 4.15(bottom row). The same operations were applied to the original 8-bit image by using CVIPtools (Umbaugh, 1998). In this case, both quantization operations with CVIPtools were performed faster than with the proposed technique. For example, the CPU time with CVIPtools was 0.03 sec. for both 8 and 32 gray levels. The reason for the poor performance of the geometric technique in this case is the high cost of the multiple dissection and retriangulation process. Therefore, the mesh quantization technique is not advantageous for accelerating digital image processing, although it is useful for being applied upon data originally described by 21/2D triangular meshes, such as terrain surfaces. Figure 4.14. (left) DEM of the Galapagos Islands converted to an 8-bit image with 262,144 pixels (512x512). (middle) Adaptive triangular mesh obtained with the algorithm described in Section 3.3.2 (5,808 sampled pixels). (right) Rendered triangular mesh.
94 GEOMETRIC PROCESSING OF ADAPTIVE TRIANGULAR MESHES: ANALYSIS OPERATIONS Figure 4.15. Adaptive triangular meshes obtained after applying the proposed quantization process: (left column) with 8 possible intensities and (right column) with 32 possible intensities. The bottom row shows the approximating images corresponding to the quantized triangular meshes.