Setting Background to Zero Messes Up Image Segmentation

2 vues (au cours des 30 derniers jours)
Samuel Leeney
Samuel Leeney le 18 Nov 2020
Hi Guys,
I am using some code written by someone else to segment medical image.
The code can be found here and the initial results when run on one of the medical images is attached.
The segmentation works well initially, however I have written an extra section into the code that removes the background of the image:
im = double(im2gray(imread('LN034_T95.png')));
im = imresize(im,[512,512]);
figure(2)
imshow(im,[])
windowWidth = 15; %Sets blur level
kernel = ones(windowWidth) / windowWidth ^ 2;
imblur = imfilter(im,kernel); %blurs image
imshow(imblur,[])
level = 30;
BW = imbinarize(imblur,level);
BWFill = imfill(BW, 'holes'); %fills 'holes' inside tissue
imshowpair(im,BWFill,'montage')
for y = 1:length(im)
for x = 1:length(im)
if BWFill(x,y) == 0
im(x,y) = BW(x,y);
end
end
end
imshow(im,[])
The problem is, that when the background is removed from the image, it seems to mess up the segmentation. See the attached images from after the background is removed (set to 0).
I have got absolutely no idea why this is happening - surely the background should all become one segment?
Thanks in advance.

Réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by