Conversion to logical from struct is not possible. (It's a binary matrix!)
8 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Stephen23
on 5 Jun 2019
Edited: Stephen23
on 5 Jun 2019
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 Comments
More Answers (0)
See Also
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!