Home > SaliencyToolbox > centerSurround.m

centerSurround

PURPOSE ^

centerSurround - computes center-surround difference maps.

SYNOPSIS ^

function [featureMaps,csLevels] = centerSurround(pyr,params)

DESCRIPTION ^

 centerSurround - computes center-surround difference maps.

 [featureMaps,csLevels] = centerSurround(pyramid,salParams)
    computes the center-surround maps in the pyramid
    according to the parameters in salParams.

    featureMaps is a vector of maps with the results.
    csLevels returns the center and surround levels in
       pyramid for later reference.

 See also defaultSaliencyParams, defaultLevelParams, makeSaliencyMap,
          centerSurroundTopDown, dataStructures.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % centerSurround - computes center-surround difference maps.
0002 %
0003 % [featureMaps,csLevels] = centerSurround(pyramid,salParams)
0004 %    computes the center-surround maps in the pyramid
0005 %    according to the parameters in salParams.
0006 %
0007 %    featureMaps is a vector of maps with the results.
0008 %    csLevels returns the center and surround levels in
0009 %       pyramid for later reference.
0010 %
0011 % See also defaultSaliencyParams, defaultLevelParams, makeSaliencyMap,
0012 %          centerSurroundTopDown, dataStructures.
0013 
0014 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2013
0015 % by Dirk B. Walther and the California Institute of Technology.
0016 % See the enclosed LICENSE.TXT document for the license agreement.
0017 % More information about this project is available at:
0018 % http://www.saliencytoolbox.net
0019 
0020 function [featureMaps,csLevels] = centerSurround(pyr,params)
0021 
0022 debugMsg('',pyr);
0023 
0024 % determine a few parameters
0025 lp = params.levelParams;
0026 siz = size(pyr.levels(lp.mapLevel).data);
0027 numLevels = length(pyr.levels);
0028 
0029 % have an exclusion map?
0030 exclusionIdx = [];
0031 if isfield(params,'exclusionMask')
0032   if ~isempty(params.exclusionMask)
0033     switch class(params.exclusionMask)
0034       case 'struct'
0035         exclusionIdx = (imresize(params.exclusionMask.data,siz,'nearest') ~= 0);
0036       case {'double','uint8'}
0037         exclusionIdx = (imresize(params.exclusionMask,siz,'nearest') ~= 0);
0038       case 'logical'
0039         exclusionIdx = imresize(params.exclusionMask,siz,'nearest');
0040       otherwise
0041         error(['Unknown class type for params.exclusionMask: ' class(params.exclusionMask)]);
0042     end
0043   end
0044 end
0045 
0046 % resize everything that needs to be resized
0047 c = 1;
0048 for l = lp.minLevel:(lp.maxLevel + lp.maxDelta)
0049   if (l > numLevels) break; end
0050   maps(c).origImage = pyr.levels(l).origImage;
0051   maps(c).label = pyr.levels(l).label;
0052   maps(c).data = imresize(pyr.levels(l).data,siz,'nearest');
0053   maps(c).data(exclusionIdx) = 0;
0054   maps(c).date = clock;
0055   idx(l) = c;
0056   c = c + 1;
0057 end
0058 
0059 % compute all the c-s differences
0060 cc = 1;
0061 borderSize = round(max(siz)/20);
0062 lab = pyr.label;
0063 for l = lp.minLevel:lp.maxLevel;
0064   for d = lp.minDelta:lp.maxDelta
0065     l2 = l + d;
0066     if (l2 > numLevels) continue; end
0067     featureMaps(cc).origImage = maps(idx(l)).origImage;
0068     featureMaps(cc).label = sprintf('%s (%d-%d)',lab,l2,l);
0069     featureMaps(cc).data = attenuateBorders(abs(maps(idx(l)).data - maps(idx(l2)).data),...
0070                                             borderSize);
0071     csLevels(cc).centerLevel = l;
0072     csLevels(cc).surroundLevel = l2;
0073     featureMaps(cc).date = clock;
0074     featureMaps(cc).parameters = params;
0075     cc = cc + 1;
0076   end
0077 end

Generated on Thu 18-Jul-2013 06:10:46 by m2html © 2005