Borrar filtros
Borrar filtros

save image names form a loop in a new variable

1 visualización (últimos 30 días)
Tommy Schumacher
Tommy Schumacher el 24 de Mzo. de 2021
Comentada: Tommy Schumacher el 24 de Mzo. de 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

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by