How to do skull stripping when the skull in the image is not complete?
Show older comments
How do I remove the skull (as well as others tissues that are not tumor, but have similar intensity) from the MRI images? I have seen methods including removing the largest blob (the skull), but the skull does not enclose the brain fully in the picture I attached here. Using imbinarize will also keep other tissues which have similar intensity as the tumor in the image.

I have tried to use imerode, but the skull is not removed entirely.
Any help is appreciated. Thanks!
3 Comments
Umar
on 19 Jul 2024
Hi Eudora,
To address solution to your posted comments, you have to follow the following steps, load the MRI image into Matlab, convert the RGB image to grayscale for processing.Use Otsu's method (graythresh) to find an optimal threshold for binarization. Binarize the grayscale image using the threshold to create a binary mask of the tumor region.Eliminate small objects (noise) from the binary mask using bwareaopen.Invert the binary mask to retain the tumor region while excluding other tissues. You should be able to show the original MRI image alongside the extracted tumor region for visualization. Here is the snippet code to help you further,
% Read the MRI image
MRI = imread('MRI_image.jpg');
% Convert the image to grayscale
MRI_gray = rgb2gray(MRI);
% Threshold the image to create a binary mask of the tumor region
threshold = graythresh(MRI_gray);
binary_mask = imbinarize(MRI_gray, threshold);
% Remove small objects to exclude noise
binary_mask_cleaned = bwareaopen(binary_mask, 1000);
% Invert the binary mask to keep the tumor region
tumor_region = imcomplement(binary_mask_cleaned);
% Display the resulting image with only the tumor region
imshowpair(MRI, tumor_region, 'montage');
This code snippet should help you effectively remove non-tumor tissues, like the skull, from MRI images while preserving the tumor region for further analysis or processing. Please let me know if you have any further questions.
Eudora
on 28 Jul 2024
Umar
on 28 Jul 2024
Hi Eudora,
Glad to help, but if these functions did not work, I will provide guidance on how to use these functions, in case if you have to utilize them in your future matlab projects, please refer to
https://www.mathworks.com/help/images/ref/bwareaopen.html
https://www.mathworks.com/help/images/ref/imcomplement.html?searchHighlight=imcomplement&s_tid=srchtitle_support_results_1_imcomplement
https://www.mathworks.com/help/images/ref/imshowpair.html?searchHighlight=imshowpair&s_tid=srchtitle_support_results_1_imshowpair
Good luck!
Accepted Answer
More Answers (1)
Hi Eudora,
I understand that you wish to remove the skull area in order to isolate the tumour from the MRI scans but are facing issues with it.
To isolate and remove everything except the tumor (assuming the bright white spot) from the MRI image, it is required to focus on segmenting the brightest region. The following approach can be followed to achieve this:
- Enhance the contrast to highlight the tumor. "imadjust" function can be used to enhance the contrast of the grayscale image.
- Use thresholding to segment the brightest region.Use "imbinarize" with a high threshold value to isolate the bright regions.
- Apply morphological operations to refine the segmentation. "imerode" and "imdilate" refine the segmentation by removing small artifacts and filling gaps. "imfill" fills any holes within the segmented region.
- Select the tumour region. Use "bwlabel" to label connected components in the binary image and "regionprops" to measure the properties of each labeled region to identify the largest one, assumed to be the tumor.
- Mask the original image to isolate the tumor.
Please refer to the following code snippet for demo:
img = imread("image.jpeg");
grayImg = rgb2gray(img);
% Apply Gaussian filter to smooth the image
filteredImg = imgaussfilt(grayImg, 1);
% Enhance contrast
enhancedImg = imadjust(filteredImg);
% Thresholding to segment the bright region
thresholdValue = 0.93; % Adjust this value as needed
binaryImg = imbinarize(enhancedImg, thresholdValue);
% Morphological operations to refine the segmentation
binaryImg = imerode(binaryImg, strel('disk', 2));
binaryImg = imdilate(binaryImg, strel('disk', 3));
binaryImg = imfill(binaryImg, 'holes');
% Label connected components
labeledImg = bwlabel(binaryImg);
% Measure properties of the blobs
stats = regionprops(labeledImg, 'Area', 'PixelIdxList');
% Find the largest blob (assuming it's the tumor)
[~, idx] = max([stats.Area]);
tumorMask = ismember(labeledImg, idx);
% Apply the mask to the original image to isolate the tumor
tumorImg = grayImg;
tumorImg(~tumorMask) = 0;
% Display the results
figure;
subplot(1, 2, 1), imshow(grayImg), title('Original Image');
subplot(1, 2, 2), imshow(tumorImg), title('Isolated Tumor');
Please refer to the following documentation links to learn more about mentioned functions:
- imadjust: https://www.mathworks.com/help/images/ref/imadjust.html
- imbinarize: https://in.mathworks.com/help/images/ref/imbinarize.html
- imdilate: https://www.mathworks.com/help/images/ref/imdilate.html
- imerode: https://www.mathworks.com/help/images/ref/imerode.html
- imfill: https://in.mathworks.com/help/images/ref/imfill.html
- bwlabel: https://in.mathworks.com/help/images/ref/bwlabel.html
- regionprops: https://www.mathworks.com/help/images/ref/regionprops.html
Hope this helps!
2 Comments
Image Analyst
on 25 Jul 2024
imadjust is not needed - it simply changes the threshold to a different gray level than it would be originally but won't change the binary image. I also doubt that blurring the image is necessary because it will just make the tumor boundary smoother and less accurate. And the code depends on the tumor being brighter than the skull but she said that in some images the tumor is not brighter because it's the same brightness as the skull.
Eudora
on 28 Jul 2024
Categories
Find more on Neuroimaging in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
