How to store the result of areas on every images on loop in one folder to workspace?

1 次查看(过去 30 天)
i keep getting an error and it only loaded some of the image not all of them, i have like 600+ files but it only loaded for 19 images idk why
clc; clear; close all;
folder_nrml = ('/Users/*/Documents/MATLAB/regionbased_seg/cv/NORMAL');
file_nrml = dir(fullfile(folder_nrml, '*jpeg'));
jumlah_file_nrml = numel(file_nrml);
training_data_nrml = zeros(jumlah_file_nrml);
calc = [];
for l = 1:jumlah_file_nrml
I = imread(fullfile(folder_nrml, file_nrml(l).name));
figure, imshow(I)
bw1= im2bw(I);
bw2 = imfill(bw1,'holes');
s = regionprops(bw2, 'centroid', 'area');
centroids = cat(1, s.Centroid);
area = cat(1, s.Area);
sum_area = sum(area);
hold on
plot(centroids(:, 1), centroids(:,2), 'r*')
[B,L] = bwboundaries(bw2, 'noholes');
[~,l]= bwlabel(bw2,4);
for k = 1:l
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'y', 'LineWidth', 2)
text(boundary(1,2), boundary(1,1), strcat(['Area = ',num2str(area(k))]), 'Color', 'r', 'FontSize',15, 'FontWeight','bold');
end
calc = [calc;sum_area];
cell_areas(l,:) = {file_nrml(l).name, sum_area};
hold off
end
here are the result and error

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by