Home > Source > Redundancy > optimise_warps.m

optimise_warps

PURPOSE ^

OPTIMISE_WAPRS:

SYNOPSIS ^

function [param_list, warped_points, warped_image, score] = optimise_warps(ref_image, ref_points, unwarped_image, unwarped_points, spline_type, placement_method, n_points, verbose, do_plot, subplot_fig, pane)

DESCRIPTION ^

 OPTIMISE_WAPRS: 

 Code written by Katherine Smith, 2003

    GENERAL

      [param_list, warped_points, warped_image, score] = 
        optimise_warps(ref_image, ref_points, unwarped_image, 
        unwarped_points, spline_type, placement_method, n_points, 
        verbose, do_plot, subplot_fig, pane)

    INPUT/S

      -X:
          X
           
    OUTPUT/S

      -X:
           X

    PENDING WORK
      
      

    KNOWN BUG/S

      

    COMMENT/S

      -This function was moved and made redandant in May 2004. It was
      only used by older functions, namely:
           eval_obj_fn_to_mean_surf.m , eval_obj_fn_to_mean.m,
           build_1d_model_2_bump.m

    RELATED FUNCTION/S

      

    ABOUT

      -Created:     November 23rd, 2003
      -Last update: December 1st, 2003
      -Revision:    0.0.2
      -Author:      R. S. Schestowitz, University of Manchester
 ==============================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [param_list, warped_points, warped_image, score] = optimise_warps(ref_image, ref_points, unwarped_image, unwarped_points, spline_type, placement_method, n_points, verbose, do_plot, subplot_fig, pane)
0002 % OPTIMISE_WAPRS:
0003 %
0004 % Code written by Katherine Smith, 2003
0005 %
0006 %    GENERAL
0007 %
0008 %      [param_list, warped_points, warped_image, score] =
0009 %        optimise_warps(ref_image, ref_points, unwarped_image,
0010 %        unwarped_points, spline_type, placement_method, n_points,
0011 %        verbose, do_plot, subplot_fig, pane)
0012 %
0013 %    INPUT/S
0014 %
0015 %      -X:
0016 %          X
0017 %
0018 %    OUTPUT/S
0019 %
0020 %      -X:
0021 %           X
0022 %
0023 %    PENDING WORK
0024 %
0025 %
0026 %
0027 %    KNOWN BUG/S
0028 %
0029 %
0030 %
0031 %    COMMENT/S
0032 %
0033 %      -This function was moved and made redandant in May 2004. It was
0034 %      only used by older functions, namely:
0035 %           eval_obj_fn_to_mean_surf.m , eval_obj_fn_to_mean.m,
0036 %           build_1d_model_2_bump.m
0037 %
0038 %    RELATED FUNCTION/S
0039 %
0040 %
0041 %
0042 %    ABOUT
0043 %
0044 %      -Created:     November 23rd, 2003
0045 %      -Last update: December 1st, 2003
0046 %      -Revision:    0.0.2
0047 %      -Author:      R. S. Schestowitz, University of Manchester
0048 % ==============================================================
0049 
0050 [grid, steps] = setup_grid(2, unwarped_image, ref_points, placement_method, n_points);
0051 % set up the grid
0052 
0053 if(do_plot) % if <do_plot> then show the unwarped image
0054   figure(subplot_fig),subplot(10,2,pane,'replace'),plot(unwarped_image); drawnow;
0055 end
0056 
0057 warp_params.green = 'biharmCPS'; % initilaise some variables here
0058 param_list = [];
0059 start_image = unwarped_image;
0060 start_points = unwarped_points;
0061 
0062 %last_score = msd(ref_image, unwarped_image);
0063 
0064 if(strcmp(spline_type,'single_point'))
0065   for i=1:size(grid,2) % for all grid size
0066     [params, score] = fminsearch(@eval_msd_cps_warp,[0],optimset('Display',verbose),grid(i),steps(i),start_points, start_image, ref_image, verbose); % warp it
0067 %    [params, score] = fminsearch(@eval_msd_cps_warp,[0],optimset('Display',verbose),grid(i),steps(i),start_points, start_image, ref_image, verbose);
0068     param_list(size(param_list,1)+1).d = params; % get parameters of warped image
0069     start_points = cps_warp_1d(start_points, grid(i), steps(i), params(1));
0070     start_image = interp1(ref_points,unwarped_image,start_points, 'linear',0);
0071     % step to next image and points
0072     last_score = score; % currently unused?
0073   end
0074 elseif(strcmp(spline_type,'multi_point'))
0075   warped_grid = grid;
0076   warp_params.green = 'biharmCPS';
0077   last_score = eval_msd_multi_warp(zeros(size(grid)),grid, unwarped_image, unwarped_points, ref_image, ref_points, 20, warp_params);
0078   [params, score] = fminsearch(@eval_msd_multi_warp,zeros(size(grid)),optimset('Display',verbose,'TolX',1e-10),grid, unwarped_image, unwarped_points, ref_image, ref_points, 20, warp_params);
0079   param_list(size(param_list,1)+1,:).d = params; % get parameters returned
0080   warped_grid = grid + params;
0081   start_points = nrr_trans_1d(start_points, grid, warped_grid, warp_params,[]);
0082   start_image = interp1(unwarped_points,unwarped_image,start_points, 'linear',0);
0083 % step forward to next image and points
0084   disp(['Initial score: ',num2str(last_score),' Final score: ',num2str(score)]);
0085 % display the score/s
0086 end
0087 
0088 warped_points = start_points;
0089 warped_image = start_image;
0090 if(do_plot) % if <do_plot> show results after warping
0091   figure(subplot_fig),subplot(10,2,pane,'replace'),plot(warped_image); drawnow;
0092 end

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