Changeset 7385 for trunk/psphot/src
- Timestamp:
- Jun 6, 2006, 5:37:11 PM (20 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 2 edited
-
Makefile.am (modified) (1 diff)
-
psphotImageMedian.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/Makefile.am
r7349 r7385 7 7 psphot_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(psphot_CFLAGS) 8 8 psphot_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) 9 10 PSLIB_DIR = `pslib-config --prefix` 9 11 10 12 # psphot_CPPFLAGS = $(libpsphot_la_CPPFLAGS) -
trunk/psphot/src/psphotImageMedian.c
r7341 r7385 3 3 // generate the median in NxN boxes, clipping heavily 4 4 // linear interpolation to generate full-scale model 5 bool psphotImageMedian (pmConfig *config, pmFPAview *view) 6 { 5 bool psphotImageMedian (pmConfig *config, pmFPAview *view) 6 { 7 7 bool status; 8 8 psRegion region; … … 15 15 16 16 MAX_SAMPLE_PIXELS = psMetadataLookupF32 (&status, recipe, "IMSTATS_NPIX"); 17 if (!status) MAX_SAMPLE_PIXELS = 1000; 17 if (!status) { 18 MAX_SAMPLE_PIXELS = 1000; 19 } 18 20 unsigned long seed = psMetadataLookupS32 (&status, recipe, "IMSTATS_SEED"); 19 if (!status) seed = 0; 20 psImageClippedStatsInit(MAX_SAMPLE_PIXELS, seed); 21 if (!status) { 22 seed = 0; 23 } 24 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed); 21 25 22 26 // subtract this amount extra from the sky 23 27 float SKY_BIAS = psMetadataLookupF32 (&status, recipe, "SKY_BIAS"); 24 if (!status) SKY_BIAS = 0; 28 if (!status) { 29 SKY_BIAS = 0; 30 } 25 31 26 32 // find the currently selected readout … … 49 55 pmReadout *model = pmFPAfileThisReadout (config->files, view, "PSPHOT.BACKMDL"); 50 56 if (model == NULL) { 51 // select model pixels, from output background model file, or create52 model = pmFPAfileCreateInternal (config->files, "PSPHOT.BACKMDL", nx, ny, PS_TYPE_F32);57 // select model pixels, from output background model file, or create 58 model = pmFPAfileCreateInternal (config->files, "PSPHOT.BACKMDL", nx, ny, PS_TYPE_F32); 53 59 } else { 54 // replace the supplied image data with an image of the desired size55 psImageRecycle (model->image, nx, ny, PS_TYPE_F32);60 // replace the supplied image data with an image of the desired size 61 psImageRecycle (model->image, nx, ny, PS_TYPE_F32); 56 62 } 57 63 psF32 **modelData = model->image->data.F32; 58 64 59 // measure clipped median for subimages 65 // measure clipped median for subimages 60 66 for (int iy = 0; iy < ny; iy++) { 61 for (int ix = 0; ix < nx; ix++) {62 // sx, sy are in parent coords63 int sx = ix*DX - dx + image->col0;64 int sy = iy*DY - dy + image->row0;65 region = psRegionSet (sx, sx + 2*DX, sy, sy + 2*DY);66 region = psRegionForImage (image, region);67 psImage *subset = psImageSubset (image, region);68 psImage *submask = psImageSubset (mask, region);67 for (int ix = 0; ix < nx; ix++) { 68 // sx, sy are in parent coords 69 int sx = ix*DX - dx + image->col0; 70 int sy = iy*DY - dy + image->row0; 71 region = psRegionSet (sx, sx + 2*DX, sy, sy + 2*DY); 72 region = psRegionForImage (image, region); 73 psImage *subset = psImageSubset (image, region); 74 psImage *submask = psImageSubset (mask, region); 69 75 70 // XXX the value of the upper and lower cuts probably should be studied...71 psStats *stats = psImageClippedStats (subset, submask, 0xff, 0.25, 0.75);72 modelData[iy][ix] = stats->robustMedian + SKY_BIAS;76 // XXX the value of the upper and lower cuts probably should be studied... 77 psStats *stats = psImageBackground(subset, submask, 0xff, 0.25, 0.75, MAX_SAMPLE_PIXELS, rng); 78 modelData[iy][ix] = stats->robustMedian + SKY_BIAS; 73 79 74 psFree (stats);75 psFree (subset);76 psFree (submask);80 psFree (stats); 81 psFree (subset); 82 psFree (submask); 77 83 78 // XXX psImageStats is still very inefficient and poorly coded...79 // psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);80 // stats = psImageStats (stats, subset, maskset, 0xff);81 // backMdl->data.F32[iy][ix] = stats->clippedMean;82 }84 // XXX psImageStats is still very inefficient and poorly coded... 85 // psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN); 86 // stats = psImageStats (stats, subset, maskset, 0xff); 87 // backMdl->data.F32[iy][ix] = stats->clippedMean; 88 } 83 89 } 84 90 psLogMsg ("psphot", 3, "build median image: %f sec\n", psTimerMark ("psphot")); … … 98 104 pmReadout *background = pmFPAfileThisReadout (config->files, view, "PSPHOT.BACKGND"); 99 105 if (background == NULL) { 100 background = pmFPAfileCreateInternal (config->files, "PSPHOT.BACKGND", Nx, Ny, PS_TYPE_F32);101 } 106 background = pmFPAfileCreateInternal (config->files, "PSPHOT.BACKGND", Nx, Ny, PS_TYPE_F32); 107 } 102 108 psF32 **backData = background->image->data.F32; 103 109 … … 115 121 // subtract the background model (save in backSub, if requested) 116 122 for (int j = 0; j < image->numRows; j++) { 117 for (int i = 0; i < image->numCols; i++) {118 if (!mask->data.U8[j][i]) {119 image->data.F32[j][i] -= backData[j][i];120 if (backSub) {121 backSub->image->data.F32[j][i] = image->data.F32[j][i];122 }123 }124 }123 for (int i = 0; i < image->numCols; i++) { 124 if (!mask->data.U8[j][i]) { 125 image->data.F32[j][i] -= backData[j][i]; 126 if (backSub) { 127 backSub->image->data.F32[j][i] = image->data.F32[j][i]; 128 } 129 } 130 } 125 131 } 126 132 127 133 psLogMsg ("psphot", 3, "subtracted background model: %f sec\n", psTimerMark ("psphot")); 128 ps ImageClippedStatsCleanup();134 psFree(rng); 129 135 130 136 // the pmReadout selected in this function are all view on entries in config->files
Note:
See TracChangeset
for help on using the changeset viewer.
