function [YPyr_reg, YPyr_class] = ...
   ToyotaFeature_ApplyModelToImage_AllScales(InImage,Model,resolution,scalestep,ImgRange,N)
%function [YPyr_reg, YPer_class] = ...
%   ToyotaFeature_ApplyModelToImage_AllScales(InImage,Model,resolution,scalestep,ImgRange,N)
%
if(length(resolution) == 1), resolution = [resolution,resolution];, end
if(nargin < 4)
  scalestep =  1/(sqrt(2));
end
if(nargin < 5)
  ImgRange =  1;
end

newsize = floor(size(InImage) * scalestep);
n = 1;
while((newsize(1) > resolution(1) * 4)&&(newsize(2) > resolution(2) * 4))
   ImPyr{n} = imresize(InImage,newsize(1:2),'bilinear');
   n = n+1;
   newsize = floor(size(InImage) * (scalestep^n));
end
nLayers = size(ImPyr,2);
for i = 1:nLayers
  fprintf('scale %d of %d\n',i,nLayers');
  if(exist('N'))
    [YPyr_reg{i}, YPyr_class{i}] = ToyotaFeature_ApplyModelToImage(ImPyr{i},Model,resolution,ImgRange,N);
  else
    [YPyr_reg{i}, YPyr_class{i}] = ToyotaFeature_ApplyModelToImage(ImPyr{i},Model,resolution,ImgRange);
  end  
end  
