problem with image brain tumor image processing

Hi everyone, I have to do tumor brain segmentation for this picture. The lesion is located at the upper right of the brain. I'm currently having difficulties in removing the background as the colour of the background is similar to the other parts of the brain too. Can someone help me with the coding? thank you so much
the final outcome should be like this:

2 Comments

May be these steps works:
Histeq>>Edge Detection>>Morpho/blob detection
If this works then the coding implementation is easy, hope you can do that.

Sign in to comment.

 Accepted Answer

See my skull stripping demo. It does that.
0000 Screenshot.png
0001 Screenshot.png

9 Comments

how do you know the gray level value before you plot the histogram? thank youu
Capture.PNG
this code did not work for my image :'( the tumor become black in colour instead of white.. help meee..help mee, I need to submit the answer today:'(
You can take the histogram first, in advance, to determine what gray level the background is. Then use that gray level to do the thresholding. That's what I did to know that 11 would be about right.
The threshold may need to be adjusted independently for each image. You can get an interactive app to do that in my File Exchange.
as for this one, what is the right threshold value ?k.PNG
What do you mean "submit"? Are you going to submit my code as your own? Assuming not, try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 22;
% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
%===============================================================================
% Read in a color demo image.
folder = pwd;
baseFileName = 'image.jpeg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows, columns, numberOfColorBands] = size(grayImage);
if numberOfColorBands > 1
fprintf('This image is RGB. I will change it to gray scale.\n');
grayImage = grayImage(:, :, 2);
end
% Display the original image.
subplot(2, 2, 1);
imshow(grayImage);
axis('on', 'image');
title('Green Channel Image', 'FontSize', fontSize);
impixelinfo;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0.1, 1, 0.9]);
subplot(2, 2, 2);
imhist(grayImage);
grid on;
title('Intensity Histogram', 'FontSize', fontSize);
% It's gray scale. Threshold to create a binary image.
binaryImage = grayImage > 35 & grayImage < 55; % or whatever value works.
subplot(2, 2, 3);
imshow(binaryImage, []);
axis('on', 'image');
title('Binary Image', 'FontSize', fontSize);
% Get rid of partial blobs leaving the field of view.
binaryImage = imclearborder(binaryImage);
% Get rid of blobs less than 500 in area.
binaryImage = bwareaopen(binaryImage, 500);
binaryImage = imfill(binaryImage, 'holes');
% Label the image so we can get rid of the dark region near the skull
[labeledImage, numberOfblobs] = bwlabel(binaryImage);
% Remove outer one
binaryImage = ismember(labeledImage, [2:numberOfblobs]);
% Take the largest blob only.
binaryImage = bwareafilt(binaryImage, 1);
% Relabel now.
[labeledImage, numberOfblobs] = bwlabel(binaryImage);
% Apply a variety of pseudo-colors to the regions.
coloredLabelsImage = label2rgb (labeledImage, 'hsv', 'k', 'shuffle');
% Display the pseudo-colored image.
subplot(2, 2, 4);
imshow(coloredLabelsImage);
axis('on', 'image');
title('Filled Binary Image', 'FontSize', fontSize);
% Make measurements of area.
props = regionprops(binaryImage, 'Area', 'Centroid', 'MajorAxisLength', 'MinorAxisLength')
allAreas = [props.Area]
majorAxisLength = [props.MajorAxisLength]
minorAxisLength = [props.MinorAxisLength]
0000 Screenshot.png
sorry for the missunderstanding earlier.what i meant is i need to submit my lesion picutre. Thank you so much for helping image analyst. your latest coding is much easier for me to understand as I'm still new in matlab. thank you very much. May god bless you :)
i want to ask you a very last question, sorry for asking a lot. Dear image analyst, how did you read "grayImage > 35 & grayImage < 55; " this value from the historam ya?
I looked for dips in the histogram.

Sign in to comment.

More Answers (0)

Categories

Find more on Medical Physics in Help Center and File Exchange

Products

Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!