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,'.')
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!