- Timestamp:
- Dec 6, 2012, 6:32:19 PM (14 years ago)
- Location:
- branches/czw_branch/20120906/psphot
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20120906/psphot
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20120905/psphot (added) merged: 34408-34409,34415-34416,34428,34466,34565,34570,34575,34735,34747
- Property svn:mergeinfo changed
-
branches/czw_branch/20120906/psphot/src
- Property svn:mergeinfo changed
-
branches/czw_branch/20120906/psphot/src/psphotAddNoise.c
r34404 r34772 1 1 # include "psphotInternal.h" 2 3 bool psphotMaskSource(pmSource *source, bool add, psImageMaskType maskVal); 2 4 3 5 bool psphotAddNoise (pmConfig *config, const pmFPAview *view, const char *filerule) { … … 30 32 } 31 33 34 static int Nmasked = 0; 35 36 // the return state indicates if any sources were actually replaced 32 37 bool psphotAddOrSubNoiseReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index, psMetadata *recipe, bool add) { 33 38 … … 47 52 48 53 psArray *sources = detections->allSources; 49 //psAssert (sources, "missing sources?"); 50 // if no work, should just return true 51 if (!sources) return true; 54 // if no work to do, should just return true 55 if (!sources) return false; 52 56 53 57 psTimerStart ("psphot.noise"); … … 56 60 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels 57 61 psAssert (maskVal, "missing mask value?"); 62 63 psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels 64 psAssert (markVal, "missing mask value?"); 58 65 59 66 // increase variance by factor*(object noise): … … 67 74 68 75 if (SIZE <= 0) { 69 return true;76 return false; 70 77 } 71 78 … … 94 101 95 102 pmSourceNoiseOp (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, FACTOR, SIZE, add, maskVal, 0, 0); 103 104 psphotMaskSource (source, add, markVal); 96 105 } 97 106 if (add) { … … 100 109 psLogMsg ("psphot.noise", PS_LOG_WARN, "sub noise for %ld objects: %f sec\n", sources->n, psTimerMark ("psphot.noise")); 101 110 } 111 fprintf (stderr, "masked %d objects\n", Nmasked); 102 112 103 113 psphotVisualShowImage (readout); … … 105 115 return true; 106 116 } 117 118 bool psphotMaskSource(pmSource *source, bool add, psImageMaskType maskVal) { 119 120 if (!source) return false; 121 if (!source->peak) return false; // XXX how can we have a peak-less source? 122 if (source->type == PM_SOURCE_TYPE_DEFECT) return false; 123 if (source->type == PM_SOURCE_TYPE_SATURATED) return false; 124 125 float Xc = source->peak->xf - source->pixels->col0 - 0.5; 126 float Yc = source->peak->yf - source->pixels->row0 - 0.5; 127 128 psImageMaskType notMaskVal = ~maskVal; 129 130 for (int iy = 0; iy < source->pixels->numRows; iy++) { 131 for (int ix = 0; ix < source->pixels->numCols; ix++) { 132 133 float radius = hypot (ix - Xc, iy - Yc) ; 134 135 if (radius > 4) continue; 136 137 if (add) { 138 source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= maskVal; 139 } else { 140 source->maskView->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] &= notMaskVal; 141 } 142 } 143 } 144 Nmasked ++; 145 146 return true; 147 } 148
Note:
See TracChangeset
for help on using the changeset viewer.
