TELKOMNIKA Telecommunication Computing Electronics and Control

Received Sep 14, 2021 Revised Dec 17, 2021 Accepted Dec 28, 2021 The history recorded moon as the most inspiring object in the sky, but it combined with visibility issues to study the phases. This research paper proposes a novel algorithm named Sunfa Ata Zuyan (SAZ), which is meant to extend the shape detection algorithms to aim for lunar phase deceleration and overcome the difficulties encountered by the previous methods to find the moon and determine its phase. The paper sets to investigate two aims. First, propose the add-on algorithm SAZ to determine the lunar phase's data faster. Secondly, evaluate the Raspberry Pi as the main CPU due to its compact size and power as the primary processor based on the idea of a portable designed system. Then to examine the ability of the SAZ algorithm, it's combined with famous algorithms like hue, saturation and value (HSV), Canny, erosion, shape detection, and binarization has been tested on both personal computers (PC) and Raspberry Pi with the same images being compared. The results show that SAZ will help the shape detection algorithm to find the object and disclose the moon phases. Furthermore, the Raspberry Pi, functioning as a CPU, can perform as a hand-to-hand system to determine the lunar phase as a compact portable remote sensing structure.


INTRODUCTION
From the early beginning, the moon has been interested.People have tried to observe it and collect information about its modes and shape, even regarded as a God worthy of worship.This attraction is probably because of its effect on the environment and the human body [1], [2].The moon has more secrets to discover than just its dark side.It affects the earth's environment and creatures, like stock [3], weather, and bird migration [4].Some recent papers even show physical and psychological effects on the human body, such as sleep, behaviour [5], and health side effects like renal colic [4], [6].There are also important applications such as navigation at sea.This application can be used to study the moon as well [7].One of the main study applications regarding the moon's declaration date is in the lunar calendar, which some countries follow and even align their religions and ethics with [7].The moon, based on its position relative to the earth and sun, has different shapes and modes, which we call phases.These phases are named specifically to help people to recognize and identify them.As shown in Figure 1, these eight phases start from the closest place in the new moon phase, which achieves less visibility because it is located behind the earth.These lunar phases are named: i) new moon defined as the case that sun and moon are arrayed, and the sun and earth are located on opposite sides of the moon; ii) waxing crescent: that when moon appears to be partly, but less than one-half, illuminated by direct sunlight; iii) first quarter (half moon), moons upper hemisphere come out to be illuminated by direct sunlight; iv) waxing gibbous when moon phase appears to be more than one-half but not fully brightened by direct sunlight; v) full moon as the case that moon's lit opposite side of the earth; vi) third quarter (last quarter) that one-half of the moon come up to be illuminated by direct sunlight; vii) waning gibbous moon appear more than half, but it is not fully illuminated by direct sunlight; and viii) waning crescent the last phase starts just after the third quarter moon and continue until the following new moon phase [7].As the name suggests, each phase has a disparate appearance and explanation.There are some affinities between similarities in the last day and middle day of the month.Some problems, like cloudy nights, different times of visibility and percentage of illumination, make shape tracking difficult.Those days are called skipped days [7].Some mobile applications (APPs) can observe the moon, but none can capture a picture of the moon in real-time.The moons' shape record for all cities is not available on the internet, which may cause problems in recognizing its shape and detecting [8] a lunar phase [9].Because of the lack of stable systems to recognize the moon and its phases, researchers and designers' accurate investigation is required.On the other hand, having an effective algorithm concerning several aspects (number of code lines, accuracy, and response) to find and determine the lunar dates against various backgrounds in the form of a portable system is a big challenge.New developments in the embedded system allow the researcher to test a new system with features like small size, fast speed and low cost (such as Raspberry Pi) [10].Our previous research paper investigated these problems, including portable systems with the Sunfa Ata Zuyan (SAZ) algorithm.The system was designed to capture and analyze the real moon pictures and estimate the moon date [11].
In this paper, along with the SAZ algorithm proposition, the comparison of the proposed algorithm with known algorithms is considered, and their performance on a personal computer (PC) and Raspberry Pi boards are summarized.This paper is arranged as follows; short reviews elaborate and compare different algorithms, including the proposed algorithm in section 2. The previously designed hardware system and components are described in section 3.In section 4 makes the comparison of six algorithms finding the moon in the picture, and their date declaration results in both a PC and Raspberry Pi.Finally, conclusions are presented with the achieved results and suggestions for future work.Based on the author's knowledge, the comparison between the Raspberry Pi and PC over the different algorithms has not been reported before that can be counted as the paper novelty.

RESEARCH METHOD
Images have many applications in recent research activities, industry, and human lives based on hidden data.This data has caused the proposal and development of different algorithms.In addition, the main TELKOMNIKA Telecommun Comput El Control  Sunfa ata zuyan machine learning models for moon phase detection … (Ata Jahangir Moshayedi) 131 purpose of image processing is to give meaning to the different variations in picture intensity [12].Based on this research's intended goal, the well-known algorithms for edge detection have been used to determine the edge plus line and morphological method.It uses the local pixel transformation to process the region shapes which are selected.The motive for selecting this method is the reputable research work that introduces it as a reliable method for finding a specific image in the picture.The edge detection method mainly attempts to reduce the image data with the intention of data minimization.The pixel boundary can distinguish two boundaries in the image [13], [14].In other words, edge detection reduces the data size and uses only the necessary data among all the data there is.In the photo, edge detectors work based on identification and location.In this process, sharp, discontinuous sections of the image, which caused the image intensity and object changes, are detected [15], [16].The morphological method works based on the shapes and is mainly used for binary images.This method works on the judgment of pixel zones with a pattern and focuses on the features like shape or morphology through logical transformations.In this way, morphology uses a structuring element that identifies small shapes and patterns.The benefits of mixing between edge detection and morphological method are reported [17], [18].According to the previous statements, another target for this research was comparing, investigating, and proposing a new SAZ algorithm to detect and determine the date.The algorithms used are the Canny technique (the edge detection method), binarization, hue, saturation and value (HSV), erosion, and shape detection represent the morphological method [19].
In brief, HSV is a well-known algorithm that can detect and localize the target in pictures even with a low-cost camera presented with similar colours and robust to noises [20].The input image from red, green, and blue (RGB) space is initially converted to HSV space into separate objects with different colours to use HSV.Then by using the medium filter, make the image clear.Afterwards, using the density-based spatial clustering of applications with noise (DBSCAN), the existing elements in the picture are classified, and the biggest one with the round outline is chosen as the target.In the end, the part of the image matrix which includes the target is added [21], [22].Erosion (minkowsky subtraction) works based on two processes of eliminating and shrinking boundary points and is mainly used for binary images but can also be applied to grayscale images [12], [19], [22], [23].Erosion mainly operates on the white part (highlighted part) and finds the highlighted parts of the original image, which are corroded, and the neighbourhood is removed from the image [24].Dilation (minkowsky addition) [12] is mainly used for binary images but can be extended for grayscale images.It typically engages a structuring part for searching and increasing the shapes contained in the input photo image.In this method, the zones of foreground pixels get enlarged.Then the areas of foreground get maximized, and the background holes get minimized.Dilation also occurs for the white part (highlighted part) and expands the image's highlighted part (neighbourhood expansion).The affected image also has a larger highlighted area than the original image [17], [24].
Canny is a famous edge detection algorithm created in 1986 [25], [26].Although some researchers know it as low-level processing [25], [26], it can detect the shape successfully used on edge detection [12].This procedure works based on the image gradient calculation and uses four gradient operators to calculate different standards.In this algorithm, first, the Gaussian filter is used to smooth the image and filter noise.Then, after that, non-maximum suppression has been applied to eliminate stray responses caused by edge detection.As the next step, double-threshold detection is applied to determine the real and potential edges.Finally, the edge has been detected by deterring the isolated weak edge [27].Binarization is used for binary images, the basis of segmentation [28], [29].In this technique, initially, the image is changed into grayscale with the threshold value.In this method, the grey image (0)-(256) grey levels changes into black and white image (0 or 1) [29], [30] and remove lightness (brightness, density) as a feature of images.binarization is in common use in picture processing and leads to a good result.But the problem is how to choose a better threshold of binarization.It is always used with another handling method because it is weak in dealing with complex surroundings [29].
Shape detection is one of the blob detection methods based on shape [30], [31].In this algorithm, the bilateral filtering on each pixel gives a smooth effect on the image.The average of the neighbourhood pixels gives the filter in each pixel, and then the edge detection with the help of the Canny algorithm is implemented.Then the contours find a base and connect the points, creating a similar intensity where colour is considered.Next, the act of finding circular shapes with the help of approximates a curve or a polygon (APPROXPOLYDP) will occur.The APPROXPOLYDP support finds the polygon shape by counting the polygon's number of vertices, known as the circular shape with a higher number of points [32].This algorithm works by using OpenCV API and can detect the shape of objects in the photo.For better accuracy, need to specify the target to classify the detected objects [8], [14], [33], [34].
SAZ Novel algorithm the main target of this research is to have a simple algorithm that can be implemented with python on the Raspberry Pi platform.The proposed algorithm SAZ aimed to separate the target from the image by colour signature.Figure 2 shows the steps, and algorithm 1 gives the pseudocode for the SAZ.As it showed in this algorithm, some initial stages are similar to the HSV method, in the first  As Figure 2 and algorithm1 show, SAZ has seven steps.Like the HSV in SAZ, it also needs to change the picture from RGB space to HSV space (image transform from RGB to HSV).With the aim of target object separation and region of interest (ROI) separation.The HSV format separates the different colour objects and then applies DBSCAN to lock the destination [7].Then, the median filter makes the picture clear in the noise cancellation step.DBSCAN is used to remove large artefacts of noise in the picture, and the medium filter is used to omit some small artefacts of noise.In the next step (edge detection and image resizing using the concentric circles), SAZ uses the geometric method to find the centre of the target and draw 11 concentric circles on the target, divided into the left and right parts.After that, SAZ in the concentric circle's step calculates the percentage of every part and compares its value with the origin data.Finally, given the differences, SAZ will give the phase declaration [11].This algorithm needs seven libraries named NumPy, pillow, scipy, matplotlib scikit, learn, and scikit-image to implement on python.

HARDWARE DESIGNED AND SYSTEM COMPONENT
To collect and analyze the moon phase and date declaration, the hardware system has been designed and has been planned to test based on the SAZ algorithms (Figure 3(a) and Figure 3(b)).Figure 3 shows the portable design hire the Raspberry Pi recognized as the smallest computer [10].The designed system as it is shown (Figure 3(a) and Figure 3(b)) includes the Raspberry Pi board and camera, a 7-inch liquid crystal display (LCD) and graphical user interface (GUI) section (Figure 3(c)) to interact with the user.The designed system is elaborated in our previous research paper [11].

ALGORITHMS EVALUATION RESULT AND COMPARISON
After the system has successfully captured the moon images, the next target is its performance comparison which has been done in two steps.First, finding the moon as the initial goal and then the date deceleration.In addition to all the pointed algorithms on Raspberry Pi, the difference between Raspberry Pi and a regular PC (Intel (R) -I 7-6700HQ/ @2.60 GHz/ Windows 10/ Python IDE version 3 : Anaconda-Spyder IDLE) is investigated.As mentioned before, the test steps (finding the moon and date declaration phases) are verified with two aspects.First, experiments were carried out on a fixed sample taken from [9], and then, some real and random images of the moon have taken by the designed system.To compare both stages, the algorithms are named HSV, erosion, dilation, Canny, binarization [35], and shape detection, as mentioned before.The tested result is mentioned in this section.

Moon finding on the fixed data set
The main aim of this section is to find the moon as the key target in the image.Besides, this part shows the algorithm accuracy and its ability to find the moon over the different objects.To do the test, the used fixed set of the picture [9] related to different phases of the moon used as is shown in Figure 4. To test fixed moon images, initially, the HSV algorithm and other algorithms named erosion, dilation, Canny, binarization and shape detection are tested, and the results are shown in Table 1 and Figure 5.The results illustrate the image detection in PC and Raspberry Pi, (using python language with two different versions of 3.6 in PC and 2.7 version in Raspberry Pi).The recent version and library improvements cause different python versions with different results after using the recent library [36].The used libraries names are numpy, pillow, scipy, matplotlib, scikit-learn, cv2, scikit-image   As it dissipated in Table 1 and Figure 3, the algorithm performance in Raspberry Pi takes more time than a personal computer.Comparing the algorithms to find the Moon with the fixed moon phase pattern shows that shape detection and binarization have 100% success (maximum).Canny has the minimum success rate for finding the Moon in the picture.HSV has the maximum time taken over the processor platforms.To compare the difficulty from different points of view, the result shows that the HSV, erosion and dilation have the least difficulty compared to others.The lowest number of used libraries in programming code belongs to HSV, and the maximum one belongs to shape detection.The number of lines in the dilation code is the least, and shape detection has the maximum number of code lines.This point is common in all algorithms, so the comparison is not repeated for all steps.The same practice is repeated for the real moon photos with different sizes, and the obtained results are shown in Table 2. From the eight sampled photos Figure 6, six are taken by hardware, and two are taken from another source regarding the noisy background.Table 2, Figure 6 and Figure 7 show the algorithm performance based on PC and Raspberry Pi. Figure 7 shows the real outcome of TELKOMNIKA Telecommun Comput El Control  Sunfa ata zuyan machine learning models for moon phase detection … (Ata Jahangir Moshayedi) 135 different algorithms named HSV, erosion, dilation, Canny, binarization, and shape detection algorithms process on captured moon image on the eight-sample image.As mentioned before, among the used eight sampled photos, six are taken by hardware, and two are taken from another source regarding the noisy background  Based on Figure 6 and Table 2, and as shown in Figure 7, the maximum number of success pattern for finding the moon belongs to the shape detection, and HSV has the second grade.Furthermore, the minimum average time belongs to binarization and the maximum time is the HSV algorithm.Besides, Figure 7 shows that shape detection successfully detected the moon in the image over the other tested algorithms.

Phase declaration test
The main problem for the mentioned algorithm, over finding the proper object in the image, is their performance rather than focusing on the target.Then, in the second stage, to show the SAZ as the proposed algorithm, the mentioned algorithm is mixed with SAZ to give a better guideline for image detection.In other words, the SAZ helps the algorithms to decelerate the phase, and the main algorithm tries to find the moon in the image.The algorithm performance with the fixed 27 samples results is shown in Table 3 and Figure 8.
As the result shows, with the help of SAZ, all 27 samples could detect and declare the moon phase by the Shape detection method.The obtained results show SAZ and Shape detection take 0.646 minutes on PC and 6.657 minutes by using the Raspberry Pi to process the 27-sample image.Even the less Average time belongs to the Canny algorithm, but the percentage of success rate is least between other tested algorithms.

Phase declaration on real moon photo
The previous results show that shape detection with SAZ displays a 100 percent success rate in finding and detecting the moon phase mode.Then, to better analyses SAZ, the algorithm performances are tested on an eight-moon sample.These samples are mixed with a noisy background, and they are the real moon images.Furthermore, to compare the result, mean-square error (MSE) and peak signal to noise ratio (PSNR) with the processor performance are listed in Table 4 and are shown in Figure 9.  4 and Figure 9, all eight samples were successfully detected.The lunar phase is based on SAZ proposed algorithm ability, and the minimum processor time belongs to sample 5.The current research can be hired on other applications like determining people's faces, inside pipeline defects [36], odor shape in odor tracking systems [37], extracting faces and palms from images [38] and other detection and analysis applications [39]- [42].determination is based on designing a portable system to test the various algorithms we have considered.The paper sets to investigate two aims.First, propose the add-on algorithm SAZ to determine the lunar phase's data faster.Secondly, test and compare the Raspberry Pi as the main CPU due to its small size and ability as the main processor based on the idea of the portable designed system.In this comparison, HSV, Canny, erosion, shape detection and binarization algorithm as the famous ones tested on the Raspberry Pi and PC.The mentioned algorithms were selected based on a good performance in other reported work.The sample picture used to test the SAZ algorithm has been split into the first 27 sample photos due to 8 major phases of the moon.Then, eight numbers of moon samples are tested.Six were taken by the Raspberry Pi camera (designed system), and two were used to represent the noisy picture with a greater number of objects.The tested sample considers two stages of finding the moon in image and date determination.The result of the combination of SAZ and the other algorithms shows that the HSV algorithm can resist noise and can be easily migrated to another device.Compared with others, it uses fewer python libraries and doesn't need other settings (such as thresholds or other things).But its weakness is that it takes more time than other algorithms.The dilation and erosion algorithm have a fair skill to resist noise and can be easily realized.But it has demerits.The larger the objects, the lower the accuracy.The main problem for this algorithm reported before is its difficulty finding the optimal binarization.It means that a different algorithm shows a different performance.
The Canny algorithm was more effective in other papers (when the dual-threshold is good for the target), but this paper's result was not the same.The Canny algorithm is effective with a smooth image, but it is difficult to realize.Besides, its dual-threshold is also hard to ensure.Shape detection can find all objects in the picture, but it needs to specify the target.It has the advantage of finding everything in the image, but the drawback is that it's hard to ensure the explored object is a target or not.Then, the SAZ as the proposed algorithm can help to detect the targets and navigate them to determine the date.The result shows that the HSV, erosion, and dilation have the least difficulty to compare an algorithm's difficult point of view.In python language, coding the least number of libraries goes to HSV, and the maximum number belongs to the shape detection.The number of code lines in dilation is the least, and shape detection has the maximum number of the code line.The results obtained indicate that the processing time is lengthy compared to PC, but the Raspberry Pi has to handle the lunar phase determination job.In conclusion, the result evaluation shows, even if the number of real samples is limited, which needs using the focus lens of the Raspberry Pi camera.However, the total SAZ performance shows its ability to disclose the moon phase by extending the shape detection algorithm with a better result as an additional algorithm.The present study could be used on various research topics such as face and palms recognition, pipeline defects detection, odor types tracking systems and other detection and analysis applications.


ISSN: 1693-6930 TELKOMNIKA Telecommun Comput El Control, Vol. 20, No. 1, February 2022: 129-140 132 four steps, the algorithm to make an effective way for the moon phase and date declarations and introduced the technique to separate the specific targets from the picture.

Figure 3 .
Figure 3.The designed hardware part (a) the system block, (b) design hardware, and (c) designed GUI[11]


Sunfa ata zuyan machine learning models for moon phase detection … (Ata JahangirMoshayedi)    137 As shown in Table

Figure 9 .
Figure 9.The date declaration and 8 real moon samples with the SAZ algorithm performance on PC and Pi

Table 1 .
PC and Raspberry Pi performance for Moon finding over the 27 fixed sample images

Table 2 .
Real Moon detection in picture over Total sample 8 samples

Table 3 .
The SAZ and various algorithm performance combinations for moon phase deceleration

Table 4 .
Phase declaration and various algorithm performance