Home > SaliencyToolbox > makeFeaturePyramids.m

makeFeaturePyramids

PURPOSE ^

makeFeaturePyramids - creates a pyramid for featureType.

SYNOPSIS ^

function pyrs = makeFeaturePyramids(img,featureType,salParams,varargin)

DESCRIPTION ^

 makeFeaturePyramids - creates a pyramid for featureType.

 pyrs = makeFeaturePyramids(img,featureType,salParams,varargin)
    Creates a feature pyramid with the parameters:
      img: the Image structure for the source image.
      featureType: what feature ('Intensity','Color','Orientation',
                  'Hue','Skin','TopDown');
      salParams: the saliency parameters for this operation;
      varargin: additional info, depending on the featureType:
        'Orientation': varargin{1} may hold an auxiliary 
                       intensity pyramid;
        'TopDown': varargin{1} must hold a vector of auxiliary 
                   maps for top-down attention;
        'Hue': varargin{1} must contain hueParams.

    pyrs: a vector of pyramids of type featureType.

 See also makeSaliencyMap, dataStructures.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % makeFeaturePyramids - creates a pyramid for featureType.
0002 %
0003 % pyrs = makeFeaturePyramids(img,featureType,salParams,varargin)
0004 %    Creates a feature pyramid with the parameters:
0005 %      img: the Image structure for the source image.
0006 %      featureType: what feature ('Intensity','Color','Orientation',
0007 %                  'Hue','Skin','TopDown');
0008 %      salParams: the saliency parameters for this operation;
0009 %      varargin: additional info, depending on the featureType:
0010 %        'Orientation': varargin{1} may hold an auxiliary
0011 %                       intensity pyramid;
0012 %        'TopDown': varargin{1} must hold a vector of auxiliary
0013 %                   maps for top-down attention;
0014 %        'Hue': varargin{1} must contain hueParams.
0015 %
0016 %    pyrs: a vector of pyramids of type featureType.
0017 %
0018 % See also makeSaliencyMap, dataStructures.
0019 
0020 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2013
0021 % by Dirk B. Walther and the California Institute of Technology.
0022 % See the enclosed LICENSE.TXT document for the license agreement.
0023 % More information about this project is available at:
0024 % http://www.saliencytoolbox.net
0025 
0026 function pyrs = makeFeaturePyramids(img,featureType,salParams,varargin)
0027 
0028 % These feature types require color images:
0029 colorTypes = {'Color','Hue','Skin'};
0030 if (ismember(featureType,colorTypes) && img.dims == 2)
0031   % not a color image for color type? terminate with error
0032   fprintf(['Feature ''' featureType ''' requires a color image!\n' ...
0033            'Use a color image or remove this feature from the\n' ...
0034            'saliency parameters!\n']);
0035   error('Could not process image.');
0036 end
0037 
0038 switch featureType
0039   
0040   case {'Intensity','Intensities'}
0041     pyrs = makeIntensityPyramid(img,salParams.pyramidType);
0042 
0043   case 'Color'
0044     pyrs(1) = makeRedGreenPyramid(img,salParams.pyramidType);
0045     pyrs(2) = makeBlueYellowPyramid(img,salParams.pyramidType);
0046 
0047   case {'Orientation','Orientations'}
0048     % varargin{1} could be an intensity pyramid, otherwise have to make one
0049     intPyr = [];
0050     if (~isempty(varargin))
0051       if (strcmp('Intensity',varargin{1}.label))
0052         intPyr = varargin{1};
0053       end
0054     end
0055     if (isempty(intPyr))
0056       intPyr = makeIntensityPyramid(img,salParams.pyramidType);
0057     end
0058 
0059     if isfield(salParams,'oriComputeMode')
0060       switch salParams.oriComputeMode
0061         case 'efficient'
0062           oriLevels = salParams.levelParams.minLevel:...
0063                       min(salParams.levelParams.maxLevel + salParams.levelParams.maxDelta,length(intPyr.levels));
0064           oriLevels = union(oriLevels,salParams.levelParams.mapLevel);
0065         case 'full'
0066           oriLevels = 1:length(intPyr.levels);
0067         otherwise
0068           error(['Unknown oriComputeMode: ' salParams.oriComputeMode]);
0069       end
0070     else
0071       oriLevels = 1:length(intPyr.levels);
0072     end
0073 
0074     for ori = 1:length(salParams.oriAngles)
0075       pyrs(ori) = makeOrientationPyramid(intPyr,...
0076                   salParams.gaborParams,salParams.oriAngles(ori),oriLevels);
0077     end
0078       
0079   case 'Hue'
0080     % varargin{1} must contain the hueParams
0081     if (isempty(varargin))
0082       error('varargin{1} must contain hueParams for Hue Channel');
0083     end 
0084     % varargin{2} might contain an alternative label
0085     if (length(varargin >= 2))
0086       pyrs = makeHuePyramid(img,salParams.pyramidType,varargin{1},varargin{2});
0087     else
0088       pyrs = makeHuePyramid(img,salParams.pyramidType,varargin{1});
0089     end
0090       
0091   case 'Skin'
0092     pyrs = makeHuePyramid(img,salParams.pyramidType,skinHueParams,'Skin');
0093     
0094   case 'TopDown'
0095     if isempty(varargin)
0096       error('varargin{1} must contain a vector of TopDown maps');
0097     end
0098     % this is a dummy function that simply copies the auxiliary pyramids
0099     pyrs = varargin{1};
0100       
0101   otherwise
0102     error(['Unknown feature: ' featureType]);
0103 end

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