- Timestamp:
- Jan 29, 2010, 6:02:38 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/ppSub/src/ppSubThreshold.c
r24862 r26739 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)) {46 if (!psImageBackground(stats, NULL, subImage, subMask, maskIgnore, rng)) { 44 47 psError(PS_ERR_UNKNOWN, false, "Unable to determine threshold."); 45 48 psFree(rng); … … 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; … … 94 100 return false; 95 101 } 96 if (!lowThreshold(in, thresh, maskVal, maskThresh, "input convolved image")) {97 psError(PS_ERR_UNKNOWN, false, "Unable to threshold input image.");98 return false;99 }100 102 101 103 pmReadout *ref = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference image … … 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(PS_ERR_UNKNOWN, false, "Unable to threshold input image."); 117 return false; 118 } 119 if (!lowThreshold(ref, thresh, maskVal, maskThresh, region, "reference convolved image")) { 120 psError(PS_ERR_UNKNOWN, 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.
