You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: subsamplergb.m
    path of file: ./repos/matImage/matImage/imFilters
    
    the code of the file until where you have to start completion: function res = subsamplergb(src, scale)
%SUBSAMPLERGB Return a sub-sampled version of an rgb image.
%
%   TAB2 = subsamplergb(TAB, N);
%   Returns matrix of dimension size(TAB)/N. Each value of result is the
%   max value of corresponding area in the input image.
%
%   Example:
%   TAB2 = subsamplergb(TAB, 4);
%   will return new array containing:
%   [max(TAB(1:4)) max(TAB(5:8)) ... ]
%   
%   N can also be an array of dimension size(TAB), then it is possible to
%   specify different subsampling in each direction. 
%
%   TODO: Future versions should provide more possibilities for filter 
%   function: mean, median, k-order ...
%   TODO: manage 3D RGB images
%
%   See also:
%     subsample, blkproc
%

%   ---------
%   author : David Legland 
%   INRA - TPV URPOI - BIA IMASTE
%   created the 10/09/2003.

    
function res = subsamplergb(src, scale)
%SUBSAMPLERGB Return a sub-sampled version of an rgb image.
%
%   TAB2 = subsamplergb(TAB, N);
%   Returns matrix of dimension size(TAB)/N. Each value of result is the
%   max value of corresponding area in the input image.
%
%   Example:
%   TAB2 = subsamplergb(TAB, 4);
%   will return new array containing:
%   [max(TAB(1:4)) max(TAB(5:8)) ... ]
%   
%   N can also be an array of dimension size(TAB), then it is possible to
%   specify different subsampling in each direction. 
%
%   TODO: Future versions should provide more possibilities for filter 
%   function: mean, median, k-order ...
%   TODO: manage 3D RGB images
%
%   See also:
%     subsample, blkproc
%

%   ---------
%   author : David Legland 
%   INRA - TPV URPOI - BIA IMASTE
%   created the 10/09/2003.
%

%   HISTORY
%   06/05/2009 return image with same class as input image
%   23/07/2009 update doc 


dim = size(src);
if length(scale) == 1
    scale = ones(2, 1) * scale;
end