IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 29, 2006, 7:51:05 AM (19 years ago)
Author:
rhl
Message:

1/ Make psImageBackground interpret nMax == 0 as "all pixels"
2/ Make psImageBackground propagate errors in psVectorStats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageBackground.c

    r10169 r10273  
    2626    PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(fmin, 1.0, NULL);
    2727    PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(fmax, 1.0, NULL);
    28     PS_ASSERT_INT_POSITIVE(nMax, NULL);
     28    PS_ASSERT_INT_NONNEGATIVE(nMax, NULL);
    2929    PS_ASSERT_PTR_NON_NULL(rng, NULL);
    3030
     
    3333    long ny = image->numRows;
    3434
    35     int Nsubset = PS_MIN(nMax, nx*ny);  // Number of pixels in nubset
    36     int Npixels = nx*ny;                // Total number of pixels
     35    const int Npixels = nx*ny;                // Total number of pixels
     36    const int Nsubset = (nMax == 0) ? Npixels : PS_MIN(nMax, Npixels); // Number of pixels in subset
    3737
    3838    psVector *values = psVectorAllocEmpty(Nsubset, PS_TYPE_F32); // Vector containing subsample
     
    9595            stats->clipSigma = 1.0;
    9696        }
    97         psVectorStats (stats, values, NULL, NULL, 0);
     97        if (psVectorStats (stats, values, NULL, NULL, 0) == NULL) {
     98            psError(PS_ERR_UNKNOWN, false, "Unable to measure statistics for image background "
     99                    "(%dx%d, (row0,col0) = (%d,%d)",
     100                    image->numRows, image->numCols, image->row0, image->col0);
     101            psFree(stats);
     102            psFree(values);
     103            return NULL;
     104        }
    98105    }
    99106
Note: See TracChangeset for help on using the changeset viewer.