- Timestamp:
- Feb 19, 2009, 7:59:50 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branch_20090215/psModules/src/objects/pmModel.c
r21381 r21536 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $9 * @date $Date: 2009-02- 06 20:54:14$8 * @version $Revision: 1.27.4.1 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-19 17:59:50 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 59 59 tmp->chisqNorm = 0.0; 60 60 tmp->nDOF = 0; 61 tmp->nPix = 0; 61 62 tmp->nIter = 0; 62 63 tmp->radiusFit = 0; … … 234 235 235 236 if (model->residuals) { 236 DX = xBin*(image->col0 - xCenter - dx) + model->residuals->xCenter + 0.5;237 DY = yBin*(image->row0 - yCenter - dy) + model->residuals->yCenter + 0.5;238 Ro = (model->residuals->Ro) ? model->residuals->Ro->data.F32 : NULL;239 Rx = (model->residuals->Rx) ? model->residuals->Rx->data.F32 : NULL;240 Ry = (model->residuals->Ry) ? model->residuals->Ry->data.F32 : NULL;241 Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;242 if (Ro) {243 NX = model->residuals->Ro->numCols;244 NY = model->residuals->Ro->numRows;245 } 237 DX = xBin*(image->col0 - xCenter - dx) + model->residuals->xCenter + 0.5; 238 DY = yBin*(image->row0 - yCenter - dy) + model->residuals->yCenter + 0.5; 239 Ro = (model->residuals->Ro) ? model->residuals->Ro->data.F32 : NULL; 240 Rx = (model->residuals->Rx) ? model->residuals->Rx->data.F32 : NULL; 241 Ry = (model->residuals->Ry) ? model->residuals->Ry->data.F32 : NULL; 242 Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL; 243 if (Ro) { 244 NX = model->residuals->Ro->numCols; 245 NY = model->residuals->Ro->numRows; 246 } 246 247 } 247 248 … … 255 256 256 257 // XXX should we use using 0.5 pixel offset? 257 // Convert to coordinate in parent image, with offset (dx,dy)258 // Convert to coordinate in parent image, with offset (dx,dy) 258 259 imageCol = ix + image->col0 - dx; 259 260 imageRow = iy + image->row0 - dy; … … 275 276 float rx = xBin*ix + DX; 276 277 277 int rx0 = rx - 0.5;278 int rx1 = rx + 0.5;279 int ry0 = ry - 0.5;280 int ry1 = ry + 0.5;281 282 if (rx0 < 0) goto skip;283 if (ry0 < 0) goto skip;284 if (rx1 >= NX) goto skip;285 if (ry1 >= NY) goto skip;286 287 // these go from 0.0 to 1.0 between the centers of the pixels 288 float fx = rx - 0.5 - rx0;289 float Fx = 1.0 - fx;290 float fy = ry - 0.5 - ry0;291 float Fy = 1.0 - fy;292 293 // check the residual image mask (if set). give up if any of the 4 pixels are masked.294 if (Rm) {295 if (Rm[ry0][rx0]) goto skip;296 if (Rm[ry0][rx1]) goto skip;297 if (Rm[ry1][rx0]) goto skip;298 if (Rm[ry1][rx1]) goto skip;299 }300 301 // a possible further optimization if we re-use these values302 // XXX allow for masked pixels, and add pixel weights303 float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx);304 float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx);305 float Vo = V0*Fy + V1*fy;306 if (!isfinite(Vo)) goto skip;307 308 float Vx = 0.0;309 float Vy = 0.0;310 311 // skip Rx,Ry if Ro is masked312 if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) {313 V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx);314 V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx);315 Vx = V0*Fy + V1*fy;316 317 V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx);318 V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx);319 Vy = V0*Fy + V1*fy;320 }321 if (!isfinite(Vx)) goto skip;322 if (!isfinite(Vy)) goto skip;323 324 // 2D residual variations are set for the true source position325 pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy);278 int rx0 = rx - 0.5; 279 int rx1 = rx + 0.5; 280 int ry0 = ry - 0.5; 281 int ry1 = ry + 0.5; 282 283 if (rx0 < 0) goto skip; 284 if (ry0 < 0) goto skip; 285 if (rx1 >= NX) goto skip; 286 if (ry1 >= NY) goto skip; 287 288 // these go from 0.0 to 1.0 between the centers of the pixels 289 float fx = rx - 0.5 - rx0; 290 float Fx = 1.0 - fx; 291 float fy = ry - 0.5 - ry0; 292 float Fy = 1.0 - fy; 293 294 // check the residual image mask (if set). give up if any of the 4 pixels are masked. 295 if (Rm) { 296 if (Rm[ry0][rx0]) goto skip; 297 if (Rm[ry0][rx1]) goto skip; 298 if (Rm[ry1][rx0]) goto skip; 299 if (Rm[ry1][rx1]) goto skip; 300 } 301 302 // a possible further optimization if we re-use these values 303 // XXX allow for masked pixels, and add pixel weights 304 float V0 = (Ro[ry0][rx0]*Fx + Ro[ry0][rx1]*fx); 305 float V1 = (Ro[ry1][rx0]*Fx + Ro[ry1][rx1]*fx); 306 float Vo = V0*Fy + V1*fy; 307 if (!isfinite(Vo)) goto skip; 308 309 float Vx = 0.0; 310 float Vy = 0.0; 311 312 // skip Rx,Ry if Ro is masked 313 if (Rx && Ry && (mode & PM_MODEL_OP_RES1)) { 314 V0 = (Rx[ry0][rx0]*Fx + Rx[ry0][rx1]*fx); 315 V1 = (Rx[ry1][rx0]*Fx + Rx[ry1][rx1]*fx); 316 Vx = V0*Fy + V1*fy; 317 318 V0 = (Ry[ry0][rx0]*Fx + Ry[ry0][rx1]*fx); 319 V1 = (Ry[ry1][rx0]*Fx + Ry[ry1][rx1]*fx); 320 Vy = V0*Fy + V1*fy; 321 } 322 if (!isfinite(Vx)) goto skip; 323 if (!isfinite(Vy)) goto skip; 324 325 // 2D residual variations are set for the true source position 326 pixelValue += Io*(Vo + XoSave*Vx + XoSave*Vy); 326 327 } 327 328 328 skip:329 skip: 329 330 // add or subtract the value 330 331 if (add) {
Note:
See TracChangeset
for help on using the changeset viewer.
