**4.2. Bounding ellipse algorithm results**

In the geometrical analysis section, the authors start with the bounding ellipse algorithm using the information from the previous proposed craters detection algorithm to bound the targeted blob as shown in Figure 18 above. The blob is selected randomly from the true craters detected by the detection algorithm such as in figure (16) above by labelling the targeted output using '*bwlabel.*' This function numbers all the objects in a binary image. By using this information, the user can select the true matching pair that can be selected for further research (to determine its position and orientation) by using the function 'find' in MATLAB and this step can be repeated for all of the true matching pairs detected by the algorithm. This is the first step before the authors can draw the ellipse around the target (figure 16) to bound it and to reconstruct the crater selected as a disc using ellipse reconstruction algorithm. This reconstruction is beneficial to later determine the orientation and position of a Lunar Lander using the equation *p* and *q* as proposed before during EDL of the spacecraft. There are some mathematical fundamentals and equations that need to be understood before one can apply the bounding ellipse algorithm to a certain targeted object. They are fundamentals of the ellipse and also the rotation matrix fundamentals. This knowledge is used to extract the embedded entities from the output of bounding ellipse algorithm in terms of basic ellipse parameters such as **a**, **b**, **Xc**, **Yc** and **ω** which are further used to draw an ellipse around the targeted object (target patch). Generally, the authors want to express all those ellipse parameters in terms of E matrix which is the output of

506 MATLAB – A Fundamental Tool for Scientific Computing and Engineering Applications – Volume 1

**Figure 15.** Craters detected from Image 2 in yellow line based on distance and angle measurements

In Figure (15) above, yellow lines, which denote as craters are detected with a minimum distance and angle detection while green lines, which denote as craters are detected with a minimum distance only prior to the minimum angle detection. This angle detection will be a final stage in defining the craters based on the light and dark patch pattern (sometimes denoted as sunny and shady parts) and the final craters are those with yellow lines. By comparison, the accuracy of the algorithm based on these two images with different types of craters, angle (Sun) and lighting condition is said to be 77% and it is quite a satisfactorily

This accuracy factor can be improved if the authors know exactly the sun elevation angle since in this research; the authors just assumed the angle and the value is not really accurate. In a real application, this sun angle can be measured separately using the satellite, altimeter or radar prior to this detection process and the value will be more accurate. Besides, this algorithm will detect the craters that are above 0.0265 meters in image size (100 pixels). This can be vouched by using the '*bwareaopen'* function where it will remove the entire blobs

In the geometrical analysis section, the authors start with the bounding ellipse algorithm using the information from the previous proposed craters detection algorithm to bound the

**Based on the original Image 2 as can be illustrated in Figure (15) below** 

Manual Detection (number of craters detected after pre-processed): 10

Automatic Detection (number of craters detected): 8

**Sun direction: > 10 degrees** 

8/10 x 100 = **80% accuracy** 

accurate.

pixel which is less than 100 pixels.

**4.2. Bounding ellipse algorithm results** 

bounding ellipse algorithm. This E matrix takes a form of 11 12 21 22 <sup>E</sup> *A A A A* . Finally, the authors

want to express the ellipse parameters in terms of 11 21 12 22 *A* ,,, *AAA* in order to draw the bounding ellipse and further to reconstruct it as a disc.

**Figure 16.** Targeted blobs chosen randomly from the matched true pairs in distance and angle measurement using bwlabel function.

After the authors obtain the bounding ellipse around the targeted patch as in shown in the figure below, the next step is to reconstruct the bounded crater using ellipse reconstruction

algorithm. As a result, the authors will get a circle which suggests that the camera is pointing straight vertically to the lunar's surface.

As can be seen in Figure (17) above, a circle, instead of an ellipse, appeared after the authors ran the bounding ellipse algorithm along with the image plane ellipse algorithm. This is because the semi major axis **a** is actually similar to the semi minor axis **b**, so a circle is produced. In fact, this means that actually the camera is pointing down vertically straight to the moon's surface providing an angle of around 90 degrees relative to the moon's surface. Next, the reconstruction ellipse algorithm took the input of **a**, **b**, centre (Xc,Yc), A , B and produced the output of the orientation *p* of the ellipse after reconstruction or projection.

## **4.3. Ellipse reconstruction algorithm results**

This algorithm is about to model a crater as a disc and reconstruct an ellipse to a circle in 2 dimension (2-D) plane in order to determine the position and orientation of a crater relative to the spacecraft. For the first case, the authors used a real image which is an optical image. To realize the above purposes, the authors have assumed several altitudes from the spacecraft to the moon's surface. As mentioned before, after the authors performed the bounding algorithm and drew the bounding ellipse on a particular targeted crater, the authors have an image of a circle that bound a targeted crater rather than an ellipse, and therefore the authors have an assumption that the camera on the spacecraft is pointing vertically, almost 90 degrees from above in angle if measured from a flat lunar's surface. From bounding ellipse algorithm, the authors have determined the image plane ellipse parameters and the results show that the semi-major axis, *a* is similar to the semi minor axis**,**  *b*. Taking advantage of this idea, a circle will only have one solution in order to determine the position of a crater and the ambiguity case (an ellipse has 2 solutions) can be eliminated. The reconstruction algorithm [18] described in the methodology and technical sections previously is then used to reconstruct a possible disc (crater) positions and orientations after taking into account of the camera's parameters [18] below where Xc and Yc is the coordinate of the centre of an ellipse. The authors use an optical image dimension of 1024x1024 pixels.

508 MATLAB – A Fundamental Tool for Scientific Computing and Engineering Applications – Volume 1

pointing straight vertically to the lunar's surface.

**4.3. Ellipse reconstruction algorithm results** 

circle line

algorithm. As a result, the authors will get a circle which suggests that the camera is

**Figure 17.** Bounded crater using bounding ellipse algorithm and Image plane ellipse algorithm in green

As can be seen in Figure (17) above, a circle, instead of an ellipse, appeared after the authors ran the bounding ellipse algorithm along with the image plane ellipse algorithm. This is because the semi major axis **a** is actually similar to the semi minor axis **b**, so a circle is produced. In fact, this means that actually the camera is pointing down vertically straight to the moon's surface providing an angle of around 90 degrees relative to the moon's surface. Next, the reconstruction ellipse algorithm took the input of **a**, **b**, centre (Xc,Yc), A , B and produced the output of the orientation *p* of the ellipse after reconstruction or projection.

This algorithm is about to model a crater as a disc and reconstruct an ellipse to a circle in 2 dimension (2-D) plane in order to determine the position and orientation of a crater relative to the spacecraft. For the first case, the authors used a real image which is an optical image. To realize the above purposes, the authors have assumed several altitudes from the spacecraft to the moon's surface. As mentioned before, after the authors performed the bounding algorithm and drew the bounding ellipse on a particular targeted crater, the authors have an image of a circle that bound a targeted crater rather than an ellipse, and therefore the authors have an assumption that the camera on the spacecraft is pointing vertically, almost 90 degrees from above in angle if measured from a flat lunar's surface. From bounding ellipse algorithm, the authors have determined the image plane ellipse In real applications, the lunar's surface is not flat, and the crater is not straight below the camera. In this case, the authors had determined a circle in bounding ellipse algorithm that bounds a certain target; hence the authors made this assumption as the above figure. By looking at the figure above, the focal axis line is not really parallel to the centre of the disc hence the perspective distortion would have an effect as being described further in the next section. When the authors set A = 0 it is important to bear in mind that the ellipse will become a disc and this means that *p* is parallel to *q* and the authors should obtain a circle. Contrary to this, if *p* is perpendicular to *q* , the authors will get a line rather than a circle.

In a real situation, the altitude assumptions above are measured prior to the landing purposes. This altitude is usually measured by the altimeter or the satellite. Before the authors can construct the position a disc, they must determine the orientation first. This orientation and position of the disc is obtained from the equations (18) and (19) previously. As being mentioned before, the orientation equation is free from the term B and can be determined fully from the reconstruction algorithm. The orientation of the disc can be described as a unit vector that gives the direction of the centre of the disc. It is a positive value since the crater can be seen positioned upwards rather than downwards (negative side).

An ellipse will be detected on the image plane for each disc that is visible on the camera's view. For each ellipse detected, there will be two discs reconstructed in 3-D space in terms of its orientation and position as well; one is pointing away from the plane which is a true direction while the other will be pointing in the wrong direction. As can be seen in the result above, the authors have the orientations of (1.0000,-0.0000, 0.0000) and (1.0000,-0.0049,- 0.0007). This ambiguity case can be removed by taking into consideration that from a camera's perspective, a disc will only be seen if they are orientated upwards (positive values) rather than downwards (negative values). So, using the information above, it is clear that the image plane is one unit away (P (1, 0, 0)) from the origin (of a camera at the spacecraft) which is the orientation of the spacecraft itself. The readers should be also reminded that in this case, the orientation vector is the unit vector that gives the direction of the centre of the crater. Hence, this orientation vector is also considered the normal vector of the crater that is pointing upward.

As can be seen in this second solution of these orientations, there is an error when the authors calculate the vector unit of this orientation which has to be 1. One of the drawbacks when the authors use MATLAB is that it will always round the value, for example 0.99995 to

1. That is why those (1.0000,-0.0049,-0.0007) values when squared, summed them all and squared root them back, the authors will have more than 1. By theory, this value should be 1 and the reason for this error is maybe due to MATLAB that has rounded the value of 1.0000 that lies on the **x** axis.

Furthermore, in order to evaluate the error of the ellipse that the authors reconstruct, the ellipse itself has an error on the image. This is because of the digitization of a real shape that has an inherent loss of information c compared with the original shape. One should notice that there is no possibility that the original ellipse can be recovered from the digital ellipse but the errors can be optimized by increasing the picture resolution of an image. If the image is unclear or has a poor resolution, the authors can pre-process the image to reduce the presence of noise in the original image by using a smoothing technique [9]. This smoothing technique is carried out by implementing the low-pass filter to the original image. The main purpose is to attenuate the high-spatial frequencies by keeping the low spatial frequencies of the signal strength [9].

Besides, what cause the error are the uncertainties that appear from hardware (altimeter, satellite, or radar), software (MATLAB) and also the landing site topography itself. In a real situation, the sensor noise that comes from the altimeter also has to be considered a noise as it will affect the accuracy of the results determined by the system.
