Effacer les filtres
Effacer les filtres

Read particular images from a folder

1 vue (au cours des 30 derniers jours)
annmaria
annmaria le 9 Août 2015
I have a folder which contain 17 images and are named like 1im,2im...17im. I am classified this images into two classes 1 and 2. so I got 12 images are in group 1 and 5 images are in group 2. I want to read the images which are classified in group 1. p gives the indices of the image which are classified into first group. I tried the following code but it does'nt give exact answer. please help me.thanks in advance
p=find(Group==1);
disp(p);
A=[];
for ii=1:17
A{ii} = imread(['H:\dataa\try4\' num2str(ii) 'im' '.bmp']);
figure;imshow(A{p});
end

Réponses (2)

Image Analyst
Image Analyst le 9 Août 2015
Modifié(e) : Image Analyst le 9 Août 2015
How do you know what filenames correspond to Group? Is Group created with the same 17 files in the very same order as you're making up the filename strings? If so, do this
p= Group==1 % Logical vector.
A=cell(1, length(Group)); % Preallocate
for k = 1 : length(Group)
thisFilename = sprintf('H:\dataa\try4\%dim.bmp', k);
if exist(thisFilename, 'file')
A{k} = imread(thisFilename);
% Display it only if it's in group 1
subplot(4, 5, k);
if p(k)
imshow(A{k});
end
else
message = sprintf('%s does not exist', thisFilename);
uiwait(warndlg(message));
end
end

Walter Roberson
Walter Roberson le 9 Août 2015
A={};
for ii=1:17
if p(ii)
A{end+1} = imread(['H:\dataa\try4\' num2str(ii) 'im' '.bmp']);
figure;imshow(A{end});
end
end

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by