function rgb = rgb_uniform_noise ( rgb, level )

%*****************************************************************************80
%
%% RGB_UNIFORM_NOISE adds uniform noise to an RGB image.
%
%  Discussion:
%
%    This function creates noise in the R, G and B channels independently.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    17 March 2017
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, uint8 RGB(:,:,3), the image.
%
%    Input, real LEVEL, the level of noise to add, between 0.0 (none)
%    and 1.0 (all).
%
%    Output, uint8 RGB(:,:,3), the image with added noise.  A fraction of
%    about LEVEL of the values in the RGB array have been reset.
%
  [ m, n, k ] = size ( rgb );

  r = rand ( m, n, k );

  i = find ( r <= level );
  n2 = length ( i );
  rgb ( i ) = randi ( [ 0, 255 ], n2, 1 );

  return
end
