Changeset 13738 for trunk/ppSub/src/ppSubReadout.c
- Timestamp:
- Jun 8, 2007, 4:47:49 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppSub/src/ppSubReadout.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubReadout.c
r13662 r13738 10 10 #include "ppSub.h" 11 11 12 #define MASK_BAD 0x01 // Mask value for bad pixel13 #define MASK_STAMP 0x02 // Mask value for bad stamp (and bad stamp region)14 15 12 bool ppSubReadout(pmConfig *config, const pmFPAview *view) 16 13 { 17 14 pmReadout *inRO = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT"); // Input readout 18 15 pmReadout *refRO = pmFPAfileThisReadout(config->files, view, "PPSUB.REF"); // Reference readout 19 #if 020 16 pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSUB.OUTPUT"); // Output cell 21 17 pmReadout *outRO = pmReadoutAlloc(outCell); // Output readout 22 #endif23 18 24 19 psImage *input = inRO->image; // Input image … … 49 44 if (!refRO->mask) { 50 45 refRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK); 51 psImageInit( inRO->mask, 0);46 psImageInit(refRO->mask, 0); 52 47 } 53 48 54 // Worried about the masks for bad pixels and bad stamps colliding, so make our own mask 55 psImage *stampMask = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Mask to use for stamps 56 for (int y = 0; y < numRows; y++) { 57 for (int x = 0; x < numCols; x++) { 58 stampMask->data.PS_TYPE_MASK_DATA[y][x] = 59 (refRO->mask->data.PS_TYPE_MASK_DATA[y][x] & maskBad) ? MASK_BAD : 0; 60 } 61 } 49 // Mask for subtraction 50 psImage *subMask = pmSubtractionMask(inRO->mask, refRO->mask, maskBad, size, footprint); 62 51 63 52 #if 0 … … 84 73 int numRejected = -1; // Number of rejected stamps in each iteration 85 74 for (int i = 0; i < iter && numRejected != 0; i++) { 86 stamps = pmSubtractionFindStamps(stamps, refRO->image, stampMask, MASK_BAD, MASK_STAMP, 87 threshold, spacing, size + footprint); 75 stamps = pmSubtractionFindStamps(stamps, refRO->image, subMask, threshold, spacing); 88 76 if (!stamps) { 89 77 psError(PS_ERR_UNKNOWN, false, "Unable to find stamps on reference image."); … … 103 91 } 104 92 105 numRejected = pmSubtractionRejectStamps(stamps, refRO->image, inRO->image, s tampMask, MASK_STAMP,93 numRejected = pmSubtractionRejectStamps(stamps, refRO->image, inRO->image, subMask, 106 94 solution, footprint, rej, kernels); 107 95 if (numRejected < 0) { … … 111 99 psLogMsg("ppSub", PS_LOG_INFO, "%d stamps rejected on iteration %d.", numRejected, i); 112 100 } 113 psFree(stampMask);114 101 115 102 if (numRejected > 0) { … … 122 109 123 110 psImage *convImage = NULL, *convWeight = NULL, *convMask = NULL; // Convolved images 124 if (!pmSubtractionConvolve(&convImage, &convWeight, &convMask, 125 refRO->image, refRO->weight, refRO->mask, 126 MASK_BAD, maskBlank, solution, kernels)) { 111 if (!pmSubtractionConvolve(&convImage, &convWeight, &convMask, refRO->image, refRO->weight, subMask, 112 maskBlank, solution, kernels)) { 127 113 psError(PS_ERR_UNKNOWN, false, "Unable to convolve reference image."); 128 114 goto ERROR; 129 115 } 116 psFree(subMask); 130 117 131 118 // Do the subtraction 132 119 if (reverse) { 133 (void)psBinaryOp(inRO->image, convImage, "-", inRO->image);120 outRO->image = (psImage*)psBinaryOp(NULL, convImage, "-", inRO->image); 134 121 } else { 135 (void)psBinaryOp(inRO->image, inRO->image, "-", convImage);122 outRO->image = (psImage*)psBinaryOp(NULL, inRO->image, "-", convImage); 136 123 } 137 (void)psBinaryOp(inRO->mask, convMask, "|", inRO->mask); 138 (void)psBinaryOp(inRO->weight, convWeight, "+", inRO->weight); 124 outRO->mask = (psImage*)psBinaryOp(NULL, convMask, "|", inRO->mask); 125 if (convWeight) { 126 outRO->weight = (psImage*)psBinaryOp(NULL, convWeight, "+", inRO->weight); 127 } 139 128 140 129 psFree(convImage); 141 130 psFree(convMask); 142 131 psFree(convWeight); 132 133 outRO->data_exists = true; 134 outCell->data_exists = true; 135 outCell->parent->data_exists = true; 136 137 if (!pmFPACopyConcepts(outCell->parent->parent, inRO->parent->parent->parent)) { 138 psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from input to output."); 139 return false; 140 } 143 141 144 142 #if 0
Note:
See TracChangeset
for help on using the changeset viewer.
