I have performed image segmentation on dicom brain tumor images. now i want to extract rest of the region except the tumor region.
2 次查看(过去 30 天)
显示 更早的评论
hello , can any one help me with this, actually i want to work on the NROI portion/ larger section of brain image after extracting the tumor using image segmentation. i am using the below code.
Im=imread('C:\Coding\Brain-Tumor-Detection-using-Image-Processing-master\5.jpg');
figure, imshow(Im); title('Brain MRI Image');
I = imresize(Im,[256,256]);
Im=I;
I= rgb2gray(I);
I= im2bw(I,.6);%binarising with thresold .6
figure, imshow(I);title('Thresholded Image');
% hy = fspecial('sobel');
% hx = hy';
% Iy = imfilter(double(I), hy, 'replicate');
% Ix = imfilter(double(I), hx, 'replicate');
% gradmag = sqrt(Ix.^2 + Iy.^2);
% L = watershed(gradmag);
% Lrgb = label2rgb(L);
% figure, imshow(Lrgb), title('Watershed segmented image ')
se = strel('disk', 20);
Io = imopen(I, se);
Ie = imerode(I, se);
Iobr = imreconstruct(Ie, I);
Iobrd = imdilate(Iobr, se);
Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));
Iobrcbr = imcomplement(Iobrcbr);
I2 = I;
fgm = imregionalmax(Iobrcbr);
I2(fgm) = 255;
se2 = strel(ones(5,5));
fgm2 = imclose(fgm, se2);
fgm3 = imerode(fgm2, se2);
fgm4 = bwareaopen(fgm3, 20);
I3 = I;
bw = im2bw(Iobrcbr);
figure
imshow(bw), title('only tumor')
bw2=bwperim(bw);
figure
imshow(bw2)
D=imfuse(Im,bw);
D=rgb2gray(D);
imshow(D)
% labeledImage = bwlabel(I, 8); % Label each blob so we can make measurements of it
% coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels
% coloredLabels=rgb2gray(coloredLabels);
% biggestLabel = ismember(I, sortIndexes(1));
% binaryImage = biggestLabel > 0;
% maskedImage = grayImage;
% maskedImage(~binaryImage) = 0;
% figure
% imshow(coloredLabels);
% ME = 1 - (nnz(~I & ~bw) + nnz(I & bw))/(numel(I));
% c=ones(size(Im,1),size(Im,2),3);
% c(:,:,2)=1;
% figure,imshow(Im)
% hold all
% h=imshow(c);
% set(h,'AlphaData',bw)
I got the result tumor sementaed image which is ROI of original image. now i want to extract rest of the image except tumor as output in last image. please help me with this. Thank you
0 个评论
采纳的回答
Image Analyst
2022-2-18
You forgot to attach your image so we can't try your code. And using non-descriptive variable names and no comments certainly doesn't help. But assuming bw is your (badly named) tumor mask and I is your (badly-named) gray scale image, you can get the non-tumor part of the image like
tumorAlone = I; % Initialize
tumorAlone(~bw) = 0; % Erase outside the tumor.
nonTumorAlone = I; % Initialize
nonTumorAlone(bw) = 0; % Erase inside the tumor to get gray scale image outside the tumor mask.
5 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!