フィルターのクリア

Read particular images from a folder

1 回表示 (過去 30 日間)
annmaria
annmaria 2015 年 8 月 9 日
回答済み: Walter Roberson 2015 年 8 月 9 日
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

回答 (2 件)

Image Analyst
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

Walter Roberson
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

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by