save image names form a loop in a new variable

조회 수: 1 (최근 30일)
Tommy Schumacher
Tommy Schumacher 2021년 3월 24일
댓글: Tommy Schumacher 2021년 3월 24일
Hi, i have images sets (1.png, 2.png, 3.png....) and load each image for some image detection action through a loop . If detection of img(j) is not possible then save the image name among each other in a new variable: problem_images. Look for this the else section below. The problem_images should look like this. Thank You
26
57
81
...
clear all; close all;
%path/directory of images
currentpath=pwd;
org=strcat(pwd);
edge=strcat(pwd,'\detection');
cd(org);
images=dir('*.png');
N=length(images);
%doing detection stuff for all images in this folder
for i=1:N
[filepath,name,ext] = fileparts(images(i).name);
img = imread(images(i).name);
if size_lines>2
%if image is ok, do some detection stuff...
else
%detection is not possible, save the name of the image(i) in a new variable
problem_images(:,1)=(images(i).name);
end
end

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 3월 24일
Here, I answered based on decription of the questions
j=1;
for i=1:total_images
%Images call one by one
%Detection Part
result=....% This variable is result from detection
%Store all those image numbers (problem Images) in cell array
if isempty(result);
problem_images{j}=['Image_number',num2str(i)];
j=j+1;
end
end
  댓글 수: 1
Tommy Schumacher
Tommy Schumacher 2021년 3월 24일
i got this error message
"Expected one output from a curly brace or dot indexing expression, but there were 0 results"

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by