function [imagelist, images, points] = make_elliptic_bumps(n_images, image_width, save_bumps, format, base_height, position_freedom, height_variation, width_variation)
% MAKE_ELLIPTIC_BUMPS: Genrates examples of elliptic 1-D images.
%
%    GENERAL
%
%      
%
%    INPUT/S
%
%      -n_images:
%           The number of images to generate.
%
%      -image_width:
%           The width of the 1-D images to be created.
%           
%    OUTPUT/S
%
%      -imagelist:
%           The list of the images generated.
%
%      -images:
%           The images generated.
%
%      -points:
%           The (control) points of the images genearted.
%
%    PENDING WORK
%
%      -
%
%    KNOWN BUG/S
%
%      -
%
%    COMMENT/S
%
%      -
%
%    RELATED FUNCTION/S
%
%      MAKE_1D_IMAGES, MAKE_1D_BUMP
%
%    ABOUT
%
%      -Created:     April 9th , 2004
%      -Last update: April 9th , 2004
%      -Revision:    0.0.7
%      -Author:      R. S. Schestowitz, University of Manchester
% ==============================================================

unwarped_points = (1:image_width)'; 
          % get original unwarped points from the input -- diagonal line
          
images_temp = zeros([image_width n_images]);          
images = zeros([image_width n_images]); 
          % set a bunch of black images of appropriate size,
          % the equivalent of making flat asymptotic curves
          
points = unwarped_points(:,ones(n_images,1));
          % duplicate points to fit number of images 

e = rand;
          % a formulation parameter for the ellipse

for i = 1:n_images,
              % for all images
     
	%   x0 = rand / 4;
	%   width = rand / 4;
	%      % 0-0.25
	%      e = rand;
	%         % set the current height       
	%   for j = ceil((x0 * image_width) + 1):floor((x0 + (width / 2)) * image_width),
	%     images(j,i) = e * sqrt(image_width.^2 - j.^2);
	%   end
	%

	x0 = ceil ((rand * position_freedom / 4) * image_width + 2);
	
	width_factor = (rand * width_variation + 3) ;
	
	height = base_height + rand / 2 * height_variation;
	
	width = image_width / width_factor;
	
	for x = - width:1: width,
      images_temp(x + width + 1, i) = e * sqrt(width.^2 - x.^2);
	end
	
	for j = x0:(width * 2 + 1) + x0,
        images(j,i) = images_temp (j - x0 + 1, i);
	end   
	
	images(:,i) = normalise_to_bounds(images(:,i), 0, height);
	
% plot(images);
  filename = ['data' num2str(i) '.' format]; 
          % set name of file
  if (save_bumps == 1),     
     imwrite(images(:,i), filename, format);
  end   
          % write file
  imagelist{i} = filename;
          % save in list of images
end