How to use a function in a loop for whole database in image processing using MatLab

2 次查看(过去 30 天)
I have a code for finding a skeleton of an image. I want to use that code to find the skeleton of all frames present in a folder as separate images. These image are named sequentially, such as 001-nm-01-090-062.png, 001-nm-01-090-063.png, 001-nm-01-090-064.png etc. I want to store the skeletonized image in a separate folder.
The code for skeleton is
% read in a sample image --
img = imread('C:\Users\anurag\Desktop\090\001-nm-01-090-064.png');
img=im2bw(img,.5);
imshow(img);
% the standard skeletonization:
imshow(bwmorph(img,'skel',inf));
% the new method:
imshow(bwmorph(skeleton(img)>35,'skel',Inf));

回答(1 个)

KSSV
KSSV 2016-12-29
imgFiles = dir('*.png'); % get all png files in the folder
numfiles = length(imgFiles); % total number of files
for k = 1:numfiles % loop for each file
img = imgFiles(k).name % present image file
%%do what you want %%
end

产品

Community Treasure Hunt

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

Start Hunting!

Translated by