# Advanced Methods for Point Cloud Processing and Simplification
## 6 Fill Gaps in Measurement Data  
During the planar surface detection process, there can be a requirement for the area determination including the inner holes. This situation occurs mainly when we process the floor or the ceiling areas. The point cloud with missing points on the floor is shown in Figure 13. This example describes the first level estimation in the Z-axis. During the point cloud analysis, there can be the assumption, that the floor is compact and we have a requirement to estimate the area of the floor. The use of \(I_{L}\) for point cloud processing offers the application of wide range image processing algorithms, which help with the important unknown parameter determination in the analyzed point cloud.  
The \(I_{L}\) in Figure 13c contains undesired holes, which are possible to fill easily by the use of image processing methods. We used the binary image and connected component labeling algorithm for the filling of the presented holes. The pseudo-code of the proposed algorithm is shown in Algorithm 1.  
```
Input: Image level element \(I_{L}E_{x}\) Output: Filled element \(I_{E/ill}\)
1\(E_{xB}\) = Element BorderPositions (\(I_{L}E_{x}\))
2\(E_{xBe}\) = Extend \(E_{xB}\) borders about 1 px
3\(I_{max}\) = true(size(\(E_{xBe}\)))
4\(I_{max}(E_{xBe}>0)\) = false
5//find separate areas (1 - surroundings, 2 - filled element)
6\(L\) = ConnectedComponentLabeling(\(I_{max}\), 4) //add edges back
7\(I_{E/ill}\) = (\(L=2\)) \(|\)\(E_{xBe}\)
8\(I_{E/ill}\) = Narrow \(I_{E/ill}\) borders about 1 px
```  
**Algorithm 1** Fill Element Area  
The level image consists of several elements representing individual planar surfaces in general. The analyzed element index is marked as \(I_{L}E_{x}\). By using the algorithm for the element borders detection, presented in our previous work [30], the borders of the element \(E_{xB}\) are extracted. The algorithm uses erasing of the eroded element by about one pixel from the original element for the border finding. It is necessary to extend the binary image borders by at least about one pixel \(E_{xBe}\) for the preserving of the indexing elements expected in further processing. Then, the second image \(I_{one}\) of the same size with all values equal to one is created. On the detected border, positions are set to zeros, as shown in the following equation:  
\[I_{one}(E_{xBe}=1)=0.\]  
Figure 13: Input point cloud and its level images: (**a**) Point cloud of the 1 st level in the Z-axis; (**b**) Segmented point cloud from (**a**); (**c**) Level image after the application of morphological operations; (**d**) Filled level image.  
The connected component algorithm with the connection of four is applied to the obtained image. The connection of eight is not possible to use because the border width is only one pixel thin and in the diagonal directions the algorithm may cross the borders. The result of labeling \(L\) is two areas with different indexes. Index 1 is the surroundings, and index 2 is the desired filled area without borders. By adding the borders of the analyzed element to the labeled area by the index 2, the original filled area is obtained as:  
\[I_{Efill}=(L=2)\lor E_{xBe} \tag{8}\]  
The extension of one pixel is erased for the getting of the original level image size. Figure 13d gives the final filled area, which is calculated from the original floor elements with the holes. The filled planar surface allows estimation of the real floor area or the space volume like in Section 8 with the results. We can reconstruct the missing points by the reverse process from the fixed floor planar surface. Moreover, from the difference of Figure 13c,d, it is possible to reconstruct only the missing parts and with the knowledge of planar surface statistical parameters, we can generate the missing points with the same statistical distribution.