Changeset 10396
- Timestamp:
- Dec 1, 2006, 1:12:16 PM (20 years ago)
- Location:
- trunk/psLib/src/imageops
- Files:
-
- 2 edited
-
psImageBackground.c (modified) (4 diffs)
-
psImageBackground.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageBackground.c
r10273 r10396 13 13 // XXX allow the user to choose the stats method? 14 14 // (SAMPLE_MEAN, CLIPPED_MEAN, ROBUST_MEDIAN, FITTED_MEAN) 15 psStats *psImageBackground(const psImage *image, const psImage *mask, psMaskType maskValue, 16 double fmin, double fmax, long nMax, psStatsOptions option, psRandom *rng) 15 bool psImageBackground(psStats *stats, const psImage *image, const psImage *mask, psMaskType maskValue, psRandom *rng) 17 16 { 18 17 PS_ASSERT_IMAGE_NON_NULL(image, NULL); … … 22 21 PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, NULL); 23 22 } 24 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(fmin, 0.0, NULL); 25 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(fmax, 0.0, NULL); 26 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(fmin, 1.0, NULL); 27 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(fmax, 1.0, NULL); 28 PS_ASSERT_INT_NONNEGATIVE(nMax, NULL); 23 if (stats->options & PS_STAT_ROBUST_QUARTILE) { 24 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->min, 0.0, NULL); 25 PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(stats->max, 0.0, NULL); 26 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(stats->min, 1.0, NULL); 27 PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(stats->max, 1.0, NULL); 28 } 29 PS_ASSERT_INT_NONNEGATIVE(stats->nSubsample, NULL); 29 30 PS_ASSERT_PTR_NON_NULL(rng, NULL); 30 31 … … 34 35 35 36 const int Npixels = nx*ny; // Total number of pixels 36 const int Nsubset = ( nMax == 0) ? Npixels : PS_MIN(nMax, Npixels); // Number of pixels in subset37 const int Nsubset = (stats->nSubsample == 0) ? Npixels : PS_MIN(stats->nSubsample, Npixels); // Number of pixels in subset 37 38 38 39 psVector *values = psVectorAllocEmpty(Nsubset, PS_TYPE_F32); // Vector containing subsample … … 62 63 values->n = n; 63 64 64 psStats *stats = psStatsAlloc(option); // Statistics, for return65 66 65 if (stats->options & PS_STAT_ROBUST_QUARTILE) { 67 66 // use simple stats code (old verions) 68 67 // XXX this hack is just for testing, drop when I am happy with the psStats version of the values 69 68 70 int imin = fmin * n;71 int imax = fmax * n;69 int imin = stats->min * n; 70 int imax = stats->max * n; 72 71 int npts = imax - imin + 1; 73 72 -
trunk/psLib/src/imageops/psImageBackground.h
r10169 r10396 7 7 8 8 // Get the background for an image 9 psStats *psImageBackground(const psImage *image, // Image for which to get the background 10 const psImage *mask, // Mask image 11 psMaskType maskValue, // Mask pixels which this mask value 12 double fmin, // Fraction to return in the lower quartile field (0.25 for LQ) 13 double fmax, // Fraction to return in the upper quartile field (0.75 for LQ) 14 long nMax, // Maximum number of pixels to subsample 15 psStatsOptions option, 16 psRandom *rng // Random number generator (for pixel selection) 17 ); 9 bool psImageBackground(psStats *stats, // desired measurement and options 10 const psImage *image, // Image for which to get the background 11 const psImage *mask, // Mask image 12 psMaskType maskValue, // Mask pixels which this mask value 13 psRandom *rng // Random number generator (for pixel selection) 14 ); 18 15 19 16 #endif // #ifndef PS_IMAGE_BACKGROUND_H
Note:
See TracChangeset
for help on using the changeset viewer.
