Changeset 34201
- Timestamp:
- Jul 24, 2012, 3:42:45 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotSourceSize.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotSourceSize.c
r32633 r34201 18 18 float sizeLimitCR; 19 19 float magLimitCR; 20 int maxWindowCR; 20 21 } psphotSourceSizeOptions; 21 22 … … 26 27 bool psphotSourceClassRegion (psRegion *region, pmPSFClump *psfClump, psArray *sources, psMetadata *recipe, pmPSF *psf, psphotSourceSizeOptions *options); 27 28 bool psphotSourceSelectCR (pmReadout *readout, psArray *sources, psphotSourceSizeOptions *options); 28 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal );29 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal, int maxWindowCR); 29 30 bool psphotMaskCosmicRayFootprintCheck (psArray *sources); 30 31 int psphotMaskCosmicRayConnected (int xPeak, int yPeak, psImage *mymask, psImage *myvar, psImage *edges, int binning, float sigma_thresh); … … 139 140 if (!status) { 140 141 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSPHOT.CRMASK.APPLY is not defined."); 142 return false; 143 } 144 options.maxWindowCR = psMetadataLookupS32 (&status, recipe, "PSPHOT.CR.MAX.WINDOW"); 145 if (!status) { 146 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSPHOT.CR.MAX.WINDOW is not defined."); 141 147 return false; 142 148 } … … 637 643 psTrace("psphot", 6, "mask cosmic ray at %f, %f\n", source->peak->xf, source->peak->yf); 638 644 if (options->applyCRmask) { 639 psphotMaskCosmicRay(readout, source, options->crMask );645 psphotMaskCosmicRay(readout, source, options->crMask, options->maxWindowCR); 640 646 } else { 641 647 source->mode |= PM_SOURCE_MODE_CR_LIMIT; … … 677 683 // does no repair or recovery of the CR pixels, it only masks them out. My test code can be 678 684 // found at /data/ipp031.0/watersc1/psphot.20091209/algo_check.c 679 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal ) {685 bool psphotMaskCosmicRay (pmReadout *readout, pmSource *source, psImageMaskType maskVal, int maxWindowCR) { 680 686 681 687 // Get the actual images and information about the peak. … … 689 695 int ys = footprint->bbox.y0; 690 696 int ye = footprint->bbox.y1 + 1; 697 698 // We occasionally get very large footprints. When the footprint bounding box is large this function will 699 // do an incredible amount of work for no benefit. 700 // Limit the size of the area we examine. 701 if (xe - xs > maxWindowCR) { 702 xs = peak->x - maxWindowCR / 2; 703 xe = xs + maxWindowCR; 704 } 705 if (ye - ys > maxWindowCR) { 706 ys = peak->y - maxWindowCR / 2; 707 ye = ys + maxWindowCR; 708 } 691 709 692 710 LIMIT_XRANGE(xs, mask); … … 731 749 for (int i = 0; i < footprint->spans->n; i++) { 732 750 pmSpan *sp = footprint->spans->data[i]; 733 for (int j = sp->x0; j <= sp->x1; j++) { 734 int y = sp->y - ys; 735 int x = j - xs; 751 int y = sp->y - ys; 752 if (y < 0 || y >= mymask->numRows) { 753 // can we break if y >= numRows? 754 continue; 755 } 756 for (int x = PS_MAX(sp->x0 - xs, 0); x <= PS_MIN(sp->x1 - xs, mymask->numCols-1); x++) { 736 757 mymask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= 0x01; 737 758 } … … 873 894 874 895 bool psphotMaskCosmicRayFootprintCheck (psArray *sources) { 875 896 #ifdef CHECK_FOOTPRINTS 897 // This gets really expensive for complex images 876 898 for (int i = 0; i < sources->n; i++) { 877 899 pmSource *source = sources->data[i]; … … 884 906 } 885 907 } 908 #endif 886 909 return true; 887 910 }
Note:
See TracChangeset
for help on using the changeset viewer.
