Changeset 19624 for trunk/ppSub/src/ppSubReadout.c
- Timestamp:
- Sep 19, 2008, 5:07:47 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppSub/src/ppSubReadout.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubReadout.c
r19343 r19624 208 208 "Subtraction kernel", kernels->description); 209 209 210 { 211 // Update variance factors 212 // It's not possible to do this perfectly, since we're combining different images: 213 // vf_sum sigma_sum^2 = vf_1 * sigma_1^2 + vf_2 * sigma_2^2 214 // It's not possible to write vf_sum as a function of vf_1 and vf_2 with no reference to the sigmas. 215 // Instead, we're going to cheat. 216 bool mdok; // Status of MD lookup 217 pmSubtractionKernels *kernels = psMetadataLookupPtr(&mdok, inConv->analysis, 218 PM_SUBTRACTION_ANALYSIS_KERNEL); // Kernels 219 if (!mdok) { 220 kernels = psMetadataLookupPtr(&mdok, refConv->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL); 221 } 222 if (!mdok) { 223 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find subtraction kernels."); 224 psFree(inConv); 225 psFree(refConv); 226 psFree(outRO); 227 return false; 228 } 229 float vfIn = psMetadataLookupF32(NULL, inRO->parent->concepts, 230 "CELL.VARFACTOR"); // Variance factor for input 231 if (!isfinite(vfIn)) { 232 vfIn = 1.0; 233 } 234 float vfRef = psMetadataLookupF32(NULL, refRO->parent->concepts, 235 "CELL.VARFACTOR"); // Variance factor for ref 236 if (!isfinite(vfRef)) { 237 vfRef = 1.0; 238 } 239 if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) { 240 vfIn *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false); 241 } 242 if (kernels->mode == PM_SUBTRACTION_MODE_2) { 243 vfRef *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false); 244 } else if (kernels->mode == PM_SUBTRACTION_MODE_DUAL) { 245 vfRef *= pmSubtractionVarianceFactor(kernels, 0.0, 0.0, true); 246 } 247 248 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics 249 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator 250 if (!psImageBackground(stats, NULL, inConv->weight, inConv->mask, maskVal | maskBad, NULL)) { 251 psError(PS_ERR_UNKNOWN, false, "Unable to measure mean variance for convolved input"); 252 psFree(inConv); 253 psFree(refConv); 254 psFree(outRO); 255 return false; 256 } 257 float inMeanVar = stats->robustMedian; // Mean variance of input 258 if (!psImageBackground(stats, NULL, refConv->weight, refConv->mask, maskVal | maskBad, NULL)) { 259 psError(PS_ERR_UNKNOWN, false, "Unable to measure mean variance for convolved reference"); 260 psFree(inConv); 261 psFree(refConv); 262 psFree(outRO); 263 return false; 264 } 265 float refMeanVar = stats->robustMedian; // Mean variance of reference 266 psFree(rng); 267 psFree(stats); 268 269 float vf = (vfIn * inMeanVar + vfRef * refMeanVar) / (inMeanVar + refMeanVar); // Resulting var factor 270 psMetadataItem *vfItem = psMetadataLookup(outRO->parent->concepts, "CELL.VARFACTOR"); 271 vfItem->data.F32 = vf; 272 } 210 273 211 274 // Statistics on the matching
Note:
See TracChangeset
for help on using the changeset viewer.
