============================================================== MAKE_1D_MODEL: Genrates examples of 2-D images. GENERAL [imagelist, images, points] = make_1d_images(n_images, image_width, image_height) INPUT/S -n_images: The number of images to generate. -image_width: The width of the 2-D images to be created. -image_height: The width of the 2-D images to be created. -position: The position of the structure -width: The width of the structure -height: The height of the structure -width_variation: The variation in width of the structure -height_variation: The variation in height of the structure 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: January 5th, 2003 -Last update: January 5th, 2003 -Revision: 0.0.1 -Author: R. S. Schestowitz, University of Manchester ==============================================================
0001 function [imagelist, images, points] = make_1d_bump(n_images, image_width, image_height, position, width, height, width_variation, height_variation) 0002 % ============================================================== 0003 % MAKE_1D_MODEL: Genrates examples of 2-D images. 0004 % 0005 % GENERAL 0006 % 0007 % [imagelist, images, points] = make_1d_images(n_images, image_width, image_height) 0008 % 0009 % INPUT/S 0010 % 0011 % -n_images: 0012 % The number of images to generate. 0013 % 0014 % -image_width: 0015 % The width of the 2-D images to be created. 0016 % 0017 % -image_height: 0018 % The width of the 2-D images to be created. 0019 % 0020 % -position: 0021 % The position of the structure 0022 % 0023 % -width: 0024 % The width of the structure 0025 % 0026 % -height: 0027 % The height of the structure 0028 % 0029 % -width_variation: 0030 % The variation in width of the structure 0031 % 0032 % -height_variation: 0033 % The variation in height of the structure 0034 % 0035 % 0036 % OUTPUT/S 0037 % 0038 % -imagelist: 0039 % The list of the images generated. 0040 % 0041 % -images: 0042 % The images generated. 0043 % 0044 % -points: 0045 % The (control) points of the images genearted. 0046 % 0047 % PENDING WORK 0048 % 0049 % 0050 % KNOWN BUG/S 0051 % 0052 % - 0053 % 0054 % COMMENT/S 0055 % 0056 % 0057 % RELATED FUNCTION/S 0058 % 0059 % MAKE_1D_IMAGES, MAKE_1D_BUMP 0060 % 0061 % ABOUT 0062 % 0063 % -Created: January 5th, 2003 0064 % -Last update: January 5th, 2003 0065 % -Revision: 0.0.1 0066 % -Author: R. S. Schestowitz, University of Manchester 0067 % ============================================================== 0068 0069 0070 bump_width = width; 0071 bump_width_variation = width_variation; 0072 0073 bump_height = height; 0074 bump_height_variation = height_variation; 0075 0076 bump_position_freedom = position; 0077 0078 initial_diminish_factor = 2; 0079 diminish_factor = 1.05 + (0.1 * rand * bump_width); 0080 % initialialise the parameters intenrnally for fine-tuning capabilities 0081 0082 %%%%%%%%%% CHANGE BELOW CONTROL POINTS %%%%%%%%%%%%% 0083 0084 unwarped_points = (1:image_width)'; 0085 % get original unwarped points from the input -- diagonal line 0086 0087 images = zeros([image_height image_width n_images]); 0088 % set a bunch of black images of appropriate size, 0089 % the equivalent of making flat asymptotic curves 0090 0091 points = unwarped_points(:,ones(n_images,1)); 0092 % duplicate points to fit number of images 0093 0094 for i=1:n_images, 0095 % for all images 0096 0097 width_x = bump_width + rand * bump_width_variation; 0098 width_y = bump_width + rand * bump_width_variation; 0099 height = bump_height + bump_height_variation * rand; 0100 position_x = bump_position_freedom * rand; 0101 position_y = (bump_position_freedom - width_y) * rand; 0102 % set attributes of the bump using some randomisation 0103 increment = height / initial_diminish_factor; 0104 current_height = height; 0105 % set the current height 0106 for k = 1:image_height, 0107 if (k < (image_height/2)) 0108 current_height = height * (k / image_height); 0109 else 0110 current_height = height * ((image_height - k) / image_height); 0111 end 0112 current_width = width_x; 0113 % if (k < (image_height/2)) 0114 % current_width = width_x * (k / image_height) 0115 % else 0116 % current_width = width_x * ((image_height - k) / image_height) 0117 % end 0118 increment = current_height / initial_diminish_factor; 0119 for j = floor(position_x * image_width):1:floor((position_x + (current_width / 2)) * image_width), 0120 images(k, j, i) = images(k, j-1, i) + increment; 0121 % images(j+1,i) = images(j-1,i) + increment; 0122 increment = increment / diminish_factor; 0123 % images(floor((position+width)*image_width)-j,i) = images(j,i); 0124 end 0125 0126 count=1; 0127 for j = floor(position_x * image_width):1:floor((position_x + (current_width / 2)) * image_width), 0128 images(k,floor((position_x + current_width) * image_width) - count,i) = images(k,j,i); 0129 count = count + 1; 0130 end 0131 end 0132 0133 % images(:,i) = normalise_to_bounds(images(:,i),0,height); 0134 0135 filename = ['1dim' num2str(i) '.png']; 0136 % set name of file 0137 % imwrite(images(i,:), filename, 'png'); 0138 % write file 0139 imagelist{i} = filename; 0140 % save in list of images 0141 % figure, plot(image); 0142 end