## 2 Methodology
### Sun Detection
#### 2.2.2. Dome Detection
From the input parameters, Algorithm 2 begins by computing the cardinality of the set \(C\) (detected circles), then the algorithm iterates over each element in \(C\), computing the distance (\(d\)) of each element (centroid of the circle) to the dome center; if the distance of an element is lower than the dome radius and the radius is between values \(MinSunRadius\) and \(MaxSunRadius\), then the system considers this element as one circle that could represent the Sun; otherwise, the system returns as the Sun position the point (0,0) with a radius of zero. That means, in the end, that the algorithm returns the last element that fulfills these conditions. As the output of this process, in Figure 6, a Sun detection example is shown. #### 2.2.4 Partially Sunny Day

The process described in Section 2.2.3 is repeated with each new image acquired by the camera. However, it may be the case that a cloud with a brightness similar to the Sun is generated; if that happens, the system could segment two objects (the cloud and the Sun), and both objects could be within the circle that represents the dome; thus, they could be valid objects, and any of them could

Figure 5: Binarization of the image. (**a**) shows the input color image. (**b**) shows the result of the binarization. Figure 6: Sun detection example. be considered as the Sun, or even worse, if a cloud is generated so close to the Sun such that the segmentation process generates an object that fuses these two elements, then the Sun's position in the image would have a translation relative to the actual position. An example of this possible scenario is shown in Figure 7.

In order to deal with this problem, an object tracking algorithm based on particle filters was implemented. ### Particle Filter

Particle filters are based on probabilistic representations of states by a set of samples (particles), with the advantage of making possible the representation of a non-linear system and measurement models and multi-modal non-Gaussian density states [19; 20]. The main idea of particle filters is to represent the required posterior density function by a set of random samples with associated weights and to compute estimates based on these samples and weights. Let \(\{\mathbf{x}_{0:k}^{i},\mathbf{\omega}_{0:k}^{i}\}_{i=0}^{N}\) denote the set of samples that characterizes the a posteriori probability density function (PDF) \(p(\mathbf{x}_{0:k}|\mathbf{z}_{0:k})\), where \(\{\mathbf{x}_{0:k}^{i},i=1,\dots,N\}\) is a set of points with associated weights \(\{\mathbf{\omega}_{0:k}^{i},i=1,\dots,N\}\) and \(\mathbf{x}_{0:k}=\{\mathbf{x}_{j},j=0,\dots,k\}\) and \(\mathbf{z}_{1:k}=\{\mathbf{z}_{j},j=0,\dots,k\}\) are the set of all states and measurements up to time k, respectively. The weights are normalized such that \(\sum_{i}\omega_{k}^{i}=1\), and they can be chosen using the principle of importance sampling [21]. In the particle filter implementation, a re-sampling step has been applied. This step allows the reduction of the effects of degeneracy, observed in the basic particle filter algorithm. The basic idea is to eliminate particles that have small weights and to concentrate on particles with large weights [21]. Particle filtering provides a robust tracking framework, as it models uncertainty; besides, particle filters can deal with occlusions. ### Sun's Position Based on the Particle Filter

After the segmentation process, the position of the Sun in the image is computed, allowing the system to use this information as an input parameter for the particle filter. By doing this, the system is able to track the Sun in each frame; then, if this position suffers an unexpected variation because it has been merged with a very close cloud, the system is capable of mitigating this change. In Figure 8, the detection (red dot), as well as the tracking (green dot) positions of the Sun are shown. Figure 7: Sun and cloud segmented as a single object.