- Timestamp:
- Apr 21, 2014, 5:42:34 AM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ppImage/src (modified) (1 prop)
-
ppImage/src/ppImageAuxiliaryMask.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/ppImage/src
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/ppImage/src/ppImageAuxiliaryMask.c
r35861 r36680 35 35 return NULL; 36 36 } 37 if (image->type.type != PS_TYPE_IMAGE_MASK) { 38 psWarning("auxiliary mask image %s has unexpected type %d\n", realName, image->type.type); 39 return false; 40 } 37 41 psFree(realName); 38 42 … … 74 78 } 75 79 76 // Find a suitable detRun with type AUXMASK 77 78 psTime *time = psMetadataLookupPtr(NULL, input->fpa->concepts, "FPA.TIME"); 79 if (time->sec == 0 && time->nsec == 0) { 80 psLogMsg ("psModules.camera", PS_LOG_WARN, "FPA.TIME has not been set.\n"); 81 } 82 83 char *cameraName = psMetadataLookupStr(NULL, input->fpa->concepts, "FPA.CAMERA"); 84 pmDetrendSelectOptions *detrendOptions = pmDetrendSelectOptionsAlloc(cameraName, *time, PM_DETREND_TYPE_AUXMASK); 85 86 pmDetrendSelectResults *results = pmDetrendSelect(detrendOptions, config); 87 psFree(detrendOptions); 88 if (!results) { 89 psError (psErrorCodeLast(), false, "no matching auxiliary mask found"); 90 return false; 91 } 92 93 pmFPALevel fileLevel = pmFPALevelFromName(results->level); 94 if (fileLevel != PM_FPA_LEVEL_CHIP) { 95 psError (PM_ERR_CONFIG, false, "invalid file level %d for selected auxiliary mask", fileLevel); 96 return false; 97 } 98 80 pmFPAfile *auxmask = psMetadataLookupPtr(&status, config->files, "PPIMAGE.AUXMASK"); 81 if (!status) { 82 psError(PS_ERR_UNEXPECTED_NULL, true, "PPIMAGE.CHIP file is not defined"); 83 return false; 84 } 85 99 86 // Go find the readout 100 87 // code to find the readouts was adapted from ppImageSubtractBackground … … 131 118 return true; 132 119 } 133 // not needed psImage *image = ro->image; 120 134 121 psImage *mask = ro->mask; 135 122 136 // now read the auxiliary mask file 137 psString class_id = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); 138 139 char *auxMaskFileName = pmDetrendFile(results->detID, class_id, config); 140 if (!auxMaskFileName) { 141 psError (PM_ERR_CONFIG, false, "unable to find auxiliary mask file name for %s %s", results->detID, class_id); 142 return false; 143 } 144 psLogMsg ("ppImage", PS_LOG_INFO, "Auxiliary mask file: %s", auxMaskFileName); 145 146 psFree(results); 147 // record that we read this file in the config dump file. 148 // Note: this value isn't used during updates though. 149 pmConfigRunFilenameAddRead(config, "PPIMAGE.AUXMASK", auxMaskFileName); 150 recordFileInHeader(chip, "DETREND.AUXMASK", "auxiliary mask", auxMaskFileName); 151 152 psImage *auxMask = readAuxiliaryMask(config, auxMaskFileName); 153 psFree(auxMaskFileName); 154 if (!auxMask) { 155 psError(PS_ERR_UNKNOWN, false, "failed to read auxiliary mask file"); 156 return false; 157 } 158 159 // if the cell has video and the recipe value 123 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 124 psWarning("mask image has unexpected type %d\n", mask->type.type); 125 return false; 126 } 127 128 pmChip *auxMaskChip = pmFPAviewThisChip(view, auxmask->fpa); 129 if (!auxMaskChip) { 130 psWarning("failed to find pmChip for auxiliary mask"); 131 return false; 132 } 133 pmCell *auxMaskCell = auxMaskChip->cells->data[0]; 134 if (!auxMaskCell) { 135 psWarning("failed to find pmCell for auxiliary mask"); 136 return false; 137 } 138 pmReadout *auxMaskReadout = auxMaskCell->readouts->data[0]; 139 if (!auxMaskReadout) { 140 psWarning("failed to find pmReadout for auxiliary mask"); 141 return false; 142 } 143 psImage *auxMaskImage = auxMaskReadout->mask; 144 if (!auxMaskImage) { 145 psWarning("failed to find psImage for auxiliary mask"); 146 return false; 147 } 148 if (auxMaskImage->type.type != PS_TYPE_IMAGE_MASK) { 149 psWarning("auxiliary mask image has unexpected type %d\n", auxMaskImage->type.type); 150 return false; 151 } 152 153 // if the cell has video and the recipe value is set or in the video mask 160 154 if (options->hasVideo && options->auxVideoMask && strcmp(options->auxVideoMask, "NULL")) { 161 155 psImage *videoMask = readAuxiliaryMask(config, options->auxVideoMask); … … 168 162 recordFileInHeader(chip, "DETREND.AUXVIDEOMASK", "auxiliary video mask", options->auxVideoMask); 169 163 170 // compute auxMask *= videoMask171 if (!psBinaryOp(auxMask , auxMask, "*", videoMask)) {172 psError(PS_ERR_UNKNOWN, false, " mulitplication of auxiliary mask and auxiliary video mask failed");164 // compute auxMask |= videoMask 165 if (!psBinaryOp(auxMaskImage, auxMaskImage, "|", videoMask)) { 166 psError(PS_ERR_UNKNOWN, false, "combination of auxiliary mask and auxiliary video mask failed"); 173 167 return false; 174 168 } … … 176 170 } 177 171 178 if ((mask->numRows != auxMask ->numRows) || (mask->numCols != auxMask->numCols) ||179 (mask->row0 != auxMask ->row0) || (mask->col0 != auxMask->col0)) {172 if ((mask->numRows != auxMaskImage->numRows) || (mask->numCols != auxMaskImage->numCols) || 173 (mask->row0 != auxMaskImage->row0) || (mask->col0 != auxMaskImage->col0)) { 180 174 psError(PS_ERR_IO, false, "structure of auxiliary mask does not match this chip"); 181 175 return false; … … 189 183 psAssert(staticMaskVal, "Need staticMaskVal!"); 190 184 185 // XXX: now that we are using an auxilary mask that matches the format of ps masks, we could just 186 // do psBinaryOp(mask, mask, "|", auxMaskImage) but run an explicit loop so that we can measure 187 // and log the number of additional pixels masked 191 188 int numCols = mask->numCols, numRows = mask->numRows; // Size of image 192 189 unsigned long numMasked = 0; 193 190 for (int y = 0; y < numRows; y++) { 194 191 for (int x = 0; x < numCols; x++) { 195 // auxMask is floating point type image with pixel value 0 meaning mask it 196 // XXX: support other types and get the mask value from the header 197 if (auxMask->data.F32[y][x] == 0) { 192 if (auxMaskImage->data.U16[y][x] != 0) { 198 193 if ((mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & staticMaskVal) == 0) { 199 194 // pixel was not previously included in the static mask so mask it … … 202 197 } 203 198 // I don't need to do this. 199 // image->data.F32[y][x] = 0.0; 204 200 // The background subtraction code runs after us and will do it there 205 // image->data.F32[y][x] = 0.0;206 201 } 207 202 } … … 215 210 } 216 211 217 psFree(auxMask);218 219 212 // psLogMsg ("ppImage", 5, "auxiliary mask: %f sec\n", psTimerMark ("aux.mask")); 220 213
Note:
See TracChangeset
for help on using the changeset viewer.
