Read particular images from a folder
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (2)
Image Analyst
am 9 Aug. 2015
Bearbeitet: Image Analyst
am 9 Aug. 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
0 Kommentare
Walter Roberson
am 9 Aug. 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
0 Kommentare
Siehe auch
Kategorien
Mehr zu C4ISR finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!