# A Robust RANSAC-Based Planet Radius Estimation for Onboard Visual Based Navigation
## 3 Methods  
We propose a multi-step method to estimate the radius of a circular-shaped celestial body from a single channel grayscale image. In this section, we will refer to the celestial body as the _target_. In the first step, we threshold the image with a tunable threshold value \(\tau_{1}\), as we expect the background to be much darker than the target. In the thresholded binary image, the target appears as a blob. We can find the blob bounding box and obtain a first crude approximation of the target center \(c_{0}\) using the marching squares algorithm [19; 20]. A graphical representation of the output for this first step is given in Figure 1. Optionally, we can also use the bounding box to define a rectangular Region Of Interest (ROI) around the target, thus reducing the original image size, if needed. In the second step, we apply an edge detection filter to identify the sharp transition from the dark background to the illuminated target. We approximate the image gradient with a discrete filter, such as Sobel [21] or Prewitt [22]--we observed small differences in applying these two filters, thus we consider them to be equivalent. In our method, we considered only the image gradient magnitude, as we are not interested in the direction of the image gradient. The third step applies dilation (\(\oplus\)) and erosion (\(\ominus\)) operations to the binary image in order to produce a thick ring-shaped mask around the target borders. The edge mask is computed as:\[edge\_mask=M\wedge\
eg m \tag{1}\]  
where \(\wedge\) and \(\
eg\) are the logical AND and NOT operations, respectively, \(m=(I>\tau_{1})\odot\mathbf{1}_{3x3}\), \(M=m\oplus\mathbf{1}_{5x5}\) with \(\mathbf{1}_{3x3}\) and \(\mathbf{1}_{5x5}\) as square structuring elements. We use this edge mask to select only the pixels from the edge image that lie at blob boundaries. This approach removes regions with high frequency components located inside the target boundary, such as regions with irregular texture (craters) or inconsistent lighting conditions. The magnitude values of the masked edges are further compared with a threshold value \(\tau_{2}\) in order to remove edges resulting from high contrast near the terminator. Indeed, we observed that stronger edges belong to the real target border, whereas edges with smaller values belong to the shaded area. We notice that simple thresholding is sufficient to eliminate most of the edges belonging to the shaded area; the remaining edges do not interfere much in the target radius estimation, as they are expected to be marked as outliers by RANSAC and suppressed accordingly. At the end of step 3, we produce as output the list of \((x,y)\) image coordinates corresponding to the remaining edges after thresholding. In the fourth step, we transform the \((x,y)\) image Cartesian coordinates to \((\rho,\theta)\) polar coordinates by using the target center \(c_{0}\) as the origin. Next, we divide the angles in \(K\) bins and define an _active bin_ as a bin with more than \(N\) points in it. We discard images that have less than \(S\) out of \(K\) active bins and preserve images that have at least \(S\) out of \(K\) active bins Figure 2.  
We used this technique to filter images with points scattered along a circumference, from images that contain points clustered tightly along a short arc, since the first images produce better radius estimations than the latter. For each bin, we select the first points with the largest radius values in order to cope with images that present thin limbs (we refer to it as \"sickle effect\"). In this kind of image,  
Figure 1: Output of the first step of the pipeline. The detected bounding box is a first crude estimation of the target centroid \(c_{0}\). Figure 2: Graphical representation of sector binning. In this example, the \(K\) parameter is set to 8 and 4 sectors are active. The orange circular sectors represent the number of points that lies inside the corresponding sector.