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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by