- Timestamp:
- Feb 4, 2010, 8:59:31 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/ppImage/src/ppImageDetrendPattern.c
r26695 r26776 16 16 pmCell *cell = NULL; 17 17 18 assert (options->doPattern); // do not call if not needed 19 assert (inputView->chip != -1); 20 assert (inputView->cell == -1); 21 assert (inputView->readout == -1); 22 bool status; 23 pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT"); 18 assert(options->doPatternRow || options->doPatternCell); // do not call if not needed 19 assert(inputView->chip != -1); 20 assert(inputView->cell == -1); 21 assert(inputView->readout == -1); 24 22 25 pmFPAview *view = pmFPAviewAlloc(0); // View for local processing 26 *view = *inputView; 23 if (options->doPatternRow) { 24 bool status; 25 pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT"); 26 pmFPAview *view = pmFPAviewAlloc(0); // View for local processing 27 *view = *inputView; 28 while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) { 29 if (!cell->process || !cell->file_exists) { 30 continue; 31 } 32 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 33 ESCAPE("load failure for Cell"); 34 } 27 35 28 while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) { 29 if (!cell->process || !cell->file_exists) { 30 continue; 31 } 32 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 33 ESCAPE("load failure for Cell"); 34 } 35 36 if (!cell->data_exists) { 37 continue; 38 } 39 40 if (cell->readouts->n > 1) { 41 psWarning ("Skipping Video Cell for ppImageDetrendPatternApply"); 42 continue; 43 } 44 45 psMetadataItem *doPattern = pmConfigRecipeValueByView(config, RECIPE_NAME, "PATTERN.SUBSET", 46 chip->parent, view); // Do we do pattern sub? 47 if (!doPattern || doPattern->type != PS_DATA_BOOL) { 48 ESCAPE("Unable to determine whether pattern matching should be applied."); 49 } 50 if (!doPattern->data.B) { 51 continue; 52 } 53 54 psLogMsg("ppImage", PS_LOG_INFO, "Performing pattern subtraction for %d,%d\n", view->chip, view->cell); 55 56 // process each of the readouts 57 pmReadout *readout; // Readout from cell 58 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 59 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 60 ESCAPE("load failure for Readout"); 61 } 62 if (!readout->data_exists) { 36 if (!cell->data_exists) { 63 37 continue; 64 38 } 65 39 66 // perfore pattern correction 67 if (!pmPatternRow(readout, options->patternOrder, options->patternIter, options->patternRej, 68 options->patternThresh, options->patternMean, options->patternStdev, 69 options->maskValue, options->darkMask)) { 70 psFree(view); 71 return(false); 40 if (cell->readouts->n > 1) { 41 psWarning ("Skipping Video Cell for ppImageDetrendPatternApply"); 42 continue; 43 } 44 45 psMetadataItem *doPattern = pmConfigRecipeValueByView(config, RECIPE_NAME, "PATTERN.ROW.SUBSET", 46 chip->parent, view); // Do pattern corr? 47 if (!doPattern || doPattern->type != PS_DATA_BOOL) { 48 ESCAPE("Unable to determine whether row pattern correction should be applied."); 49 } 50 if (!doPattern->data.B) { 51 continue; 52 } 53 54 psLogMsg("ppImage", PS_LOG_INFO, "Performing row pattern correction for %d,%d\n", 55 view->chip, view->cell); 56 57 // process each of the readouts 58 pmReadout *readout; // Readout from cell 59 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 60 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 61 ESCAPE("load failure for Readout"); 62 } 63 if (!readout->data_exists) { 64 continue; 65 } 66 67 // Perform pattern correction 68 if (!pmPatternRow(readout, options->patternRowOrder, options->patternRowIter, 69 options->patternRowRej, options->patternRowThresh, options->patternRowMean, 70 options->patternRowStdev, options->maskValue, options->darkMask)) { 71 psFree(view); 72 return(false); 73 } 72 74 } 73 75 } 76 psFree(view); 74 77 } 75 78 76 psFree(view); 79 if (options->doPatternCell) { 80 int numCells = chip->cells->n; // Number of cells 81 psVector *tweak = psVectorAlloc(numCells, PS_TYPE_U8); // Tweak cell? 82 pmFPAview *view = pmFPAviewAlloc(0); // View for local processing 83 *view = *inputView; 84 for (int i = 0; i < chip->cells->n; i++) { 85 view->cell = i; 86 psMetadataItem *doPattern = pmConfigRecipeValueByView(config, RECIPE_NAME, "PATTERN.CELL.SUBSET", 87 chip->parent, view); // Do pattern sub? 88 if (!doPattern || doPattern->type != PS_DATA_BOOL) { 89 ESCAPE("Unable to determine whether cell pattern correction should be applied."); 90 } 91 if (doPattern->data.B) { 92 tweak->data.U8[i] = 0xFF; 93 } 94 } 95 96 // Tweak the cells 97 if (!pmPatternCell(chip, tweak, options->patternCellBG, options->patternCellMean, 98 options->maskValue, options->darkMask)) { 99 psFree(tweak); 100 psFree(view); 101 return false; 102 } 103 psFree(tweak); 104 psFree(view); 105 } 106 77 107 return(true); 78 108 }
Note:
See TracChangeset
for help on using the changeset viewer.
