- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ppSub/src
- Property svn:ignore
-
old new 13 13 ppSubErrorCodes.c 14 14 ppSubVersionDefinitions.h 15 ppSubConvolve
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/ppSub/src/ppSubThreshold.c
r24862 r27840 27 27 psImageMaskType maskIgnore, // Ignore pixels with this mask 28 28 psImageMaskType maskThresh, // Give pixels this mask if below threshold 29 psRegion *region, // Region of interest 29 30 const char *description // Description of image 30 31 ) … … 37 38 psImage *image = ro->image; // Image 38 39 psImage *mask = ro->mask; // Mask 39 int numCols = ro->image->numCols, numRows = ro->image->numRows; // Size of image 40 41 psImage *subImage = psImageSubset(image, *region); // Image with region of interest 42 psImage *subMask = psImageSubset(mask, *region); // Maks with region of interest 40 43 41 44 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics 42 45 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 43 if (!psImageBackground(stats, NULL, image, mask, maskIgnore, rng)) {44 psError(P S_ERR_UNKNOWN, false, "Unable to determine threshold.");46 if (!psImageBackground(stats, NULL, subImage, subMask, maskIgnore, rng)) { 47 psError(PPSUB_ERR_DATA, false, "Unable to determine threshold."); 45 48 psFree(rng); 46 49 psFree(stats); … … 49 52 psFree(rng); 50 53 54 psFree(subImage); 55 psFree(subMask); 56 51 57 float threshold = stats->robustMedian - thresh * stats->robustStdev; // Threshold below which to clip 52 58 psFree(stats); 53 59 psLogMsg("ppSub", PS_LOG_INFO, "Masking pixels below %f in %s", threshold, description); 54 60 55 for (int y = 0; y < numRows; y++) {56 for (int x = 0; x < numCols; x++) {61 for (int y = region->y0; y < region->y1; y++) { 62 for (int x = region->x0; x < region->x1; x++) { 57 63 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskIgnore) { 58 64 continue; … … 91 97 pmReadout *in = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input image 92 98 if (!in) { 93 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find readout."); 94 return false; 95 } 96 if (!lowThreshold(in, thresh, maskVal, maskThresh, "input convolved image")) { 97 psError(PS_ERR_UNKNOWN, false, "Unable to threshold input image."); 99 psError(PPSUB_ERR_UNKNOWN, false, "Unable to find readout."); 98 100 return false; 99 101 } … … 101 103 pmReadout *ref = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference image 102 104 if (!ref) { 103 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find readout.");105 psError(PPSUB_ERR_UNKNOWN, false, "Unable to find readout."); 104 106 return false; 105 107 } 106 if (!lowThreshold(ref, thresh, maskVal, maskThresh, "reference convolved image")) { 107 psError(PS_ERR_UNKNOWN, false, "Unable to threshold input image."); 108 return false; 108 109 psMetadataIterator *regIter = psMetadataIteratorAlloc(in->analysis, PS_LIST_HEAD, 110 "^" PM_SUBTRACTION_ANALYSIS_REGION "$"); 111 psMetadataItem *regItem; // Item with region 112 while ((regItem = psMetadataGetAndIncrement(regIter))) { 113 psAssert(regItem->type == PS_DATA_REGION && regItem->data.V, "Expect region type"); 114 psRegion *region = regItem->data.V; // Region of interest 115 if (!lowThreshold(in, thresh, maskVal, maskThresh, region, "input convolved image")) { 116 psError(psErrorCodeLast(), false, "Unable to threshold input image."); 117 return false; 118 } 119 if (!lowThreshold(ref, thresh, maskVal, maskThresh, region, "reference convolved image")) { 120 psError(psErrorCodeLast(), false, "Unable to threshold input image."); 121 return false; 122 } 109 123 } 124 psFree(regIter); 110 125 111 126 psFree(view);
Note:
See TracChangeset
for help on using the changeset viewer.
