Home > Source > Evaluate_Objective > eval_obj_fn_to_mean_surf.m

eval_obj_fn_to_mean_surf

PURPOSE ^

SEE EVAL_OBJ_FN_TO_MEAN; Indentation here is horrible

SYNOPSIS ^

function eval_obj_fn_to_mean_surf

DESCRIPTION ^

 SEE EVAL_OBJ_FN_TO_MEAN; Indentation here is horrible

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function eval_obj_fn_to_mean_surf
0002 % SEE EVAL_OBJ_FN_TO_MEAN; Indentation here is horrible
0003     
0004 % make images and points
0005 do_plot = 0;
0006 obj_fn_type = 'model';
0007 n_images = 10;
0008 n_iterations = 10;
0009 n_sets = 10;
0010 image_width = 50;
0011 ref_shift = 0.2;
0012 max_shift = 0.2;
0013 step = 0.1;
0014 los = zeros(n_images,floor((max_shift-ref_shift)/step));
0015 his = zeros(n_images,floor((max_shift-ref_shift)/step));
0016 blurred = 0;
0017 spec_iters = 25;
0018 gen_iters = 25;
0019 min_error = 0;
0020 max_error = 1;
0021 error_step = 0.1;
0022 n_error_steps = (max_error-min_error)/error_step;
0023 
0024 for this_set = 1:n_sets
0025     [imagelist images points his los] = make_1d_images(n_images, image_width, 0.2);
0026     % smooth images
0027     window = 9;
0028     %    images = average_smooth(images, window); blurred = 1;
0029     %    images = gaussian_smooth(images, window); blurred = 1;
0030     
0031     % normalise points from -1 to 1
0032     points = -1 + 2*(points-1)/(image_width-1);
0033     los = -1 + 2*(los-1)/(image_width-1);
0034     his = -1 + 2*(his-1)/(image_width-1);
0035         
0036     keep = 0.999999;
0037     ref_points_vec = points(:,1);
0038     ref_image_vec = images(:,1);
0039     if(strcmp(obj_fn_type,'model'))
0040     ref_hi = mean(his);
0041     ref_lo = mean(los);
0042     elseif(strcmp(obj_fn_type,'msd'))
0043     ref_hi = his(1);
0044     ref_lo = los(1);
0045     end
0046     
0047     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0048     % Warping images, then modelling warped images
0049     % attempt to register images by warping.
0050   if(do_plot)
0051       subplot_fig = figure;
0052     figure(subplot_fig),for i=1:n_images,subplot(n_images,2,(2*i)-1),plot(images(:,i)),title('Unwarped images'); end;
0053   end
0054     warped_images = images;
0055     warped_points = points;
0056     
0057     % move points iteratively towards mean
0058     for n=1:n_iterations*2-1
0059       for m=1:n_iterations*2-1
0060       disp(['iter ',num2str(n)]);
0061       % correct registration
0062       % attempt to register
0063       for i=1:n_images
0064         disp(['Warping image ',num2str(i),' of ',num2str(n_images)]);
0065         image_vec = images(:,i);
0066         points_vec = points(:,i);
0067         hi_step = (his(i)-ref_hi)/n_iterations;
0068         lo_step = (los(i)-ref_lo)/n_iterations;
0069         params.green = 'biharmCPS';
0070         [warped_points,E,data] = nrr_trans_1d(points_vec,[his(i),los(i)],[his(i)+hi_step*n, los(i)+lo_step*n],params,[]);
0071         warped_image = interp1(points_vec,image_vec,warped_points, 'linear',0);
0072 %      [param_list, warped_point, warped_image, score] = optimise_warps(ref_image_vec, ref_points_vec, image_vec, points_vec, 'multi_point', 'edge',subplot_fig,i*2);
0073 
0074         warped_images(:,i) = warped_image;
0075         warped_points(:,i) = warped_points;
0076         if(do_plot)
0077           figure(subplot_fig),subplot(10,2,2*i,'replace'),plot(warped_image); drawnow;
0078           pause(0.05);
0079         end
0080       end
0081           
0082             if(strcmp(obj_fn_type,'model'))
0083           norm_type = 'edge';
0084           keep = 0.9999;
0085           c_model = build_model(warped_images, warped_points, keep, '', norm_type);
0086           obj_fn(n,this_set) = measure_model(c_model.variances,20);
0087             elseif(strcmp(obj_fn_type,'msd'))
0088           for i = 1:n_images
0089             temp(i) = msd(warped_images(:,i),ref_image_vec);
0090           end
0091           obj_fn(n,this_set) = mean(temp);
0092             end
0093     end % m
0094     end % n_iterations
0095 end % n_sets
0096 %figure,errorbar(mean(obj_fn,2)),std(obj_fn,0,2),title(obj_fn_type);
0097 figure,errorbar(log(mean(obj_fn,2)),std(obj_fn,0,2)./mean(obj_fn,2)),title([obj_fn_type, '(log)']);

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