0001 function eval_obj_fn_to_mean
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 do_plot = 0;
0045 obj_fn_type = 'msd';
0046 n_images = 10;
0047 n_iterations = 10;
0048 n_sets = 10;
0049 image_width = 50;
0050 ref_shift = 0.2;
0051 max_shift = 0.2;
0052 step = 0.1;
0053 los = zeros(n_images,floor((max_shift-ref_shift)/step));
0054 his = zeros(n_images,floor((max_shift-ref_shift)/step));
0055 blurred = 0;
0056 spec_iters = 25;
0057 gen_iters = 25;
0058 min_error = 0;
0059 max_error = 1;
0060 error_step = 0.1;
0061 n_error_steps = (max_error-min_error)/error_step;
0062
0063 for this_set = 1:n_sets
0064 [imagelist images points his los] = make_1d_images(n_images, image_width, 0.2);
0065
0066 window = 9;
0067
0068
0069
0070
0071 points = -1 + 2*(points-1)/(image_width-1);
0072 los = -1 + 2*(los-1)/(image_width-1);
0073 his = -1 + 2*(his-1)/(image_width-1);
0074
0075 keep = 0.999999;
0076 ref_points_vec = points(:,1);
0077 ref_image_vec = images(:,1);
0078 if(strcmp(obj_fn_type,'model'))
0079 ref_hi = mean(his);
0080 ref_lo = mean(los);
0081 elseif(strcmp(obj_fn_type,'msd'))
0082 ref_hi = his(1);
0083 ref_lo = los(1);
0084 end
0085
0086
0087
0088
0089 if(do_plot)
0090 subplot_fig = figure;
0091 figure(subplot_fig),for i=1:n_images,subplot(n_images,2,(2*i)-1),plot(images(:,i)),title('Unwarped images'); end;
0092 end
0093 warped_images = images;
0094 warped_points = points;
0095
0096
0097 for n=1:n_iterations*2-1
0098 disp(['iter ',num2str(n)]);
0099
0100
0101 for i=1:n_images
0102 disp(['Warping image ',num2str(i),' of ',num2str(n_images)]);
0103 image_vec = images(:,i);
0104 points_vec = points(:,i);
0105 hi_step = (his(i)-ref_hi)/n_iterations;
0106 lo_step = (los(i)-ref_lo)/n_iterations;
0107 params.green = 'biharmCPS';
0108 [warped_points,E,data] = nrr_trans_1d(points_vec,[his(i),los(i)],[his(i)+hi_step*n, los(i)+lo_step*n],params,[]);
0109 warped_image = interp1(points_vec,image_vec,warped_points, 'linear',0);
0110
0111
0112 warped_images(:,i) = warped_image;
0113 warped_points(:,i) = warped_points;
0114 if(do_plot)
0115 figure(subplot_fig),subplot(10,2,2*i,'replace'),plot(warped_image); drawnow;
0116 pause(0.05);
0117 end
0118 end
0119
0120 if(strcmp(obj_fn_type,'model'))
0121 norm_type = 'edge';
0122 keep = 0.9999;
0123 c_model = build_model(warped_images, warped_points, keep, '', norm_type);
0124 obj_fn(n,this_set) = measure_model(c_model.variances,20);
0125 elseif(strcmp(obj_fn_type,'msd'))
0126 for i = 1:n_images
0127 temp(i) = msd(warped_images(:,i),ref_image_vec);
0128 end
0129 obj_fn(n,this_set) = mean(temp);
0130
0131 end
0132 end
0133 end
0134
0135
0136 figure,errorbar(log(mean(obj_fn,2)),std(obj_fn,0,2)./mean(obj_fn,2)),title([obj_fn_type, '(log)']);
0137
0138
0139