# Range-Doppler Based CFAR Ship Detection with Automatic Training Data Selection
## 5 Clustering and Tracking  
Ships are generally extended targets occupying more than a single resolution cell in the data (cf. Figures 18 and 19). After obtaining multiple pixel-based detections for a single ship, clustering has an important role to declare this group of detections per scene and per ship as a single \"physical object\". For clustering, we use the DBSCAN (density based spatial clustering of applications with noise) method [49]. It is able to form clusters of arbitrary shape with only two inputs from the user, i.e., _minPts_ (minimum number of points) and \(\varepsilon\) (radius). Given a set of points, DBSCAN algorithm starts with an arbitrary point \(a\). Point \(a\) is considered as a core point and forms a cluster if there are at least _minPts_ points (including \(a\)) within distance \(\varepsilon\) of point \(a\). Every reachable point from point \(a\) belongs to the same cluster. Point \(b\) is directly reachable from point \(a\) if it is within distance \(\varepsilon\) from point \(a\). Point \(c\) is also reachable from point \(a\) if there is a chain of points \(a_{1},\ldots,a_{\rm n}\) (all are core points, except \(a_{\rm n}\)) with \(a_{1}=a\) and \(a_{\rm n}=c\), where each \(a_{\rm i+1}\) is directly reachable from \(a_{\rm i}\). The edge of the cluster is defined by the reachable non-core points, also known as the border points. The non-reachable points are considered as outliers or noise. The radius \(\varepsilon\) is set based on the Euclidean distance. This distance metric can only be used in the case when the two axes have the same unit. However, in a range-Doppler image, the y-axis corresponds to the slant range (in meters) and the x-axis to the Doppler frequency (in Hz). Therefore, to do clustering, the detected pixels in slant range are firstly projected to ground range. Then, the corresponding Doppler frequency bins (which are spaced in Hz) are mapped to meters (i.e., cross-range coordinates) using the following approximation [24]  
\[\delta_{\rm cr}=\frac{\lambda r_{0}}{2v_{\rm p}T_{\rm CPI}}. \tag{30}\]  
where \(\delta_{\rm cr},v_{\rm p},r_{0}\) and \(T_{\rm CPI}\) are the cross-range resolution (in meters), platform velocity (in meters/second), the target range (in meters) and the time duration of a CPI (in seconds), respectively. An example of clustering applied on a CPI of 128 azimuth samples is shown in Figure 20.  
Figure 19: Binary detection map in range-Doppler domain using (**a**) K-distribution and (**b**) K-Rayleigh distribution. The thresholds estimated in both the cases are shown on the top right. The X-band HH F-SAR data were used as an input. The detection maps were generated using 128 azimuth and 512 range samples, the desired false alarm rate was set to \(P_{\rm fa}=10^{-6}\). Figure 20c shows the clustered ship signal with its centroid and the corresponding bounding box. The estimated 2D cluster centroids in ground-range/cross-range coordinates are projected back to slant range/Doppler coordinates for performing target tracking afterwards. Target tracking is a method to reconstruct the trajectory of a moving object based on a given noisy measurement. Although tracking is not the main focus of this paper, for completeness we also show some tracking results. Here, the Kalman filter [50] is used to track the cluster centroids in successive range-Doppler image patches. It is a recursive filter that updates the probability density function of the state recursively over azimuth time using the measurements at each time step, i.e., at each CPI. In the Kalman filter, the target dynamics, measurements and the probability distribution of the state are assumed to be Gaussian and linear. It is computationally very fast as it uses the current measurement and the estimated state and uncertainty matrix from the previous time step. In our case, tracking is performed completely in the range-Doppler domain where the range and Doppler coordinates are considered as the target dynamics which are written in the form of a vector \(x_{k}\), where \(k\) is the given time step (=CPI).