I have this code and I want to perform this process on multiple images. kindly help me through code.

1 Ansicht (letzte 30 Tage)
Kindly help me, i am new to Matlab.
clc;
[filename, filepath] = uigetfile ({'*.jpg';'*.bmp';'*.png'}, 'File Selector');
img = strcat(filepath, filename);
img = imread(img);
figure(1),imshow(img);
FaceDetect = vision.CascadeObjectDetector;
FaceDetect.MergeThreshold = 7 ;
BB = step(FaceDetect,img); figure(2),imshow(img);
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',3,'LineStyle','- ','EdgeColor','r');
end
for i = 1:size(BB,1)
J= imcrop(img,BB(i,:));
figure(3),subplot(6,6,i);
imshow(J);
end

Akzeptierte Antwort

Jan
Jan am 2 Dez. 2017
[filename, filepath] = uigetfile ({'*.jpg';'*.bmp';'*.png'}, 'File Selector', ...
'MultiSelect', 'on');
filename = cellstr(filename);
for iFile = 1:numel(filename)
img = fullfile(filepath, filename{iFile}); % Better than STRCAT
img = imread(img);
figure % New figure, do not specify the index
imshow(img);
FaceDetect = vision.CascadeObjectDetector;
FaceDetect.MergeThreshold = 7 ;
BB = step(FaceDetect,img); figure(2),imshow(img);
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',3,'LineStyle','- ','EdgeColor','r');
end
figure
for i = 1:size(BB,1)
J= imcrop(img,BB(i,:));
subplot(6,6,i);
imshow(J);
end
end
  3 Kommentare
Image Analyst
Image Analyst am 2 Dez. 2017
I guess you overlooked my Answer below, which gave code for doing exactly that.
Jan
Jan am 3 Dez. 2017
Bearbeitet: Jan am 3 Dez. 2017
@saeeda: Your question was not clear in what you exactly want.
All you need is to implement the code suggested in the link posted by Image Analyst:
FileList = dir(fullfile(Folder, '*.png')); % Adjust to your needs
for iFile = 1:numel(FileList)
file = fullfile(Folder, FileList(iFile).name))
...
end
You will find similar answers if you search in the net or in this forum for "process sequence of files".

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 2 Dez. 2017
Sample code is in the FAQ. http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F Take it and adapt it.
  2 Kommentare
Jan
Jan am 3 Dez. 2017
+1. While I like the contents of this wikia page, I hate to get commercials there. When I want to learn something about processing the sequence of files, this information is a waste of time:
The FANDOM 100 — From Luke Skywalker to Pickle Rick, breaking down
2017s most iconic characters from movies, TV and video games.
Image Analyst
Image Analyst am 3 Dez. 2017
I don't like ads either. Many/most web sites have them. Luckily we've trained ourselves to ignore them so we don't waste too much time reading them.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by