# An Efficient Automatic Midsagittal Plane Extraction in Brain MRI
## 2 Materials and Methods
### Estimation of Yaw Angle (\(\theta_{r}\))
#### 2.2.1 Region of Interest Extraction  
Due to the fact that the human brain is nearly elliptical, PCA is used, as it aligns the data in the direction of maximum variance (data spread). A reference 2-D slice \(\mathbf{I}_{o}\) is selected from the 3-D volume of the brain MRIs. The selection of the slice is important. As in fact, the higher slice (before and after the half of the total slices present in the volume), the brain in the 2-D image becomes more elliptical in shape. It can give a good estimate of the angle of brain symmetric axis as compared to other slices [43].  
Therefore, a \(1/55\)th slice of the total slices present in the volume of brain MRIs is considered as a reference slice. Next, the image is binarized [44] and noise is removed by a mathematical morphological filtering operation called area opening [45] (pp. 112-114). In this filtering procedure, small connected pixels of which the area (in a number of pixels) is less than a specified threshold (\(\eta\)) are removed. The value of \"\(\eta\)\" can be varied depending upon the type of brain MRIs and the extent of noise. After several experiments, a value of 100 pixels has been considered a good estimate for \(\eta\) (area threshold) in all the brain MRIs including tumor datasets. Mathematical, area opening is represented as:  
\[\gamma_{\eta}=\underset{i}{\cup}\big{\{}\gamma_{\text{B}_{i}}|_{i}\text{ is connected and card}(_{i})=\eta\big{\}},\,i=1,2\dots,k. \tag{8}\]  
where \(\gamma_{\eta}\) is the area opening, \(\eta\) is the value of threshold area of the connected pixels, and _card_(B) is the number of elements (cardinal number) of B.  
Area opening is equivalently defined as the union of all the morphological opening (erosion followed by dilation) with the connected structuring element of which the size is equal to \(\eta\). 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, as shown in Figure 2.  
Some of the ROI pixels inside the rectangular boundary (image \(I_{3}\)) have value 0. To make all the ROI pixels in the image \(I_{3}\) to one, the complement of noise-free binary image \(I_{2}\) is multiplied (logical AND) with the rectangular boundary, such that all the pixels inside the boundary are equal to 1 (Figure 3a). Largest connected component (LCC) is chosen (Figure 3b) from the resulted image and added (logical OR) to \(I_{3}\) (Figure 3c). Lastly, morphological flood-fill operation [45] (p. 208) is used to fill the holes (0-valued pixels) and achieved the binary image \(I_{4}\) with a single ROI. This image is exploited as an input for PCA (Figure 3d).  
Figure 3: Intermediate steps between images \(I_{3}\) and \(I_{4}\), (**a**) logical AND of \(I_{2}\) with the rectangular boundary, (**b**) largest connected component, (**c**) logical OR of (**b**) with \(I_{3}\), (**d**) holes filling using morphological flood-fill operation.  
Figure 2: Steps for noise removal and region of interest (ROI) extraction.