save image names form a loop in a new variable

1 Ansicht (letzte 30 Tage)
Tommy Schumacher
Tommy Schumacher am 24 Mär. 2021
Kommentiert: Tommy Schumacher am 24 Mär. 2021
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

Akzeptierte Antwort

KALYAN ACHARJYA
KALYAN ACHARJYA am 24 Mär. 2021
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 Kommentar
Tommy Schumacher
Tommy Schumacher am 24 Mär. 2021
i got this error message
"Expected one output from a curly brace or dot indexing expression, but there were 0 results"

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by