BUILD_MODEL: Builds a model for the set of images and points. Code written by Katherine Smith, 2003 GENERAL c_model = build_model(image_set, points_set, keep, label, norm_type, shape_weight) INPUT/S -image_set: The input images set. -points_set: The input points set. -keep: The precision required from PCA?? -label: Label of the model created? -norm_type: -shape_weight: The value of Ws which is the weighing factor in the model. OUTPUT/S -c_model: The model built. PENDING WORK Review input/output documentation. KNOWN BUG/S COMMENT/S -This also resembles some parts of eval_app_model_obj_fn. -same as BUILD_AND_EVAL but no evaluation at bottom. RELATED FUNCTION/S BUILD_AND_EVALUATE_MODEL ABOUT -Created: November 23rd, 2003 -Last update: December 1st, 2003 -Revision: 0.0.2 -Author: R. S. Schestowitz, University of Manchester ==============================================================
0001 function c_model = build_model(image_set, points_set, keep, label, norm_type, shape_weight) 0002 % BUILD_MODEL: Builds a model for the set of images and points. 0003 % 0004 % Code written by Katherine Smith, 2003 0005 % 0006 % GENERAL 0007 % 0008 % c_model = build_model(image_set, points_set, 0009 % keep, label, norm_type, shape_weight) 0010 % 0011 % 0012 % INPUT/S 0013 % 0014 % -image_set: 0015 % The input images set. 0016 % 0017 % -points_set: 0018 % The input points set. 0019 % 0020 % -keep: 0021 % The precision required from PCA?? 0022 % 0023 % -label: 0024 % Label of the model created? 0025 % 0026 % -norm_type: 0027 % 0028 % 0029 % -shape_weight: 0030 % The value of Ws which is the weighing factor in the model. 0031 % 0032 % 0033 % OUTPUT/S 0034 % 0035 % -c_model: 0036 % The model built. 0037 % 0038 % PENDING WORK 0039 % 0040 % Review input/output documentation. 0041 % 0042 % KNOWN BUG/S 0043 % 0044 % 0045 % 0046 % COMMENT/S 0047 % 0048 % -This also resembles some parts of eval_app_model_obj_fn. 0049 % -same as BUILD_AND_EVAL but no evaluation at bottom. 0050 % 0051 % RELATED FUNCTION/S 0052 % 0053 % BUILD_AND_EVALUATE_MODEL 0054 % 0055 % ABOUT 0056 % 0057 % -Created: November 23rd, 2003 0058 % -Last update: December 1st, 2003 0059 % -Revision: 0.0.2 0060 % -Author: R. S. Schestowitz, University of Manchester 0061 % ============================================================== 0062 0063 [intensity_model.pcs,intensity_model.variances,intensity_model.params, intensity_model.mean, intensity_model.var_r, intensity_model.total_var, intensity_model.impdata] = st_pca(image_set', keep); 0064 [shape_model.pcs,shape_model.variances,shape_model.params, shape_model.mean, shape_model.var_r, shape_model.total_var, shape_model.impdata] = st_pca(points_set', keep); 0065 % get shape and intensity model 0066 c_model.shape_weight = ones(1,size(shape_model.pcs,2)); 0067 % set weight to be a column vector of 1's? Would that mean equal weighing for shape and intensity? 0068 intensity_model.sd = std(intensity_model.params); 0069 % get and record standard deviation 0070 shape_model.sd = std(shape_model.params); 0071 if (strcmp(norm_type,'variance')), 0072 % combine params - initially normalise to variance described in model 0073 total_shape_variance = sum(shape_model.variances); 0074 total_intensity_variance = sum(intensity_model.variances); 0075 if(total_shape_variance ~= 0) 0076 c_model.shape_weight(:) = sqrt(total_intensity_variance/total_shape_variance); 0077 end 0078 % disp(['Shapeweight: ',num2str(c_model.shape_weight(1))]); 0079 elseif (strcmp(norm_type,'constant')), 0080 c_model.shape_weight(:) = shape_weight; 0081 % simply assign the predefined value 0082 elseif (strcmp(norm_type,'edge')), 0083 edges = abs(diff(image_set,1,2)); 0084 mean_edge_strength = sum(edges(:))/size(edges(:),1); 0085 c_model.shape_weight(:) = mean_edge_strength; 0086 % disp(['edge weight: ',num2str(mean_edge_strength)]); 0087 else 0088 error(['Unknown normalisation type: ',norm_type]); 0089 end 0090 0091 [c_model.pcs, c_model.variances, c_model.params, c_model.mean, c_model.total_var, c_model.impdata] = make_combined_model(shape_model, intensity_model, c_model.shape_weight); 0092 c_model.sd = sqrt(c_model.variances); 0093 c_model.intensity_model = intensity_model; 0094 0095 % intensity_model 0096 % shape_model 0097 % figure; 0098 % plot(intensity_model); 0099 % attempt to look at the models built from the data (RSS) 0100 0101 c_model.shape_model = shape_model; 0102 c_model.n_shape_modes = size(shape_model.sd,2); 0103 c_model.label = label; 0104 % save some of the values to be returned by the function