How to extract the backgroung from the object .....after using Watershed segmentation??

1 view (last 30 days)
I= imread('C:\Users\IT Lab\Downloads\brain.jpeg');
I1= imtophat(I, strel('disk',50));
figure,imshow(I1);
title('1');
level = graythresh(I1);
BW = im2bw(I1,level);
figure,imshow(BW);
title('2')
C=~BW;
figure,imshow(C);
D= -bwdist(C);
D(C)= -Inf;
L= watershed(D);
figure,imshow(L);
wi=label2rgb(L);
figure,imshow(wi);
im=I;
im(L==0)=0;
figure,imshow(im);
Here is my segmentation code, but now I have to work with the background only, not the brain image, which I will merge later....So, can anybody help me in separating the background from the Brain image(x-ray)?

Answers (2)

yanqi liu
yanqi liu on 27 Sep 2021
sir,may be you should upload brain.jpeg to develop

Image Analyst
Image Analyst on 27 Sep 2021
~BW would be the background. It's just the inverse of the foreground.
You can get a better answer if you upload the image.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!