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

Generated on Thu 13-May-2004 18:00:46 by m2html © 2003