1 Introduction

Image registration is an essential step in medical image analysis. It is a very active research field due to the steady improvement of medical imaging technology. Image registration is the geometric alignment of images obtained from different viewpoints, at different times, or using different sensors [1, 2]. Computed tomography (CT) is one of the most important medical imaging techniques used to detect and diagnose many diseases. CT systems use superimposed radiographic images to create a volume image where each slice can be manipulated with dedicated software to produce the image of the body part being examined.

Coronavirus (COVID-19) is a dangerous and rapidly spreading disease that has recently appeared and caused panic throughout the world, leading to many victims every day. Since the emergence of COVID-19, the discovery and diagnosis of this disease relied on CT imaging which has become the goal of many researchers in the medical field. As mentioned in [3], CT imaging shows the presence of ground-glass opacities (GGO) in areas of the lung 3 days after infection with the virus [4, 5].

The accuracy of the disease diagnosis increases whenever there is additional information on the results of CT imaging [6]. Thus, identifying the infected person in a short period and isolating him are done to contain this virus. Therefore, the search for an effective optimization method to increase the amount of information in tomography of the virus will have an important role in facilitating the process of diagnosis and detection. The importance of CT image registration is to provide an image that clearly shows the evolution of the GGO in the lung, confirming virus infection. This process will reduce the spread of the virus by isolating the infected person [7].

The image registration process is based on calculating a spatial transformation function between two images to be superimposed on the optimum of their resemblance criteria [8]. One of the two images is referred to as the reference image, and the second is the target input image [1]. Image registration techniques can be divided into intensity-based and feature-based. In the intensity-based methods, the intensity patterns in the two images are compared utilizing correlation metrics. In contrast, in the feature-based techniques, the image features such as points, lines, and contours are used to find correspondence between them. The intensity-based methods are simple and more robust than feature-based methods. Meanwhile, the feature-based process is sensitive to the extracted features [2].

Three tools are needed to perform registration: a transformation model, a similarity metric, and an optimization algorithm [8]. The transformation model determines which geometrical transformation to apply for the registration. This model can be rigid, affine, or perspective. Similarity metrics are based on intensity difference, cross-correlation, and mutual information (MI) [9]. The optimization method is a searching strategy to find the best transformation parameters for aligning the input images. Since optimization is an essential step to obtaining good registration results, the main objective of the present research paper is to design a new optimization algorithm that increases the quality of medical image registration. Many optimization methods have been introduced and adopted for the registration process, such as Downhill Simplex, conjugate gradient descent, and the Levenberg–Marquardt method [8].

Recently, meta-heuristic methods such as genetic algorithm, simulated annealing [10], differential evolution [11], ant colony optimization [12], particle swarm optimization (PSO) [13], and Biogeography-based optimization (BBO) have been widely used in various fields including the image registration [14]. However, some of these approaches do not always provide a global optimum solution or require significant computing time for converging. An improved sine cosine algorithm (SCA) has been proposed in this study to maximize the structural SIMilarity metric (SSIM) [15] instead of the normalized mutual information (NMI) criterion. The sine cosine algorithm of Mirjalili is a global optimization approach based on two trigonometric functions, the sine, and the cosine functions [16]. Despite the simplicity of this method, it does not always provide a global optimum solution and is sometimes trapped in a local minimum. To improve the SCA, the PSO algorithm, which is widely used in image registration, has been taken as an advantage to improve the SCA [17, 18]. This hybridization results in the new algorithm named improved SCA (ISCA) specifically designed to obtain better registration of medical images.

The rest of the article is organized as follows. Section 2 presents a detailed description of the proposed approach. In Sect. 3, we will show the simulation results by comparing the proposed algorithm with the original SCA using different datasets. Finally, Sect. 4 concludes the paper.

2 Description of the proposed method

Generally, image registration is a process of aligning a pair of input images where a parametric transformation \(\widehat{T}\) is applied to the input image \({I}_{m}\) to maximize its similarity with the reference image \({I}_{r}\) [8]. After that, the similarity metric S is chosen to measure the similarity between these two pictures. Finally, an optimization technique is used to find the optimal transformation parameters minimizing the similarity measure [19].

In this section, we describe the proposed algorithm to register a pair of images. In the registration process, we define a spatial \(\widehat{T}\) which maximizes the structural similarity metric SSIM of the reference \({I}_{r}\) and floating \({I}_{m}\) images as:

$$\widehat T=\arg\;\underset T{\max\;}SSIM\;\left[I_r\left(x,y\right),T\left(I_m\left(x,y\right)\right)\right]$$
(1)

In this equation, \(\left(x,y\right)\) is the coordinates of the image. The flowchart of our method is given in Fig. 1.

Fig. 1
figure 1

Block diagram of image registration process

2.1 Transformation

The transformation model determines which geometrical transformation to apply for the registration. Our study is limited to the rigid transformation, which contains a translation along x and y axes \({t}_{x}\) , \({t}_{y}\) , and rotation \(\theta\), and it can be defined as [19]:

$$M=\left[\begin{array}{ccc}\begin{array}{c}\mathrm{cos}\left(\theta \right)\\ \mathrm{sin}\left(\theta \right)\\ 0\end{array}& \begin{array}{c}-\mathrm{sin}\left(\theta \right)\\ \mathrm{cos}\left(\theta \right)\\ 0\end{array}& \begin{array}{c}{t}_{x}\\ {t}_{y}\\ 1\end{array}\end{array}\right]$$
(2)

2.2 Similarity measure

In this paper, we use the structural similarity index metric (SSIM) to evaluate the similarity between the reference image and floating source image instead of the normalized mutual information (NMI) criterion [5]. The structural similarity metric (SSIM) is given by [15]:

$$SSIM\left({I}_{r},{I}_{m\_reg}\right)=\frac{\left(2{\mu }_{r}{\mu }_{m\_reg}+{\left({k}_{1}L\right)}^{2}\right)\left(2{\mu }_{m\_reg}+{\left({k}_{2}L\right)}^{2}\right)}{\left({\mu }_{r}^{2}+{\mu }_{m\_reg}^{2}+{\left({k}_{1}L\right)}^{2}\right)\left({\sigma }_{r}^{2}+{\sigma }_{m\_reg}^{2}+{\left({k}_{2}L\right)}^{2}\right)}$$
(3)

where \({\mu }_{r}\) and \({\sigma }_{r}\) denote the local mean and standard deviation of reference image \({I}_{r},{I}_{m\_reg}\) and \({\sigma }_{m\_reg}\) denote the local mean and standard deviation of registered image\({I}_{m\_reg}\), \({\sigma }_{r,m\_reg}\) is cross-covariance for the reference image \({I}_{r}\) and registered image \({I}_{m\_reg}\) . \({k}_{1}\) , \({k}_{2}\) are parameters with small values and \(L\) is the maximum pixel value. SSIM values have the range of \(\left[ {0, 1} \right]\) .

2.3 Optimization algorithm

Optimization is the most important stage in the image recording process as optimization techniques are used to find the optimum transformation parameters needed to align the images. Optimization algorithms are the primary source that influences the convergence speed of a similarity measure [20, 21].

2.3.1 SCA

The sine cosine algorithm (SCA) proposed by Mirjalili [16] is a population-based optimization technique. It begins by generating a set of random solutions, and then, these solutions are updated based on the sine or cosine function as in Eq. (4).

$${X}_{i}^{i+1}=\left\{\begin{array}{c}{X}_{i}^{t}+{r}_{1} . \mathrm{sin}\left({r}_{2}\right).\left|{r}_{3}{P}_{i}^{t}-{X}_{i}^{t}\right|, {r}_{4}<0.5\\ {X}_{i}^{t}+{r}_{1} . \mathrm{cos}\left({r}_{2}\right).\left|{r}_{3}{P}_{i}^{t}-{X}_{i}^{t}\right|, {r}_{4}<0.5\end{array}\right\}$$
(4)

where \({P}_{i}^{t}\) is the position of the destination point in i-th dimension at iteration t , \({X}_{i}^{t}\) is the position of current solution in i-th dimension.\({r}_{1}\), \({r}_{2}\) ,\({r}_{3}\) and \({r}_{4}\) are random variables and are uniformly distributed between 0 and \(2\pi\) , 0, and 2, and between 0 and 1 respectively. The random variable \({r}_{1}\) is responsible for the area of the next solution, which can be either in the space between the solution and the destination or outside it. The variable \({r}_{1}\) is updated as:

$${r}_{1}=a\left(1-\frac{t}{{T}_{max}}\right)$$
(5)

where \(a\) is a constant, Tmax is the maximum iterations. The sine cosine algorithm is summarized as follows [16].

Algorithm 1: sine cosine algorithm.

figure b

2.3.2 Improved SCA

As mentioned above, the SCA does not always converge to the global solution. To overcome this drawback, the SCA should be improved. In this paper, we propose to hybridize the SCA with the PSO algorithm by choosing between SCA and PSO updating procedures. The updating rule of the improved SCA (ISCA) is as follows:

$${x}_{i}^{t+1}=\left\{\begin{array}{cc}\begin{array}{l}{x}_{i}^{t}+{r}_{1}. \mathrm{sin}{r}_{2}. \left|{r}_{3}{g}^{t}-{x}_{i}^{t}\right|,\\ {x}_{i}^{t}+{r}_{1}. \mathrm{cos}{r}_{2}. \left|{r}_{3}{g}^{t}-{x}_{i}^{t}\right|\\ {x}_{i}^{t}+{v}_{i}^{t+1};\end{array},0.4\ge & \begin{array}{c}{r}_{4}>0.4\\ {r}_{4}>0.6\\ {r}_{4}\ge 0.6\end{array}\end{array}\right.$$
(6)
$${v}_{i}^{t+1}={v}_{i}^{t}+{r}_{5}.{c}_{1}\left({p}_{i}^{t}-{x}_{i}^{t}\right)+{r}_{6}.{c}_{2}\left({g}^{t}-{x}_{i}^{t}\right)$$
(7)

where \({p}_{i}^{t}\) is the best position of the solution \(i\) , and \({g}^{t}\) is the global best position found by all solutions [21]. The acceleration constants C1 and C2 have real value, usually in the range 0 ≤ C1 and C2 ≤ 4 . The values r5 and r6 are uniformly distributed in the range [0,1]. The improved SCA is summarized as follows:

Algorithm 2: ISCA algorithm.

figure c

3 Computer simulation

Several simulations were performed on the images of the lungs of people infected with the COVID-19 using the SCA algorithm and ISCA to obtain good registering of these images.

3.1 Test images

In this paper, two kinds of images were used, CT images and microscopic images. Although they do not provide information on the type of viral pneumonia, CT images are still useful for diagnosing COVID-19 during the breakout. On the other hand, the microscopy images of histopathology tissue are the only ones that allow researchers to study the disease mechanism at the cellular level and understand the pathophysiology of COVID-19. Test CT scans and microscopy images are obtained from the American Journal of Roentgenology (AJR) dataset, COVID-19 CT database [4] and PathologyOutlines.com website, respectively [22].

3.2 Evaluation criterion

To assess the performance of the two methods, SCA and ISCA, the SSIM, the mean squared error (MSE), absolute error (AE) between true \(T^{*} = \left( {t_{x}^{*} ,t_{y}^{*} ,\theta^{*} } \right)\) and estimated \(T = \left( {t_{x} ,t_{y} ,\theta } \right)\) transformation, and Dice similarity coefficient (DSC) are used as quantitative assessment metrics to compare various registration algorithms. They are defined as:

$$MSE=\frac{1}{MN}\sum_{i=1}^{M}\sum_{j=1}^{N}{\left({I}_{r}\left(i,j\right)-{\mathrm{I}}_{m\_reg}\left(i,j\right)\right)}^{2}$$
(8)

\({I}_{r}\left(i,j\right)\) and \({\mathrm{I}}_{m\_reg}\left(i,j\right)\) are the pixel values of the ground truth and registered images, \(M \times N\) is the size of images.

$${AE}_{x}=\left|{t}_{x}^{*}-{t}_{x}\right|$$
(9)
$${AE}_{y}=\left|{t}_{y}^{*}-{t}_{y}\right|$$
(10)
$${AE}_{\theta }=\left|{\theta }^{*}-\theta \right|$$
(11)

The higher SSIM value and the less (MSE, AE) value indicate better registration results.

The Dice similarity coefficient (DSC) is defined as an instrument of determining a similarity measure between images A and B, and it can be given as follows [23]:

$$DSC\left(A,B\right)=\frac{2\left|A\cap B\right|}{\left|A\right|\cap \left|B\right|}$$
(12)

where \(DSC\left(A,B\right)\in \left[\mathrm{0,1}\right]\), with \(DSC\left(A,B\right)=0\) if there is no correspondence between the images and \(DSC\left(A,B\right)=1\) if complete correspondence.

3.3 Accuracy

In the experiment, three images were randomly chosen from the AJR dataset. A floating image (test) is obtained by applying the translation \(\left({t}_{x}^{*},{t}_{y}^{*}\right)=\left(5,-5\right)\) and, a rotation of \({\theta }^{*}=5^\circ\) to the ground truth image. Figures 2 and 3 show ground truth images and the superposing of the test and the reference images. The gray areas correspond to areas that the two images have similar intensities, while magenta and green areas show regions where one image is brighter than the other.

Fig. 2
figure 2

CT images of the lungs of a patient infected with the COVID-19. (a) CT image 1.) (b) CT image 2. (c) CT image 3

Fig. 3
figure 3

Superposing of the test and the reference images. (a) CT image 1. (b) CT image 2. (c). CT image 3

Bio-inspired algorithms SCA and ISCA have been used to register the images. The used parameters are generated by the trial-and-error method. They are illustrated in Table 1.

Table 1 SCA and ISCA parameter values

After applying the SCA and ISCA algorithms, the results were recorded and compared to determine the best algorithm that helps us obtain a helpful image in diagnosing COVID-19. From the results obtained after applying the two algorithms to the images of the lungs with COVID-19 that appear in Table 2, we found that the results obtained from the ISCA are more accurate than those obtained by the SCA. The SSIM and DSC values from the ISCA are higher than those obtained with the SCA for the three images, while the MSE values for ISCA are smaller, which proves that the two images are well-aligned using the ISCA.

Table 2 Performances of SCA and ISCA for AJR dataset

From the absolute error shown in Fig. 4, the transformation parameters obtained by the ISCA algorithm are more accurate than those obtained with the SCA. Figure 5 shows the affinity curves after applying the algorithms to the tree target images in this paper. As we can see, the ISCA is faster and more accurate compared to the SCA algorithm. Through these curves, we note that the SCA accuracy never reaches that of the ISCA up to 80 iterations. This confirms the efficiency of the ISCA algorithm for these used images.

Fig. 4
figure 4

Absolute error of the transformation for three CT images from AJR dataset

Fig. 5
figure 5

Convergence curves for CT image registration using SSIM for AJR dataset. (a) CT image 1. (b) CT image 2. (c) CT image 3

Figure 6 shows the visual results of registering the three images using the ISCA and the SCA. The absolute error map and the SSIM map justify a good alignment of the test and reference images since white regions, which correspond to high values of the SSIM, indicate a good alignment of the two images.

Fig. 6
figure 6

Visual registration results for three CT images from AJR dataset

To justify the generalization ability of the proposed method, we carried out experiments using another COVID-19 CT database. The COVID-CT-Dataset consists of 349 CT images from 216 patients with the coronavirus. It is publicly available at [24]. Figure 7 shows some image samples randomly chosen from this dataset. These CT images have different sizes. The minimum, average, and maximum height are 153, 491, and 1853. The minimum, average, and maximum width are 124, 383, and 1485.

Fig. 7
figure 7

Illustration of twelve CT images from the COVID-CT dataset

In the first simulation, the SCA and ISCA were applied on 12 image samples after having undergone random transformations. Figure 8 shows the absolute error of the transformation parameters, while Fig. 9 shows the mean values of the similarity metric, DSC metric, and the mean square error. Through the similarity curves of the SSIM and DSC, the ISC algorithm outperformed SCA for all used images. For the absolute error, the ISC algorithm outperformed the SC algorithm in most cases. We can show that the values are close together for the absolute error in the horizontal direction in image 6, the rotation absolute error in image 5. According to these results, we can conclude that the proposed method can perform better.

Fig. 8
figure 8

Absolute error in (a) the horizontal direction, (b) the vertical direction, (c) rotation angle for the COVID-CT dataset

Fig. 9
figure 9

Registration results for the COVID-CT-Dataset. (a) SSIM curve, (b) DSC curve, (c) MSE curve

To check the robustness of the proposed algorithm, we have used the whole images of the dataset. As shown in Fig. 10, the SSIM values after convergence of the ISCA are closer on 1 than the SCA. The mean and the standard deviation (STD) values of the SSIM, DSC, MSE, and the absolute error of the transformation parameters \(AE_{x}\),\(AE_{y}\), \(AE_{\theta }\) were reported in Table 3. As we can see, the ISCA outperforms the SCA for all metrics.

Fig. 10
figure 10

SSIM values of SCA and ISCA after convergence for COVID-CT images

Table 3 Statistical analysis of SCA and ISCA for the COVID-CT dataset

3.4 Additional simulation on microscopic images

COVID-19 can progress to severe acute respiratory syndrome with pneumonia and acute respiratory distress syndrome. Histologically, this disease causes diffuse alveolar damage corresponding to the phase of the disease. There are three lung injury patterns: epithelial, which are diffuse alveolar damage with varying degrees of organization, denudation, and hyperplasia of pneumocytes, vascular, diffuse intra-alveolar fibrin, microvascular injury, (micro) thrombi, acute fibrinous, and organizing pneumonia and fibrotic which is diffuse alveolar damage, interstitial fibrosis [22]. Figure 11 shows the all images of lung injury patterns.

Fig. 11
figure 11

Microscopy images of histopathology tissue samples of lung infected by COVID 19

We will now apply the two methods on the all images after undergoing random rigid geometric transformations as we did for the previous simulations. Figure 12 shows the absolute error between the true and the estimated rigid transformation parameters. We can see that the ISCA has a minimum error for most images. Even if there is an underestimation of one of the three parameters, this does not affect the similarity criteria. We can see in Fig. 13 that the ISCA remains better compared to the SCA. Table 4 resumes the mean and the standard deviation values of the SSIM, DSC, MSE, and the absolute error of the transformation parameters \(AE_{x}\),\(AE_{y}\), \(AE_{\theta }\). As we can see, the ISCA outperforms the SCA for all the metrics as in the case of CT images.

Fig. 12
figure 12

Absolute error for microscopy images (a) the horizontal direction, (b) the vertical direction, (c) rotation angle

Fig. 13
figure 13

Quantitative registration results for microscopy images: (a) SSIM curve, (b) DSC curve, (c) MSE curve

Table 4 Statistical analysis of SCA and ISCA for COVID19 microscopy images

In the same way, three images with epithelial, vascular and fibrotic lung injury patterns, as shown in Fig. 14, were chosen for the visual investigation. From Fig. 15, we can see almost no effects of misregistration for the ISCA. The SSIM map image is whiter, and the absolute error image is blacker. While for the SCA, some misregistrations are visible in the registered images.

Fig. 14
figure 14

Input microscopy images for registration

Fig. 15
figure 15

Registration results on COVID19 microscopy images

3.5 Comparisons with state-of-the-art algorithms

It is more judicious to compare the proposed method with other methods using the same image test to make a meaningful comparison. To our knowledge, there is no work related to COVID-19 image registration that was performed until the writing of this paper. So, we have compared our method with the other methods based on self-adapting pulse-coupled neural networks (SAPCNN) [25] and mutual information using particle swarm optimization (MI- PSO) [26, 27], which have been applied to register other medical images from the Whole Brain database. It is a popular database in medical image registration. It provides thousands of images from Harvard Medical University that deal with human brain tumors. This database is publicly available at (http://www.med.harvard.edu/AANLIB/). Through Table 5, we can see that the proposed method can achieve good accuracy and outperforms the two state-of-the-art methods used in this comparison.

Table 5 Comparative analysis between the proposed method against some existing work

4 Conclusion

Early diagnosis and better monitoring of the COVID-19 are ideal solutions for controlling and containing this disease. Suitable registration methods of computed tomography will significantly influence the diagnosis. In this paper, we have proposed an improved sine cosine algorithm to register computed tomography images of lungs infected with COVID-19. The method has been applied to several medical image data from different databases. From the obtained results, we found that the ISCA algorithm is more accurate than the SCA algorithm for CT image registration of the person infected with COVID-19. Some related works have been considered to make a meaningful comparison. After several experiments, we have found that the proposed algorithm outperforms the state-of-the-art methods in most cases. Therefore, the ISCA could play a prominent role in diagnosing and the evolution of the disease. This method can be extended further to 3D image registration and non-rigid transformations in future work.