function varargout = rgb2gray(varargin)
%RGB2GRAY Convert RGB gpuArray image or colormap to grayscale.
%   RGB2GRAY converts RGB gpuArray images to grayscale by eliminating the
%   hue and saturation information while retaining the
%   luminance.
%   
%   I = RGB2GRAY(RGB) converts the truecolor gpuArray image RGB to the
%   grayscale intensity image I.
%   
%   NEWMAP = RGB2GRAY(MAP) returns a grayscale colormap
%   equivalent to MAP.
%   
%   Class Support
%   -------------
%   If the input is an RGB gpuArray image, it can be uint8, uint16, double,
%   or single. The output gpuArray image I has the same class as the input
%   image. If the input is a colormap, the input and output colormaps are
%   both of class double.
%   
%   Example
%   -------
%    
%   I = gpuArray(imread('board.tif'));
%   J = rgb2gray(I);
%   figure, imshow(I), figure, imshow(J);
%   
%    
%   [X,map] = gpuArray(imread('trees.tif'));
%   gmap = rgb2gray(map);
%   figure, imshow(X,map), figure, imshow(X,gmap);
%   
%   See also RGB2GRAY, IMSHOW, GPUARRAY.


%   Copyright 2013-2018 The MathWorks, Inc.

% try...catch prevents error being reported by internal
try
    [varargout{1:nargout}] = parallel.internal.flowthrough.rgb2gray(varargin{:});
catch ME
    throw(ME);
end
