1 Introduction

Monitoring of the ionizing radiations is necessary for occupationally exposed individuals and the general public. Ionizing radiations such as X-rays and gamma rays are well utilized in industry, agriculture and medical field, and radioactivity-related incidents occur due to improper management of the radiation sources or facilities, from the missing of an 192I source in Nanjing, China on May 7, 2014 [1], to the Fukushima Daiichi nuclear disaster in Japan in March 2011 [2]. Monitoring ensures the maximization of benefits and minimization of risks.

Radiation monitoring is achieved using specialized radiation instruments. In radiation dosimetry, the Geiger–Mueller counter is the most popular instrument used to assess the radiation levels and the related risk. In spectrometry, scintillator and semiconductor detectors are widely employed. However, dedicated detectors are not suitable for large-scale uses, and equipping everyone with such a device is uneconomic, unnecessary and impractical.

Charge-coupled device (CCD) and complementary metal–oxide–semiconductor (CMOS) sensors are widely used in X-ray imaging and spectroscopy. A common way is coupling them with phosphor and scintillator materials which converts the X-/γ-rays to visible light photons [3]. It was found that they can interact directly with X-/γ-rays without any converter and generate bright blotches in the acquired images [4,5,6,7,8]. Figure 1 shows a summed image of 100 frames taken by a smartphone near a ~10 mCi 99mTc source with its camera covered by a light-tight tape. The bright blotches are generated by the interaction of gamma rays. This phenomenon has been employed to detect low-energy X-/γ-rays for imaging [4] or dosimetry [5,6,7,8].

Fig. 1
figure 1

A summed image of 100 frames taken by a smartphone near a ~10 mCi 99mTc source with its camera covered by a light-tight tape

The new-generation devices for radiation monitoring are based on the latest smartphone technology with built-in CCD/CMOS sensors [9,10,11,12,13]. Although stand-alone CCD/CMOS sensors are of much lower efficiency than the dedicated detectors, they are much cheaper and widely diffused. Almost everyone has a smartphone nowadays. Several processing algorithms were developed to retrieve ionizing radiation events from the images or videos acquired by the built-in cameras on smartphones. Applications (Apps) were developed based on these algorithms, such as GammaPix [12] and Radioactivity-Counter [13]. To the best of our knowledge, most of the methods in the literatures required the camera lens of the smartphone to be covered with a light-tight tape to completely shield the sensors from ambient light. It is inconvenient and may compromise the camera’s optical lens. Also, the measurement is not a real-time process. Compared to a computer, a smartphone has much lower processing performance, such as slower processors, less memory and power consumption issue of reduced battery life. Thus, the processing algorithm should be simple for real-time measurements.

In this paper, a fast algorithm is developed to survey ionizing radiations in real time without requiring covering the camera lens. The Android App of Raydose can be downloaded freely from Xiaomi App store [14].

2 Materials and methods

2.1 Real-time processing algorithm

The program proposed in this paper consists of two threads. In the first thread, the rear camera of the smartphone is called to take consecutive video frames through the Camera API using Preview class (android.hardware.camera). The video stream is processed by the other thread. Firstly, temporal difference images are generated. Then, an adaptive thresholding method is used to determine whether the images contain radiation events. Finally, the radiation dose rate and cumulative dose are updated. Based on such an algorithm, an App was developed for Android 4.0 and higher platforms using Android studio 2015. Details of the algorithm are described below:

Step 1 The maximum value (V n ) of the temporal difference image (I n  − I n−1) are calculated and compared with a threshold T n . If V n is higher than T n , the nth frame will be judged as indication of the present of radiation:

$$ \left\{ \begin{gathered} V_{n} = \max (I_{n} - I_{{n - 1}} ) \hfill \\ \delta (n) = \left\{ \begin{gathered} 1,\quad {\text{if}}{\kern 1pt} {\kern 1pt} V_{n} > T_{n} \hfill \\ 0,\quad {\text{otherwise}} \hfill \\ \end{gathered} \right. \hfill \\ \end{gathered} \right., $$
(1)

where T n is dynamically changed as:

$$ T_{n} = \mu_{n} + 5\sigma_{n} , $$
(2)

where μ n is the mean value of {V}1−n , and σ n is the standard deviation of {V}1−n . Because noise obeys a normal distribution, the probability of mistaking noise for a signal is 0.012% for 5 sigma values. In order to reduce the computational expense and memory, μ n and σ n are calculated by an approximate updating algorithm as shown in Eq. (3)

$$ \begin{aligned} \mu_{n} &= \mu_{n - 1} \frac{n - 1}{n} + V_{n} \frac{1}{n} \hfill \\ \sigma_{n} &= \sqrt {\sigma_{n - 1}^{2} \frac{n - 1}{n} + (V_{n} - \mu_{n} )^{2} \frac{1}{n}}. \end{aligned}$$
(3)

If V n is higher than T n , V n is not a norm background signal; thus, it will be taken away from the updating process, i.e., the value of μ n and σ n are reset to μ n−1 and σ n−1. Step 2 The dose rate (DR) and cumulative dose (D) are updated using Eq. (4):

$$ \left\{ \begin{aligned} & H_{n} = \sum\limits_{1}^{n} {V_{i} \delta \left( i \right)} \hfill \\ & {{DR}}_{n} = \frac{{H_{n} f}}{n}R_{{{D \mathord{\left/ {\vphantom {D H}} \right. \kern-0pt} H}}} \hfill \\ & D_{n} = H_{n} R_{{{D \mathord{\left/ {\vphantom {D H}} \right. \kern-0pt} H}}} \hfill \\ \hfill \\ \end{aligned} \right.,$$
(4)

where δ(i) is the Dirac delta function in Eq. (1); H n is the cumulative gray value; DR n and D n stand for the radiation dose rate in μSv/h and cumulative dose in μSv, respectively, at the time of gathering nth frame; f is the frame rate per hour of the video; and R D/H is the calibrated ratio of the cumulative radiation dose to accumulative gray value.

2.2 Dose calibration experiments

A Xiaomi Mi2 smartphone with the App installed and a Geiger counter FJ2000 (HUATEC, China) were placed side-by-side on the treatment couch of a Varian Trilogy™ (Varian Medical Systems Inc., USA) radiotherapy system (Fig. 2). They were placed at one end of couch that far away from the accelerator module due to the high radiation dose generated by the linac. Therefore, only the scattered X-rays were used in the dose calibration studies. The supported Preview frame rate of the smartphone is 12.5 fps, with 6 MV X-rays from the accelerator. Three groups of repeated experiments were carried out to ensure the validity of the results. Each group included 12 measurements with different monitor units.

Fig. 2
figure 2

Experimental setup to calibrate the dose of a Xiaomi Mi2 with ‘Raydose’ App using a Geiger counter FJ2000 with the X-ray source from a Varian Trilogy™ radiotherapy system

2.3 Performance experiments

Two experiments were carried out with a 22Na source (Φ3 mm in an enclosure) in activity of ~1.7 × 105 Bq being placed on a supported platform (Fig. 3). Case one: the camera lens of the smartphone was covered by a light-tight black tape; Case two: the black tape was removed. To obtain correct initial values of μ n and σ n , the App was set to run without the radiation source at the beginning. The 22Na source was put on a pedestal to measure the dose rate and cumulative dose of 5 s.

Fig. 3
figure 3

Setup for the measurements with and without a light-tight tape on the camera lens

The smartphone was put on a desk with the rear camera facing to the desk. The app took one-minute measurement with the 22Na source placed on the top of the smartphone near the rear camera.

3 Results and discussion

For the Varian Trilogy™ system experiments, the accumulated gray value (H) as a function of the average cumulative dose (D) by the G–M counter is shown in Fig. 4. The linear fitting is H = 4320D + 78, with a good linearity by R 2 = 0.9895. Thus, the scale ratio from image gray value to radiation dose in Eq. (4) is R D/H  = 1/4320.

Fig. 4
figure 4

Cumulative maximum pixel value as a function of the cumulative dose

Figure 5 shows the measurement results of the smartphone exposed to the source with and without covering the camera lens. The μ n and σ n without covering the camera lens (dotted lines in Fig. 5a, b) are higher than those with the camera lens covered (solid lines in Fig. 5a, b). This means that the differencing images have higher noise without covering the camera lens. The dose rate and cumulative dose without covering the camera lens (dotted lines in Fig. 5c, d) are less than those with camera lens being covered (solid lines in Fig. 5c, d). The ratio of the cumulative doses of the two cases at 5 min is about 1:1.32. The main reason for this performance is that the dynamic threshold is getting higher. The result verifies that the program can work normally without covering the lens if the view is static. Thus, it does not require to fully cover the camera lens with a light-tight tape. The App can perform well with the smartphone laying on a desk with the rear camera facing down or just being put in a pocket.

Fig. 5
figure 5

Measurement results with and without the lens covered

The algorithm used in the App is simple and fast that can perform ionizing radiation detection in real time like a GM tube. Compared to the existing programs, our program is advantageous in that it does not require light-tight setup, i.e., a smartphone with this App can work normally when directly laid on a desk without covering its camera lens with black tape.

The CMOS sensor can be used to detect ionizing radiation. Different smartphones might have different size of CMOS sensors, noise and supported preview frame rates, etc. Thus, in order to obtain more accuracy results for dosimetry measurements, each kind of smartphone should be calibrated individually. Due to its small size, the sensitivity of the CMOS sensor is much lower than dedicated detectors; thus, the dose measurement accuracy is still low after calibration. Thus, it is not suitable for high-accuracy dose measurement. Also, it is not practical for a person to carry the smartphone with the App running persistent due to the power consumption and the light-tight or light-static requirements; thus, it is not suitable for a long-term personal radiation dose monitor. However, it can be employed as a low-cost tool for public people to do fast ionizing radiation survey for checking environment safety. It is useful for the situations whenever a nuclear accident happens. As smartphones are used everywhere and are connected by communication modules, a measurement network can easily be built if necessary under the situation that not necessary to measure the ionizing radiation in high accuracy.

4 Conclusion

A smartphone application with a simple and fast algorithm is developed to extract radiation events from the video stream captured by the built-in camera. The proposed method can perform in real time without requiring covering the lens of the camera. A smartphone with this application can be employed as a fast survey tool for ionizing radiation.