Changeset 20753 for trunk/ppStack/src/ppStackMatch.c
- Timestamp:
- Nov 13, 2008, 10:58:27 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStackMatch.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackMatch.c
r20752 r20753 47 47 #endif 48 48 49 static psArray *stackSourcesFilter(psArray *sources, // Source list to filter 50 int exclusion // Exclusion zone, pixels 51 ) 52 { 53 psAssert(sources && sources->n > 0, "Require array of sources"); 54 if (exclusion <= 0) { 55 return psMemIncrRefCounter(sources); 56 } 57 58 int num = sources->n; // Number of sources 59 psVector *x = psVectorAlloc(num, PS_TYPE_F32), *y = psVectorAlloc(num, PS_TYPE_F32); // Coordinates 60 int numGood = 0; // Number of good sources 61 for (int i = 0; i < num; i++) { 62 pmSource *source = sources->data[i]; // Source of interest 63 if (!source) { 64 continue; 65 } 66 x->data.F32[numGood] = source->peak->xf; 67 y->data.F32[numGood] = source->peak->yf; 68 numGood++; 69 } 70 x->n = y->n = numGood; 71 72 psTree *tree = psTreePlant(2, 2, x, y); // kd tree 73 74 psArray *filtered = psArrayAllocEmpty(numGood); // Filtered list of sources 75 psVector *coords = psVectorAlloc(2, PS_TYPE_F64); // Coordinates of source 76 int numFiltered = 0; // Number of filtered sources 77 for (int i = 0; i < num; i++) { 78 pmSource *source = sources->data[i]; // Source of interest 79 if (!source) { 80 continue; 81 } 82 coords->data.F32[0] = source->peak->xf; 83 coords->data.F32[1] = source->peak->yf; 84 if (psTreeWithin(tree, coords, exclusion) == 1) { 85 // Only itself inside the exclusion zone 86 filtered = psArrayAdd(filtered, filtered->n, source); 87 } else { 88 numFiltered++; 89 } 90 } 91 psFree(coords); 92 psFree(tree); 93 94 psLogMsg("ppStack", PS_LOG_INFO, "Filtered out %d of %d sources", numFiltered, numGood); 95 96 return filtered; 97 } 98 99 49 100 bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels, float *chi2, float *weighting, 50 constpsArray *sources, const pmPSF *psf, psRandom *rng, const pmConfig *config)101 psArray *sources, const pmPSF *psf, psRandom *rng, const pmConfig *config) 51 102 { 52 103 assert(readout); … … 247 298 } 248 299 300 // For the sake of stamps, remove nearby sources 301 psArray *stampSources = stackSourcesFilter(sources, footprint); // Filtered list of sources 302 249 303 if (threads > 0) { 250 304 pmSubtractionThreadsInit(readout, fake); … … 253 307 // Do the image matching 254 308 if (!pmSubtractionMatch(output, NULL, readout, fake, footprint, stride, regionSize, spacing, 255 threshold, s ources, stampsName, type, size, order, widths, orders, inner,256 ringsOrder, binning, penalty, optimum, optWidths, optOrder, optThresh,257 iter, rej, sysError, maskVal, maskBad, maskPoor, poorFrac, badFrac,258 PM_SUBTRACTION_MODE_1)) {309 threshold, stampSources, stampsName, type, size, order, widths, orders, 310 inner, ringsOrder, binning, penalty, optimum, optWidths, optOrder, 311 optThresh, iter, rej, sysError, maskVal, maskBad, maskPoor, poorFrac, 312 badFrac, PM_SUBTRACTION_MODE_1)) { 259 313 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); 260 314 psFree(fake); 261 315 psFree(optWidths); 316 psFree(stampSources); 262 317 psFree(output); 263 318 return false; … … 286 341 psFree(fake); 287 342 psFree(optWidths); 343 psFree(stampSources); 288 344 289 345 if (threads > 0) {
Note:
See TracChangeset
for help on using the changeset viewer.
