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.
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-2007 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 for ori = 1:length(salParams.oriAngles) 0060 pyrs(ori) = makeOrientationPyramid(intPyr,... 0061 salParams.gaborParams,salParams.oriAngles(ori)); 0062 end 0063 0064 case 'Hue' 0065 % varargin{1} must contain the hueParams 0066 if (isempty(varargin)) 0067 fatal('varargin{1} must contain hueParams for Hue Channel'); 0068 end 0069 % varargin{2} might contain an alternative label 0070 if (length(varargin >= 2)) 0071 pyrs = makeHuePyramid(img,salParams.pyramidType,varargin{1},varargin{2}); 0072 else 0073 pyrs = makeHuePyramid(img,salParams.pyramidType,varargin{1}); 0074 end 0075 0076 case 'Skin' 0077 pyrs = makeHuePyramid(img,salParams.pyramidType,skinHueParams,'Skin'); 0078 0079 case 'TopDown' 0080 if isempty(varargin) 0081 fatal('varargin{1} must contain a vector of TopDown maps'); 0082 end 0083 % this is a dummy function that simply copies the auxiliary pyramids 0084 pyrs = varargin{1}; 0085 0086 otherwise 0087 fatal(['Unknown feature: ' featureType]); 0088 end