How to use a function in a loop for whole database in image processing using MatLab
Show older comments
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));
Answers (1)
KSSV
on 29 Dec 2016
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
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!