function cloud_test ( )

%*****************************************************************************80
%
%% CLOUD_TEST tests IMAGE_BOUNDARY on the "cloud" file.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    02 August 2015
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Alessandra Agostini, Chiara Piazzola,
%    Mesh Generation with FreeFem++ and Triangle,
%    Master's degree presentation,
%    University of Verona, 2014.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'CLOUD_TEST:\n' );
  fprintf ( 1, '  Apply IMAGE_BOUNDARY to an image of a cloud.\n' );

  b = image_boundary ( 'cloud.png' );

  [ m, n ] = size ( b );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Extracted pixel list has dimensions %d x %d\n', m, n );
%
%  Write the data as a MAT file.
%
  filename = 'cloud.mat';
  save ( filename, 'b' );
  fprintf ( 1, '  Boundary pixel list (i,j) saved in "%s"\n', filename );
%
%  Write the data as a TXT file.
%
  filename = 'cloud.txt';
  i4mat_write ( filename, m, n, b );
  fprintf ( 1, '  Boundary pixel list (i,j) saved in "%s"\n', filename );
%
%  Write the data as a POLY file for use by Triangle.
%
  filename = 'cloud.poly';
  boundary_to_poly ( m, b, filename );
  fprintf ( 1, '  Created the poly file "%s"\n', filename );
%
%  Write 1/40 of the data as a TXT file for use by FreeFem++.
%  Also, reverse the points so they are listed in counterclockwise order.
%  Also, make sure first point is repeated at end.
%  You still need to prepend a line listing the number of points.
%
  bfreefem = b(1:40:m,1:2);
  [ m2, ~ ] = size ( bfreefem );
  bfreefem(1:m2,1:2) = bfreefem(m2:-1:1,1:2);
  bfreefem(m2,1:2) = bfreefem(1,1:2);
  filename = 'cloud_points.txt';
  i4mat_write ( filename, m2, n, bfreefem );
  fprintf ( 1, '  Saved 1/6 of data for FreeFem++ in "%s"\n', filename );

  return
end

