Speckle Noise Removal in Image-based Detection of Refractive Index Changes in Porous Silicon Microarrays

Based on porous silicon (PSi) microarray images, we propose a new method called the phagocytosis algorithm (PGY) for removing the influence of speckle noise on image gray values. In a theoretical analysis, speckle noise of different intensities is added to images, and a suitable denoising method is developed to restore the image gray level. This method can be used to reduce the influence of speckle noise on the gray values of PSi microarray images to improve the accuracy of detection and increase detection sensitivity. In experiments, the method is applied to detect refractive index changes in PSi microcavity images, and a good linear relationship between the gray level change and the refractive index change is obtained. In addition, the algorithm is applied to a PSi microarray image, and good results are obtained.

gray level of each cell in the array. Before the biological reaction, each cell of the PSi array is modified, and probe biomolecules (such as DNA or antibodies) are immobilized in the PSi. After the reaction, the reactants formed by the specific binding of the target biological molecules (such as complementary DNA or antigens) and the probe molecules are also fixed in the PSi. This results in different morphologies of the PSi surface before and after the biological reaction, resulting in different speckle noise intensities in the corresponding images. In addition, the concentrations of the target biomolecules are different, and the amounts of reactants formed are different, also leading to different levels of speckle noise in the images. These different speckle noise intensities will cause different amounts of interference with the gray levels of the images, thus severely affecting the detection accuracy. To address this problem, the influence of speckle noise on the image gray levels is analyzed. A method of reducing the influence of speckle noise on the gray levels of PSi microarray images is proposed, and this method is demonstrated to improve the accuracy of the detection results.
theoretical Analysis Speckle noise model. In PSi microarray images, speckle noise is caused by the interaction between the laser light and the roughness of the PSi surface. The existence of speckle noise is inherent to this detection method, and it exhibits distinctive characteristics in terms of its certainty and randomness. Speckle noise can be modeled as multiplicative noise, with the obtained signal being a product of the original signal and the speckle noise 25 . Let I(i, j) denote a distorted pixel in an image, and let M(i, j) denote the corresponding noiseless image pixel. According to the multiplicative noise model, where N(i, j) represents the speckle noise signal 25 . Speckle noise also affects the gray values of the image itself. The larger the variance of the speckle noise is, the greater its influence on the gray values of the image, and the more difficult it is to recover the noiseless image. To better explain the influence of speckle noise, the effects of speckle noise with variances of 0.1 and 0.9 on an image with a gray value of 40 are shown in Fig. 1.
If the mean values of the N normal speckles participating in the superposition are denoted by Ik, K = 1, 2, …, N, then the probability density function of the intensity of the kth normal speckle, Ik, is an exponential distribution 26 , as shown in formula (2): Because the I k are statistically independent, the probability density function of their sum can be calculated as N-1 reconvolutions of the corresponding functions P I (I), as shown in formula (3): If the N I k are not zero and are not equal to each other, then formula (2) can be rewritten as follows: The probability density functions of N different independent speckle patterns of equal intensity are shown in Fig. 2. As N changes with the average total strength remaining unchanged, the probability density function changes from a negative exponential distribution (N = 1) to a Gaussian density function distribution (N = 10), which is consistent with the central limit theorem. www.nature.com/scientificreports www.nature.com/scientificreports/ Influence of speckle noise. Figure 3a shows an original image with a gray level of 40 at each pixel. Speckle noise of different intensities (variances) was added to this original image in MATLAB (2016a, MathWorks, Natick, MA, USA) to generate noisy experimental images. The variance (Var) of the noise was varied between 0 and 1 in intervals of 0.1; thus, 10 images with different speckle intensities were generated. The corresponding variances are 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, and 1.0. In Fig. 3b-f, five of the resulting noisy images are presented.
In research on speckle noise, previous works have evaluated denoising algorithms in two ways. Subjective evaluations concern how the textural details and visual effect of an image are improved after denoising. Objective evaluations rely on quantitative metrics such as the speckle index (SI), peak signal-to-noise ratio (PSNR), equivalent number of looks (ENL), and standard deviation (SD).
For the denoising of PSi microarray images, however, the subjective effects and traditional objective indicators are not important. Because the final detection result depends only on the average gray level of each cell in the  www.nature.com/scientificreports www.nature.com/scientificreports/ array, these gray levels need to be restored to remove the influence of the noise to enable accurate detection. At present, there are no related works on the restoration of gray levels affected by speckle noise. To study the effects of speckle noise on the image gray values, we added speckle noise with variances from 0 to 1 to 2500 images with a gray value of 40 and obtained the corresponding relationship between the resulting average gray value and the speckle intensity, as shown in Fig. 4c. As the speckle intensity increases, the average gray value of the image increases. The same result was found after testing testing three other sets of 2500 images each, with initial gray values of 20, 30 and 50.
To explain the reason for the observed relationship between the speckle intensity and the average gray value, we analyzed 7500 images containing speckle noise and considered the speckle intensity and the number of singular pixels (bright spots with an abnormal increase in gray value). The relationship between the speckle intensity and the number of singular pixels is shown in Fig. 5. By comparing Figs 4 and 5, it can be seen that the variation in the average gray value of the image is related to the number of singular pixels. When the speckle intensity is within the range of [0, 0.3], the number of bright spots is very small. Hence, the randomness of the scattered noise becomes the main factor affecting the average gray value of the image, causing the average gray value to fluctuate around the original gray value. As the speckle intensity increases beyond 0.3, the number of bright spots gradually increases, and these bright spots become the main factor affecting the average gray value of the image, resulting in an overall increase in the average gray value.
The findings from Fig. 5 can be used as follows: 1. The results provide a basis for the new algorithm proposed below: 2. An approximate relationship between the speckle intensity and the number of singular points can be obtained. By analyzing an unknown grayscale image, it is possible to estimate the degree of speckle contamination of the image, which will then play a large role in the subsequent image analysis.
The above conclusions are very important for the detection of biological reactions in PSi microarrays based on digital images [19][20][21] . In this image-based detection method, the changes in refractive index that are caused by biological reactions are determined by measuring the changes in the gray values of PSi microarray images. Speckle noise produced by laser irradiation will always be present in PSi microarray images obtained directly with digital imaging equipment. Moreover, the speckle noise intensities will be different for PSi surface images obtained before and after a reaction. According to the findings reported above, the higher the speckle noise intensity is, the greater its impact on the image gray levels. Thus, the changes in the gray levels measured in a biological detection www.nature.com/scientificreports www.nature.com/scientificreports/ experiment are partly due to the true changes in the refractive index of the PSi before and after the reactions and partly due to image speckle noise. Therefore, the ability to remove speckle noise in PSi microarray images is very important for the detection of biological reactions.

Methods
Many excellent algorithms have emerged from research on speckle noise. The classical algorithms include common Lee filters, Kuan filters, mean filters, and median filters [27][28][29] . Previous works have introduced some improvements to these classical algorithms and have achieved good results [30][31][32][33][34][35] . Recently, scholars have also proposed advanced algorithms, such as probability-based nonlocal means filtering 36 , numerical multilook and 3D block matching filtering 37 , adaptive wavelet threshold processing 38 , and adaptive anisotropic diffusion 39 . In this paper, a variety of filtering algorithms are experimentally analyzed. Most algorithms show good performance with respect to common evaluation indexes, such as the SI, PSNR and ENL, but they cannot modify the gray level of an image. Therefore, these algorithms cannot restore the gray level in the presence of speckle noise. The weights in the BM3D and PNLM algorithms are determined by the distances between similar blocks, and the gray value of a target pixel is obtained by weighting the gray values of all the pixels in its neighborhood. A large number of scattered spots and speckle blocks will increase the gray value differences between two neighborhood windows and thus affect the accuracy of the weights. The gradients of images with scattered spots and speckle blocks will be large, and the good edge retention of the PM algorithm can result in incorrectly identified edges and a poor denoising effect. A large number of scattered spots and speckle blocks will similarly affect the selection of the optimal threshold for the adaptive wavelet transform, thereby worsening the denoising effect. For the classical median and adaptive median algorithms, a large number of scattered spots and speckle blocks will result in a large difference between the selected median pixel and the original pixel, affecting the denoising process. To overcome these challenges, in this paper, we develop a new method of processing images with speckle blocks and a large number of scattered spots: the phagocytosis algorithm (PGY). This method not only can recover images contaminated with speckle noise but also exhibits good stability.
The flow chart of the phagocytosis algorithm used in this paper is shown in Fig. 6. The specific steps are described below.  www.nature.com/scientificreports www.nature.com/scientificreports/ Note that there exists an optimal number of phagocytosis iterations: an excessively large number of iterations will greatly impair the time performance of the algorithm, while an insufficient number of iterations will result in an inability to remove the speckle noise. In this study, 17500 speckle images in different formats and with different gray values were experimentally investigated to determine the optimal number of phagocytosis iterations. As a result, the relationship between the optimal number of phagocytosis iterations and the proportion of singular pixels was determined as shown in Fig. 7.
Step 1: The proportion of singular pixels is calculated for an unknown gray image, and the optimal number of phagocytosis steps (N) is found according to Fig. 7.
Step 2: The gradient magnitudes and directions for 8 neighborhoods in the smoothed gray image are calculated using a 3 × 3 template. Thresholds are applied to identify not only the speckle points but also the edges of speckle blocks based on the first-order partial derivatives at each pixel, which are calculated as follows.
Partial derivative in the X direction: x Partial derivatives in the Y direction: Partial derivatives in the 45° direction: 45 Partial derivatives in the 135° direction: The expression of gradient amplitude calculated by second-order Euclidean norm is as follows: x y 2 2 45 2 135 2

 
The calculation expression of gradient direction is as follows: Here, G x (x, y) is the gradient at point (x, y) in the X direction, G y (x, y) is the gradient at point (x, y) in the Y direction, G 45°( x, y) is the gradient at point (x, y) in the 45° direction, and G 135°( x, y) is the gradient at point (x, y) in the 135° direction.
Step 3: The remaining pixels are divided into 9 regions. The average gray values of the 9 regions are obtained and sorted to obtain the median gray value. The gray value of the identified speckle pixel is replaced with this median gray value. Thus, a phagocytosis iteration is completed, and the iteration number (X) is recorded.
Step 4: Steps (2) and (3) are repeated a number of times equal to the specified number of phagocytosis iterations.
Step 5: The image is further processed with an adaptive median filtering algorithm to remove any remaining speckles.
comparison with other methods. Five advanced algorithms previously proposed by other scholars, as implemented in MATLAB, were considered for comparison in terms of calculating the average gray value and SI: probability-based nonlocal mean filtering 36 , numerical multilook and 3D block matching filtering 37 , adaptive wavelet threshold processing 38 , adaptive anisotropic diffusion 39 , and Lee filtering. The average gray values were processed to two decimal places, and the SI was processed to four decimal places. In addition, with regard to the www.nature.com/scientificreports www.nature.com/scientificreports/ speckle intensity, we used 10 images to calculate the root-mean-square error (RMSE) of the method; the results can well reflect the measurement accuracy, as shown in Table 1. The gray level of an image with a speckle variance of 0.9 was restored, as shown in Fig. 8.
Based on the statistical data from the experimental images, the curves showing the variation in the average gray value with the speckle intensity after the application of the six algorithms were obtained, as shown in Fig. 9.
As shown in Figs 8 and 9 and Table 1, the phagocytosis algorithm can restore an image contaminated with speckle noise, achieving an SI value close to zero, indicating that the speckle noise has been suppressed. Compared with the five previously proposed algorithms, the phagocytosis algorithm shows a remarkable advantage in terms of recovery ability. To further verify the universality of the phagocytosis algorithm, a restoration test was carried out on 17500 images containing speckle noise in different formats and with different gray values,  www.nature.com/scientificreports www.nature.com/scientificreports/ and the recovery accuracy was 99.97%. Thus, it is shown that speckle noise can be effectively removed from images in different formats and with different gray values. For convenience and clarity, the results for only 2000 speckle-noise-contaminated images with different gray levels are shown in Fig. 10. experimental study. In our previous study, when laser light was incident on the surface of a PSi microcavity at 0° (vertical incidence), the reflection spectrum of the PSi microcavity obtained by increasing the incidence angle was the same as that obtained by increasing the refractive index 21 . Therefore, a change in the refractive index of a PSi microcavity can be considered equivalent to a change in the laser incidence angle. For a small angle of incidence, the enhancement of the reflected light intensity on the microcavity surface is proportional to the increase in the incidence angle 19 , that is, the gray value of a digital image of the microcavity surface increases with an increasing incidence angle 19 . Here, we applied the proposed phagocytosis algorithm to detect refractive index changes in PSi microcavity images. Each microcavity unit is a circular cell region in the PSi microarray.  www.nature.com/scientificreports www.nature.com/scientificreports/ PSi microcavities were prepared via electrochemical etching. Each microcavity consisted of a defect layer sandwiched between two Bragg layers, an upper layer and a lower layer. The Bragg structures on both sides each contained 6 cycles. The refractive index and thickness of each layer in a PSi microcavity are controlled by the corrosion current density and time. The PSi microcavities in our experiment had a defect-state wavelength of 633 nm. The structure of a PSi microcavity is illustrated in Fig. 11.
In the detection device 19 , laser light with a wavelength of 633 nm was incident on the PSi microcavities at different angles, and images of the device surface were obtained with a digital imaging device, as shown in Fig. 12.
First, the RGB image of the light reflected by the PSi microcavity at an incidence angle of 5° in Fig. 12 was transformed into a grayscale image, and seven methods were used to restore the gray level, as shown in Fig. 13. It can be seen from this figure that the phagocytosis algorithm is effective for eliminating speckles that obscure the  www.nature.com/scientificreports www.nature.com/scientificreports/ real image, can suppress the influence of speckle noise, and can restore the gray value of the image. We compare the results of our proposed algorithm to the results of five other advanced algorithms: probability-based nonlocal mean filtering 36 , numerical multilook and 3D block matching filtering 37 , adaptive wavelet threshold processing 38 , adaptive anisotropic diffusion 39 , and Lee filtering. We find that the adaptive median filtering algorithm does not achieve the desired effect in removing real speckles. Additionally, it does not restore the true gray value of the original image.
Based on the theoretical analysis presented in this paper and the observed effect of real speckle removal, it can be concluded that the phagocytosis algorithm can effectively achieve gray value restoration. Therefore, we applied this algorithm to all images in Fig. 12. The correspondence between the different incidence angles and gray values obtained after processing with the phagocytosis algorithm is shown in Fig. 14.
The fitting formula and judgment coefficient before processing are respectively: The fitting formula and judgment coefficient after processing are respectively:  www.nature.com/scientificreports www.nature.com/scientificreports/ It can be seen from Fig. 14 that the linear fit to the data processed with our denoising algorithm is better than the fit to the unprocessed data. In addition, for the same change in gray value, the change in angle as evaluated with our denoising algorithm is larger than that achieved without processing.
From the refractive indexes calculated based on the relationship between the changes in incidence angle and refractive index, the relationship between the changes in the gray level and the refractive index was obtained, as shown in Fig. 15. There is a good linear relationship between the change in the refractive index and the change in the gray level. As seen from Figs 14 and 15, after an image is processed with our denoising algorithm, the obtained change in the refractive index is larger than that obtained before processing for the same change in the gray value, demonstrating that the sensitivity of refractive index detection is improved.
It can be seen from the above experiment that the phagocytosis algorithm is very suitable for recovering the gray levels of images affected by speckle noise. The proposed algorithm can effectively reduce the influence of speckle noise in PSi microarray images and improve the detection accuracy achieved based on those images.

Gray-level restoration of pSi microcavity array images.
A PSi microarray was fabricated on monocrystalline silicon by means of lithography and electrochemical etching technology 19 . Each cell in the array was a microcavity structure, and the device parameters were the same as the microcavity parameters. The structure of the PSi microcavity array is shown in Fig. 16.
Each cell in the array had a defect-state wavelength of 633 nm. Laser light with a wavelength of 633 nm was incident on the surface of the PSi microarray at different angles, and surface images of the array were obtained with a digital microscope. Figure 17a shows a microarray image acquired with an incidence angle of 5°. The theoretical analysis presented above has demonstrated that the phagocytosis algorithm has the best ability to restore the gray levels of such images. Therefore, the proposed algorithm was applied to an actual PSi microarray image to verify this finding. In this experiment, we used previously described methods of preprocessing, tilt correction and sample segmentation 22 . Finally, we obtained the sample points to be measured, as shown in Fig. 17b. By measuring the average gray level of each sample point in Fig. 17b, we obtained the overall average gray level and the SI of all sample points. The measurement results are shown in Tables 2 and 3. Table 2 shows the measurement results before filtering, and Table 3 shows the measurement results for the sample points after the application of the phagocytosis algorithm.
It can be seen from the above experiment that after filtering with the phagocytosis algorithm, the SI is close to zero, indicating that the gray value can be effectively recovered. The phagocytosis algorithm has a better recovery ability than the other advanced algorithms considered. The proposed algorithm can effectively eliminate  www.nature.com/scientificreports www.nature.com/scientificreports/ the influence of speckle noise and improve the image-based detection accuracy achieved using PSi microarray images.

conclusions
This paper reports research conducted on the effect of speckle noise on the gray levels of PSi microarray images. A corresponding theoretical analysis is presented, and an algorithm suitable for restoring image gray levels in the presence of speckle noise is proposed. A PSi microcavity sensor was prepared for an experimental evaluation, and images of the light reflected from the sensor were obtained. The proposed algorithm was applied to detect refractive index changes in the PSi microcavities, and good results were obtained. At present, the algorithm proposed in this paper exhibits better performance than other advanced algorithms in terms of recovering image gray levels in the presence of speckle noise and improving the detection accuracy achieved with a PSi microcavity sensor. There are no related works that have investigated the recovery of image gray levels.