How I can develop this segmentation codes ? I am so close to exact shape

6 ビュー (過去 30 日間)
Ali Zulfikaroglu
Ali Zulfikaroglu 2021 年 11 月 22 日
回答済み: Image Analyst 2021 年 11 月 26 日
I am using miasdatabase and this is mdb005 image segmentation process. I found this image in a scientific paper .
And part (c) shows exact segmentation . Actually I need part c . My codes is below and result is so close to part (c) but not exactly.
What can I do to get it ? I added mdb005 image on the attachment part.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear;
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
imgf=imread('mdb005.png');
if(size(imgf,3)>1)
imgf=rgb2gray(imgf);
end
img=imgaussfilt(imgf);
IM=img;
subplot(3,3,1),imshow(IM);
title('Original Image', 'FontSize', fontSize);
% Maximize the figure window.
set(gcf, 'Position', get(0, 'ScreenSize'));
axis square;
thresholdValue = 135;
binaryImage = IM > thresholdValue;
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Area');
% Get all the areas
allAreas = [measurements.Area];
[biggestArea, indexOfBiggest] = sort(allAreas, 'descend');
% Extract biggest
biggestBlob = ismember(labeledImage, indexOfBiggest(1));
% Convert to binary
biggestBlob = biggestBlob > 0;
subplot(3, 3, 2);
% figure,
imshow(biggestBlob, []);
axis on;
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Final', 'fontSize', fontSize);
drawnow;
maskedGrayImage = imgf; % Initialize.
maskedGrayImage(~biggestBlob) = 0;
% Display the masked grayscale image.
subplot(3, 3, 3);
imshow(maskedGrayImage);
axis on;
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Masked Gray Scale Image', 'fontSize', fontSize);
drawnow;
I_eq = adapthisteq(maskedGrayImage);
subplot(3,3,4),imshow(I_eq);
title('Equalized Image', 'FontSize', fontSize);
se = strel('disk',20);
Io = imopen(I_eq,se);
subplot(3, 3, 5);
imshow(Io)
title('Opening')
Ie = imerode(I_eq,se);
Iobr = imreconstruct(Ie,I_eq);
subplot(3, 3, 6);
imshow(Iobr)
title('Opening-by-Reconstruction')
Ioc = imclose(Io,se);
subplot(3, 3, 7);
imshow(Ioc)
title('Opening-Closing')
Iobrd = imdilate(Iobr,se);
Iobrcbr = imreconstruct(imcomplement(Iobrd),imcomplement(Iobr));
Iobrcbr = imcomplement(Iobrcbr);
subplot(3, 3, 8);
imshow(Iobrcbr)
title('Opening-Closing by Reconstruction')
fgm = imregionalmax(Iobrcbr);
subplot(3, 3, 9);
imshow(fgm)
title('Regional Maxima of Opening-Closing by Reconstruction')
se2 = strel(ones(5,5));
fgm2 = imclose(fgm,se2);
fgm3 = imerode(fgm2,se2);
fgm4 = bwareaopen(fgm3,10);
% I3 = labeloverlay(grayImage,fgm4);
figure,
subplot(2, 2, 1);
imshow(fgm4)
title('Modified Regional Maxima Superimposed on Original Image')
IM_cb = imclearborder(fgm4);
BW2 = bwareaopen(IM_cb, 200);
BW_filled = imfill(BW2, 'holes');
subplot(2, 2, 2);
imshow(BW_filled);
axis on;
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Small Lines Eliminated', 'fontSize', fontSize);

回答 (2 件)

yanqi liu
yanqi liu 2021 年 11 月 23 日
sir,use the code at 《Detection-of-Breast-Cancer-using-Neural-Networks-master》
the result is
  7 件のコメント
Ali Zulfikaroglu
Ali Zulfikaroglu 2021 年 11 月 26 日
@yanqi liu thank you for your struggle. But mammography images comes with usually label and pectoral muscle. That's why I have to segment with them

サインインしてコメントする。


Image Analyst
Image Analyst 2021 年 11 月 26 日
I didn't read the paper but assuming you implemented the functions correctly, the problem may be that your image sizes don't match theirs and you need to adjust some of the image processing parameters like window sizes or min acceptable blob size or something like that.

Community Treasure Hunt

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

Start Hunting!

Translated by