- Timestamp:
- May 8, 2010, 1:55:26 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/psphot.20100506/src/psphotStackMatchPSFsUtils.c
r27883 r27884 259 259 260 260 // perform the bulk of the PSF-matching 261 bool matchKernel(pmConfig *config, pmReadout *readout Cnv, pmReadout *readoutRaw, psphotStackOptions *options, int index) {261 bool matchKernel(pmConfig *config, pmReadout *readoutOut, pmReadout *readoutSrc, psphotStackOptions *options, int index) { 262 262 263 263 bool mdok; … … 338 338 stampSources = stackSourcesFilter(options->sourceLists->data[index], footprint); // Filtered list of sources 339 339 340 fake = makeFakeReadout(config, readout Raw, stampSources, options->psf, maskVal | maskBad, footprint + size);340 fake = makeFakeReadout(config, readoutSrc, stampSources, options->psf, maskVal | maskBad, footprint + size); 341 341 if (!fake) goto escape; 342 342 343 dumpImage(fake, readout Raw, index, "fake");344 dumpImage(readout Raw, readoutRaw, index, "real");343 dumpImage(fake, readoutSrc, index, "fake"); 344 dumpImage(readoutSrc, readoutSrc, index, "real"); 345 345 346 346 if (threads) pmSubtractionThreadsInit(); 347 347 348 348 // Do the image matching 349 pmSubtractionKernels *kernel = psMetadataLookupPtr(&mdok, readout Raw->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL); // Conv kernel349 pmSubtractionKernels *kernel = psMetadataLookupPtr(&mdok, readoutSrc->analysis, PM_SUBTRACTION_ANALYSIS_KERNEL); // Conv kernel 350 350 if (kernel) { 351 if (!pmSubtractionMatchPrecalc(NULL, readout Cnv, fake, readoutRaw, readoutRaw->analysis, stride, kernelError, covarFrac, maskVal, maskBad, maskPoor, poorFrac, badFrac)) {351 if (!pmSubtractionMatchPrecalc(NULL, readoutOut, fake, readoutSrc, readoutSrc->analysis, stride, kernelError, covarFrac, maskVal, maskBad, maskPoor, poorFrac, badFrac)) { 352 352 psError(psErrorCodeLast(), false, "Unable to convolve images."); 353 353 goto escape; … … 361 361 } 362 362 363 if (!pmSubtractionMatch(NULL, readout Cnv, fake, readoutRaw, footprint, stride, regionSize, spacing, threshold, stampSources, stampsName, type, size, order, widthsCopy, orders, inner, ringsOrder, binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej, normFrac, sysError, skyErr, kernelError, covarFrac, maskVal, maskBad, maskPoor, poorFrac, badFrac, PM_SUBTRACTION_MODE_2)) {363 if (!pmSubtractionMatch(NULL, readoutOut, fake, readoutSrc, footprint, stride, regionSize, spacing, threshold, stampSources, stampsName, type, size, order, widthsCopy, orders, inner, ringsOrder, binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej, normFrac, sysError, skyErr, kernelError, covarFrac, maskVal, maskBad, maskPoor, poorFrac, badFrac, PM_SUBTRACTION_MODE_2)) { 364 364 psError(psErrorCodeLast(), false, "Unable to match images."); 365 365 goto escape; … … 369 369 // Reject image completely if the maximum deconvolution fraction exceeds the limit 370 370 float deconvLimit = psMetadataLookupF32(NULL, stackRecipe, "DECONV.LIMIT"); // Limit on deconvolution fraction 371 float deconv = psMetadataLookupF32(NULL, readout Cnv->analysis, PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Max deconvolution fraction371 float deconv = psMetadataLookupF32(NULL, readoutOut->analysis, PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Max deconvolution fraction 372 372 if (deconv > deconvLimit) { 373 373 psWarning("Maximum deconvolution fraction (%f) exceeds limit (%f) --- rejecting image %d\n", deconv, deconvLimit, index); … … 375 375 } 376 376 377 dumpImage(readout Cnv, readoutRaw, index, "conv");378 dumpImageDiff(readout Cnv, fake, readoutRaw, index, "diff");377 dumpImage(readoutOut, readoutSrc, index, "conv"); 378 dumpImageDiff(readoutOut, fake, readoutSrc, index, "diff"); 379 379 380 380 psFree(fake); … … 542 542 543 543 // generate a fake readout against which to PSF match 544 pmReadout *makeFakeReadout(pmConfig *config, pmReadout *readout Raw, psArray *sources, pmPSF *psf, psImageMaskType maskVal, int fullSize) {544 pmReadout *makeFakeReadout(pmConfig *config, pmReadout *readoutSrc, psArray *sources, pmPSF *psf, psImageMaskType maskVal, int fullSize) { 545 545 546 546 pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout with target PSF … … 548 548 psStats *bg = psStatsAlloc(PS_STAT_ROBUST_STDEV); // Statistics for background 549 549 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 550 if (!psImageBackground(bg, NULL, readout Raw->image, readoutRaw->mask, maskVal, rng)) {550 if (!psImageBackground(bg, NULL, readoutSrc->image, readoutSrc->mask, maskVal, rng)) { 551 551 psError(PSPHOT_ERR_DATA, false, "Can't measure background for image."); 552 552 psFree(fake); … … 560 560 561 561 bool oldThreads = pmReadoutFakeThreads(true); // Old threading state 562 if (!pmReadoutFakeFromSources(fake, readout Raw->image->numCols, readoutRaw->image->numRows, sources, SOURCE_MASK, NULL, NULL, psf, minFlux, fullSize, false, true)) {562 if (!pmReadoutFakeFromSources(fake, readoutSrc->image->numCols, readoutSrc->image->numRows, sources, SOURCE_MASK, NULL, NULL, psf, minFlux, fullSize, false, true)) { 563 563 psError(PSPHOT_ERR_DATA, false, "Unable to generate fake image with target PSF."); 564 564 psFree(fake); … … 567 567 pmReadoutFakeThreads(oldThreads); 568 568 569 fake->mask = psImageCopy(NULL, readout Raw->mask, PS_TYPE_IMAGE_MASK);569 fake->mask = psImageCopy(NULL, readoutSrc->mask, PS_TYPE_IMAGE_MASK); 570 570 571 571 // Add the background into the target image 572 psImage *bgImage = stackBackgroundModel(readout Raw, config); // Image of background572 psImage *bgImage = stackBackgroundModel(readoutSrc, config); // Image of background 573 573 psBinaryOp(fake->image, fake->image, "+", bgImage); 574 574 psFree(bgImage);
Note:
See TracChangeset
for help on using the changeset viewer.
