Changeset 13898 for trunk/psModules/src/objects/pmModel.c
- Timestamp:
- Jun 19, 2007, 4:22:26 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmModel.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmModel.c
r13803 r13898 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.1 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-06- 13 23:41:51$8 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-06-20 02:22:26 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 60 60 tmp->radiusFit = 0; 61 61 tmp->flags = PM_MODEL_STATUS_NONE; 62 tmp->residuals = NULL; // XXX should the model own this memory?62 tmp->residuals = NULL; // XXX should the model own this memory? 63 63 64 64 psS32 Nparams = pmModelParameterCount(type); … … 105 105 /****************************************************************************** 106 106 pmModelEval(source, level, row): evaluates the model function at the specified coords. 107 107 108 108 NOTE: The coords are in subImage source->pixel coords, not image coords. 109 109 110 110 XXX: Use static vectors for x (NO: needs to be thread safe) 111 111 *****************************************************************************/ … … 132 132 } 133 133 134 bool AddOrSubModel(psImage *image, 135 psImage *mask, 136 pmModel *model, 137 pmModelOpMode mode, 138 bool add 139 ) 134 static bool AddOrSubModel(psImage *image, 135 psImage *mask, 136 pmModel *model, 137 pmModelOpMode mode, 138 bool add, 139 psMaskType maskVal 140 ) 140 141 { 141 142 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); … … 151 152 psS32 imageRow; 152 153 psF32 pixelValue; 153 154 154 155 // save original values; restore before returning 155 156 // use the true source position for the residual model … … 161 162 162 163 if (mode & PM_MODEL_OP_NORM) { 163 params->data.F32[PM_PAR_I0] = 1.0;164 params->data.F32[PM_PAR_I0] = 1.0; 164 165 } 165 166 if (!(mode & PM_MODEL_OP_SKY)) { 166 params->data.F32[PM_PAR_SKY] = 0.0;167 params->data.F32[PM_PAR_SKY] = 0.0; 167 168 } 168 169 if (mode & PM_MODEL_OP_CENTER) { 169 params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols;170 params->data.F32[PM_PAR_YPOS] = image->row0 + 0.5*image->numRows;170 params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols; 171 params->data.F32[PM_PAR_YPOS] = image->row0 + 0.5*image->numRows; 171 172 } 172 173 … … 185 186 psImageInterpolateOptions *Ry = NULL; 186 187 if (model->residuals && (mode & (PM_MODEL_OP_RES0 | PM_MODEL_OP_RES1))) { 187 Ro = psImageInterpolateOptionsAlloc(188 PS_INTERPOLATE_BILINEAR,189 model->residuals->Ro, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);190 Rx = psImageInterpolateOptionsAlloc(191 PS_INTERPOLATE_BILINEAR,192 model->residuals->Rx, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);193 Ry = psImageInterpolateOptionsAlloc(194 PS_INTERPOLATE_BILINEAR,195 model->residuals->Ry, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);196 197 xBin = model->residuals->xBin;198 yBin = model->residuals->yBin;199 xResidCenter = model->residuals->xCenter;200 yResidCenter = model->residuals->yCenter;188 Ro = psImageInterpolateOptionsAlloc( 189 PS_INTERPOLATE_BILINEAR, 190 model->residuals->Ro, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0); 191 Rx = psImageInterpolateOptionsAlloc( 192 PS_INTERPOLATE_BILINEAR, 193 model->residuals->Rx, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0); 194 Ry = psImageInterpolateOptionsAlloc( 195 PS_INTERPOLATE_BILINEAR, 196 model->residuals->Ry, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0); 197 198 xBin = model->residuals->xBin; 199 yBin = model->residuals->yBin; 200 xResidCenter = model->residuals->xCenter; 201 yResidCenter = model->residuals->yCenter; 201 202 } 202 203 203 204 for (psS32 iy = 0; iy < image->numRows; iy++) { 204 205 for (psS32 ix = 0; ix < image->numCols; ix++) { 205 if ((mask != NULL) && mask->data.U8[iy][ix])206 if ((mask != NULL) && (mask->data.U8[iy][ix] & maskVal)) 206 207 continue; 207 208 208 209 // Convert i/j to image coord space: 209 // XXX should we use using 0.5 pixel offset?210 imageCol = ix + image->col0;211 imageRow = iy + image->row0;210 // XXX should we use using 0.5 pixel offset? 211 imageCol = ix + image->col0; 212 imageRow = iy + image->row0; 212 213 213 214 x->data.F32[0] = (float) imageCol; 214 215 x->data.F32[1] = (float) imageRow; 215 216 216 pixelValue = 0.0;217 pixelValue = 0.0; 217 218 218 219 // add in the desired components for this coordinate 219 220 if (mode & PM_MODEL_OP_FUNC) { 220 221 pixelValue += modelFunc (NULL, params, x); 221 } 222 223 // get the contribution from the residual model224 if (Ro) {225 // fractional image position226 float ox = xBin*(imageCol + 0.5 - xCenter) + xResidCenter;227 float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter;228 229 if (mode & PM_MODEL_OP_RES0) {230 psU8 mflux = 0;231 double Fo = 0.0;232 psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro);233 if (!mflux && isfinite(Fo)) {234 pixelValue += Io*Fo;235 }236 }237 if (mode & PM_MODEL_OP_RES1) {238 psU8 mflux = 0;239 double Fx = 0.0;240 double Fy = 0.0;241 psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx);242 psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry);243 if (!mflux && isfinite(Fx) && isfinite(Fy)) {244 pixelValue += Io*(xPos*Fx + yPos*Fy);245 }246 }247 }222 } 223 224 // get the contribution from the residual model 225 if (Ro) { 226 // fractional image position 227 float ox = xBin*(imageCol + 0.5 - xCenter) + xResidCenter; 228 float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter; 229 230 if (mode & PM_MODEL_OP_RES0) { 231 psU8 mflux = 0; 232 double Fo = 0.0; 233 psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro); 234 if (!mflux && isfinite(Fo)) { 235 pixelValue += Io*Fo; 236 } 237 } 238 if (mode & PM_MODEL_OP_RES1) { 239 psU8 mflux = 0; 240 double Fx = 0.0; 241 double Fy = 0.0; 242 psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx); 243 psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry); 244 if (!mflux && isfinite(Fx) && isfinite(Fy)) { 245 pixelValue += Io*(xPos*Fx + yPos*Fy); 246 } 247 } 248 } 248 249 249 250 // add or subtract the value … … 275 276 psImage *mask, 276 277 pmModel *model, 277 pmModelOpMode mode) 278 { 279 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 280 psBool rc = AddOrSubModel(image, mask, model, mode, true); 278 pmModelOpMode mode, 279 psMaskType maskVal) 280 { 281 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 282 psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal); 281 283 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 282 284 return(rc); … … 288 290 psImage *mask, 289 291 pmModel *model, 290 pmModelOpMode mode) 291 { 292 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 293 psBool rc = AddOrSubModel(image, mask, model, mode, false); 292 pmModelOpMode mode, 293 psMaskType maskVal) 294 { 295 psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__); 296 psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal); 294 297 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 295 298 return(rc);
Note:
See TracChangeset
for help on using the changeset viewer.
