Looping images in folder

2 views (last 30 days)
Bart Smulders
Bart Smulders on 29 Jan 2019
Answered: Image Analyst on 29 Jan 2019
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,'.')

Accepted Answer

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

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!