Changeset 36582 for trunk/ppBackground/src/ppBackgroundStackLoop.c
- Timestamp:
- Mar 11, 2014, 3:46:50 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/ppBackground/src/ppBackgroundStackLoop.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppBackground/src/ppBackgroundStackLoop.c
r36580 r36582 13 13 ) 14 14 { 15 //pmConfig *config = data->config; // Configuration data15 pmConfig *config = data->config; // Configuration data 16 16 int i; 17 17 // … … 63 63 // Loop over the input images, and apply the models to construct the restored versions. 64 64 65 for (i = 0; i < data->stacks->n; i++) { 65 for (i = 0; i < data->stack_data->n; i++) { 66 pmFPAfile *stack = data->stack_data->data[i]; 67 pmFPAview *view = pmFPAviewAlloc(0); 66 68 // Define output image 67 // Calculate model for each pixel of output 68 // Close output image 69 pmFPAfile *stack_model = pmFPAfileDefineOutput(config,stack->fpa,"PPBACKGROUND.STACK.MODEL"); 70 71 if (!stack_model) { 72 psError(psErrorCodeLast(), false, "Unable to generate output model"); 73 return (false); 74 } 75 76 pmFPAfile *stack_corr = pmFPAfileDefineOutput(config,stack->fpa,"PPBACKGROUND.STACK.OUTPUT"); 77 if (!stack_corr) { 78 psError(psErrorCodeLast(), false, "Unable to generate output result"); 79 return (false); 80 } 81 stack_model->save = true; 82 stack_corr->save = true; 83 84 // Iterate over the images. 85 pmChip *chip; 86 while ((chip = pmFPAviewNextChip(view, stack->fpa, 1))) { 87 if (!chip->process || !chip->file_exists) { 88 continue; 89 } 90 91 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 92 psError(psErrorCodeLast(), false, "load failure for Chip"); 93 return(false); 94 } 95 96 pmCell *cell; 97 98 while ((cell = pmFPAviewNextCell(view, stack->fpa, 1)) != NULL) { 99 psLogMsg ("ppImageLoop", 5, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 100 if (!cell->process || !cell->file_exists) { 101 continue; 102 } 103 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 104 psError(psErrorCodeLast(), false, "load failure for Cell"); 105 return(false); 106 } 107 if (cell->readouts->n > 1) { 108 psWarning ("Skipping Video Cell for ppImageDetrendReadout"); 109 continue; 110 } 111 112 // process each of the readouts 113 pmReadout *readout; // Readout from cell 114 while ((readout = pmFPAviewNextReadout (view, stack->fpa, 1)) != NULL) { 115 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) { 116 psError(psErrorCodeLast(), false, "load failure for Readout"); 117 return(false); 118 } 119 if (!readout->data_exists) { 120 continue; 121 } 122 123 pmReadout *model = pmFPAfileThisReadout(config->files,view,"PPBACKGROUND.STACK.MODEL"); 124 pmReadout *corr = pmFPAfileThisReadout(config->files,view,"PPBACKGROUND.STACK.OUTPUT"); 125 126 psPlane *pix = psPlaneAlloc(); // Pixel coordinates on chip 127 psPlane *fp = psPlaneAlloc(); // Focal plane coordinates 128 psPlane *tp = psPlaneAlloc(); // Tangent plane coordinates 129 130 int x,y; 131 for (y = 0; y < readout->image->numRows; y++) { 132 for (x = 0; x < readout->image->numCols; x++) { 133 // Calculate model for each pixel of output 134 psPlaneTransformApply(fp, chip->toFPA, pix); 135 psPlaneTransformApply(tp, stack->fpa->toTPA, fp); 136 137 model->image->data.F32[y][x] = psImageMapEval(data->modelMap,tp->x,tp->y); 138 corr->image->data.F32[y][x] = readout->image->data.F32[y][x] + model->image->data.F32[y][x]; 139 } 140 } 141 psFree(pix); 142 psFree(fp); 143 psFree(tp); 144 } // Close readout 145 146 // Close output image 147 // Close cells (XXX shouldn't pmFPAfileClose iterate down as needed?) 148 view->cell = -1; 149 while ((cell = pmFPAviewNextCell(view, stack->fpa, 1)) != NULL) { 150 if (!cell->process || !cell->file_exists) { 151 continue; 152 } 153 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 154 psError(psErrorCodeLast(), false, "save failure for Cell"); 155 return(false); 156 } 157 } 158 } // Close Cell 159 160 // Close chip 161 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 162 psError(psErrorCodeLast(), false, "save failure for Chip"); 163 return(false); 164 } 165 } // Close chip. 166 // Output and Close FPA 167 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { 168 psError(psErrorCodeLast(), false, "save failure for FPA"); 169 return(false); 170 } 171 psFree(view); 69 172 } 70 173 174 71 175 return(true); 72 176 }
Note:
See TracChangeset
for help on using the changeset viewer.
