Home > Source > Redundancy > build_1d_model_2_bump.m

build_1d_model_2_bump

PURPOSE ^

(Unused)

SYNOPSIS ^

function build_1d_model_2_bump

DESCRIPTION ^

 (Unused)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function build_1d_model_2_bump
0002 % (Unused)
0003 
0004 %% SEEMS UNFINISHED... MAYBE JUST SUBROUTINE.. KATE SAYS IT MAY BE REDUNDANT
0005 %% AND IS MOSTLY MADE OF CUT-AND-PASTE
0006 
0007 % make images and points
0008 n_images = 10;
0009 n_iterations = 1;
0010 n_sets = 10;
0011 image_width = 100;
0012 spline_type = 'multi_point';
0013 placement_type = 'random';
0014 n_points = 5;
0015 do_plot = 0;
0016 
0017 white_ctr = 0;
0018 ref_shift = 0.2;
0019 max_shift = 0.2;
0020 step = 0.1;
0021 los = zeros(n_images,floor((max_shift-ref_shift)/step));
0022 his = zeros(n_images,floor((max_shift-ref_shift)/step));
0023 factor_step = 0.1;
0024 factor_min = 0;
0025 factor_max = 0.4;
0026 blurred = 0;
0027 spec_iters = 25;
0028 gen_iters = 25;
0029 min_error = 0;
0030 max_error = 1;
0031 error_step = 0.1;
0032 n_error_steps = (max_error-min_error)/error_step;
0033 
0034 tic;
0035 for this_set = 1:n_sets
0036   tic;
0037   ['calculating set ', num2str(this_set)]
0038   % for each set of n_sets images, build a model
0039   % calculate obj fn values from these models, plot the mean with error
0040   % bars given by 1 stddev away
0041   for white_width = ref_shift:step:max_shift
0042     white_ctr = white_ctr+1;
0043 
0044     [imagelist1 images1 points1 his1(:,white_ctr) los1(:,white_ctr)] = make_1d_images(n_images, image_width/2, white_width);
0045     [imagelist2 images2 points2 his2(:,white_ctr) los2(:,white_ctr)] = make_1d_images(n_images, image_width/2, white_width);
0046     images = vertcat(images1, images2);
0047     points = vertcat(points1, points2+image_width/2);
0048     his = vertcat(his1, his2);
0049     los = vertcat(los1, los2);
0050     % smooth images
0051     window = 9;
0052 %    images = average_smooth(images, window); blurred = 1;
0053 %    images = gaussian_smooth(images, window); blurred = 1;
0054 
0055     % normalise points from -1 to 1
0056     points = -1 + 2*(points-1)/(image_width-1);
0057 
0058     keep = 0.999999;
0059     ref_points_vec = points(:,1);
0060     ref_image_vec = images(:,1);
0061     ref_hi = his(1);
0062     ref_lo = los(1);
0063     
0064 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0065 % Warping images, then modelling warped images
0066 % attempt to register images by warping.
0067 subplot_fig = figure;
0068 figure(subplot_fig),for i=1:n_images,subplot(n_images,2,(2*i)-1),plot(images(:,i)),title('Unwarped images'); end;
0069 warped_images = images;
0070 warped_points = points;
0071 % correctly_warped_points = points;
0072 % correctly_warped_images = images;
0073 % for i=1:n_images
0074 %   % now bung in the right deformations to get them back
0075 %   correctly_warped_points(:,i) = linear_warp(ref_points_vec, los(i,white_ctr), his(i,white_ctr), ref_lo, ref_hi);
0076 %   correctly_warped_points_vec = correctly_warped_points(:,i);
0077 %   image_vec = images(:,i);
0078 %   % resample at the warped points - point on reg. grid has value of point at same index in warpy grid
0079 %   % need to interpolate
0080 %   correctly_warped_images(:,i) = interp1(ref_points_vec, image_vec, correctly_warped_points_vec);
0081 %   correct_model = build_model(correctly_warped_images,correctly_warped_points,1,'','edge',0);
0082 %   converging_score(i) = measure_model(correct_model.variances,50);
0083 % end
0084 % figure,plot(log(converging_score)),title('Log of score as model converges');
0085 %
0086 
0087   for n=1:n_iterations
0088   disp(['iter ',num2str(n)]);
0089     % correct registration
0090     % attempt to register
0091     for i=1:n_images
0092       disp(['Warping image ',num2str(i),' of ',num2str(n_images)]);
0093       image_vec = warped_images(:,i);
0094       points_vec = warped_points(:,i);
0095 %      [param_list, warped_point, warped_image, score] = optimise_warps_model([warped_images(:,1:i-1),warped_images(:,i+1:n_images)], [warped_points(:,1:i-1),warped_points(:,i+1:n_images)], image_vec, points_vec,placement_type,spline_type,subplot_fig,i*2, n_points);
0096       [param_list, warped_point, warped_image, score] = optimise_all_warps(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type,subplot_fig,i*2, n_points);
0097 %      [param_list, warped_point, warped_image, score] = optimise_warps(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type, n_points);
0098 
0099       warped_images(:,i) = warped_image;
0100       warped_points(:,i) = warped_point;
0101 
0102 %      figure(subplot_fig),title(['Warped images, after image ',num2str(i),' iteration ',num2str(n)]);
0103       %      dummy = waitforbuttonpress;
0104       if(n==n_iterations)
0105         final_score(i, this_set) = score;
0106       end
0107     end
0108   end
0109 
0110     % build model from warped images
0111     w_c_model = build_model(warped_images, warped_points, keep,'Optimised warp', 'variance');
0112 %    [w_c_model.mean_specificity, w_c_model.std_specificity] = find_specificity(w_c_model, images, spec_iters, ref_points_vec);
0113 %    show_combined_model(w_c_model,ref_points_vec, 2, 0.2, 'Combined model built from optimised warps');
0114 
0115   fig_title = 'Automatically aligned: ';
0116 %  show_shape_model(w_shape_model, ref_points_vec, ref_image_vec, 2, white_width)
0117 %  show_intensity_model(w_intensity_model, 2, white_width, fig_title)
0118 %  show_combined_model(w_c_model, ref_points_vec, 2, white_width, fig_title)
0119 
0120     w_intensity_total_vars(white_ctr) = w_c_model.intensity_model.total_var;
0121     w_shape_total_vars(white_ctr) = w_c_model.shape_model.total_var;
0122 
0123     warped_score(white_ctr, this_set) = measure_model(w_c_model.variances, 20);
0124     shape_modes(white_ctr, this_set) = w_c_model.n_shape_modes;
0125     intensity_modes(white_ctr, this_set) = size(w_c_model.intensity_model.pcs,2);
0126     shape_variance(white_ctr, this_set) = sum(w_c_model.shape_model.variances);
0127     intensity_variance(white_ctr, this_set) = sum(w_c_model.intensity_model.variances);
0128     white_ctr = 1;
0129   end % white width
0130   t = toc;
0131   disp(['Time for set ',num2str(this_set),': ',num2str(t)]);
0132 end % set
0133 disp('Mean match score:');
0134 mean(final_score(:))
0135 disp('Std match score:');
0136 std(final_score(:))
0137 
0138 disp('Mean model score:');
0139 mean(warped_score(:))
0140 disp('Std model score:');
0141 std(warped_score(:))
0142 
0143 disp('Mean shape modes:');
0144 mean(shape_modes(:))
0145 disp('Std shape modes:');
0146 std(shape_modes(:))
0147 
0148 disp('Mean intensity modes:');
0149 mean(intensity_modes(:))
0150 disp('Std intensity modes:');
0151 std(intensity_modes(:))
0152 
0153 disp('Mean shape variance:');
0154 mean(shape_variance(:))
0155 disp('Std shape variance:');
0156 std(shape_variance(:))
0157 
0158 disp('Mean intensity variance:');
0159 mean(intensity_variance(:))
0160 disp('Std intensity variance:');
0161 std(intensity_variance(:))
0162 
0163 t = toc;
0164 disp(['Total time: ',num2str(t)]);

Generated on Fri 14-May-2004 10:05:30 by m2html © 2003