Changeset 13738
- Timestamp:
- Jun 8, 2007, 4:47:49 PM (19 years ago)
- Location:
- trunk/ppSub/src
- Files:
-
- 2 edited
-
ppSubCamera.c (modified) (3 diffs)
-
ppSubReadout.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubCamera.c
r13737 r13738 82 82 83 83 // Output image 84 pmFPAfile *output = pmFPAfileDefine Output(config, input->fpa, "PPSUB.OUTPUT");84 pmFPAfile *output = pmFPAfileDefineSkycell(config, NULL, "PPSUB.OUTPUT"); 85 85 if (!output) { 86 86 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT")); … … 93 93 94 94 // Output mask 95 pmFPAfile *outMask = pmFPAfileDefine Output(config, output->fpa, "PPSUB.OUTPUT.MASK");95 pmFPAfile *outMask = pmFPAfileDefineSkycell(config, output->fpa, "PPSUB.OUTPUT.MASK"); 96 96 if (!outMask) { 97 97 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.MASK")); … … 104 104 105 105 // Output weight 106 pmFPAfile *outWeight = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.WEIGHT"); 107 if (!outWeight) { 108 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.WEIGHT")); 106 if (inputWeight && refWeight) { 107 pmFPAfile *outWeight = pmFPAfileDefineSkycell(config, output->fpa, "PPSUB.OUTPUT.WEIGHT"); 108 if (!outWeight) { 109 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.WEIGHT")); 110 return false; 111 } 112 if (outWeight->type != PM_FPA_FILE_WEIGHT) { 113 psError(PS_ERR_IO, true, "PPSUB.OUTPUT.WEIGHT is not of type WEIGHT"); 114 return false; 115 } 116 } 117 118 pmFPAview *view = pmFPAviewAlloc(0);// View to PHU 119 const char *name = psMetadataLookupStr(NULL, input->fpa->concepts, "FPA.NAME"); 120 if (!pmFPAAddSourceFromView(output->fpa, name, view, output->format)) { 121 psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to output."); 122 psFree(view); 109 123 return false; 110 124 } 111 if (outWeight->type != PM_FPA_FILE_WEIGHT) { 112 psError(PS_ERR_IO, true, "PPSUB.OUTPUT.WEIGHT is not of type WEIGHT"); 113 return false; 114 } 125 psFree(view); 115 126 116 127 // psPhot input -
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.
