Home > Source > Evaluation > eval_model_cps_warp.m

eval_model_cps_warp

PURPOSE ^

EVAL_MODEL_CPS_WARP: apply a simple warp and evaluate model

SYNOPSIS ^

function [score, warped_points] = eval_model_cps_warp(params, warp_centre, r, unwarped_image_vec, unwarped_points_vec, image_set, points_set, n_modes, start_points_vec, model_evaluation_method, weighting_normalisation_method, shape_weight, variation_kept, show_warps_while_optimising)

DESCRIPTION ^

 EVAL_MODEL_CPS_WARP: apply a simple warp and evaluate model

 Code written by Katherine Smith, 2003

    GENERAL

      

    INPUT/S

      -
           
    OUTPUT/S

      -
           

    PENDING WORK

      -

    KNOWN BUG/S

      -None.

    COMMENT/S

      -

    RELATED FUNCTION/S

      P

    ABOUT

      -Created:     November 2003
      -Last update: March 26th, 2004
      -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 [score, warped_points] = eval_model_cps_warp(params, warp_centre, r, unwarped_image_vec, unwarped_points_vec, image_set, points_set, n_modes, start_points_vec, model_evaluation_method, weighting_normalisation_method, shape_weight, variation_kept, show_warps_while_optimising)
0002 % EVAL_MODEL_CPS_WARP: apply a simple warp and evaluate model
0003 %
0004 % Code written by Katherine Smith, 2003
0005 %
0006 %    GENERAL
0007 %
0008 %
0009 %
0010 %    INPUT/S
0011 %
0012 %      -
0013 %
0014 %    OUTPUT/S
0015 %
0016 %      -
0017 %
0018 %
0019 %    PENDING WORK
0020 %
0021 %      -
0022 %
0023 %    KNOWN BUG/S
0024 %
0025 %      -None.
0026 %
0027 %    COMMENT/S
0028 %
0029 %      -
0030 %
0031 %    RELATED FUNCTION/S
0032 %
0033 %      P
0034 %
0035 %    ABOUT
0036 %
0037 %      -Created:     November 2003
0038 %      -Last update: March 26th, 2004
0039 %      -Revision:    0.0.2
0040 %      -Author:      R. S. Schestowitz, University of Manchester
0041 % ==============================================================
0042 
0043 %d = params(1);
0044 start_points = unwarped_points_vec;
0045 max_d = 0.67;
0046 
0047 if (any((abs(params) > max_d)) | any(warp_centre - r < -1) | any(warp_centre + r > 1))
0048   score = realmax;
0049   warped_points = unwarped_points_vec;
0050 else
0051     
0052       % return maximum value if warp is invalid
0053 
0054       
0055   for i=1:size(params,2),
0056 %       index=i
0057 %       cent=warp_centre(i)
0058 %       rad=r(i)
0059 %       param=params(i)
0060 %       rand_num = (rand - 0.5)/ 10;
0061       
0062 %      figure(50);
0063 %      hold on;
0064 %      plot(start_points);
0065 %      plot(start_points_vec);
0066 %      axis([0 size(unwarped_image_vec,1) -1 1])
0067 %      hold off;
0068 
0069 
0070 %      params(i)
0071 %      start_points_vec
0072 %      warp_centre(i)
0073 %      r(i)
0074 
0075 %     params(i) = params(i) + 0.5;
0076 
0077 
0078 
0079     warped_points = cps_warp_1d(start_points_vec, warp_centre(i), r(i), params(i));
0080     
0081     
0082     if (show_warps_while_optimising == 1),    
0083          figure(40);
0084          plot(warped_points);
0085          axis([0 size(unwarped_image_vec,1) -1 1])
0086     end
0087 
0088     start_points = warped_points;
0089   end
0090   
0091   warped_image = interp1(unwarped_points_vec, unwarped_image_vec, warped_points, 'linear', 0);
0092   
0093   % figure(102);
0094   % plot(warped_image)
0095   
0096   image_set(:,size(image_set,2) + 1) = warped_image;
0097   points_set(:,size(points_set,2) + 1) = warped_points;
0098   
0099   
0100   
0101  % figure(30);
0102  % plot(warped_image);
0103  
0104 
0105   c_model = build_model(image_set, points_set, variation_kept, '', weighting_normalisation_method, shape_weight);
0106   score = measure_model(c_model.variances, n_modes, model_evaluation_method, c_model);
0107 end

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