Changeset 37778
- Timestamp:
- Jan 2, 2015, 11:46:31 AM (12 years ago)
- Location:
- tags/ipp-20141224/psModules/src/objects
- Files:
-
- 2 edited
-
pmPSFtryMakePSF.c (modified) (2 diffs)
-
pmTrend2D.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20141224/psModules/src/objects/pmPSFtryMakePSF.c
r36858 r37778 45 45 #include "pmSourceVisual.h" 46 46 47 bool pmPSF_DataDump (char *filename, psVector *x, psVector *y, psVector *e0, psVector *e1, psVector *e2, psVector *mask); 48 47 49 /***************************************************************************** 48 50 pmPSFFromPSFtry (psfTry): build a PSF model from a collection of source->modelEXT entries … … 356 358 } 357 359 360 bool pmPSF_DataDump (char *filename, psVector *x, psVector *y, psVector *e0, psVector *e1, psVector *e2, psVector *mask) { 361 362 363 FILE *f = fopen (filename, "w"); 364 if (!f) return false; 365 366 for (int i = 0; i < x->n; i++) { 367 368 fprintf (f, "%6.1f %6.1f : %5.2f %5.2f %5.2f : %2d\n", 369 x->data.F32[i], 370 y->data.F32[i], 371 e0->data.F32[i], 372 e1->data.F32[i], 373 e2->data.F32[i], 374 mask->data.U8[i]); 375 } 376 fclose (f); 377 return true; 378 } -
tags/ipp-20141224/psModules/src/objects/pmTrend2D.c
r30044 r37778 211 211 // XXX need to add the API which adjusts the scale 212 212 status = psImageMapClipFit(pGoodFit, trend->map, trend->stats, mask, maskVal, x, y, f, df); 213 if (!status) { 214 psError(PS_ERR_UNKNOWN, true, "failed to build PSF model map"); 215 return false; 216 } 217 218 // the psf model map can have nan pixels: repair this by extrapolation / interpolation 219 // XXX TEST: p_psImagePrint(0, trend->map->map, "before"); 220 status = psImageMapRepair (trend->map->map); 221 // XXX TEST: p_psImagePrint(0, trend->map->map, "after"); 222 if (!status) { 223 psError(PS_ERR_UNKNOWN, true, "failed to repair PSF model map"); 224 return false; 225 } 213 226 break; 214 227 … … 217 230 } 218 231 return status; 232 } 233 234 bool psImageMapRepair (psImage *map) { 235 236 237 // XXX why is my repair not working?? 238 239 // patch over bad regions (use average of 8 possible neighbor pixels) 240 // XXX consider testing all pixels against the 8 neighbors and replacing outliers... 241 double Count = 0; // number of good pixels 242 double Value = 0; // sum of good pixel's value 243 for (int iy = 0; iy < map->numRows; iy++) { 244 for (int ix = 0; ix < map->numCols; ix++) { 245 if (isfinite(map->data.F32[iy][ix])) { 246 Value += map->data.F32[iy][ix]; 247 Count++; 248 continue; 249 } 250 251 double value = 0; 252 double count = 0; 253 for (int jy = iy - 1; jy <= iy + 1; jy++) { 254 if (jy < 0) continue; 255 if (jy >= map->numRows) continue; 256 for (int jx = ix - 1; jx <= ix + 1; jx++) { 257 if (!jx && !jy) continue; 258 if (jx < 0) continue; 259 if (jx >= map->numCols) continue; 260 if (!isfinite(map->data.F32[jy][jx])) continue; 261 value += map->data.F32[jy][jx]; 262 count += 1.0; 263 } 264 } 265 if (count > 0) { 266 // psLogMsg ("psphot", PS_LOG_DETAIL, "patching image map %d, %d: %f (%d pts)\n", ix, iy, (value / count), (int) count); 267 map->data.F32[iy][ix] = value / count; 268 } 269 } 270 } 271 if (Count == 0) { 272 psError(PS_ERR_UNKNOWN, true, "failed to repair PSF model map"); 273 return false; 274 } 275 Value /= Count; 276 277 // patch over remaining bad regions (use global average) 278 for (int iy = 0; iy < map->numRows; iy++) { 279 for (int ix = 0; ix < map->numCols; ix++) { 280 if (!isnan(map->data.F32[iy][ix])) continue; 281 map->data.F32[iy][ix] = Value; 282 } 283 } 284 return true; 219 285 } 220 286
Note:
See TracChangeset
for help on using the changeset viewer.
