# An Efficient Automatic Midsagittal Plane Extraction in Brain MRI
## 2 Materials and Methods
### Fitting of Plane in Three Dimensions  
According to Equation (4), the angle \(\theta_{r}\) will be same for all the 2-D axial symmetric lines on each axial slice, irrespective of the position of slice \(Z_{r}\). Therefore, each image in the 3-D volume of the brain MRIs is rotated by an angle of \(-\theta_{r}\), so that bilateral symmetry axis of the brain becomes vertically oriented in each image. Normally, the translation offset \(p_{r}\) of each symmetric axis can be computed using a cross-correlation of the aligned image with its vertical reflection about the center of the image [18; 25]. This technique has two complications. The first one is the existence of outlier in the translation offset due to pathology effects, image artifacts, and symmetry axis ambiguity in the superior slices of brain. The second one is that this technique is also computationally intensive as it takes approximately 10 s for each slice of size (rows, column) 512 \(\times\) 512 [18]. We have introduced a fast approach to estimating the translation offset independent of these constraints. The technique is based on the straightforward and effective observation that the head in the slices of brain MRIs is shaped like an ellipse (ellipsoid in three dimensions). Moreover, a trapezoid area on the surface of the head, center upon \(+x\) and \(-x\) (from ear to ear) directions of a height (30-45\({}^{\circ}\)) and a width (45-70\({}^{\circ}\)), has the most significant geometrical features as described by [16]. Fitting of plane consists of the following three steps:  
1. Elliptical Area Extraction  
The main objective to extract the elliptical area is to make the offset estimation independent of pathological effects, image artifacts, symmetry axis ambiguity in the higher slices, and computationally efficient. The aligned image is binarized [44] and noise is removed by the same procedure as described in the previous Section 2.2.1. Then, a rectangular area is achieved by searching for the first and last nonzero pixels along the rows (top and bottom) and columns (left and right) of the noise-free binary image (Figure 6d). First and last nonzero columns and rows are denoted by \(c_{1}\), \(c_{2}\), \(r_{1}\), and \(r_{2}\), respectively. Accordingly, the vertices of the rectangle are labeled as: \(A(c_{1}\), \(r_{1})\), \(B(c_{2}\), \(r_{1})\), \(C(c_{2}\), \(r_{2})\), and \(D(c_{1}\), \(r_{2})\), respectively. Now, the parameters of an ellipse can be determined as:  
\[Center\ of\ ellipse:\ O=\left(\frac{c_{1}+c_{2}}{2},\frac{r_{1}+r_{2}}{2}\right) \tag{20}\]  
\[Semi-major\ axis:a=\left(\frac{r_{2}-r_{1}}{2}\right) \tag{21}\]  
\[Semi-minor\ axis:b=\left(\frac{c_{2}-c_{1}}{2}\right) \tag{22}\]  
Now, ellipse in parametric form can be written as:  
\[x=\frac{c_{1}+c_{2}}{2}+b\,\cos\,\theta \tag{23}\]  
\[y=\frac{r_{1}+r_{2}}{2}+a\,\sin\,\theta \tag{24}\]  
Now, within \(I(i,j)\), which consists of all the pixels inside the elliptical boundary, the pixels are set to \"1\" based on Equation (25), as shown in Figure 6e,f, respectively. \[I(i,j)= \begin{cases}1&\text{if $(i,j)$ lies inside elliptical area}\\ 0&\text{otherwise}\end{cases}  \tag{25}\]2. Set of Mid-Parallel Lines Extraction  
In the axial orientation, inferior and superior slices of the brain volume have ambiguous symmetry axes as compared to the slices near the center of the brain. Secondly, slices higher in the brain are almost ovals [16]. Therefore, ambiguous symmetry slices are automatically eliminated based on the ratio of the semi-axes of the ellipse, and only those slices of which this ratio is greater than 1.2 are extracted. This significantly improves the accuracy and efficiency of the algorithm. Selected sample slices with their respective elliptical area are illustrated in Figure 7.  
Figure 6: Elliptical area extraction. (**a**) Input image, (**b**) binary image, (**c**) noise removal, (**d**) rectangular boundary extraction, (**e**) elliptical area extraction, and (**f**) symmetric axis (midline) extraction using PCA. Figure 7: Selected slices from a 3-D volume of brain MRIs.