Home > Source > Optimise > MI > optimise_warps_nmi.m

optimise_warps_nmi

PURPOSE ^

OPTIMISE_WAPRS_NMI: Optimise warps using NMI.

SYNOPSIS ^

function [param_list, warped_points, warped_image, score] = optimise_warps_nmi(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, number_of_bins, precision_required)

DESCRIPTION ^

 OPTIMISE_WAPRS_NMI: Optimise warps using NMI.

 Code written by Katherine Smith, 2003

    GENERAL

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

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