🩻 Brain Tumor Detection using Image Processing

An approach through Anisotropic Diffusion, Top-hat Filtering, Histogram Equalization and Watershed Segmentation

Mlachahe Said Salimo
Wanabilini
14 min readMar 22, 2024

--

Brain tumors represent a significant and growing concern in the global health landscape, as highlighted in recent studies, underscores the urgent need for improved diagnostic and treatment methods.

Globally, an estimated 308,102 new cases of primary brain or spinal cord tumors were diagnosed in 2020, and approximately 251,329 deaths occurred due to these tumors in the same year [12]. In the United States alone, 24,810 adults were expected to be diagnosed with primary cancerous brain and spinal cord tumors in 2023. In 2018, brain tumors were ranked as the 10th most common type of tumor among Indians, with over 28,000 cases reported annually and more than 24,000 deaths each year in India alone [5]. Brain tumors are among the leading causes of cancer-related deaths, ranking 10th for both men and women. Survival rates vary by age, with a 5-year relative survival rate of about 36% for all ages, 75% for those under 15, and 21% for those 40 and older [12].

Fig. 1 : Image of a grid of MRI brain scans where the tumors are emphasized with glowing edges or highlights, in a pop art style. Generated by DALL-E.

This alarming statistic is mirrored globally, with significant disparities in rates across different regions : high-income regions such as Europe and America showing the highest age-standardized rates of incidence and mortality, while the lowest rates were observed in the African Region.

This underscores the global burden of this disease and highlights the necessity for continuous improvement in diagnostic and therapeutic strategies [5].

Fig. 2 : Tumor detection in a brain MRI.

This article aims to contribute to this ongoing effort by exploring the application of advanced image processing techniques to enhance the accuracy of brain tumor diagnosis from Magnetic Resonance Imaging (MRI) scans.

LITERATURE REVIEW

Across the studies — Maurya et al. [1], Karthika et al. [2], Rashid et al. [3], Yousuf et al. [4], Jain et al. [6], Supraja et al. [7], Lakshmi et al. [8], and Hiremath et al. [9] — the importance of preprocessing for noise reduction and the potential of classification and traditional segmentation techniques in identifying tumor regions from MRI images are well-documented. The methodologies employed exhibit strengths in specific contexts, with limitations primarily arising from the 2D nature of the analyses and manual feature selection processes.

OBJECTIVE

The purpose of this article is to evaluate the simple methodology proposed by Maurya and Wadhwani [1] as a reliable method for the segmentation of brain tumors in MR images, by exploring the various advanced image processing techniques. Our analysis aims to not only validate the effectiveness of their approach but also to identify potential areas for improvement.

Although the methodologies developed [1, 2, 3, 4, 6, 7, 8, 9] referring to the field of brain tumor segmentation using MRI images, a common thread among these studies is their reliance on MATLAB for implementation. MATLAB, while powerful, is not universally accessible due to its licensing constraints. This limitation poses a barrier to the widespread replication and extension of these methodologies within the broader research community.

By doing so, we endeavor to work leveraging the capabilities of Python as a tool for scientific investigation and innovation, specifically by using scikit-image.

Fig. 3 : The logo of scikit-image, a library for image processing in Python.

METHODOLOGY

As we said, our study seeks to replicate and enhance the methodology of Maurya et al. [1] through the integration of advanced image processing techniques.

Indeed, Maurya and Wadhwani (2022) developed an innovative method for preprocessing and segmenting brain images to detect tumors efficiently, from Magnetic Resonance Imaging (MRI). The technique comprises several preprocessing steps, including the application of an Anisotropic Diffusion Filter (ADF) for noise reduction while preserving edge detail, skull stripping to remove non-brain tissues, and contrast enhancement to improve visual clarity. The use of the watershed algorithm for segmentation separates image objects effectively, facilitating tumor identification. Morphological opening operations further refine the segmentation by highlighting the tumor region. The performance of this system is validated through a comprehensive set of measures. By comparing their results with existing literature, Maurya and Wadhwani demonstrate the superiority of their method in terms of accuracy and speed, making it a significant contribution to the field of medical imaging and diagnostics.

Fig. 4 : The methodology diagram.

To sum up, the methodology [1] unfolds in the following structured steps :

  1. Acquisition of the MRI image dataset for analysis.
  2. Reducing noise and enhancing image quality through Anisotropic Diffusion Filtering (ADF).
  3. Isolating brain tissue from the rest of the image via Skull Stripping, to focus analysis on the brain and tumor tissues.
  4. Enhance the visibility of tumors against a dark background by applying Top-hat Filtering.
  5. Enhancing image contrast to highlight features critical using techniques such as Histogram Equalization (HE)
  6. Converting grayscale images to binary to select the most relevant information for tumor identification through Binarization
  7. Segmentation of the preprocessed brain images using the Watershed algorithm
  8. Refinement of the segmented regions with Morphological Operations to precisely delineate the tumor boundaries.
  9. Assessing the segmented images with performance metrics among image features.

My implementation of the method is available on my Github :

DATASET

The dataset comprises 80 brain MRI images sourced from Kaggle [13]. It includes both normal (non-tumorous) and abnormal (tumorous) brain images. For this study, we focused exclusively on 8 tumorous images to refine our segmentation and detection techniques.

Fig. 5 : Sample of brain MRI images A-H. This figure presents a sample of the MR images utilized in this research.

Through the following sections, we will show step-by-step the processing of image A.

PREPROCESSING

The preprocessing phase is pivotal for enhancing image quality and preparing the MRI scans for accurate tumor identification. This section details the various techniques employed to improve image clarity, including noise reduction, skull stripping, and contrast enhancement.

ADF Filtering

Filters used in image processing can be categorized into linear and nonlinear. A comparative analysis shows that while linear filtering effectively removes noise, it blurs the image edges. In contrast, nonlinear
filtering maintains edge integrity while removing noise
(see Figure 6).

Fig. 6 : Comparison of linear and nonlinear filtering on MRI images [6]. Left: Linear Filtering. Right: Non-Linear Filtering.

Anisotropic Diffusion Filtering (ADF), a nonlinear filter, was applied to the images to reduce noise while preserving important edge details. During the diffusion process, the pixel intensity changes with each iteration to prevent the over-smoothing of image features as given in the ADF formula.

Three iterations have been identified as optimal for achieving the highest SSIM value in brain imaging, which underscores the filter’s ability to enhance image quality without sacrificing detail. This optimal balance between noise reduction and edge preservation permit with ADF is significantly better than other filters as supported by the findings of [6].

Fig. 7 : The effect of ADF on image A. This figure captures showcases the filter’s prowess in improving image clarity and detail.

Skull Stripping

Skull stripping was performed to remove non-brain tissues from the MRI images, a crucial step for isolating the brain region of interest and facilitating a more focused analysis on the tumor area [1]. This process ensures that subsequent analyses, such as tumor detection and segmentation, are more accurate and relevant.

Fig. 8 : The effect of skull stripping on filtred image A. This figure demonstrates the process and effect of skull stripping on filtered image A, showcasing the meticulous removal of non-brain tissues.

Top-hat Filtering

Top-hat filtering was applied to enhance the contrast of MRI images by emphasizing small bright structures, such as tumors, on a dark background. This morphological technique effectively mitigates uneven illumination, improving the clarity of the tumor regions for subsequent segmentation.

Fig. 9 : The effect of top-hat filtering on skull-stripped image A. This figure showcases how this method significantly enhances the visibility of tumors.

Contrast Enhancement

Contrast enhancement techniques, such as Histogram Equalization (HE), were employed to improve the visibility of tumor regions. HE enhances the visual contrast of images by adjusting the image intensities to distribute more evenly across the histogram, resulting in a more uniform and approximately flat histogram. This adjustment enhances the differentiation between normal and abnormal tissues, significantly aiding in the accurate segmentation of tumors by making the tumor regions more distinguishable from the surrounding tissues .

Fig. 10 : The effect of HE on TP-filtred image A. As demonstrated in this figure, the contrast-enhanced output clearly shows enhanced differentiation between the tumor and normal brain tissues.
Fig. 11 : The effect of HE on TP-filtred image A’s histogram. This figure illustrates the histogram of the TP-filtred image (left) and the contrast-enhanced image (right), where the drastic changes in the distribution of image intensity are evident.

Binarization

Binarization simplifies image processing by converting grayscale images into binary images, where pixels are either black or white. This process is straightforward with Histogram Equalization (HE) because the most relevant information appears very white, requiring only a threshold to retain pixels with intensities above 200–220.

Fig. 12 : The effect of binarization on constrated image A. This figure illustrates the selection of the relevant information in the constrasted image

These enhancements ensure that features such as tumors are not only more visible but also more accurately segmented in the subsequent analysis stages.

SEGMENTATION

Following preprocessing, the segmentation phase aims to precisely delineate tumor boundaries within the brain images. Here, we explore the application of advanced segmentation algorithms and post-segmentation refinements to accurately segment and analyze tumor regions.

Watershed Segmentation

The Watershed Algorithm is a widely-used technique in image processing, particularly in the field of medical imaging.

We utilized the Watershed Segmentation algorithm to delineate the tumor boundaries within the preprocessed images. It is a region-based image segmentation method that is very useful for separating adjacent objects in an image where the boundary between the objects is not clearly defined, making it particularly useful for identifying tumor regions that may not be clearly separated from the surrounding brain tissue.

The application of the Watershed Segmentation algorithm plays a critical role in the accurate identification and analysis of tumor regions, ensuring that subsequent treatments can be precisely targeted.

Fig. 13 : The effect of watershed segmentation on preprocessed image A. This figure highlights the enhanced capability of this technique to segment and delineate tumor boundaries accurately.

Morphological Operations

Morphological operations were applied post-segmentation to refine the results. These operations help in smoothing the edges of the segmented tumor, removing small artifacts, and filling in gaps within the tumor region.

Fig. 14 : Mathematical morphology : Dilation, Erosion, Closing and Opening. Blue pixels are pixels that are added and Red pixels are pixels that are removed from the segment [10].

Firstly, a Closing operation is applied to fill the gaps in the segments. Next, an Opening operation is employed to retain only the tumor.

Fig. 15 : The effect of morphological operations on segmented image A. This figure illustrates the significant improvement in the segmentation’s quality by enhancing the visual consistency and accuracy of the tumor boundaries.

Opening consists of Erosion followed by Dilation. During Erosion, only pixels where the structural element fits entirely within the object (tumor in this case) remain, shrinking all objects. Dilation then aims to restore the original size of larger objects, but not the small ones removed by erosion. The result is an image where small structures or noise are removed, preserving larger, significant shapes like a large tumor (see Figure 15).

Choosing the right structural element is crucial. It should be smaller than the objects to be retained (the tumor) but larger than the noise or objects to be eliminated. If the structural element is too large, it might erode significant parts of the tumor. If too small, it may not remove all noise. The shape of the structural element should match the objects in the image; for instance, a circular one for round tumors.

Such refinements are essential for achieving a more accurate representation of the tumor, facilitating better analysis and evaluation of the segmented regions.

RESULTS & DISCUSSION

This section outlines the outcomes of our image preprocessing and segmentation operations, presenting the data both visually and through quantitative evaluation metrics.

Visualization Results

In the visualization phase, the processed MRI images exhibit notable enhancements at each stage of the applied methodology. Figures 16 through 23 present a series of images that demonstrate the stepwise improvements and the effectiveness of the techniques employed.

Fig. 16 : Visualization of the processing steps for image A.
Fig. 17 : Visualization of the processing steps for image B.
Fig. 18 : Visualization of the processing steps for image C.
Fig. 19 : Visualization of the processing steps for image D.
Fig. 20 : Visualization of the processing steps for image E.
Fig. 21 : Visualization of the processing steps for image F.
Fig. 22 : Visualization of the processing steps for image G.
Fig. 23 : Visualization of the processing steps for image H.

Each figure captures a distinct processing step, providing a clear visual representation of the progression from raw data to a finely segmented tumor image.

Quantitative Evaluations

The quantitative assessment of our methodology is grounded on a comprehensive set of performance measures, a combination of
statistical and textural information extracted from
the segmented images.

Before diving into the granular details of our textural analysis, let’s examine a few key metrics that are essential for understanding the broader impacts of our methodology on image quality, such as :

Eq. 1 : SSIM assesses the visual impact of three characteristics of an image: luminance, contrast, and structure. For ADF filtered images, SSIM close to 1 indicates high similarity to the reference image.
Eq. 2 : PSNR (Peak Signal to Noise Ratio) gives information about the quality of a segmented image relative to the original.
Eq. 3 : blabla.
Eq. 4 : Mean intensity reflects the average brightness and is a fundamental descriptor in image analysis. A high mean value indicates a brighter image, while a low mean value suggests a darker image.
Eq. 5 : Entropy measures the level of unpredictability or randomness within the image. A high entropy value indicates a more complex image with more randomness, while a low entropy value suggests a more uniform and less complex image.
Eq. 6 : Smoothness indicates the uniformity of image intensity. A high smoothness value means the image has less variation in intensity and appears smoother, while a low smoothness value indicates more variation and texture in the image.
Eq. 7 : RMS (Root Mean Square) quantifies the average intensity variation, providing a measure of the overall contrast in the image. A high RMS value implies high contrast, while a low RMS value indicates low contrast.

Now, let’s introduce the textural analysis, thanks to GLCM.

The Gray Level Cooccurrence Matrix (GLCM) is a statistical tool [13, 14, 15, 16] that quantifies the frequency of co-occurring pixel intensity values at a specified spatial relationship in an image, enabling the analysis of its textural characteristics.

Fig. 24 : Illustration of the Gray Level Co-occurrence Matrix (GLCM) operation methodology from the input image (a) to GLCM image (b) [14]. This figure illustrates the spatial relationships of pixels in the array of row-offsets and column-offsets where D represents the distance from the pixel of interest. Red circles indicate that how often a different combination of gray-levels cooccur in the input image and arrows indicate the number of co-occurs in the GLCM image

After computing the GLCM, from this matrix we can calculate specific textural features such :

Eq. 8 : Contrast : measures the intensity variations between adjacent pixels, essential for texture differentiation. A high contrast value indicates significant differences between pixel intensities and usually corresponds to a high level of texture in the image, while a low contrast value suggests a smoother, less textured image.
Eq. 9 : Correlation : evaluates the predictability of pixel intensity values based on their spatial relationship within the image. A high correlation value indicates that pixel intensities are similar across the image, which is typical for homogeneous textures. A low correlation value, on the other hand, indicates a high degree of variability in pixel intensities, often found in complex textures.
Eq. 10 : Energy : also known as uniformity, sums the squared intensity values in the GLCM. A high energy value indicates that certain pixel intensity pairs occur very frequently, suggesting a uniform or repetitive texture. A low energy value implies more diversity in pixel intensity pairs, corresponding to a more varied texture.
Eq. 11 : Homogeneity : gauges the similarity of adjacent pixel intensities. High homogeneity values indicate that the intensity differences between neighboring pixels are minimal, which often corresponds to smooth and consistent textures. Low homogeneity indicates greater variability in intensity between neighboring pixels and often corresponds to complex textures.

Table 1 and Table 2 encapsulates the results derived from these evaluations, offering a detailed insight into our image preprocessing and segmentation methods.

Table 1 : SSIM for ADF filtered images. The similarity of filtered images, as shown this table, is in the range of 0.94–0.97, indicates that the edge intensity is kept and the noisy pixels are smoothed, thus the crucial information is conserved in the image.
Table 2 : Our performance parameters of segmented tumor image A-H. The performance measures encompass various statistical and textural metrics such as Mean intensity, Entropy, Smoothness, RMS, PSNR, and GLCM features (Contrast, Correlation, Energy, Homogeneity). Indeed, images denoted with an asterisk(*) differ from the dataset used in [1].

The discrepancies in our results, relative to the work of Maurya et al. [1], can be ascribed to the difference in input image dimensions and the configuration of our GLCM parameters (informations not given in [1]). Our method considers all surrounding pixels, potentially leading to divergent textural information. For instance, our elevated mean intensity values z_m imply more luminous pixels, potentially due to smaller image sizes or expanded segmented regions compared to the study by Maurya et al. [1].

CONCLUSION

In conclusion, our work, conducted with Python and scikit-image, successfully demonstrates the effectiveness of advanced image processing techniques in the segmentation of brain tumors from MRI scans, opening avenues for their use in various other medical and non-medical applications.

Our findings also illuminate the path for future work, particularly in the realm of texture analysis using the Gray Level Co-occurrence Matrix (GLCM). As you can see, the GLCM is really cool. Unfortunately, it would be too lengthy to develop more in detail here.

Fig. 25 : Visualization of GLCM properties across selected brain image patches, highlighting differences between greymatter and tumor regions in Terms of Correlation and Dissimilarity.
Fig. 26 : Visualization of GLCM matrix for selected brain image patches, highlighting differences between greymatter and tumor regions.

The promising results obtained from GLCM in distinguishing between tumorous and healthy tissues (see Figure 25 and Figure 26 above) suggest a potential for integrating these textural features with machine learning classifiers, as explored in this incredible article “GLCMs — a Great Tool for Your ML Arsenal” written by Martim Chaves :

Lastly, this article opens avenues for validating the proposed methodology across diverse datasets, such as the BraTS2020, to further ascertain its robustness and adaptability, by comparing the computed segmented tumor with our method and the actual segmented tumor.

Mlachahe SAID SALIMO.

Acknowledgements — I would like to express sincere gratitude to the professors at Paris-Est Créteil School of Engineering (EPISEN) for their invaluable guidance and exceptional training.

Post-Scriptum — Below is an additional image generated by DALL-E, shared simply because I find it both fun and beautiful :

Fig. 27 : Image of a grid of MRI brain scans with tumors, inspired by pop art style. Generated by DALL-E. Indeed, it’s a little homage to Andy Warhol’s Marilyn prints.

REFERENCES

  1. R. Maurya and S. Wadhwani, “An efficient method for brain image preprocessing with anisotropic diffusion filter & tumor segmentation,” International Journal of Light and Electron Optics, vol. 169474, 2022. https://doi.org/10.1016/j.ijleo.2022.169474
  2. A. Karthika and D. Kiruba Jothi, “Detection and recognition of human brain tumor based on automated medical image segmentation techniques,” International Journal of Mechanical Engineering, vol. 6, no. 3, pp. 4681, Dec. 2021. https://doi.org/10.56452/6-3-68501
  3. M. H. O. Rashid, M. A. Mamun, M. A. Hossain, and M. P. Uddin, “Brain tumor detection using anisotropic filtering, SVM classifier and morphological operation from MR images,” in Proceedings of the International Conference on Computer, Communication, Chemical, Material and Electronic Engineering (IC4ME2), 2018. IEEE. https://doi.org/10.1109/IC4ME2.2018.8465613
  4. M. Yousuf, K. B. Khan, M. A. Azam, and M. Aqeel, “Brain tumor localization and segmentation based on pixel-based thresholding with morphological operation,” in Advances in Intelligent Systems and Computing, May 2020. https://doi.org/10.1007/978–981–15–5232–8_48
  5. I. Ilic and M. Ilic, “International patterns and trends in the brain cancer incidence and mortality: An observational study based on the
    global burden of disease,” Heliyon, e18222, 2023. https://doi.org/10.1016/j.heliyon.2023.e18222
  6. P. Jain and P. Parmar, “Analysis of various Preprocessing filtering methods for MRI brain tumour detection in a noisy environment,” Jour-
    nal of Physics: Conference Series, vol. 2335, article 012030, 2022. https://doi.org/10.1088/1742–6596/2335/1/012030
  7. V. Supraja et al., “Brain Tumor Detection and Segmentation Using Watershed Segmentation and Morphological Operation,” International Journal of Scientific Research in Science, Engineering and Technology, vol. 218451, 2021. https://doi.org/10.32628/IJSRSET218451
  8. T. Maha Lakshmi et al., “MATLAB Implementation of an Efficient Technique for Detection of Brain Tumor by using Watershed Segmentation and Morphological Operation,” GRD Journal for Engineering, vol. 1, no. 4, March 2016. ISSN: 2455–5703.
  9. S. Hiremath and A. Shobha Rani, “Image filtering using Anisotropic Diffusion for Brain tumor detection,” BMS Institute of Technology & Management, 2022. https://doi.org/10.21203/rs.3.rs-3339443/v1
  10. R. Martina et al., “Digital Terrain Models from Airborne Laser Scanning for the Automatic Extraction of Natural and Anthropogenic Linear Structures,” Developments in Earth Surface Processes, vol. 15, 2022. https://doi.org/10.1016/B978–0–444–53446–0.00018–5
  11. R. Haralick, K. Shanmugam, and I. Dinstein, “Textural Features for Image Classification,” IEEE Transactions on Systems, Nov. 1973. https://doi.org/10.1109/TSMC.1973.4309314
  12. Cancer.Net Editorial Board, “Brain Tumor: Statistics,” Cancer.Net, March 2023. Adapted from Cancer Facts & Figures 2023, CBTRUS Statistical Report, IARC, and NCI. Accessed February 2023. https://www.cancer.net/cancer-types/brain-tumor/statistics
  13. A. Foucart, “Image processing (9) | Image Information | Grayscale co-occurrence matrix,” YouTube, Oct. 22, 2020. https://www.youtube.com/watch?v=cq0Br3zB2AU&t=229s&ab_channel=AdrienFoucart.
  14. M. A. Wirth, “Texture Analysis,” University of Guelph, Computing and Information Science, Image Processing Group, 2004. http://www.cyto.purdue.edu/cdroms/micro2/content/education/wirth06.pdf
  15. M. R. Ahmed, “Morphological Quality Assessment of Seed using Radiographic Image Analysis,” Thesis, North Dakota State University, August 2020. https://doi.org/10.13140/rg.2.2.30598.60483
  16. M. Chaves, “GLCMs — a Great Tool for Your ML Arsenal,” Towards Data Science, Jan. 21, 2022. https://towardsdatascience.com/glcms-a-great-tool-for-your-ml-arsenal-7a59f1e45b65
  17. “Brain MRI Images for Brain Tumor Detection,” Kaggle, https://www.kaggle.com/datasets/navoneel/brain-mri-images-for-brain-tumor-detection/data
  18. M. Said Salimo, “Brain-Tumor-Detection-using-Image-Processing Repository,” GitHub, 2024. https://github.com/PhDMlachahe/Brain-Tumor-Detection-using-Image-Processing.git

--

--

Mlachahe Said Salimo
Wanabilini

French Student in Computer Science for Health. J'écris mes notes ici + J'écris pour apprendre, pas parce que je sais !