function [caYPyr_reg, caYPyr_class] = ...
   ToyotaFeature_ApplyManyModelsToImage_AllScales(InImage,caModel,resolution,scalestep,ImgRange)
%function [YPyr_reg, YPer_class] = ...
%   ToyotaFeature_ApplyModelToImage_AllScales(InImage,Model,resolution,scalestep,ImgRange)
%
%output is a double cell array, the outer cell is the resolution, the inner cell is the Model

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');
    [caYPyr_reg{i}, caYPyr_class{i}] = ToyotaFeature_ApplyManyModelsToImage(ImPyr{i},caModel,resolution,ImgRange);
end  
