フィルターのクリア

Conversion to logical from struct is not possible. (It's a binary matrix!)

6 ビュー (過去 30 日間)
chang zhao
chang zhao 2019 年 6 月 5 日
編集済み: Stephen23 2019 年 6 月 5 日
myFolder = '/MATLAB Drive/saliency/code_forMetrics/dataset/test';
filePattern1 = fullfile(myFolder,'saliency', '*.jpg');
filePattern2 = fullfile(myFolder,'fixation_b', '*.mat');
imgFiles = dir(filePattern1);
fixFiles = dir(filePattern2);
for k = 1:length(imgFiles)
baseFileName1 = imgFiles(k).name;
fullFileName1 = fullfile(myFolder,'saliency', baseFileName1);
baseFileName2 = fixFiles(k).name;
fullFileName2 = fullfile(myFolder,'fixation_b', baseFileName2);
img{k} = imread(fullFileName1);
fix{k} = load(fullFileName2);
score{k} = NSS(img{k}, fix{k});
end
Output:
test_0_bfix
Error using logical
Conversion to logical from struct is not possible.
Error in NSS (line 16)
score = mean(map(logical(fixationMap)));
Error in test_0_bfix (line 14)
score{k} = NSS(img{k}, fix{k});
Since the problem doesn't seem to appear before,is this the version problem?
fixation.mat suppose to be a binary matrix
Besides,as a newbee in ML,i would like to ask how to calculate the mean of score since it's a cell.
I'd appreciate for your help.

採用された回答

Stephen23
Stephen23 2019 年 6 月 5 日
編集済み: Stephen23 2019 年 6 月 5 日
As the load documentation clearly states, if the file is a .mat file then the output of load is a scalar structure, whos fields are the variables that were saved in the .mat file. So you will need to refer to the field of that structure:
S = load(...);
F{k} = S.whateverFieldNameYourDataHas;
If there is only one variable per file and you do not know its name, then you could do this:
S = load(...);
C = struct2cell(S);
F{k} = C{1};
Note that naming a variable fix is not a good idea, as this shadows the inbuilt fix function.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVariables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by