save image names form a loop in a new variable

1 次查看(过去 30 天)
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