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

조회 수: 4 (최근 30일)
Anurag
Anurag 2016년 12월 29일
답변: KSSV 2016년 12월 29일
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

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by