Changeset 2282
- Timestamp:
- Nov 4, 2004, 10:52:17 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmReadoutCombine.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmReadoutCombine.c
r2277 r2282 1 p/** @file pmReadoutCombine.c1 /** @file pmReadoutCombine.c 2 2 * 3 3 * This file will contain a module which will combine multiple readout images. … … 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-11-04 19:22:07 $7 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-11-04 20:52:17 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 43 43 } 44 44 45 45 #define MAX_INT 10000 46 46 psImage *pmReadoutCombine(psImage *output, 47 47 const psList *inputs, … … 55 55 PS_PTR_CHECK_NULL(inputs, NULL); 56 56 PS_PTR_CHECK_NULL(params, NULL); 57 unsigned int maskVal = params->maskVal;57 // unsigned int maskVal = params->maskVal; 58 58 psStats *stats = params->stats; 59 59 int i; … … 61 61 int numInputCols = -1; 62 62 int numInputRows = -1; 63 int minInputCols = HUGE; 64 int minInputRowss = HUGE; 63 int maxInputCols = 0; 64 int maxInputRows = 0; 65 int minInputCols = MAX_INT; 66 int minInputRows = MAX_INT; 65 67 psListElem *tmpInput = NULL; 66 68 int numInputs = 0; 67 69 psReadout *tmpReadout; 70 float tmpF; 68 71 69 72 // … … 90 93 (tmpReadout->row0 + tmpReadout->image->row0)); 91 94 tmpF = tmpReadout->col0 + 92 tmpReadout->numCols +93 95 tmpReadout->image->col0 + 94 96 tmpReadout->image->numCols; … … 98 100 (tmpReadout->col0 + tmpReadout->image->col0)); 99 101 tmpF = tmpReadout->row0 + 100 tmpReadout->numRows +101 102 tmpReadout->image->row0 + 102 103 tmpReadout->image->numRows; … … 109 110 output = psImageAlloc(numInputCols-minInputCols, 110 111 numInputRows-minInputRows, PS_TYPE_F32); 111 output->col0= minInputCols;112 output->row0= minInputRows;112 *(int *) &(output->col0) = minInputCols; 113 *(int *) &(output->row0) = minInputRows; 113 114 } else { 114 115 if (((output->col0 + output->numCols) < maxInputCols) || 115 116 ((output->row0 + output->numRows) < maxInputRows)) { 116 psError(__func__, "Output image (%d, %d) is too small to hold combined images.\n",117 output->row0 + output->numRows,118 output->col0 + output->numCols);117 //XXX psError(__func__, "Output image (%d, %d) is too small to hold combined images.\n", 118 // output->row0 + output->numRows, 119 // output->col0 + output->numCols); 119 120 return(NULL); 120 121 } … … 122 123 if ((output->col0 > minInputCols) || 123 124 (output->row0 > minInputRows)) { 124 psError(__func__, "Output image offset is larger then input image offset.\n");125 //XXX psError(__func__, "Output image offset is larger then input image offset.\n"); 125 126 return(NULL); 126 127 } … … 128 129 129 130 if (1 < p_psDetermineNumBits(params->stats->options)) { 130 psError(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");131 //XXX psError(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n"); 131 132 return(NULL); 132 133 } … … 145 146 for (i = 0; i < output->numRows ; i++) { 146 147 for (j = 0; j < output->numCols ; j++) { 147 148 // XXX: put code in here to figure out for each readout if it has149 a pixel that corresponds to this output pixel.150 151 148 for (int r = 0; r < numInputs ; r++) { 152 if (i,j are valid for this readout) { 153 if (0) { 154 tmpPixels->data.F32[r] = WHATEVER; 155 tmpPixelMask->data.U8[r] = 0; 156 } else { 157 tmpPixels->data.F32[r] = 0.0; 158 tmpPixelMask->data.U8[r] = 1; 159 } 149 // if (i,j are valid for this readout) { 150 if (0) { 151 // tmpPixels->data.F32[r] = WHATEVER; 152 tmpPixelMask->data.U8[r] = 0; 153 } else { 154 tmpPixels->data.F32[r] = 0.0; 155 tmpPixelMask->data.U8[r] = 1; 156 } 157 } 158 159 // Determine how many pixels lie between fracLow and fracHigh. 160 int pixelCount = 0; 161 for (int r = 0; r < numInputs ; r++) { 162 if (tmpPixelMask->data.U8[r] == 0) { 163 if ((params->fracLow <= tmpPixels->data.F32[r]) && 164 (params->fracHigh >= tmpPixels->data.F32[r])) { 165 pixelCount++; 160 166 } 161 162 // Determine how many pixels lie between fracLow and fracHigh. 163 int pixelCount = 0; 167 } 168 } 169 170 // If more than params->nKeep pixels lie between the valid range, 171 // then loop through the pixels, and mask away any pixels outside 172 // that range. 173 if (pixelCount >= params->nKeep) { 164 174 for (int r = 0; r < numInputs ; r++) { 165 175 if (tmpPixelMask->data.U8[r] == 0) { 166 176 if ((params->fracLow <= tmpPixels->data.F32[r]) && 167 177 (params->fracHigh >= tmpPixels->data.F32[r])) { 168 pixelCount++; 178 tmpPixelMaskNKeep->data.U8[r] = 0; 179 } else { 180 tmpPixelMaskNKeep->data.U8[r] = 1; 169 181 } 170 182 } 171 183 } 172 173 // If more than params->nKeep pixels lie between the valid range, 174 // then loop through the pixels, and mask away any pixels outside 175 // that range. 176 if (pixelCount >= params->nKeep) { 177 for (int r = 0; r < numInputs ; r++) { 178 if (tmpPixelMask->data.U8[r] == 0) { 179 if ((params->fracLow <= tmpPixels->data.F32[r]) && 180 (params->fracHigh >= tmpPixels->data.F32[r])) { 181 tmpPixelMaskNKeep->data.U8[r] = 0; 182 } else { 183 tmpPixelMaskNKeep->data.U8[r] = 1; 184 } 185 } 186 } 187 } 188 189 // Calculate the specified statistic on the stack of pixels. 190 stats = psVectorStats(stats, 191 tmpPixels, 192 tmpPixelMaskNKeep, 193 1); 194 195 // Set the pixel value in the output image to the stat value. 196 double statValue; 197 if (!p_psGetStatValue(stats, &statValue)) { 198 psError(PS_ERR_UNKNOWN,true, "Could not determine stats value.\n"); 199 return(NULL); 200 } else { 201 output->data.F32[i][j] = (float) statValue; 202 } 203 } 204 } 205 206 psFree(tmpPixels); 207 psFree(tmpPixels); 208 psFree(tmpPixelMask); 209 psFree(tmpPixelMaskNKeep); 210 psFree(tmpReadouts); 211 212 return(output); 213 } 184 } 185 186 // Calculate the specified statistic on the stack of pixels. 187 stats = psVectorStats(stats, 188 tmpPixels, 189 tmpPixelMaskNKeep, 190 1); 191 192 // Set the pixel value in the output image to the stat value. 193 double statValue; 194 if (!p_psGetStatValue(stats, &statValue)) { 195 psError(PS_ERR_UNKNOWN,true, "Could not determine stats value.\n"); 196 return(NULL); 197 } else { 198 output->data.F32[i][j] = (float) statValue; 199 } 200 } 201 } 202 203 psFree(tmpPixels); 204 psFree(tmpPixels); 205 psFree(tmpPixelMask); 206 psFree(tmpPixelMaskNKeep); 207 psFree(tmpReadouts); 208 209 return(output); 210 }
Note:
See TracChangeset
for help on using the changeset viewer.
