error in cell segmentation

i want to make this overlapping cell segmentation same as this link. but when i using their coding in my coding they not work. they have some error. but i dont know how to solve it. please see the link and my coding in pdf

7 个评论

There are so many line breaks introduced by the PDF that it would take long than I'm willing to spend for you to fix them. Please attach the m-file itself.
clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 14;
figure;
set(gcf, 'Renderer', 'Painters');
folder = 'C:\Users\User\Pictures';
baseFileName = 'N8.jpg';
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
fullFileName = baseFileName;
if ~exist(fullFileName, 'file')
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
[rows, columns, numberOfColorBands] = size(rgbImage);
figure(1),subplot(3, 3, 2);
imshow(rgbImage);
title('Original Sputum Image', 'FontSize', fontSize);
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
hsv = rgb2hsv(rgbImage);
hImage = hsv(:, :, 1);
sImage = hsv(:, :, 2);
vImage = hsv(:, :, 3);
figure(1),subplot(3, 3, 4);
imshow(hImage, []);
title('Hue Image', 'FontSize', fontSize);
figure(1),subplot(3, 3, 5);
imshow(sImage, []);
title('Saturation Image', 'FontSize', fontSize);
figure(1),subplot(3, 3, 6);
imshow(vImage, []);
title('Value Image', 'FontSize', fontSize);
hueBinary = hImage > 0.2 | hImage < 0.1;
saturationBinary = sImage > 0.22;
valueBinary = vImage > 0.28 & vImage < 0.9;
binaryImage = hueBinary & saturationBinary & valueBinary;
binaryImage = bwareaopen(binaryImage, 400);
binaryImage = imfill(binaryImage, 'holes');
figure(2),subplot(2, 2, 1);
imshow(binaryImage, []);
axis on;
title('Opening', 'FontSize', fontSize);
se = strel('disk',10);
afterclosing = imclose(binaryImage,se);
figure(2), subplot (2,2,2), imshow(afterclosing,[]);
axis on;
title('Closing','FontSize', fontSize);
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
bw2 = imfill(afterclosing,'holes');
bw3 = imopen(bw2, ones(5,5));
bw4 = bwareaopen(bw3, 40);
bw4_perim = bwperim(bw4);
overlay1 = imoverlay(sImage, bw4_perim, [.3 1 .3]);
imshow(overlay1);
mask_em = imextendedmax(sImage, 30);
imshow(mask_em);
mask_em = imclose(mask_em, ones(5,5));
mask_em = imfill(mask_em, 'holes');
mask_em = bwareaopen(mask_em, 40);
overlay2 = imoverlay(sImage, bw4_perim | mask_em, [.3 1 .3]);
imshow(overlay2);
I_eq_c = imcomplement(I_eq);
I_mod = imimposemin(I_eq_c, ~bw4 | mask_em);
L = watershed(I_mod);
figure(3),imshow(label2rgb(L));
sir i already attach my coding i know the error at overlay
clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 14;
figure;
set(gcf, 'Renderer', 'Painters');
folder = 'C:\Users\User\Pictures';
baseFileName = 'N8.jpg';
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
fullFileName = baseFileName;
if ~exist(fullFileName, 'file')
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
[rows, columns, numberOfColorBands] = size(rgbImage);
figure(1),subplot(3, 3, 2);
imshow(rgbImage);
title('Original Sputum Image', 'FontSize', fontSize);
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
hsv = rgb2hsv(rgbImage);
hImage = hsv(:, :, 1);
sImage = hsv(:, :, 2);
vImage = hsv(:, :, 3);
figure(1),subplot(3, 3, 4);
imshow(hImage, []);
title('Hue Image', 'FontSize', fontSize);
figure(1),subplot(3, 3, 5);
imshow(sImage, []);
title('Saturation Image', 'FontSize', fontSize);
figure(1),subplot(3, 3, 6);
imshow(vImage, []);
title('Value Image', 'FontSize', fontSize);
hueBinary = hImage > 0.2 | hImage < 0.1;
saturationBinary = sImage > 0.22;
valueBinary = vImage > 0.28 & vImage < 0.9;
binaryImage = hueBinary & saturationBinary & valueBinary;
binaryImage = bwareaopen(binaryImage, 400);
binaryImage = imfill(binaryImage, 'holes');
figure(2),subplot(2, 2, 1);
imshow(binaryImage, []);
axis on;
title('Opening', 'FontSize', fontSize);
se = strel('disk',10);
afterclosing = imclose(binaryImage,se);
figure(2), subplot (2,2,2), imshow(afterclosing,[]);
axis on;
title('Closing','FontSize', fontSize);
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
bw2 = imfill(afterclosing,'holes');
bw3 = imopen(bw2, ones(5,5));
bw4 = bwareaopen(bw3, 40);
bw4_perim = bwperim(bw4);
overlay1 = imoverlay(sImage, bw4_perim, [.3 1 .3]);
imshow(overlay1);
mask_em = imextendedmax(sImage, 30);
imshow(mask_em);
mask_em = imclose(mask_em, ones(5,5));
mask_em = imfill(mask_em, 'holes');
mask_em = bwareaopen(mask_em, 40);
overlay2 = imoverlay(sImage, bw4_perim | mask_em, [.3 1 .3]);
imshow(overlay2);
I_eq_c = imcomplement(I_eq);
I_mod = imimposemin(I_eq_c, ~bw4 | mask_em);
L = watershed(I_mod);
figure(3),imshow(label2rgb(L));
done sir. thank you for helping me to send .m file here. but please see my error. i want to make as link given but they have error at overlay

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by