Home > Source > Optimise > MSD > optimise_warps_msd.m

optimise_warps_msd

PURPOSE ^

==============================================================

SYNOPSIS ^

function [param_list, warped_points, warped_image, score] = optimise_warps_msd(ref_image, ref_points, unwarped_image, unwarped_points, spline_type, placement_method, n_points, verbose, do_plot, subplot_fig, pane, column, image_width, number_of_images, verbose_score, precision_required)

DESCRIPTION ^

 ==============================================================
 OPTIMISE_WAPRS_MSD: Optimise warps using MSD.

 Code written by Katherine Smith, 2003

    GENERAL

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

    INPUT/S

      -X:
          X
           
    OUTPUT/S

      -X:
           X

    PENDING WORK
      
      

    KNOWN BUG/S

      

    COMMENT/S
        See similarity to <optimise_warps>. The function is almost 
        identical, but it seems to call different routines that use MSD.     

    RELATED FUNCTION/S

        OPTIMISE_*

    ABOUT

      -Created:     November 23rd, 2003
      -Last update: January 23rd, 2004
      -Revision:    0.1.5
      -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_msd(ref_image, ref_points, unwarped_image, unwarped_points, spline_type, placement_method, n_points, verbose, do_plot, subplot_fig, pane, column, image_width, number_of_images, verbose_score, precision_required)
0002 % ==============================================================
0003 % OPTIMISE_WAPRS_MSD: Optimise warps using MSD.
0004 %
0005 % Code written by Katherine Smith, 2003
0006 %
0007 %    GENERAL
0008 %
0009 %      [param_list, warped_points, warped_image, score] =
0010 %        optimise_warps_msd(ref_image, ref_points, unwarped_image,
0011 %        unwarped_points, spline_type, placement_method, n_points,
0012 %        verbose, do_plot, subplot_fig, pane)
0013 %        image_width, number_of_images, verbose_score)
0014 %
0015 %    INPUT/S
0016 %
0017 %      -X:
0018 %          X
0019 %
0020 %    OUTPUT/S
0021 %
0022 %      -X:
0023 %           X
0024 %
0025 %    PENDING WORK
0026 %
0027 %
0028 %
0029 %    KNOWN BUG/S
0030 %
0031 %
0032 %
0033 %    COMMENT/S
0034 %        See similarity to <optimise_warps>. The function is almost
0035 %        identical, but it seems to call different routines that use MSD.
0036 %
0037 %    RELATED FUNCTION/S
0038 %
0039 %        OPTIMISE_*
0040 %
0041 %    ABOUT
0042 %
0043 %      -Created:     November 23rd, 2003
0044 %      -Last update: January 23rd, 2004
0045 %      -Revision:    0.1.5
0046 %      -Author:      R. S. Schestowitz, University of Manchester
0047 % ==============================================================
0048 
0049 [grid, steps] = setup_grid(2, unwarped_image, ref_points, placement_method, n_points);
0050 
0051 % set up the grid
0052 
0053 if (do_plot),
0054   figure(subplot_fig);
0055   subplot(number_of_images, column, pane, 'replace');
0056   plot(unwarped_image);
0057   axis([0 image_width 0 1]);
0058   drawnow;
0059 end
0060 
0061 warp_params.green = 'biharmCPS';
0062 param_list = [];
0063 start_image = unwarped_image;
0064 start_points = unwarped_points;
0065 last_score = msd(ref_image, unwarped_image);
0066 if(strcmp(spline_type,'single_point'))
0067   for i=1:size(grid,2)
0068     [params, score] = fminsearch(@eval_msd_cps_warp,zeros(size(grid)),optimset('Display',verbose,'TolX', precision_required), grid, steps, start_points, start_image, ref_image);
0069     param_list(size(param_list,1)+1).d = params;
0070     start_points = cps_warp_1d(start_points, grid(i), steps(i), params(1));
0071     start_image = interp1(ref_points,unwarped_image,start_points, 'linear',0);
0072     last_score = score;
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', precision_required),grid, unwarped_image, unwarped_points, ref_image, ref_points, 20, warp_params);
0079   param_list(size(param_list,1)+1,:).d = params;
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 else
0084   error('Unknown spline type');
0085 end
0086 
0087 if (verbose_score == 1),
0088       disp(['Initial score: ',num2str(last_score),' Final score: ', num2str(score), ' Difference: ', num2str(last_score - score)]);
0089 end 
0090 
0091 warped_points = start_points;
0092 warped_image = start_image;
0093 
0094 if (do_plot),
0095   figure(subplot_fig);
0096   subplot(number_of_images, column, pane, 'replace');
0097   plot(warped_image);
0098   axis([0 image_width 0 1]);
0099   title(num2str(score));
0100   drawnow;
0101 end

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