MATLAB: I want to extract skull from Brain MRI usinG MORPHOLOGICAL OPERATIONS . But i didnt get a useful output by using the following code..Please help me to solve this.s

brainbrain extraction morphological operationsImage Processing Toolboximage segmentationmorphologymriskull removeskull stripskull strippingtumor detection

clear all;
clc
[filename pathname] = uigetfile({'*.jpg';'*.bmp'},'Select MRI');
inputimage=strcat(pathname, filename);
I = imread(inputimage);
figure,imshow(I), title('input');
se = strel('disk',7);
closeBW = imclose(I,se);
figure, imshow(closeBW);title('close operation');
afterOpening = imopen(closeBW,se);
figure, imshow(afterOpening,[]);title('open operation');
J=I-afterOpening;
figure, imshow(J,[]);title('Skull of MRI');
K=I-J;
figure, imshow(K,[]);title('Skull removed MRI');

Best Answer

See attached m-file.