how can I access the index of one class? details are given below
3 ビュー (過去 30 日間)
古いコメントを表示
i have a dataset which contains 1400 images.. these images are divided into 70 classes. Each class contains the 20 images. so i have each image name as "class number_image number" e.g if i have class 2 and its image number 17 then I'll write it as "2_17"..
now keep all above in mind, i have made indexing of images from 1 to 1400.... So if i need to access an image that is on index 34 then its mean that it is from class 2 and its image number is 14 in that class.. but how can i do that??.. i.e. just looking at the image number how can identify that its belong to which class and in that class actually it is on which index??
u got it??.. plz help me out to write its syntax....
for this i have tried to separate the image number into digits and then divided the first one digit on 2 but not getting the accurate result as it fails if the image number is say 235 or 1245 or 1375..
0 件のコメント
採用された回答
José-Luis
2012 年 9 月 17 日
classnumber = floor((your_number-1)/20) + 1;
inclass = mod(your_number-1,20) + 1;
0 件のコメント
その他の回答 (2 件)
Walter Roberson
2012 年 9 月 17 日
classnumber = floor((indexnumber-1)/20)+1;
inclass = indexnumber - 20*classnumber;
Image Analyst
2012 年 9 月 17 日
編集済み: Image Analyst
2012 年 9 月 17 日
How about this (untested):
% Get only those filenames with given class number, and NO others.
classNumberToRetrieve = 2;
filePattern = sprintf('%d_*.*', classNumberToRetrieve);
files = dir(filePattern)
% Get the index of the one image wanted.
imageNumberWanted = 17;
for index = 1 : length(files)
if strfind(files(index).name, num2str(imageNumberWanted))
break;
end
end
% index is now the item in the files list that you want.
% Now process files(index).name
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!