# Advanced Methods for Point Cloud Processing and Simplification
## 4 Correction of Initial Point Cloud Rotation  
A space 3D scanner is usually placed into a scanned space on several positions sequentially. Each scanner positioning can be influenced by the wrong heading of the scanner even in a few angle degrees. This fact is negligible for the registration process but, for example, when the first point cloud is influenced by this error, the composed final point cloud is rotated in the same way. The knowledge of an initial point cloud rotation angle is necessary for the best results and the speed assurance of our proposed methods. We can also rotate by the point cloud in a prescribed range of angles (see reference [29]) and find the best match of points in the detected planar surfaces, but this is time-consuming and inefficient. We developed the following approach for the purpose of finding the initial rotation angle of a point cloud. A density histogram of the points in the individual axes is also possible to use for the correction of a point cloud rotation. This correction can be likewise applied before the registration process on individual point clouds. It improves the registration success probability. The known orientation angle of the point cloud significantly improves the processing time in our proposed methods for point cloud processing. The main assumption for its success lies in the presence of flat surfaces in the input point cloud, which is true in most cases of indoor space. The point cloud with correct orientation in the X and Y axes is shown in Figure 5a. Its bottom planar surface is parallel to the zero level in the Z-axis. The unknown  
Figure 4: Removal outliers result: (**a**) Resultant point cloud; (**b**) New range of histograms. parameter is the rotation in the Z-axis. Figure 5b gives constructed histograms of all coordinate axes with a resolution of 1 mm. The developed method for the estimation of the initial rotation is able to determine the rotation angle of one coordinate axis from the two others. The one main maximum is noticeable in the histogram of the Z-axis, as is shown in Figure 5b. Its position marks the floor of the edge. In the case of the X and Y axes, the maxima of histograms represent the walls of the model and the radiator. The proposed method analyzes these maxima in the prescribed range of the rotation angles to estimate the correction angle of the initial rotation. In the following example, shown in Figure 6, the rotation estimation of the Z-axis from the X and Y axes is shown. The flat surfaces in the analyzed point cloud may occur in different levels. It is necessary to analyze all local maxima from this reason, and not only the biggest. Their values may also vary depending on a concentration of points. To get these maxima from a histogram, we use the modified algorithm for the connected components searching, which respects gaps between two components. If a gap _iz_ is smaller than the user-defined threshold, then these two components are considered as one bigger one. For the better separation of local maxima, we recommend applying the threshold of a histogram defined as:  
\[h_{d}(h_{d}<(\mu(h_{d})+\sigma(h_{d})))=0, \tag{5}\]  
where \(d\) marks the selected dimension as in Equation (1). The values of constructed histogram \(h_{d}\) lower than its mean value \(\mu(h_{d})\) with the added standard deviation \(\sigma(h_{d})\) are set to zero. After using Equation (5), the modified algorithm for the connected component labeling with \(i_{Z}=0.05N_{d}\) is applied. The value _iz_ denotes 5% of the total count of the histogram elements \(N_{d}\). The result with marked local maxima by the red points and numbered components is shown in Figure 6b, presenting the histogram of the X-axis. Figure 5: Output point cloud from the registration process: (**a**) X–Y top view; (**b**) Histograms of all coordinate axes.