1 Introduction

Studies in predicting early lunar crescent visibility can be divided into two main categories. First, The statistical studies that are based on collection of observation reports over a long period of time. The results will be used to develop a criterion for prediction. But due to the nature of this method, the criteria are not always reliable.

One of the first criterion was used by Babylonian. They deduced, if “Moon age”Footnote 1 was over 24 h and “delay time”Footnote 2 was more than 48 min, then the crescent can be seen by naked eye (Odeh 2004). Fotheringham (1910) and also Maunder (Odeh 2004). Developed another criterion at the beginning of the nineteenth century. Then Bruin (1977) introduced another criterion. Schaefer (1996) used 295 observation records as his database and tried to consider effect of atmosphere. After Schaefer, Yallop (1997) and South African Astronomical Observatory (SAAO) (2001) criteria have been developed based on his database. Moreover, many Muslim astronomers had also developed their own criteria such as: Ibn Tariq, Habash, Al-Khwarzmi, Al-Khazin, Al-Tabari, Al-Fahhad, Al-Farghani,Thabet Bin Qurrah, Al-Battani, IbnMaimon, Al-Biruni, Al-Sufi, IbnSina, At-Tusi and Al-Kashani (Ilyas 1994; Schaefer 1996). As an example, Ilyas presented the criteria: Ilyas A, Ilyas B, Ilyas C that each one relies on some specifications of Moon crescent (Odeh 2004). Odeh (2004) established the last criterion (in the Islamic Crescent Observation Project, ICOP) which is based on 737 records, in which Airless Topocentric (ARCV) and Topocentric crescent Width (W) are two important variable in his calculations.

Second part of studies presents observing of new Moon crescent, using new methods and tools like large telescopes. Using large telescopes provides high degree of magnification, and consequently makes discerning of the Moon crescent easier. But high magnification also causes high level of noise. In addition there is very low contrast between Moon crescent and its background which makes it indistinguishable. We should also consider that, due to “false contouring”Footnote 3 (Gonzalez et al. 2008) and inefficiency of optical equipment to show true data near the borders, in some images noise and artifacts appear beside the true data that makes the work more difficult. In such a case, eye can hardly distinguish the noise and true data and consequently it becomes impossible to verify true observations. As a solution Fatemi and Lesani (2008) studied some algorithms based on spatial filters to extract Moon crescent from the observed images. In his method, spatial filters, are designed and applied to the image. Applying this type of filters without additional processing can lead to proper results except images with very low SNR. In order to improve SNR and detect Moon crescent visually, Rezaei et al. (2011) proposed a spatial filtering algorithm using a circular window. This circular window turns from 0 to 360 degrees for each individual pixel. Another method was offered by Elsasser (2010) in public observation center of Munich. He used large number of images, taken uninterruptedly in a short period of time. This method relied on averaging techniques to reduce noise.

This article introduces a new method based on image processing algorithms to extract Moon crescent from observed images. Initially the SNR of image is improved. Then contrast is enhanced using a method based on histogram processing to recognize Moon crescent visually. In addition circular Hough transform (CHT) is used to detect Moon crescent centers. In CHT Moon crescent is considered as part of a circle (full Moon). In order to confirm the method the results of both algorithms (visual detection and machine detection) have been checked and analyzed at the end.

2 Methods

To drive the crescent out of the image for visual detection, a histogram processing algorithm is used that increases the contrast and also an algorithm based on CHT is used in parallel as a machine detection algorithm that can detect probable crescents. Figure 1 shows the block diagram generally that indicates how this system works.

Fig. 1
figure 1

General block diagram for processing and discerning Moon crescent

2.1 New Moon Crescents Imaging

Today telescopes and binoculars are usually used to view new crescent. In order to observe by a telescope, the angle of observing the crescent in the sky should be calculated. After finding approximate location of the crescent, observation can be started. This attempt can succeed or fail. The failure can be due to false calculation. If it be assumed that correct position is targeted, sometimes the eye is unable to see the crescent. Figure 2 shows similar examples.

Fig. 2
figure 2

Two images of a new crescents

Image-recording can ensure the observer to confirm their observations. It can be seen easily that, images have very low contrast and this can make visual discerning difficult. Figure 3 shows histogram related to the images of Fig. 2.

Fig. 3
figure 3

The histogram of two images recorded from the location of the crescent

The eye can’t see the crescent—if exists- out of these observed images and it’s difficult to verify observation if it is reported “seen”. Therefore it is necessary to extract true information from images.

In this research, the images are taken by a Canon camera that is installed on a 12” Schmidt-Cassegrain telescope. Figure 4 shows a sample image recorded by our equipment and corresponding histogram.

Fig. 4
figure 4

Sample of taken images (left) and corresponding histogram (right)

2.2 Space Domain Filtering

Background of images with high magnification, include high level of noise, similar to pepper and salt noise. This noise can cause problems in the next steps of algorithm. In order to solve the problem in space domain, a Gaussian smoothing filter is used. Gaussian smoothing filter is one of the most well-known tool in the denoising and restoration of grey level and color images. The idea of Gaussian smoothing is to use 2-D distribution as a point-spread function, and this is achieved by convolution(Gonzalez et al. 2008). Then the new output are smoothed (blurred) as they are convolved with 2D Gaussian filter. Window size is selected 5 and Standard deviation is fixed on 0.33.

2.3 Histogram-Based Algorithm

Global histogram equalization maps the input image’s intensity values so that the histogram of the resulting image will have an approximately uniform distribution (Duan 2004; Natendra et al. 1981). Given an image A(x, y) and a desired output image B(x, y) there is some transformation function, f, which maps A to B. All intensity values in A in the region of values n A to n A  + dn A will have their values mapped to a corresponding region in B in the value range of n B to n B  + dn B . Each of these images will have a probability density function (PDF) P A (n A ) and P B (N B ). Assuming a 1-1 mapping, it is easy to show that:

$$P_{\text{A}} (n_{\text{A}} )dn_{\text{A}} = PB(N_{\text{B}} )dn_{\text{B}}$$
(1)

using this relationship, it can be shown that the mapping function from A to B is:

$$f\left( {n_{A} } \right) = \mathop \int \limits_{0}^{{n_{A} }} p(u)du = nF_{A} (n_{A} )$$
(2)

where \(F_{A} \left( {n_{A} } \right)\) is the cumulative probability distribution function of the original image. Therefore, to return a histogram equalized image, an image must be transformed using its cumulative probability function. The primary reason for histogram equalizations success at image enhancement is because it expands the dynamic range of intensity values while flattening the histogram.

Many alterations of histogram equalization have been proposed to counter the effects of this range expansion (Duan 2004). The most basic is adaptive local histogram equalization. A Moon crescent image histogram has low degree of diffusion so Moon crescent and the background of the image would be some sort of similar. This could make visual discerning of data difficult. Local histograms equalizing can be a useful way to enhance the quality of the image however; since data is not presented on the whole image, using global histogram equalization increases the noise. The data which represent the crescent can be found only in particular parts of the image and there is no useful information in whole part of images. Therefore if the algorithms process the quality enhancement locally, we will reach better result. The local computations are made by Eq. (3):

$$g = h_{k} (p(i,j))\quad \begin{array}{*{20}c} {0 < i < m} \\ {0 < j < n } \\ \end{array}$$
(3)

where parameter p is the grey level value of the pixel (i, j) from kth window, h k shows the output on k th window after equalization, m and n are local window size which should be optimized based on the imaging equipment. In this article, based on used imaging equipment m, n are selected 20. In fact g presents an output image in which all individual pixels are made based on the original image. Two samples of the crescent images and corresponding outputs are shown in Figs. 5 and 6.

Fig. 5
figure 5

a Original image, b global histogram equalization applied, c local histogram equalization applied

Fig. 6
figure 6

a Original image, b applying histogram equalizing algorithm, c applying local algorithm

2.4 Edge Detection

An edge is the boundary between an object and the background. The shape of edges in images depends on many parameters: The geometrical and optical properties of the object, the illumination conditions, and the noise level in the images (Chidiac 1999). In other words an edge is defined by a discontinuity in gray level values. After enhancement the quality of the Moon crescent’s image, true data should be extracted. In regard to the grey level difference of the pixels presenting Moon crescent data and the image background, edge detection can be used as an appropriate tool. In the next step edge detection is carried out by using Sobel operator and Canny algorithm. Figure 7 indicates the used 3 × 3 Sobel windows.

Fig. 7
figure 7

Masks used as Sobel operator

Sobel operator acts as a bi-dimensional differentiator. By using the Sobel operator, the points of the image with high degree of frequency range can be observed on space domain, and high degree of grey level changes, can be detected and highlighted. In order to drive the crescent Moon out of the background, given Sobel windows are convolved with the original image and then the output image is recorded. Canny algorithm initially smoothes the image and reduces its noise; then it uses differential operators to find the regions with high degree of grey level variation. At the next stage, the algorithm traces the found edges in order to distinguish the shapes by connecting the edges. Figure 8 indicates the result of applying Sobel operator and Canny algorithm to the image.

Fig. 8
figure 8

Result on Fig. 5a. a Applying Sobel operator, b applying Canny algorithm

The algorithm represents good results for both methods while Canny algorithm can also link the edges. Figure 9 indicates the result after applying Gaussian smoothing filtering and then Canny algorithm.

Fig. 9
figure 9

Canny edge detection result on (a) Fig. 5a (b) Fig. 6a

2.5 Circular Hough Transform (CHT)

After edge detection, the resulting connected component is labeled. Each connected component is expressed as a chain of the coordinates of its inputs. We connect pairs of points of the same component, using a sliding window. HT is a feature extraction technique used in image analysis. HT can be used for detecting simple shapes, such as straight lines, circles or ellipses. HT with transforming data to other areas tries to detect the specific patterns. In this article the aim is to find circle shapes and we should use a kind of HT that can detect circle patterns. So we use CHT which is based on HT procedure. In this method the center of circles that may exist in image are detected. Detection of the circle that the crescent may perch on it is done by CHT. In fact the image center shows the center of Moon. The output of edge detection operation will be a binary image. If in edge detection algorithm, a pixel is detected as the edge its value is chosen 1 otherwise 0 assigned to the correspond pixel.In CHT algorithm we have:

$$(x - x_{0} ) ^{2} + (y - y_{0} ) ^{2} = r^{2}$$
(4)

As it can be seen the circle got three parameters, r, x 0 and y 0, where x 0 and y 0 are the center of the circle in the x and y direction, respectively, and where r is the radius. The parametric representations of the circle are:

$$x = x_{0} + r\;\cos (\theta )$$
(5)
$$y = y_{0} + r\;\sin \left( \theta \right)$$
(6)

Thus the parameter space for a circle will belong to R3 whereas the line only belonged to R2. As the number of parameters needed to describe the shape increases as well as the dimension of the parameter space R increases so do the complexity of the HT.

In order to simplify the parametric representation of the circle, the radius can be held as a constant or limited. At each edge point we draw a circle with center in the point with the desired radius. This circle is drawn in the parameter space, such that our x axis is the x 0 value and the y axis is the y0 value while the z axis is the radius. At the coordinates which belong to the perimeter of the drawn circle we increment the value in our accumulator matrix which essentially has the same size as the parameter space. In this way we sweep over every edge point in the input image drawing circles with the desired radii and incrementing the values in our accumulator. When every edge point and every desired radius is used, we can turn our attention to the accumulator. The accumulator will now contain numbers corresponding to the number of circles passing through the individual coordinates. Thus the highest numbers (selected in an intelligent way, in relation to the radius) correspond to the center of the circles in the image (Kimme et al. 1975; Rizon et al. 2005).

The distance of any point on the circle from center equals to r. So we can conclude that if the distance of a point (pixel) from circle’s center be equal r, that point is on the circle. In different point of view we can say if a point on Cartesian coordinate system exists that the relation of it to the mentioned circle is a question, a line should be drawn from that point and the length of r if the circle passes the center, the point belongs to the mentioned circle. In CHT, for processing the image of Moon crescent we use the idea of belonging points to the circle in CHT accumulator. But the difference is here, if the pixels which in the edge detection operation assumed 1 belong to a circle with the radius of r = 150, drawn circles should cross each at the specific pixel which is the center of that circle with radius of 150. The mentioned point can be the supposed center of Moon. The result of the CHT algorithm in expressed method is shown in Fig. 10.

Fig. 10
figure 10

Result of CHT on (a) Fig. 9a (b) Fig. 9b

Center of the circle that Moon crescent is located on, has been diagnosed well with a suitable approximation. In fact if there is a Moon crescent in the image, the presented algorithm in Fig. 1 can either improve image quality for visual recognition or find the possibility of Moon crescent existence with analyzing centers of circles. If ideally we have an image of Moon like Fig. 11a, b, c represent result of the proposed algorithm.

Fig. 11
figure 11

a Moon image (b) edge detection (c) CHT result

The algorithm presents really good result which shows its high capability. But certainty there are limitations like minimum SNR which should be assessed as it can cause failure in detection of crescents. Thus in order to evaluate the algorithm extra Gaussian noise is added to images until the algorithm fails. SNR of single images are calculated based on the method introduced as “Single Image Signal-to-Noise Ratio Estimation”(Thong et al. 2001). For Figs. 5a and 6a the estimated SNR are 0.95 and 1.07 respectively. In next step the white Gaussian noise is added until the algorithm failed to detect the centers that illustrates the minimum required SNR. The limited SNRs for Figs. 5a and 6a are calculated 0.87 and 0.82 respectively. Figure 12 shows noisy images and the algorithm output:

Fig. 12
figure 12

a, b Noisy image of Fig. 5a and 6a (c) and (d) Edge detection of noisy images (e) and (f) CHT result of low SNR images

3 Result

In this paper, 31 images are tested and analyzed. For tested database acceptable and attributable results is achieved. The algorithm is also examined by other databases:

Different Moon Crescent images are taken under different climate conditions so images have different SNRs. Calculated SNRs are listed in Table 1. For example Fig. 13a, b SNRs are 0.72 and 0.84 respectively. In addition contour effect is observed specially in Figs. 14a and g that can cause failure in next steps. Contour effect is created in borders images. These phenomena should be considered and reduced during photography. Contour effect in Fig. 13g caused many artifacts which can be clearly seen in Fig. 15g. In this case, the crescent doesn’t locate near borders, so CHT could extract it from background.

Table 1 Single image SNR estimation of Fig. (13) respectively
Fig. 13
figure 13

Initial images used as inputs

Fig. 14
figure 14

Local enhancement done on images

Fig. 15
figure 15

Edge detection result

In cases with low SNRs like Fig. 13a, e, i, SNRs are 0.72, 0.93 and 0.86 respectively. Noise is very similar to data and vice versa. In such cases the edge detection algorithm may consider noise instead of signal like Fig. 15i and true data may be considered as noise like Fig. 15e that crescent is not clearly recognized.

CHT is a robust algorithm which is used to distinguish center of Moon crescents. Figure 16 shows the CHT output. Amazingly CHT have acceptable performance in all cases including low SNR cases. Figure 16g shows successful result of applying CHT to Fig. 13g.

Fig. 16
figure 16

CHT result based on edge detection result

The algorithm performs noticeably successful for all images which illustrate the capability of the algorithm. Of course when the crescent is under high intensity of noise the algorithm (likelihood estimation process) predicts more than one center like Fig. 13a, e, g, i. To overcome this trouble the center which is determined with highest number of edges is assumed as correct center. Detection of incorrect edges leads to face problems in CHT process.

To evaluate the algorithm white Gaussian noise is added to all images in Fig. 13 until CHT failed to detect the centers. Table 1 shows estimated SNRs of images and Table 2 illustrates the SNRs in which the algorithm failed.

Table 2 The SNR in which the algorithm failed to detect the centers for Fig. (13) respectively

As it can be seen in Fig. 17 there is minimum SNR that below it, algorithm fails to detect correct centers. The reason is, although CHT is robust in cases with high intensity of noise but under a minimum SNR noise may be detected as true data and vice versa. Under such circumstance, edge detection output is mixture of true and false edges. As much the SNR is lower, edge detection output includes more wrong edges and consequently under minimum SNR, CHT will fail to detect correct centers.

Fig. 17
figure 17

Algorithm performance while adding noise and reducing SNRs of Images in Fig. 13

The database is divided into two parts. Second part of data has higher SNR and is easier to detect by naked eye or optical instrument without any process. The result of the algorithm for the second part of database is also shown in Figs. 18, 19, 20, 21.

Fig. 18
figure 18

Initial images used as inputs

Fig. 19
figure 19

Local enhancement done on image of Fig. 18

Fig. 20
figure 20

Edge detection result of Fig. 18

Fig. 21
figure 21

CHT result based on edge detection result of Fig. 18

4 Discussion

Clearly processing of Moon crescent and its surface has more applications in the world and Moon surface image analysis seems to be more practical in future. For example for landing on the Moon or the other planets, spacecrafts need image processing technology.

The developed algorithm seems really flexible and practical. It should be considered that the whole performance of the algorithm is depended on taking true and useful images using optical instrument like cameras and telescopes which have various options. Therefore the method we collect raw data is really important. Furthermore as the background of images is always bright, clarifying correct and overexposed images is really hard. So, setting true camera or telescope options is noticeably essential.

5 Conclusion

New presented method for lunar crescent detection based on image processing algorithms such as edge detection and HT, has acceptable practical results. Extracting the objects that the eye is unable to recognize can be beneficially used by astronomers as a reliable method as a way to verify result of reports. In addition, using this technique can help to have more accurate criteria.