- https://www.mathworks.com/matlabcentral/answers/369933-i-have-following-code-i-want-to-perform-following-task-on-many-images-reading-from-directory-kindl (this one)
- https://www.mathworks.com/matlabcentral/answers/368049-i-have-directory-which-has-many-images-i-want-to-perform-face-detection-and-cropping-process-on-th
- https://www.mathworks.com/matlabcentral/answers/368409-how-to-create-loop-to-read-many-images-from-directory-and-then-create-a-folder-for-each-image-and-sa
- https://www.mathworks.com/matlabcentral/answers/367782-i-have-directory-there-are-many-images-in-this-directory-i-want-to-detect-the-face-from-images-an
I have following code, i want to perform following task on many images reading from directory. kindly help me through code.
조회 수: 1 (최근 30일)
이전 댓글 표시
I=imread('E:\a.jpg');
figure(1),imshow(I);
FaceDetect = vision.CascadeObjectDetector;
BB = step(FaceDetect,I);
figure(2),imshow(I);
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',3,'LineStyle','- ','EdgeColor','r');
end
for i = 1:size(BB,1)
J= imcrop(I,BB(i,:));
% figure(3),subplot(5,5,i);imshow(J);
fname = sprintf('b_cropped_%d.jpg', i);
fpath = fullfile('E:\face', fname);
imwrite(J, fpath)
% imwrite(J,'E:\g_cropped.jpg')
end
댓글 수: 2
Jan
2017년 11월 30일
@saeeda saher: You have posted 4 very similar questions now:
In the last one you have removed your comments, such that the thread became useless for other readers now. This is not liked in the forum, because the answers a given with the intention to be useful for the community and all readers. Posting multiple questions for the same problem is confusing for the readers and it wastes the time of the persons, who want to help you.
Please post one thread per problem and explain the remaining problems as comments until the question is solved. Add comments, if the suggested code works or what is still missing. Avoid to remove information, which is required to understand the thread. Thanks.
답변 (1개)
Jan
2017년 11월 29일
편집: Jan
2017년 11월 29일
Simply replace
I = imread('E:\a.jpg');
by
Folder = 'E:\';
FileList = dir(fullfile(Folder, '*.jpg'));
for iFile = 1:numel(FileList)
File = fullfile(Folder, FileList(iFile).name);
I = imread(File);
...
% Consider the name or index of the original file:
fname = sprintf('b_cropped_%d_%d.jpg', iFile, i);
...
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!