**2.1. Real time craters detection algorithm**

This reliable topography-based Craters Detection Algorithm that the authors are proposing in this chapter is mainly based on a real image (optical image) analysis and morphological

Image Analysis. There are various stages of coding in order to get a satisfactory result, provided that the sun's elevation angle is known. This algorithm is suitable for any optical images taken from 'Lunar Orbiter' or 'Apollo' sources. The Algorithm flowchart is presented in Figure (4) below:

**Figure 4.** Flowchart of the proposed Craters Detection Algorithm

In the proposed craters detection algorithm, the authors used the original image (3D optical image) of the moon's surface. Originally, this image is a coloured image. For pre-processing step, the authors invented a colour conversion technique which started/originated from RGB (red,green,blue) image to HSV (hue,saturation,value) image using rgb2hsv function in MATLAB. Converting the RGB image to HSV image is basically the transformational of colours from RGB space into HSV space. Value (brightness) gives the amount of light in the colour; hue describes the dominant wavelength which determines the colour type while saturation indicated the vibrancy of the colour. The vital reason for this colour conversion is that the authors want to analyze only one of the entities that is Value entity in HSV component range 0(tend to be dark) to 1(tend to be light) which is then further used in the thresholding calculation. Besides, HSV plane is more popular in analyzing images because of its similarities to the way human intends to recognize colour. RGB and CMYK (Cyan, Magenta, Yellow and Black) colour models are additive and subtractive models respectively, defining colour in terms of the combination of primary colours whilst HSV encapsulates information about a colour in terms of its familiarity to the human adaptation such as; what colour is it? How light and dark the picture is? Or what is the colour vibrant?

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

**Figure 4.** Flowchart of the proposed Craters Detection Algorithm

In the proposed craters detection algorithm, the authors used the original image (3D optical image) of the moon's surface. Originally, this image is a coloured image. For pre-processing

presented in Figure (4) below:

Image Analysis. There are various stages of coding in order to get a satisfactory result, provided that the sun's elevation angle is known. This algorithm is suitable for any optical images taken from 'Lunar Orbiter' or 'Apollo' sources. The Algorithm flowchart is

> For thresholding purposes, a similar approach as Sawabe et al's [13] has been implemented and is discussed thoroughly in the technical section. The purpose of applying a threshold is to distinguish the craters on the moon's surface to light and dark patches groups. Thresholding is the simplest method of image segmentation. This segmentation procedure is to classify the pixels into object pixel (light and dark patch) and non object pixel (background). In this classification of images, it is clearly seen that a crater is formed by two different patterns that are light and dark patches under a different angle of sun beam. The authors use this property of craters in order to analyze and detect them on a lunar's surface. These light and dark patches pattern is distinguished based on the values of pixel's intensity for both images. For an instance, alight patch is determined by a pixel value that is below the threshold brightness calculated whilst a dark patch is determined from a pixel by a pixel value that is above the similar threshold brightness calculated.

> Furthermore, in morphology image analysis, erosion and dilation is applied as a combined analysis to the tested image. These two operations can be described simply in terms of adding or removing pixels from the binary image according to certain rules which depend on the pattern of neighbouring pixels. Erosion removes pixel from features in an image or equally turns pixel OFF that were originally ON [20]. Fundamentally, erosion can entirely remove extraneous pixels representing point noise or line defects which are only a single pixel wide. The image that is processed using erosion and dilation are shown in Figure (9) below for better visualization. These two methods are discussed entirely in the experimental results section (craters detection algorithm results) later. Another method is called dilation, which is widely used to add pixels. The dilation rule is that for erosion, is to add (set to ON) any background pixel which touches another pixel that is already part of a foreground region [20]. This will add a layer of pixels around the periphery of all regions which results in dimension increment and may cause images to merge or expand.

> In centroid determination, the authors use 'regionprops' function to get every centre for each light and dark blob classified previously. After that, the authors then have to link the

blobs together in a single picture. As a result, the final image will comprise a group of clusters or patches that correspond to craters on the moon's surface. These groups of blobs (light and dark patches) will then be used to measure the minimum distance and angle between each of them. First, the algorithm will calculate all the distances of every patch and will pick only the minimum distance. The light patches with minimum distances that are attached to the dark patches will be considered craters as a first step. Second, every angle between the known input sun vector and pairing patches vector is calculated using a scalar product or dot product. Technically, all these methods will be elaborated further in the technical section and experimental results section.
