Looping images in folder

2 次查看(过去 30 天)
Hey all,
How do i loop the code under here so in the end i get a plot of all the data from all images in the wanted folder?
clear all; clc;
cur_dir = 'C:\RESULTS';
%name correct file that you want to detect the lines for
I = double(imread([cur_dir '\proccesed\424.bmp']));
%imageinfo([cur_dir '\proccesed\test 1.bmp'])
BW = logical(I);
L = bwlabel(BW,4);
Data = regionprops(L,'All');
A = [Data.Area];
ind = find(A<=10);
Data(ind) = [];
clear ind
%%% Get line co-ordinates %%%
Centroid = [Data.Centroid];
x = Centroid(1:2:end);
y = Centroid(2:2:end); clear Centroid
%%% Get line areas %%%
A = [Data.Area];
%%% Get line lengths %%%
for kk = 1 : length(Data)
I_temp = Data(kk).Image;
I_temp = bwmorph(I_temp,'skel');
I_end = bwmorph(I_temp,'endpoints');
ind = find(I_end);
D = bwdistgeodesic(I_temp,ind(1),'quasi');
D_act(kk) = max(D(:));
clear I_end ind D I_temp
end
plot(x,D_act,'.')

采纳的回答

Image Analyst
Image Analyst 2019-1-29
Put all that stuff into a function. Then call the function inside a loop over all files, like you'll find in the FAQ

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by