Home > Source > Evaluation > eval_model_cps_warp.m

eval_model_cps_warp

PURPOSE ^

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

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

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