function maple_boundary_test ( )

%*****************************************************************************80
%
%% maple_boundary_test() tests maple_boundary().
%
%  Discussion:
%
%    For a discussion of quasirandom sampling, Brian Hayes published a 
%    picture of a maple leaf and considered how its area could be
%    estimated using a regular grid of points, random sampling, or
%    quasirandom sampling.
%
%    For various reasons, it will be interesting to have a copy of this
%    maple leaf image accessible.  The MAPLE_BOUNDARY functions use various
%    MATLAB procedures to turn the maple leaf image into a polygonal
%    curve definining the boundary, following which various calculations
%    may be made.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 February 2019
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Brian Hayes,
%    Quasirandom Ramblings,
%    American Scientist,
%    Volume 99, Number 4, July-August 2011, pages 282-287.
%
  addpath ( '../maple_boundary' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'maple_boundary_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  maple_boundary() determines the boundary of the image\n' );
  fprintf ( 1, '  of a maple leaf.\n' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Test CANCELLED!\n' );
  fprintf ( 1, '  It requires the Image Processing Toolbox.\n' );
  return
%
%  B is a list of points constituting the polygonal boundary of a white
%  object on a black background.
%
  [ b, p_m, p_n ] = maple_boundary ( 'maple_bw.png' );
 
  [ b_m, b_n ] = size ( b );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Polygonal boundary involves %d vertices.\n', b_m );
%
%  For some reason, our data has reversed the X coordinate 
%  from the picture.  Unreverse it.
%
  b(:,1) = p_m + 1 - b(:,1);
  fprintf ( 1, '\n' );
  fprintf ( 1, '  b(:,1)=%d+1- b(:,1)) corrects reflected X coordinates.\n', p_m );
%
%  Display the boundary b.
%
  maple_boundary_plot ( b );
%
%  Display the boundary vertices.
%
  maple_boundary_vertex_plot ( b );
%
%  Save the boundary information to a file.
%
  filename = 'maple_boundary.txt';
  i4mat_transpose_write ( filename, b_m, b_n, b );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Boundary vertices written to file "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'maple_boundary_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../maple_boundary' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

