Home > SaliencyToolbox > makeSqrt2Pyramid.m

makeSqrt2Pyramid

PURPOSE ^

makeSqrt2Pyramid - creates a sqrt(2) Gaussian pyramid.

SYNOPSIS ^

function pyr = makeSqrt2Pyramid(map,varargin)

DESCRIPTION ^

 makeSqrt2Pyramid - creates a sqrt(2) Gaussian pyramid.

 pyr = makeSqrt2Pyramid(map)
    Creates a Gaussian pyramid with levels separated by a 
    factor of sqrt(2) by bilinear interpolation between 
    levels of a dyadic Gaussian pyramid.

 pyr = makeSqrt2Pyramid(map,depth)
    Creates at most depth levels.

 See also makeDyadicPyramid, mexGaussianSubsample, makeGaussianPyramid, dataStructures.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % makeSqrt2Pyramid - creates a sqrt(2) Gaussian pyramid.
0002 %
0003 % pyr = makeSqrt2Pyramid(map)
0004 %    Creates a Gaussian pyramid with levels separated by a
0005 %    factor of sqrt(2) by bilinear interpolation between
0006 %    levels of a dyadic Gaussian pyramid.
0007 %
0008 % pyr = makeSqrt2Pyramid(map,depth)
0009 %    Creates at most depth levels.
0010 %
0011 % See also makeDyadicPyramid, mexGaussianSubsample, makeGaussianPyramid, dataStructures.
0012 
0013 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2013
0014 % by Dirk B. Walther and the California Institute of Technology.
0015 % See the enclosed LICENSE.TXT document for the license agreement.
0016 % More information about this project is available at:
0017 % http://www.saliencytoolbox.net
0018 
0019 function pyr = makeSqrt2Pyramid(map,varargin)
0020 
0021 if (isempty(varargin)) depth = -1;
0022 else depth = varargin{1}; end
0023 
0024 lab = map.label;
0025 
0026 pyr.origImage = map.origImage;
0027 pyr.label = lab;
0028 pyr.type = 'sqrt2';
0029 map.label = [lab '-1'];
0030 map.parameters.type = 'sqrt2';
0031 
0032 pyr.levels(1) = map;
0033 
0034 method = 'bilinear';
0035 
0036 n = 1;
0037 while (min(size(pyr.levels(n).data)) > 1)
0038   if ((depth > 0) & (n >= depth)) break; end
0039   
0040   n = n + 1;
0041   
0042   newMap = [];
0043   newMap.origImage = map.origImage;
0044   newMap.label = sprintf('%s-%d',lab,n);
0045   
0046   if (mod(n,2) == 0)
0047     
0048     % even levels: interpolate from previous level
0049     prev = pyr.levels(n-1).data;
0050     if (min(size(prev)) <= 4)
0051       method = 'nearest';
0052     end
0053     newMap.data = imresize(prev,round(size(prev)/sqrt(2)),method);
0054   else
0055     
0056     % odd levels: dyadic subsampling from the level two back
0057     newMap.data = gaussianSubsample(pyr.levels(n-2).data);
0058   end
0059   
0060   newMap.date = clock;
0061   newMap.parameters.type = 'sqrt2';
0062   pyr.levels(n) = newMap;
0063 end
0064 
0065 pyr.date = clock;

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