Skip to content

Commit

Permalink
Fix MATLAB conversion issues and clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkunic committed Jan 15, 2019
1 parent f881990 commit e30ab79
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 124 deletions.
24 changes: 12 additions & 12 deletions models/matlab/CVS/smiler.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
"model_files": [],
"parameters": {
"size": {
"default": 512,
"description": "The dimensions that the image gets resized to when calculating the saliency map. Note that this is always a square.",
"valid_values": "Any integer greater than 0."
},
"default": 512,
"description": "The dimensions that the image gets resized to when calculating the saliency map. Note that this is always a square.",
"valid_values": "Any integer greater than 0."
},
"quantile": {
"default": 0.1,
"description": "A parameter which specifies the proportion of regions (sorted by degree of similarity) from the neighbourhood which are included in the calculation.",
"valid_values": "A number greater than 0 and less than or equal to 1"
},
"default": 0.1,
"description": "A parameter which specifies the proportion of regions (sorted by degree of similarity) from the neighbourhood which are included in the calculation.",
"valid_values": "A number greater than 0 and less than or equal to 1"
},
"modeltype": {
"default": "CovariancesOnly",
"description": "CovariancesOnly calculates saliency based on the covariances of the image patches, whereas SigmaPoints includes both covariances and means.",
"valid_values": ["CovariancesOnly", "SigmaPoints"]
}
"default": "CovariancesOnly",
"description": "CovariancesOnly calculates saliency based on the covariances of the image patches, whereas SigmaPoints includes both covariances and means.",
"valid_values": ["CovariancesOnly", "SigmaPoints"]
}
}
}
6 changes: 3 additions & 3 deletions models/matlab/FES/FES_wrap.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
% saliency model in the common SMILER format. If you use results produced
% by this model, please cite
% the following paper:
% Tavakoli, Hamed Rezazadegan, Esa Rahtu, and Janne Heikkilä. "Fast and
% efficient saliency detection using sparse sampling and kernel
% Tavakoli, Hamed Rezazadegan, Esa Rahtu, and Janne Heikkilä. "Fast and
% efficient saliency detection using sparse sampling and kernel
% density estimation." In Scandinavian Conference on Image Analysis,
% pp. 666-675. Springer, Berlin, Heidelberg, 2011.
%
Expand Down Expand Up @@ -34,7 +34,7 @@
params = checkCommonParams(in_params);

% get the path to smiler.json
pathroot = mfilename('fullpath');
pathroot = mfilename('fullpath');
[pathroot, ~, ~] = fileparts(pathroot);

% check the model-specific parameter fields
Expand Down
12 changes: 5 additions & 7 deletions models/matlab/FES/computeFinalSaliency.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function saliency = computeFinalSaliency(img, pScale, sScale, alpha, sigma0, sigma1, p1)
% function saliency = computeFinalSaliency(image, pScale, sScale, alpha, sigma0, sigma1, p1)
%
% compute multi scale saliency over an image
% compute multi scale saliency over an image
%
% @input
% img - a given image to process
Expand All @@ -14,15 +14,15 @@
% p1 - P(1|x) [128x171 matrix]
% @output
% saliency - saliency of inputed image
%
%
% please refer to the following paper for details
% Rezazadegan Tavakoli H, Rahtu E & Heikkil? J,
% Rezazadegan Tavakoli H, Rahtu E & Heikkil? J,
% "Fast and efficient saliency detection using sparse sampling and kernel density estimation."
% Proc. Scandinavian Conference on Image Analysis (SCIA 2011), 2011, Ystad, Sweden.
%
% The code has been tested on Matlab 2010a (32-bit) running windows.
% The code has been tested on Matlab 2010a (32-bit) running windows.
% This code is publicly available for demonstration and educational
% purposes, any commercial use without permission is strictly prohibited.
% purposes, any commercial use without permission is strictly prohibited.
%
% Please contact the author in case of any questions, comments, or Bug
% reports
Expand Down Expand Up @@ -57,5 +57,3 @@

saliency = mean(saliency, 3);
saliency = (saliency - min(saliency(:))) / (max(saliency(:)) - min(saliency(:)));


1 change: 1 addition & 0 deletions models/matlab/GBVS/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
util/mypath.mat
8 changes: 4 additions & 4 deletions models/matlab/GBVS/GBVS_wrap.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% GBVS_wrap executes the Graph-Based Visual Saliency (GBVS) model in the
% SMILER format. If you use results produced by this model, please cite
% SMILER format. If you use results produced by this model, please cite
% the following paper:
% J. Harel, C. Koch, and P. Perona (2006). Graph-Based Visual Saliency.
% Proc. Neural Information Processing Systems (NIPS)
Expand Down Expand Up @@ -39,7 +39,7 @@
params = checkCommonParams(in_params);

% get the path to smiler.json
pathroot = mfilename('fullpath');
pathroot = mfilename('fullpath');
[pathroot, ~, ~] = fileparts(pathroot);

% check the model-specific parameter fields
Expand Down Expand Up @@ -77,7 +77,7 @@
params.channels = strrep(params.channels, 'C', 'D');
end
params.dklcolorWeight = params.colorWeight;

%% Reading the image
img = checkImgInput(input_image, params.color_space);

Expand All @@ -87,4 +87,4 @@
salmap = out.master_map_resized;

% do any final post-processing as specified by the parameters
salmap = fmtOutput(salmap, params);
salmap = fmtOutput(salmap, params);
34 changes: 17 additions & 17 deletions models/matlab/GBVS/gbvs.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function [out,motionInfo] = gbvs(img,param,prevMotionInfo)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% This computes the GBVS map for an image and puts it in master_map. %
% %
% If this image is part of a video sequence, motionInfo needs to be recycled in a %
Expand All @@ -24,7 +24,7 @@
% Jonathan Harel, Last Revised Aug 2008. [email protected] %
%
% ** Code modified from the original source code as part of SMILER
% All effort has been made to preserve original functionality while
% All effort has been made to preserve original functionality while
% bringing code execution into a common format. **
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand All @@ -36,7 +36,7 @@
end

if ( (nargin < 2) || (~exist('param')) || isempty(param) )
param = makeGBVSParams();
param = makeGBVSParams();
end
[grframe,param] = initGBVS(param,size(img));

Expand All @@ -49,15 +49,15 @@
mymessage(param,'NOTE: Computing STANDARD Itti/Koch instead of Graph-Based Visual Saliency (GBVS)\n\n');
end

%%%%
%%%%
%%%% STEP 1 : compute raw feature maps from image
%%%%

mymessage(param,'computing feature maps...\n');
if ( size(img,3) == 3 ) imgcolortype = 1; else, imgcolortype = 2; end
[rawfeatmaps motionInfo] = getFeatureMaps( img , param , prevMotionInfo );

%%%%
%%%%
%%%% STEP 2 : compute activation maps from feature maps
%%%%

Expand All @@ -74,7 +74,7 @@
map_types{fmapi} = mapsobj.description;
for typei = 1 : numtypes
if ( param.activationType == 1 )
for lev = param.levels
for lev = param.levels
mymessage(param,'making a graph-based activation (%s) feature map.\n',mapnames{fmapi});
i = i + 1;
[allmaps{i}.map,tmp] = graphsalapply( mapsobj.maps.val{typei}{lev} , ...
Expand All @@ -85,10 +85,10 @@
for centerLevel = param.ittiCenterLevels
for deltaLevel = param.ittiDeltaLevels
mymessage(param,'making a itti-style activation (%s) feature map using center-surround subtraction.\n',mapnames{fmapi});
i = i + 1;
i = i + 1;
center_ = mapsobj.maps.origval{typei}{centerLevel};
sz_ = size(center_);
surround_ = imresize( mapsobj.maps.origval{typei}{centerLevel+deltaLevel}, sz_ , 'bicubic' );
surround_ = imresize( mapsobj.maps.origval{typei}{centerLevel+deltaLevel}, sz_ , 'bicubic' );
allmaps{i}.map = (center_ - surround_).^2;
allmaps{i}.maptype = [ fmapi centerLevel deltaLevel ];
end
Expand All @@ -97,8 +97,8 @@
end
end

%%%%

%%%%
%%%% STEP 3 : normalize activation maps
%%%%

Expand All @@ -109,19 +109,19 @@
if ( param.normalizationType == 1 )
mymessage(param,' using fast raise to power scheme\n ', i);
algtype = 4;
[norm_maps{i}.map,tmp] = graphsalapply( allmaps{i}.map , grframe, param.sigma_frac_norm, param.num_norm_iters, algtype , param.tol );
[norm_maps{i}.map,tmp] = graphsalapply( allmaps{i}.map , grframe, param.sigma_frac_norm, param.num_norm_iters, algtype , param.tol );
elseif ( param.normalizationType == 2 )
mymessage(param,' using graph-based scheme\n');
algtype = 1;
[norm_maps{i}.map,tmp] = graphsalapply( allmaps{i}.map , grframe, param.sigma_frac_norm, param.num_norm_iters, algtype , param.tol );
[norm_maps{i}.map,tmp] = graphsalapply( allmaps{i}.map , grframe, param.sigma_frac_norm, param.num_norm_iters, algtype , param.tol );
else
mymessage(param,' using global - mean local maxima scheme.\n');
norm_maps{i}.map = maxNormalizeStdGBVS( mat2gray(imresize(allmaps{i}.map,param.salmapsize, 'bicubic')) );
end
norm_maps{i}.maptype = allmaps{i}.maptype;
end

%%%%
%%%%
%%%% STEP 4 : average across maps within each feature channel
%%%%

Expand All @@ -139,7 +139,7 @@
end
%%% divide each feature channel by number of maps in that channel
for fmapi = 1 : length(mapnames)
if ( param.normalizeTopChannelMaps)
if ( param.normalizeTopChannelMaps)
mymessage(param,'Performing additional top-level feature map normalization.\n');
if ( param.normalizationType == 1 )
algtype = 4;
Expand All @@ -154,7 +154,7 @@
comb_norm_maps{fmapi} = cmaps{fmapi};
end

%%%%
%%%%
%%%% STEP 5 : sum across feature channels
%%%%

Expand Down Expand Up @@ -185,7 +185,7 @@
master_map = mat2gray(master_map);
end

if ( param.unCenterBias )
if ( param.unCenterBias )
invCB = load('invCenterBias');
invCB = invCB.invCenterBias;
centerNewWeight = 0.5;
Expand All @@ -195,7 +195,7 @@
master_map = mat2gray(master_map);
end

%%%%
%%%%
%%%% save descriptive, rescaled (0-255) output for user
%%%%

Expand Down
8 changes: 4 additions & 4 deletions models/matlab/GBVS/saltoolbox/makeGaborFilterGBVS.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

% This file is part of the Saliency Toolbox - Copyright (C) 2006
% by Dirk Walther and the California Institute of Technology.
% The Saliency Toolbox is released under the GNU General Public
% License. See the enclosed COPYRIGHT document for details.
% For more information about this project see:
% The Saliency Toolbox is released under the GNU General Public
% License. See the enclosed COPYRIGHT document for details.
% For more information about this project see:
% http:https://www.saliencytoolbox.net

if isempty(varargin)
Expand All @@ -40,7 +40,7 @@
if (sz == -1)
sz = ceil(max_stddev*sqrt(10));
else
sz = floor(sz/2);
sz = floor(sz/2);
end

psi = pi / 180 * phase;
Expand Down
Loading

0 comments on commit e30ab79

Please sign in to comment.