IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 16, 2006, 3:18:05 PM (20 years ago)
Author:
Paul Price
Message:

Using Poisson distribution if threshold is negative.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmMaskBadPixels.c

    r10022 r10026  
    165165        }
    166166
    167         float target = histo->nums->data.F32[0] * powf(10.0, thresh); // Level to which histogram must fall
    168         int index;
    169         for (index = 0; histo->nums->data.F32[index] > target && index < histo->nums->n; index++)
    170             ;
    171         limit = histo->bounds->data.F32[index];
     167        // Find the mode.  Since this is a Poisson distribution (more or less), this should also be the mean
     168        // and variance.
     169        int max = 0;                    // Index of the mode
     170        for (int i = 0; i < histo->nums->n; i++) {
     171            if (histo->nums->data.F32[i] > histo->nums->data.F32[max]) {
     172                max = i;
     173            }
     174        }
     175
     176        // Since the mode is most likely zero, we add one to get something realistic.  Then "thresh" is
     177        // negative, so we subtract instead of add.
     178        limit = max + 1.0 - thresh * sqrtf((float)max + 1.0);
     179
    172180    } else {
    173181        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
Note: See TracChangeset for help on using the changeset viewer.