Changeset 20805 for trunk/psastro/src/psastroRemoveClumps.c
- Timestamp:
- Nov 19, 2008, 3:28:01 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroRemoveClumps.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroRemoveClumps.c
r17109 r20805 11 11 float Ymax = obj->FP->y; 12 12 for (int i = 0; i < input->n; i++) { 13 obj = (pmAstromObj *)input->data[i];14 if (!isfinite(obj->FP->x)) continue;15 if (!isfinite(obj->FP->y)) continue;16 Xmin = PS_MIN (Xmin, obj->FP->x);17 Xmax = PS_MAX (Xmax, obj->FP->x);18 Ymin = PS_MIN (Ymin, obj->FP->y);19 Ymax = PS_MAX (Ymax, obj->FP->y);13 obj = (pmAstromObj *)input->data[i]; 14 if (!isfinite(obj->FP->x)) continue; 15 if (!isfinite(obj->FP->y)) continue; 16 Xmin = PS_MIN (Xmin, obj->FP->x); 17 Xmax = PS_MAX (Xmax, obj->FP->x); 18 Ymin = PS_MIN (Ymin, obj->FP->y); 19 Ymax = PS_MAX (Ymax, obj->FP->y); 20 20 } 21 21 … … 27 27 // accumulate 2D histogram in image 28 28 for (int i = 0; i < input->n; i++) { 29 obj = (pmAstromObj *)input->data[i];30 if (!isfinite(obj->FP->x)) continue;31 if (!isfinite(obj->FP->y)) continue;32 int Xi = PS_MIN (PS_MAX((obj->FP->x - Xmin) / scale + 5, 0), count->numCols);33 int Yi = PS_MIN (PS_MAX((obj->FP->y - Ymin) / scale + 5, 0), count->numRows);34 count->data.U32[Yi][Xi] ++;29 obj = (pmAstromObj *)input->data[i]; 30 if (!isfinite(obj->FP->x)) continue; 31 if (!isfinite(obj->FP->y)) continue; 32 int Xi = PS_MIN (PS_MAX((obj->FP->x - Xmin) / scale + 5, 0), count->numCols); 33 int Yi = PS_MIN (PS_MAX((obj->FP->y - Ymin) / scale + 5, 0), count->numRows); 34 count->data.U32[Yi][Xi] ++; 35 35 } 36 36 … … 38 38 psStats *stats = psStatsAlloc (PS_STAT_MAX | PS_STAT_MAX | PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 39 39 if (!psImageStats(stats, count, NULL, 0)) { 40 psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");41 psFree(stats);42 psFree(count);43 return NULL;40 psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n"); 41 psFree(stats); 42 psFree(count); 43 return NULL; 44 44 } 45 45 46 46 if (stats->max < 1) { 47 psError(PS_ERR_UNKNOWN, false, "no valid sources in image\n");48 psFree(stats);49 psFree(count);50 return NULL;47 psError(PS_ERR_UNKNOWN, false, "no valid sources in image\n"); 48 psFree(stats); 49 psFree(count); 50 return NULL; 51 51 } 52 52 … … 55 55 psTrace ("psastro", 4, "skipping stars in cells with more than %f stars\n", limit); 56 56 57 psastroVisualPlotRemoveClumps (input, count, scale, limit); 58 57 59 // find and exclude objects in bad pixels 58 60 psArray *output = psArrayAllocEmpty (input->n); 59 61 for (int i = 0; i < input->n; i++) { 60 obj = (pmAstromObj *)input->data[i];61 if (!isfinite(obj->FP->x)) continue;62 if (!isfinite(obj->FP->y)) continue;63 int Xi = PS_MIN (PS_MAX((obj->FP->x - Xmin) / scale + 5, 0), count->numCols);64 int Yi = PS_MIN (PS_MAX((obj->FP->y - Ymin) / scale + 5, 0), count->numRows);65 if (count->data.U32[Yi][Xi] > limit) continue;66 psArrayAdd (output, 16, obj);62 obj = (pmAstromObj *)input->data[i]; 63 if (!isfinite(obj->FP->x)) continue; 64 if (!isfinite(obj->FP->y)) continue; 65 int Xi = PS_MIN (PS_MAX((obj->FP->x - Xmin) / scale + 5, 0), count->numCols); 66 int Yi = PS_MIN (PS_MAX((obj->FP->y - Ymin) / scale + 5, 0), count->numRows); 67 if (count->data.U32[Yi][Xi] > limit) continue; 68 psArrayAdd (output, 16, obj); 67 69 } 68 70 … … 77 79 for (int iy = 0; iy < count->numRows; iy++) { 78 80 for (int ix = 0; ix < count->numCols; ix++) { 79 if (count->data.U32[iy][ix] > limit) {80 psPlane *pixel = psPlaneAlloc();81 pixel->x = ix;82 pixel->y = iy;83 psArrayAdd (badpix, 16, pixel);84 psFree (pixel);85 }81 if (count->data.U32[iy][ix] > limit) { 82 psPlane *pixel = psPlaneAlloc(); 83 pixel->x = ix; 84 pixel->y = iy; 85 psArrayAdd (badpix, 16, pixel); 86 psFree (pixel); 87 } 86 88 } 87 89 }
Note:
See TracChangeset
for help on using the changeset viewer.
