function I = image_normalize ( filename, h, w );

%*****************************************************************************80
%
%% image_normalize() reads an image from a file, returns normalized gray version.
%
%  Discussion:
%
%    If necessary, the image is converted to gray scale.
%
%    The image is resized to H pixels high and W pixels wide.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 December 2018
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string FILENAME, the name of the file containing the image.
%
%    integer H, W, the desired height and width of the output array.
%
%  Output:
%
%    uint8 I(H,W), the image.
%
  I = imread ( filename );
%
%   If not a grayscale image, convert it.
%
  if ( 1 < size ( I, 3 ) )
    I = rgb2gray ( I );
  end
%
%  Resize the image to a standard.
%
  I = imresize ( I, [ h, w ] );

  return
end
 
