# Skull Stripping for MRI Images Using Morphological Operators

Joanna Swiebocka-Wiek

► To cite this version:

Joanna Swiebocka-Wiek. Skull Stripping for MRI Images Using Morphological Operators. 15th IFIP International Conference on Computer Information Systems and Industrial Management (CISIM), Sep 2016, Vilnius, Lithuania. pp.172-182, 10.1007/978-3-319-45378-1_16 . hal-01637463

HAL Id: hal-01637463

https://inria.hal.science/hal-01637463

Submitted on 17 Nov 2017

**HAL** is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Skull stripping for MRI images using
morphological operators

Joanna Swiebocka-Wiek¹

AGH University of Science and Technology, Cracov 30-059, PL
Faculty of Physics and Applied Computer Science
jsw@agh.edu.pl

**Abstract.** One of the most common MRI (Magnetic Resonance Imaging) use is a brain visualisation. Brain anatomy is highly complicated therefore it might be difficult to extract only these structures which have diagnostic value. In a consequence it is so necessary to develop and apply most efficient brain's segmentation algorithms. One of the first steps in case of neurological MRI analysis is skull stripping. It involves removing extra-meningeal tissue from the head image, therefore it is essential to find the best method to determine the brain and skull boundaries. In T1-weighted images, cerebrospinal fluid (CSF) space and skull are dark, that is why the edges between the brain and the skull are well-marked but even strong edges might be unsettled because of finite resolution during MRI acquisition or the presence of other anatomical partial structures within the brain (connections between the brain and optic nerves or brainstem). There are many ways to perform this operation, none of them is not so great as to constitute a standard proceedings. In many cases, there are limitations associated with the development environment, license and images input that hinder skull stripping without specialised software. Proposed method is free of these constraints. It is based on application of morphological operations and image filtration to enhance the result of the edge detection and to provide better tissues separation. The efficiency was compared with other methods, common in commercial use, and the results of this comparison was presented in this paper.

**Keywords:** skull stripping, brain extraction, morphological operators, image segmentation, MRI

# 1 Introduction

Skull stripping is a process of the brain tissue segmentation (cortex and cerebellum) from surrounding region (skull and nonbrain area). It is also a very important preprocessing step which precedes further analysis in case of many MRI neurological images (such as image registration or tissue classification) [7]. In clinical practice, this method is widely used in developing automated methods for progress evaluation of neurodegenerative diseases such as: Alzheimer's disease, multiple sclerosis and other neurological disorders like brain aging or even some
mental illness.

In search of the most effective skull stripping techniques there were proposed many innovative automatic and semiautomatic brain segmentation techniques [6] [1] [2] [3], particularly in the filed of MR image processing. However, published studies comparing common used algorithms [5] demonstrate that each of methodologies has significant number of advantages and disadvantages as well, so it's very difficult to find one approach which could be consider as the ideal solution.

These factors result in increasing need for the further development and examination of new effective skull stripping methods. In this paper one of approaches will be introduced.

## 2 Proposed method

All images used and processed in this paper are the private property of the Author. They were registered in the John Paul II Hospital in Cracov. The images were registered with the following acquisition parameters: magnetic field: 3T, Spin Echo sequence, T1-weighted, slice thickness: 3mm and contrast application). During selection of images for algorithms evaluation, the key criteria was to ensure their representativeness (to choose the most common type of images, which are also most often processed and compared in scientific dissertations). Algorithm was tested on images in all 3 projections, all scans were acquired in the middle of the T1-weighted session so that the area of the brain was possibly the greatest in any case.

Skull stripping techniques can be divided into 3 main categories [7]:

- **intensity-based methods**. They are based on the threshold classification. The main disadvantage of this approach is its significant sensitivity for intensity fluctuations (in case of MRI caused for example by magnetic field inhomogeneity, registered noise or even device's properties)

- **morphology-based methods**. The basic idea is to combine the use of morphological operations, thresholding and edge detection techniques, in order to separate the area of the brain from the surrounding tissue in the most precisely way.

- **deformable model-based methods** which applied the active contour deformation and fitting to localise brain area and its identification by using image characteristic.

The algorithm presented in this paper belongs to morphology-based methods' group. It was implemented using JAVA and MATLAB environment [9], [10], [11]. The proposed method has 5 steps.

1. image thresholding (segmentation),

2. filling the gaps in extracted objects using morphological operators,

3. edge detection and improving the edges if it's needed

4. selection of the largest area in the image and creating a binary mask
5. combining the binary mask and the input image as an output image.

The simplicity of this method which is clear, is one of its more significant
advantages rather than flaws. In comparison with the methods used commonly
and commercially (AFNI, FSL, Robex algorithm), the proposed algorithm due
to its simplicity has a lower computational complexity, process .jpg and DICOM
files (usually in these formats medical data are available for patients), enables
work on other operating platforms than UNIX, does not require a specialized
knowledge about program's structure (the only requirement is to install the MCR
Installer on computers without Matlab environment). At the same time, despite
its simplicity, the algorithm gives good visual results. Furthermore its proper
proper working was confirmed by combining the input image and the image with
brain extraction mask borders. Mask borders and brain borders in anatomical
image are nearly the same! The obtained results of algorithms application and
comparison with other methods were shown in further parts of this paper.

## 2.1 Image thresholding

Image thresholding is essential for best algorithm's effectiveness. It allows to
separate the background noise and foreground brain tissues[8]. In this paper 3
techniques were tested [9]:

- **Global thresholding.** It relies on selection of the arbitrary threshold (usually it is gray scale image mean or median intensity) and its comparing with each pixel value. If the value is greater than or equal to the threshold the pixel is converted to white (for values smaller than threshold pixel became black).

- **Local thresholding.** In this method separate threshold is determined for a particular part of the image or each pixel individually. Frequently the threshold is calculated as mean or median intensity value in pixel's surrounding with defined radius.

- **Mixed thresholding** which is the same as the local thresholding with only one difference: if the mean or median local to a given pixel differs, by more than a predetermined value from the global threshold, global thresholding is applied.

The best results were obtained for mixed thresholding method. Local thresholding leaves too many details in the image, which made it unclear with specific structures poorly separated. In case of global thresholding part of the important (from the diagnostic point of view) edges were removed from the image, what disqualifies this method for further application. In Figures 1, 2, 3 the results for each technique and each imaging plane were presented.

## 2.2 Designing a mask for the brain extraction

The next step was to create a mask which multiplied by the input image would
allow to extract only the brain tissue region. Mask was designed using morpho-
logical operations, which are based on the application of so called (*structural*
<figure><img src="image_2.png" /><figcaption>**Fig. 1.** Different thresholding method comparison (sagittal plane). From left to right: input image, global threshold, local threshold, mixed threshold</figcaption></figure>

<figure><img src="image_3.png" /><figcaption>**Fig. 2.** Different thresholding method comparison (horizontal plane). From left to right: input image, global threshold, local threshold, mixed threshold</figcaption></figure>

<figure><img src="image_4.png" /><figcaption>**Fig. 3.** Different thresholding method comparison (coronal plane). From left to right: input image, global threshold, local threshold, mixed threshold</figcaption></figure>
element). It is a set of pixels which may have different shapes and sizes and contain any combination of 0 and 1 values. If pixel's value is not significant it could be marked in structural element as z. Following morphological operators were applied in proposed method:

- **Dilatation** (thickening) The structural element is compared with each pixel of the image. If at least one pixel the neighborhood has a value equal to "1", the focal point also receives it (in another case is assigned the value "0"). Types of structural element strongly affects the output image.

- **Erosion** (thinning). This operation applies rotated structural element for each pixel in the image. If even one pixel in the neighborhood has a value equal to "0", the focal point also receives this value. Otherwise, its value does not change. This is an operation which is the inverse of dilatation. Erosion is significantly influenced by the choice of the structural element

- **Opening** Imposition of dilatation operation on the result of the erosion of the original image. It causes image smoothing (removal of details, the greater the structural element is used, the stronger image smoothing can be observed).

- **Closing** The imposition of erosion operations on the result of dilatation of the original image. It removes all the holes in the image and the concave lower than the structural element (the greater structural element, the more elements are filled in).

During creating the mask, the main goal was to examine the influence of the various structural elements (shape, size) and the sequence morphological operations selection, for the output mask image. Matlab packages allows to analyze up to nine types of structural elements with different shapes and sizes: diamond (with defined radius), disk (with defined radius), line (with defined length and angle), octagon (with defined distance from the structuring element origin to the octagon's size, along to the vertical and horizontal axis), pair (the structure with 2 elements), periodicline, rectangle (with specified 2-piece vector defining its size), square (with specified width) and even arbitrary structural element (shape defined by user). In the first step of choosing the optimal structural element, the line and periodicline options were rejected. Assuming that in each imaging plane, the brain structure is nearly symmetrical, structural element should not favor any processing direction. In a consequence it cannot take the angle as a procedure input parameter. In the next step, the square and rectangular structural elements were rejected as well form the further analysis. It was examined that increasing their size of even one pixel can cause unwanted sharpening of the brain edges. The mask constructing procedure should guarantee keeping the edges unchanged in their course and shape, because of their diagnostic value. On the other hand, rectangular structural element was used as very effective in later algorithm's stages for removing single black pixel (or small group of pixels) within a created mask. Disk, square, diamond and octagon structural elements were tested. It was assumed that due to the edge course, the structural element size can not be too high. Disk with radius equal to 3 has 25 elements (5x5 matrix) and
square element with width equal to 5 and give same unsatisfactory results. Diamond with the same radius 3 and octagon in the smallest possible size has 49 elements (7x7 matrix). That is why the maximum acceptable radius of structural element was assigned as 2. For this size disk and diamond look identical. Finally, the disk element with radius equal to 2 was chosen as providing the best visual results. Unfortunately even then it was not possible to avoid leaving some small unwanted clusters of black pixels. In some cases these clusters caused additional signal areas extractions inside the mask area. Therefore in this step all the gaps in the image were removed by using morphological operators once again (square structural element as it was mentioned before). In Figures 4, 5, 6 the received masks for each imaging plane were shown.

<figure><img src="image_5.png" /><figcaption>**Fig. 4.** The following steps of creating mask for brain region extraction (coronal plane). From left to right: image after mixed thresholding, mask received after image erosion, mask revised by removing small areas from the image</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>**Fig. 5.** The following steps of creating mask for brain region extraction (sagittal plane). From left to right: image after mixed thresholding, mask received after image erosion, mask revised by removing small areas from the image</figcaption></figure>
<figure><img src="image_7.png" /><figcaption>**Fig. 6.** The following steps of creating mask for brain region extraction (horizontal plane). From left to right: image after mixed thresholding, mask received after image erosion, mask revised by removing small areas from the image</figcaption></figure>

## 2.3 Edge detection

Edge detection allows to verify if there is a correlation between the edges of the mask (applied for the brain extraction) and the anatomical edges of the input image. Overlap of the brain's boundaries in the input image with the boundaries set by the proposed skull stripping method would prove that algorithm is correct. For each imaging plane the Canny edge detection filter was applied. Next, image presenting the edges was combined with corresponding input image. In each case correlation was confirmed which means that mask corresponds to the brain area and that it can be applied for the brain extraction.

<figure><img src="image_8.png" /><figcaption>**Fig. 7.** The effect of imposing the edge of the brain extraction mask on the input image (in all planes)</figcaption></figure>
## 2.4 Selection of the largest area in the image

The main purpose of next step is to find the largest area in the image of connected white pixels representing the brain tissue.

The goal was achieved by assigning labels to each object in the image and counting the number of pixels with a given tag. This operation was performed using built-in Matlab functions. Based on the results a mask representing the brain area was created. With the received mask it was possible to separate the brain tissue (represented by white pixels) from the area diagnostically irrelevant(background represented by black pixels). The last algorithm step was combining the the binary mask image and an input MRI image. The output image consists only this part of the input image that corresponds to the brain tissue. In Figure 8 the results of skull stripping for each imaging plane was shown. The method gave the satisfactory and promising results, although after more careful analysis it can be seen that some part of the information is missing. It is particularly visible on the edges of the isolated brain (white matter area). In addition, the edges are slightly sharpened, and in a consequence the shape of the brain is not recreated in an ideal way.

<figure><img src="image_9.png" /><figcaption>Fig. 8. Skull stripping result after algorithm implementation in all planes</figcaption></figure>

## 2.5 Comparison with other methods

To be able to fully evaluate the algorithm's capabilities it is necessary to compare it with other commonly used brain extraction methods.

The most popular are AFNI (3DSkullStrip module)[13] and FSL (BET algorithm)[14]. AFNI approach is automated process based on three steps: preprocessing (removing artifacts and brain positioning), expanding a spherical surface
(until it envelopes the brain)and finally creating all sets of masks and surfaces for brain modeling. FSL is a set of libraries of analysis tools for fMRI (Functional Magnetic Resonance Imaging), MRI and DTI (Diffusion Tensor Weighting) brain imaging data. Unfortunately, it was found that both programs have certain limitations, critical for the comparing them with proposed algorithm. The main difficulty is related to the type of supported files: both programs process only files with the .nii extension (Neuroimaging Informatics Technology Initiative, NIFTI), optionally .dcm files (Digital Imaging and Communications in Medicine, DICOM)after their conversion to .nii. During preparing this article Author did not have access to this kind of files and conversion was obligatory. The second limitation is that program dependant on operating system: both programs run under Unix and MacOS (none of them runs directly under Windows environment). What is more AFNI approach requires at least 16 MRI scans (only 3D brain extraction is possible), what ultimately made it impossible to compare developed algorithm with AFNI results. Taking it into consideration,it is crucial to highlight the advantages of the Authors method and its suitability for processing .jpg files, specially under the Windows operating system. Short comparison of the developed algorithm and methods AFNI and FSL was shown in the Table 1.

<table><caption>**Table 1.** Comparison of the Author's method with FSL and AFNI approach.</caption><thead><tr><th>Criteria</th><th>Author's method</th><th>FSL</th><th>AFNI</th></tr></thead><tbody><tr><td>Supported files</td><td>DICOM, JPG, BMP, PNG, TIFF</td><td>NIFTI, DICOM</td><td>NIFTI, DICOM</td></tr><tr><td>Operating system</td><td>WINDOWS</td><td>Unix, Mac OS</td><td>Unix, Mac OS</td></tr><tr><td>Difficulties</td><td>—</td><td>—</td><td>at least 16 scans required</td></tr></tbody></table>

Obtained images were compared with FSL-BET results and some alternative method, also based on using morphological operators. In case of alternative approach first step was image global thresholding with the threshold equals to After that small noise speckles were removed by using `bwareaopen` function(the concept of speckles means all connected components that have fewer than 10 pixels). In next step the holes in binary image were removed by applying `imfill` function. In a final step single erosion with disk structural element (radius 15) was made. The results of all method comparison were shown in Figures 9, 10, 11. As it can be seen only in case of horizontal plane all methods gave similar results. In case of sagittal and coronal plane, proposed in this paper method not only makes it possible to eliminate the skull structure but also extract only the brain tissue. This was possible thanks to an implementation in the algorithm the part which is responsible for the selection of the largest area in the image. Based on this area, filtration mask was built. It can also be noted that in the alternative method filtration leads to the removal some of the brain tissue sections which is unacceptable in case of diagnostic applications. In addition FSL methods in coronal plane leaves some redundant tissue.
<figure><img src="image_10.png" /><figcaption>**Fig. 9.** Comparison of the proposed method (b), FSL-BET result (c) and the alternative Matlab approach (d). Horizontal plane. Methods description was presented in the text</figcaption></figure>

<figure><img src="image_11.png" /><figcaption>**Fig. 10.** Comparison of the proposed method (b), FSL-BET result (c) and the alternative Matlab approach (d). Sagittal plane. Methods description was presented in the text</figcaption></figure>

<figure><img src="image_12.png" /><figcaption>**Fig. 11.** Comparison of the proposed method (b), FSL-BET result (c) and the alternative Matlab approach (d). Coronal plane. Methods description was presented in the text</figcaption></figure>
Another approach to verify the algorithm's effectiveness is to evaluate its performance in the boundary conditions. In this case, it is the analysis of images in which the share of the signal from the skull and the brain tissue is comparable. It turns out that the algorithm may encounter some difficulties at the stage of segmentation (thresholding). The main cause is the lack of the cerebrospinal fluid signal which low intensity (dark, similar to black color) would precisely separate two light areas: the skull and brain tissue. As a result, even in the case of mixed thresholding, automatically predetermined threshold is too low and the tissues are not separated properly. The implementation of further steps of the algorithm was considered unreliable. That is why algorithm's application in the boundary conditions will be a subject of further development and research. The obtained results was presented in Figure 12.

<figure><img src="image_13.png" /><figcaption>**Fig. 12.** Different thresholding method comparison (horizontal plane). From left to right: input image, global threshold, local threshold, mixed threshold</figcaption></figure>

## 3 Summary and conclusions

In this paper a skull stripping method for T1-weighted MRI images based on using morphological operators was proposed. The algorithm gives satisfactory and promising results. However despite the fact the area of the skull was removed from the image completely, closer image analysis shows cerebrospinal fluid (CSF) space the was partially preserved, while it should be removed as well. This will be the subject of further work and algorithm improvement. Another challenge is to correct edge detection of the brain area i.e. by using morphological gradients. In the present algorithm's version, the edges are sharpened, what is related to the partial loss of information on the borders of the area. Proposed method was compared with the commonly used solutions which have certain limitations associated with programming environment (AFNI, FSL). The algorithm assured comparable and is some cases even better results. High efficiency of the algorithm is associated with the use of the thresholding as one of the basic processing steps which allows for precise separation of the structures. It is planned to perform the algorithm's evaluation on a large database of images to confirm its effectiveness
for images with a higher degree of complexity. The algorithm has a preliminary study status, therefore it is also planned in a future to compare its efficiency with other common used skull stripping methods and taking into consideration gray-scale morphology.

## References

1. Somasundaram K, Shankar R S, Skull Stripping of MRI using Clustering and Resonance Method, Int. J. Knowledge Management and e-Learning, Vol. 3, pp. 19-23 (2011)

2. Somasundaram K, Shankar R S, Automated Skull Stripping Method using Clustering and Histogram Analysis for MRI Human Head Scans, International Journal of Advanced Research in Computer Science Technology, Vol. 2 pp.117-122 (2014)

3. Carass A, Wheeler M B, A joint registration and segmentation approach to skull stripping, Biomedical Imaging: From Nano to Macro IVth IEEE Symposium, pp. 656-659 (2007)

4. Sadananthan, S.A., Zheng, W., Chee, M. Skull stripping using graph cuts NeuroImage, Vol 49, pp. 225-239, (2010)

5. Fennema-Notestine, C., Ozyurt, I.B., Quantitative Evaluation of Automated Skull-stripping Method Applied to Contemporary and Legacy Images, Effects of Diagnosis, Bias Correction, and Slice Location. Human Brain Mapping 27 (2), pp. 99-113 (2006)

6. Grau, V., Mewes, A.U.J., Alcaniz, M., Kikinis, R., and Warfield, S.K., Improved watershed transform for medical image segmentation using prior information. IEEE Trans. Med. Imag., 23(4): pp. 447-458 (2004)

7. Zhuang, A.H., Valentino D., Toga A., Skull-stripping Magnetic Resonance Brain Images Using a Model-based Level Set NeuroImage, Vol 32, pp. 79-92, (2006)

8. Tadeusiewicz R, mietanski J, "Pozyskiwanie obrazw medycznych oraz ich przetwarzanie, analiza, automatyczne rozpoznawanie i diagnostyczna interpretacja", Student Scientific Society Publishing, 2011 (in polish)

9. Landini L., Positano V., Santarelli M.F., "Advanced Image Processing in Magnetic Resonance Imaging", Taylor Francis Group, 2005

10. Gonzalez R, Woods R., Eddins S. "Digital Image Processing using Matlab", Prentice Hall Inc., 2009

11. http://www.mathworks.com

12. http://www.mathworks.com/matlabcentral/answers/172701-how-to-perform-skull-stripping-using-matlab

13. AFNI homeage: https://afni.nimh.nih.gov/

14. FSL homepage: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/BET