Home > SaliencyToolbox > makeSaliencyMap.m

makeSaliencyMap

PURPOSE ^

makeSaliencyMap - creates a saliency map for an image.

SYNOPSIS ^

function [salmap, saliencyData] = makeSaliencyMap(img, salParams, varargin)

DESCRIPTION ^

 makeSaliencyMap - creates a saliency map for an image.

 [salmap, saliencyData] = makeSaliencyMap(img, salParams, varargin)
    Creates a saliency map for img according to salParams.
       img: Image structure for the input image.
       salParams: the saliency parameters structure
       varargin: additional data needed by individual channels.
          Currently, varargin may hold a vector of auxiliary pyramids
          used for TopDown attention.

       salmap: a map structure containing the saliency map
       saliencyData: a vector of structures for each feature with 
                     additional information with the fields:
          origImage: Image structure of the input image.
          label: the feature name.
          pyr: a vector of pyramids for this feature.
          FM: a vector of feature maps.
          csLevels: the center and surround levels used to
                    compute the feature maps.
          CM: the conspicuity map for this feature.
          date: the time and date when this structure was created.

 See also runSaliency, batchSaliency, estimateShape, defaultSaliencyParams,
          initializeImage, dataStructures.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % makeSaliencyMap - creates a saliency map for an image.
0002 %
0003 % [salmap, saliencyData] = makeSaliencyMap(img, salParams, varargin)
0004 %    Creates a saliency map for img according to salParams.
0005 %       img: Image structure for the input image.
0006 %       salParams: the saliency parameters structure
0007 %       varargin: additional data needed by individual channels.
0008 %          Currently, varargin may hold a vector of auxiliary pyramids
0009 %          used for TopDown attention.
0010 %
0011 %       salmap: a map structure containing the saliency map
0012 %       saliencyData: a vector of structures for each feature with
0013 %                     additional information with the fields:
0014 %          origImage: Image structure of the input image.
0015 %          label: the feature name.
0016 %          pyr: a vector of pyramids for this feature.
0017 %          FM: a vector of feature maps.
0018 %          csLevels: the center and surround levels used to
0019 %                    compute the feature maps.
0020 %          CM: the conspicuity map for this feature.
0021 %          date: the time and date when this structure was created.
0022 %
0023 % See also runSaliency, batchSaliency, estimateShape, defaultSaliencyParams,
0024 %          initializeImage, dataStructures.
0025 
0026 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2013
0027 % by Dirk B. Walther and the California Institute of Technology.
0028 % See the enclosed LICENSE.TXT document for the license agreement.
0029 % More information about this project is available at:
0030 % http://www.saliencytoolbox.net
0031 
0032 function [salmap, saliencyData] = makeSaliencyMap(img, salParams, varargin)
0033 
0034 % ensure that salParams.features is a cell array
0035 if ischar(salParams.features)
0036   salParams.features = {salParam.features};
0037 end
0038 numFeat = length(salParams.features);
0039 
0040 % loop over all requested features
0041 for f = 1:numFeat
0042   saliencyData(f).origImage = img;
0043   saliencyData(f).label = salParams.features{f};
0044   
0045   if (strcmp('Orientation',salParams.features{f}))   
0046      
0047     % for orientation computation, see if we already have an
0048     % intensity pyramid that we can borrow to make things faster
0049     idx = strmatch('Intensity',{saliencyData(1:f-1).label});
0050     if isempty(idx)
0051       % found no intensity pyramid
0052       saliencyData(f).pyr = makeFeaturePyramids(img,salParams.features{f},...
0053                               salParams)
0054     else
0055       % found an intensity pyramid - hand it over to be used for orientation filtering
0056       saliencyData(f).pyr = makeFeaturePyramids(img,salParams.features{f},...
0057                               salParams,saliencyData(idx(1)).pyr(1));
0058     end
0059   else
0060 
0061     % for all other features: call with the auxiliary data in varargin
0062     saliencyData(f).pyr = makeFeaturePyramids(img,salParams.features{f},salParams,varargin{:});
0063   end
0064   
0065   combFM = [];
0066   numPyr = length(saliencyData(f).pyr);
0067   
0068   % center-surround contrasts for all pyramids
0069   for p = 1:numPyr
0070     if (strcmp('TopDown',salParams.features{f}))
0071       
0072       % special version of centerSurround for TopDown
0073       [FM,csLevels] = centerSurroundTopDown(saliencyData(f).pyr(p),salParams);
0074     else
0075       
0076       % Plain vanilla version for everything else
0077       [FM,csLevels] = centerSurround(saliencyData(f).pyr(p),salParams);
0078     end
0079     
0080     saliencyData(f).FM(p,:) = maxNormalize(FM,salParams,[0,10]);
0081     saliencyData(f).csLevels(p,:) = csLevels;
0082     
0083     % combine the feature maps over all scales
0084     combFM = [combFM combineMaps(saliencyData(f).FM(p,:),...
0085                                  [salParams.features{f} 'CM'])];
0086   end
0087   
0088   % normalize the combined feature maps
0089   combFM = maxNormalize(combFM,salParams,[0,0]);
0090   
0091   % compute conspicuity maps over all sub-features
0092   if (numPyr == 1)
0093     saliencyData(f).CM = combFM;
0094   else
0095     % more than 1 sub-feature: additional normalization step
0096     saliencyData(f).CM = maxNormalize(combineMaps(combFM,[salParams.features{f} 'CM']),...
0097                                       salParams,[0,0]);
0098   end
0099     
0100   % weigh the conspicuity map appropriately
0101   saliencyData(f).CM.data = salParams.weights(f) * saliencyData(f).CM.data / numPyr / numFeat;  
0102   saliencyData(f).date = clock;
0103 end % end loop over features
0104 
0105 % compute the saliency map by combining all the conspicuity maps
0106 salmap = combineMaps([saliencyData.CM],'SaliencyMap');
0107 salmap = maxNormalize(salmap,salParams,[0,2]);
0108 salmap.parameters = salParams;

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