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