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