function [imagelist,images,points, his, los] = make_1d_images(n_images, image_width, white_width)
% MAKE_1D_MODEL: Genrates examples of 1-D images.
%
% Code written by Katherine Smith, 2003
%
%    GENERAL
%
%      [imagelist,images,points, his, los] = 
%         make_1d_images(n_images, image_width, white_width)
%
%    INPUT/S
%
%      -n_images:
%           The number of images to generate.
%
%      -image_width:
%           The width of the 1-D images to be created.
%
%      -white_width:
%           The width of the white component??
%           
%    OUTPUT/S
%
%      -imagelist:
%           The list of the images generated.
%
%      -images:
%           The images generated.
%
%      -points:
%           The (control) points of the images generted.
%
%      -his:
%           The upper bound of the examples generated? IT
%           APPEARS TO BE NUMBER OF POINTS WHERE BUMP IS HIGH
%
%      -los:
%           The lower bound of the examples generated?
%
%    PENDING WORK
%
%      -Understand function better.
%      -Improve input/output documentation.
%
%    KNOWN BUG/S
%
%      -
%
%    COMMENT/S
%
%      -Some comments added 28/11/03. The notion of 'white' is
%       still not understood.
%      -Most comments are old and should be ignored (2004)
%
%    RELATED FUNCTION/S
%
%      
%
%    ABOUT
%
%      -Created:     November 23rd, 2003
%      -Last update: Novermber 28th, 2003
%      -Revision:    0.0.4
%      -Author:      R. S. Schestowitz, University of Manchester
% ==============================================================

unwarped_points = (1:image_width)'; 
          % set original unwarped points to be diagonal 1..50
          % unwarped points is then a column vector [1;2;3...]
          % size of <unwarped_points> is 50,1
images = zeros([image_width n_images]); 
          % set a bunch of black images of appropriate
          % size (rather a flat horizontal line at y=0)
points = unwarped_points(:,ones(n_images,1));
          % set points to be a copy of 
          % unwarped points but of width ten
	  for i=1:n_images 
          % for all images
%  image = zeros(image_width,1);
  white = 0.75 + (rand-0.5)*0.2; 
          % get some bright shade of white (gray)
          % range will be .75 to 0.85
%  white = 0.9;
  this_white_width = rand*(image_width/5) + white_width*image_width; 
          % get random up to 20% of image width and add to 50 times
          % white_width which is input often assigned to 0.2
          % so values of this_white_width lie between 10 and 30
  if(this_white_width > 0) 
          % if this white shade/value exists
    los(i) = floor((image_width+1)/2-this_white_width/2); 
          % set high and low value
    his(i) = ceil((image_width+1)/2+this_white_width/2);
          % Is this the half bumb which is symmetric??
    for j=los(i):his(i) 
          % within this range...
%      image(j) = white;
      images(j,i) = white;
    end
  end
  filename = ['1dim' num2str(i) '.png']; 
          % set name of file
%  imwrite(images(i,:), filename, 'png'); 
          % write file
  imagelist{i} = filename;
          % save in list of images
  %figure, plot(image);
  his = his'; 
          % returns the highs and lows in correct form
  los = los';
end