how can i give multiple images from folder??

clear
clear all
% Read the image
imgSet = imageSet(imageLocation)
I = imread('A1.JPG','jpg');
Igray = rgb2gray(I);
% Extract target regions
BW = edge(Igray);
se90 = strel('line', 2, 90);
se0 = strel('line', 2, 0);
BW2 = imdilate(BW,[se90 se0]);
BWfill = imfill(BW2,'holes');
seD = strel('diamond',3);
BWfinal = imerode(BWfill,seD);
% Measure the statistics
stats = regionprops(BWfinal,'Area','BoundingBox','MajorAxisLength','MinorAxisLength','Eccentricity','ConvexArea','FilledArea')%{'Area','Centroid','});
% M = mean(stats(:,2:end),all);
% M = mean(stats{:,{'Area','MajorAxisLength','MinorAxisLength'}});
% stats = struct2table(stats);
mean_value=mean(stats,'all');
% Show the result
figure
imshow(I)
hold on
for kk = 1:height(stats)
text(stats.Centroid(kk,1)+10, stats.Centroid(kk,2),....
num2str(stats.Area(kk)))
end

Answers (1)

imagefiles = dir('*.jpg') ; % you are in the folder of images
N = length(imagefiles) ; % toal number of images
% loop for each image
for i = 1:N
I = imread(imagefiles(i).name) ;
imshow(I)
% do what you want
end

Asked:

on 7 Feb 2019

Answered:

on 7 Feb 2019

Community Treasure Hunt

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

Start Hunting!