Read particular images from a folder
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Image Analyst
2015-8-9
编辑:Image Analyst
2015-8-9
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 个评论
Walter Roberson
2015-8-9
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!