# Particle Swarm Optimization-Based Unconstrained Polygonal Fitting of 2D Shapes
## 5 Conclusions  
In this work, a novel PSO based polygonal fitting algorithm (UPF-PSO) has been proposed to solve a general version of the polygonal fitting problem called Unconstrained Polygonal Fitting (UPF), that is defined and solved for the first time in this work. According to the UPF-PSO algorithm, the location of the N-vertices of \(P\) that can be placed anywhere in the 2D space, generally providing better solutions compared to those of the classical polygonal approximation problem, where the vertices are restricted to belong in the boundary of the given 2D shape.  
In our experimental results, we have also compared the proposed UPF-PSO with several baselines in two standard datasets of 2D shapes of more than 2800 images, showing the high performance of the proposed framework. As was expected, when the number of vertices is low, the difference in performance between UPF-PSO and the rest baseline methods increases as the solutions of classical polygonal approximation problem generally fails to provide well fitting results due to the limited search space of PA problem. On the other side, when N obtains high values, the solutions of classical PA significantly better approximate the given shape, reducing the gap from the UPF methods. The equal area principle, which is also studied in this work, usually provides better results for low values  
Figure 8: Results of the proposed methods and baselines for \(N=3,6,9\) vertices on a horse shape from LEMS dataset. The red dots and green lines correspond on vertices and line segments of the polygonal curves, respectively. The green plus symbol represents the centroid of the shape.  
of N (especially for \(N=3\)), where the fitting polygon is less complex. If we could obtain the optimal solutions of UPF problem given a 2D shape, the optimal solution of UPF would outperform or be equivalent with optimal solutions of the PA. However, in some cases, the results of UPF-PSO, which correspond to sub-optimal solutions of UPF due to the PSO optimization, are obviously not the optimal ones, especially for high values of N where the search space is more complex for the PSO.  
The goal of this work is to provide high performance solutions for low values of N, where even the optimal solutions of PA are not sufficient to well approximate the given shape. Our experimental results show that for low values of N, the results of UPF-PSO are almost always better than the corresponding results of PA methods. As N increases, and it tends to infinity, the optimal solution PA converges to the initial shape having IoU equal to one, therefore even if we could obtain the optimal solutions of UPF, then the performance difference between UPF and PA methods will tend to zero, showing that the cases for high values of N are less promising to provide improvements, compared to the cases with low values of N.  
In ongoing and future work, our aim is to study more unconstrained fitting problems and to provide better solutions by combining solutions of PA problem, e.g., in initialization step of particles and better exploring the search space of UPF. Additionally, we plan to consider extensions of UPF-PSO towards handling more complex shapes than polygons. Finally, we plan to extend the proposed framework on 3D shape and to explore real applications in which the proposed system may be useful.  
This research received no external funding.  
Not applicable.  
The code implementing the proposed method together with the datasets are publicly available at [[https://sites.google.com/site/costaspanagiotakis/research/unconstrained-polygonal-fitting](https://sites.google.com/site/costaspanagiotakis/research/unconstrained-polygonal-fitting)]([https://sites.google.com/site/costaspanagiotakis/research/unconstrained-polygonal-fitting](https://sites.google.com/site/costaspanagiotakis/research/unconstrained-polygonal-fitting)) (accessed on 4 January 2024).  
The author declares no conflicts of interest.