0001 function build_1d_model_2_bump
0002
0003
0004
0005
0006
0007
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
0039
0040
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
0051 window = 9;
0052
0053
0054
0055
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
0066
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
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 for n=1:n_iterations
0088 disp(['iter ',num2str(n)]);
0089
0090
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
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
0098
0099 warped_images(:,i) = warped_image;
0100 warped_points(:,i) = warped_point;
0101
0102
0103
0104 if(n==n_iterations)
0105 final_score(i, this_set) = score;
0106 end
0107 end
0108 end
0109
0110
0111 w_c_model = build_model(warped_images, warped_points, keep,'Optimised warp', 'variance');
0112
0113
0114
0115 fig_title = 'Automatically aligned: ';
0116
0117
0118
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
0130 t = toc;
0131 disp(['Time for set ',num2str(this_set),': ',num2str(t)]);
0132 end
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)]);