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: rgbConvert.m
    path of file: ./repos/toolbox/channels
    
    the code of the file until where you have to start completion: function J = rgbConvert( I, colorSpace, useSingle )
% Convert RGB image to other color spaces (highly optimized).
%
% If colorSpace=='gray' transforms I to grayscale. The output is within
% numerical error of Matlab's rgb2gray, except ~10x faster. The output in
% this case is hxwx1, and while the input must be hxwx3 for all other
% cases, the input for this case can also be hxwx1 (normalization only).
%
% If colorSpace=='hsv' transforms I to the HSV color space. The output is
% within numerical error of Matlab's rgb2hsv, except ~15x faster.
%
% If colorSpace=='rgb' or colorSpace='orig' only normalizes I to be in the
% range [0,1]. In this case both the input and output may have an arbitrary
% number of channels (that is I may be [hxwxd] for any d).
%
% If colorSpace=='luv' transforms I to the LUV color space. The LUV color
% space is "perceptually uniform" (meaning that two colors equally distant
% in the color space according to the Euclidean metric are equally distant
% perceptually). The L,u,v channels correspond roughly to luminance,
% green-red, blue-yellow. For more information see:

    
function J = rgbConvert( I, colorSpace, useSingle )
% Convert RGB image to other color spaces (highly optimized).
%
% If colorSpace=='gray' transforms I to grayscale. The output is within
% numerical error of Matlab's rgb2gray, except ~10x faster. The output in
% this case is hxwx1, and while the input must be hxwx3 for all other
% cases, the input for this case can also be hxwx1 (normalization only).
%
% If colorSpace=='hsv' transforms I to the HSV color space. The output is
% within numerical error of Matlab's rgb2hsv, except ~15x faster.
%
% If colorSpace=='rgb' or colorSpace='orig' only normalizes I to be in the
% range [0,1]. In this case both the input and output may have an arbitrary
% number of channels (that is I may be [hxwxd] for any d).
%
% If colorSpace=='luv' transforms I to the LUV color space. The LUV color
% space is "perceptually uniform" (meaning that two colors equally distant
% in the color space according to the Euclidean metric are equally distant
% perceptually). The L,u,v channels correspond roughly to luminance,
% green-red, blue-yellow. For more information see:
%   http://en.wikipedia.org/wiki/CIELUV - using this color spaces
%   http://en.wikipedia.org/wiki/CIELAB - more info about color spaces
% The LUV channels are normalized to fall in ~[0,1]. Without normalization
% the ranges are L~[0,100], u~[-88,182], and v~[-134,105] (and typically
% u,v~[-100,100]). The applied transformation is L=L/270, u=(u+88)/270, and
% v=(v+134)/270. This results in ranges L~[0,.37], u~[0,1], and v~[0,.89].
% Perceptual uniformity is maintained since divisor is constant
% (normalizing each color channel independ