IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 9, 2008, 7:17:43 PM (18 years ago)
Author:
Paul Price
Message:

Changing from drop-dead simple remnance algorithm to something a bit
more complicated: accumulate up the columns and compare each column
with the others.

File:
1 edited

Legend:

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

    r20620 r20621  
    88#include "pmFPA.h"
    99#include "pmRemnance.h"
     10
     11#define SIZE 30                         // Size of accumulation patch
    1012
    1113#define THRESHOLD 4.0                   // Threshold above background
     
    3436    }
    3537    psFree(rng);
    36     float thresh = stats->robustMedian + THRESHOLD * stats->robustStdev; // Threshold for significant pixels
    37     psFree(stats);
     38    float bg = stats->robustMedian;     // Background level
    3839
    3940    // Starting at the bottom of the detector, mask pixels that are significant
     41    psVector *colSums = psVectorAlloc(numCols, PS_TYPE_F32); // Sums for each column
     42    psVectorInit(colSums, 0.0);
     43    psVector *colNums = psVectorAlloc(numCols, PS_TYPE_S32); // Number for each column
     44    psVectorInit(colNums, 0);
     45    psVector *colAvgs = psVectorAlloc(numCols, PS_TYPE_F32); // Average for each column
     46    psVector *colMask = psVectorAlloc(numCols, PS_TYPE_MASK); // Mask for each column
    4047    int numMasked = 0;                  // Number of pixels masked
    41     for (int x = 0; x < numCols; x++) {
    42         bool significant = true;        // Are pixels significant?
    43         for (int y = 0; significant && y < numRows; y++) {
    44             if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
    45                 continue;
     48    int numAccumulations = ceil(numRows / (float)SIZE); // Number of accumulations up the columns
     49    for (int i = 0; i < numAccumulations; i++) {
     50        int min = i * SIZE;             // Minimum coordinate
     51        int max = PS_MIN(min + SIZE, numRows); // Maximum coordinate
     52        for (int x = 0; x < numCols; x++) {
     53            int num = 0;                // Number of pixels in accumulation
     54            float sum = 0.0;            // Sum of pixels in accumulation
     55            for (int y = min; y < max; y++) {
     56                if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     57                    continue;
     58                }
     59                sum += image->data.F32[y][x] - bg;
     60                num++;
    4661            }
    47             if (image->data.F32[y][x] > thresh) {
    48                 mask->data.PS_TYPE_MASK_DATA[y][x] |= maskRem;
    49                 numMasked++;
    50             } else {
    51                 significant = false;
     62            colSums->data.F32[x] = sum;
     63            colNums->data.S32[x] = num;
     64            colAvgs->data.F32[x] = sum / (float)num;
     65            colMask->data.PS_TYPE_MASK_DATA[x] = (colNums->data.S32[x] == 0 ? 0xFF : 0);
     66        }
     67
     68        if (!psVectorStats(stats, colAvgs, NULL, colMask, 0xFF)) {
     69            psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on column accumulations.");
     70            psFree(colSums);
     71            psFree(colNums);
     72            psFree(colAvgs);
     73            psFree(colMask);
     74            psFree(stats);
     75            return false;
     76        }
     77
     78        float threshold = stats->robustMedian + THRESHOLD * stats->robustStdev; // Threshold for masking
     79
     80        max = PS_MIN(max + SIZE, numRows);
     81
     82        for (int x = 0; x < numCols; x++) {
     83            if (colAvgs->data.F32[x] > threshold) {
     84                for (int y = 0; y < max; y++) {
     85                    mask->data.PS_TYPE_MASK_DATA[y][x] = maskRem;
     86                    numMasked++;
     87                }
    5288            }
    5389        }
    5490    }
     91
     92    psFree(colSums);
     93    psFree(colNums);
     94    psFree(colAvgs);
     95    psFree(colMask);
     96    psFree(stats);
     97
    5598
    5699    psMetadataAddS32(ro->analysis, PS_LIST_TAIL, PM_REMNANCE_ANALYSIS_NUM, 0,
Note: See TracChangeset for help on using the changeset viewer.