IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2005, 5:22:13 PM (21 years ago)
Author:
eugene
Message:

running sources in brightness order, using a mask

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/image_stats.c

    r4114 r4115  
    1313    // pass on the stats
    1414    {
    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);
    1619        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);
    2020
    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];
    3029        }
    3130
    32     got_subset:
    3331        // this should use ROBUST not SAMPLE median
    3432        // robust median is broken in pslib (0.5)
Note: See TracChangeset for help on using the changeset viewer.