Changeset 4115 for trunk/psphot/src/image_stats.c
- Timestamp:
- Jun 4, 2005, 5:22:13 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/image_stats.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/image_stats.c
r4114 r4115 13 13 // pass on the stats 14 14 { 15 bool status = false; 15 bool status = false; 16 int Npixels = image->numRows*image->numCols; 17 int Nsubset = PS_MIN (Npixels, psMetadataLookupF32 (&status, config, "NSUBSET")); 18 psVector *subset = psVectorAlloc (Nsubset, PS_TYPE_F32); 16 19 psRandom *rnd = psRandomAlloc (PS_RANDOM_TAUS, 0); 17 int Nsubset = psMetadataLookupF32 (&status, config, "NSUBSET");18 double fSubset = (double) Nsubset / (image->numRows*image->numCols);19 psVector *subset = psVectorAlloc (Nsubset, PS_TYPE_F32);20 20 21 subset->n = 0; 22 for (int i = 0; i < image->numRows; i++) { 23 for (int j = 0; j < image->numCols; j++) { 24 double frnd = psRandomUniform (rnd); 25 if ((fSubset < 1.0) && (fSubset < frnd)) continue; 26 subset->data.F32[subset->n] = image->data.F32[j][i]; 27 subset->n ++; 28 if (subset->n == Nsubset) goto got_subset; 29 } 21 // choose Nsubset points between 0 and Nx*Ny, convert to coords 22 Npixels = image->numRows*image->numCols; 23 for (int i = 0; i < Nsubset; i++) { 24 double frnd = psRandomUniform (rnd); 25 int pixel = Npixels * frnd; 26 int ix = pixel / image->numCols; 27 int iy = pixel % image->numCols; 28 subset->data.F32[i] = image->data.F32[iy][ix]; 30 29 } 31 30 32 got_subset:33 31 // this should use ROBUST not SAMPLE median 34 32 // robust median is broken in pslib (0.5)
Note:
See TracChangeset
for help on using the changeset viewer.
