# 2D/3D Multimode Medical Image Alignment Based on Spatial Histograms
## 2 Materials and Methods  
The algorithms involved in this paper are all based on the open-source software toolkit ITK (Insight Toolkit) [32]. ITK is an open-source toolkit for medical imaging research, mainly used for medical image registration and segmentation. Moreover, ITK includes many image-processing algorithms, such as medical image filtering and image data statistical analysis. When ITK is used to develop medical image registration, it is necessary to build a complex environment, which is not reported here. The DICOM sequence obtained from the human brain model's CT scan was used as a 3D floating image in the registration experiment. In addition, the digitally reconstructed radiograph (DRR) generated by projection rendering under specific CT parameters was used as a 2D reference image to simulate a real X-ray image. The size of the CT image was 512 \(\times\) 512 \(\times\) 283, the voxel spacing was 0.7813 \(\times\) 0.7813 \(\times\) 1.0, and the unit was mm. The projected image size was 512 \(\times\) 512, the pixel spacing was 0.5 \(\times\) 0.5, and the unit was mm. The 3D screenshot of the CT image is shown in Figure 1, and the 3D model rendered by the CT image is shown in Figure 2.  
Resampling was carried out on the CT images to facilitate the calculation and reduce the amount of experimental calculation. The sampled image data are shown in Table 1.  
The experiment's pixel range for all 2D images was linearly mapped to 0-255 through Formula (1):  
\[outputPixel=(inputPixel-inpMin)\times\frac{255}{inpMax-inpMin} \tag{1}\]  
A weighted histogram of gradient directions (WHGD) is a simple image histogram that considers only the gradient information in the image [33]. It takes the gradient direction as the histogram bin's division basis, making it sensitive to rotation transformation. Like other image histograms, the weighted histogram of gradient directions completely ignores \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Data** & **Size** & **Spacing/mm** & **Pixel Range** \\ \hline CT image & 200 \(\times\) 200 \(\times\) 142 & 2 \(\times\) 2 \(\times\) 2 & 11,024–2976 \\ Analog X-ray image (DRR) & 300 \(\times\) 300 & 1 \(\times\) 1 & 0–255 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Related parameters of image registration. Figure 1: Three dimensional CT image of the brain model. Figure 2: CT rendering of the brain model. the image's spatial information, making it very insensitive to translation transformation. To complete the registration, it must be assisted by other registration algorithms. Because of the complexity of parameter decoupling, the accuracy of translation parameters is difficult to guarantee. Spatial information can be added to the gradient direction histogram to compensate for the translation transform's sensitivity, helping to overcome these defects. Therefore, this paper proposes the use of a spatial histogram instead of a simple image histogram to count the gradient feature information of the image. For a discrete function \(f:x\to v\), the simple histogram of \(f\) is \(h_{f}:v\to N\); \(N\) is a set of nonnegative integers, and \(h_{f}(v)\) is the number or frequency of elements \(x\). This describes a simple zero-order moment histogram that discards all information about a domain or space. [PERSON] et al. [34] proposed the use of high-order moments containing spatial information to make up for the defects of the simple histogram, and named the new histogram a spatial histogram or spatial graph. A spatial histogram can capture the frequency information of function elements and the spatial domain information of function. Each pixel's weight in space is determined by the average value and covariance of the pixel position when the spatial histogram is calculated based on the second moment of the image. For a 2D image \(I\), its value at the pixel coordinates \((x,y)\) is \(v\), representing the original pixel value or the value after image preprocessing. The pixel value is assumed.