## 3 Methods
### A* with Map Processing
Therefore, in order to protect the A* algorithm from determining the path through the area occupied by the obstacles on the original map, the obstacle is artificially expanded as a result of dilation. Additionally, erosion is used to filter random noise in the image. If, for example, a disc-shaped structural element is used, some information about obstacles will be lost in places where the values of the structural element are equal to 0 (Figure 8--black pixels). On the other hand, a larger structural element size will result in an excessive safety zone, significantly extending the route planned by the A* algorithm. A similar situation will occur in the case of a diamond-shaped structural element (Figure 8). Other examples of structural elements may be a line, a rectangle, or an octagon. However, in this case, the obstacle must be stretched equally in x and y coordinates, so a square was chosen from among the various shapes. Figure 6: Structural element used for morphological operations. The size of the structural element must be appropriately selected to compensate for losses resulting from averaging pixel values in the process of reducing resolution. If the map is reduced five times, 1 pixel represents an area of 5 \(\times\) 5 pixels relative to the original map size. Therefore, the structural element must have a size at least equal to the number of pixels that 1 pixel represents in the original map, i.e., 5 \(\times\) 5 pixels. In the proposed approach, a structural element in the shape of a square 4 \(\times\) 4 pixels was chosen in order to use the same structural element in all morphological operations, which are dilation and closing. Since a double dilatation was performed (the closing operation consisted of dilation as well), the above condition was met. Examples of the same map fragment using different scaling factors and different structural elements for the same mathematical morphology operations are presented in Table 2.  
For a disc-shaped structural element with a radius of 4 pixels, the matrix used in mathematical morphology-based processing had dimensions of 7 \(\times\) 7 pixels, while for a diamond-shaped with the distance from the origin to the point of diamond r = 4, the matrix had dimensions of 9 \(\times\) 9 pixels. It can be seen that a greater reduction in map resolution for the same size of structural elements leads to greater deformations of the original shape and excessive enlargement of obstacles. Additionally, the use of structural elements such as a disc or a diamond of the sizes shown above excessively stretches the obstacles in relation to square-shaped structural elements. On the other hand Table 3 shows a comparison of the same structural elements with the dimensions selected in such a way that the matrix used in the mathematical morphology operation was 5 \(\times\) 5 pixels in relation to the processing results obtained for a square-shaped structural element with dimensions of 4 \(\times\) 4 pixels. Figure 8: Examples of disc- and diamond-shaped structural elements. Figure 7: An example of map processing using mathematical morphology operations. Due to the fact that for r = 2, the disc-shaped and diamond-shaped structural element matrices look the same, the results are presented in one column. Based on the processing results, it can be seen that a disc-shaped structural element with a radius of 2 provides a smaller safety zone than a square-shaped one (for both sizes). It is worth noting that for r = 3, the disc-shaped element gives the same matrix as the square-shaped element with dimensions of 5 \(\times\) 5 pixels. Moreover, for r = 3, a diamond-shaped element gives a matrix with dimensions of 7 \(\times\) 7 pixels. Therefore, a square-shaped element with dimensions of 4 \(\times\) 4 pixels was selected for further processing. Figure 9 shows a comparison of the map obtained with threshold segmentation (75/255) and the map processed according to the proposed approach.