function im2 = ipsubsample2(im,rowfact,colfact,rowoff,coloff)
% function im2 = ipsubsample2(im,rowfact,colfact,rowoff,coloff)
% This function subsamples the input image im and returns image im2.
%
% The origin is top left corner. Remember Matlab indexes start from 1.
% No checks are made
%
% im -  input image
% rowfactor - row subsampling factor (default 2)
% colfactor - column subsampling factor (default 2)
% rowoffset - row offset (default 0)
% coloffset - column offset (default 0)
 
  if nargin < 2
        rowfact = 2;
  end
  if nargin < 3
        colfact = rowfact;
  end
  if nargin < 4
        rowoff = 0;
  end
  if nargin < 5
        coloff = rowoff;
  end
 
  [r,c] = size(im);
  im2 = im((rowoff + 1):rowfact:r,(coloff+1):colfact:c); 
