IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15807


Ignore:
Timestamp:
Dec 13, 2007, 7:53:28 AM (18 years ago)
Author:
eugene
Message:

updates to get new mask api working

Location:
branches/eam_branch_20071212/ppMerge/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20071212/ppMerge/src/ppMergeMaskByImageStats.c

    r15804 r15807  
    1515#include "ppMergeMask.h"
    1616
     17// this function measures the statistics of the pixel values for a single readout (median and stdev)
     18// and identifies pixels which deviate from the median by more than MASK.SUSPECT * stdev.
    1719
    1820// Generate a mask image consisting of pixels which are outliers from the image mean
     
    6567                            view->chip, view->cell, view->readout);
    6668                    float frac = options->sample / (float)(roIn->image->numCols * roIn->image->numRows);
     69
     70                    // measure the global image stats: median and stdev
     71                    // XXX note that this now will accept any of several stats options
     72                    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV);
     73                    stats->nSubsample = frac * image->numCols * image->numRows;
     74                    if (!psImageBackground(stats, NULL, image, mask, maskVal, rng) ||
     75                        !isfinite(stats->robustMedian) || !isfinite(stats->robustUQ) || !isfinite(stats->robustLQ)) {
     76                      psError(PS_ERR_UNKNOWN, false, "Unable to measure image statistics.\n");
     77                      psFree(stats);
     78                      psFree(rng);
     79                      return NULL;
     80                    }
     81                    psFree(rng);
     82
     83                    float median = stats->robustMedian; // Median value
     84                    float stdev = stats->robustStdev; // Estimate of the standard deviation
     85                    psFree(stats);
     86
    6787                    suspect = pmMaskFlagSuspectPixels(suspect, roIn, options->maskSuspect,
    68                                                       options->combine->maskVal, frac, rng);
     88                                                      options->combine->maskVal, median, stdev);
     89                   
     90                    psMetadataAddF32(roIn->analysis, PS_LIST_TAIL, "MEDIAN", 0, "median", median);
     91                    psMetadataAddF32(roIn->analysis, PS_LIST_TAIL, "STDEV", 0, "stdev", stdev);
    6992                }
    7093
  • branches/eam_branch_20071212/ppMerge/src/ppMergeMaskReadoutByPixelStats.c

    r15804 r15807  
    99#include <pslib.h>
    1010#include <psmodules.h>
     11
     12// this function measures the statistics of the inputs->n representations of a given pixel (median and stdev) and identifies pixels
     13// which deviate from the median by more than MASK.PIXEL.SUSPECT * stdev.
     14
     15// it also identifies pixels for which the stdev is more than MASK.PIXEL.NOISY * the image stdev
    1116
    1217// XXX: Maybe add support for S16 and S32 types.  Currently, only F32 supported.
     
    2732    }
    2833
    29     // XXX is it possible / desired to use the weight in this analysis?
    30     for (int i = 0; i < inputs->n; i++) {
    31         pmReadout *readout = inputs->data[i]; // Readout of interest
    32         if (params->weights && !readout->weight) {
    33             psError(PS_ERR_UNEXPECTED_NULL, true,
    34                     "Rejection based on weights requested, but no weights supplied for image %d.\n", i);
    35             return false;
    36         }
    37     }
     34    // XXX note : we are ignoring weights for now.
    3835
    3936    bool first = !output->image;        // First pass through?
     
    7774    psTrace("psModules.imcombine", 7, "Output minimum: %d,%d\n", output->col0, output->row0);
    7875
     76    // Get the correct statistics option for weights
    7977    psStatsOptions combineStdev = 0; // Statistics option for weights
    80     if (params->weights) {
    81 
    82         if (!output->weight) {
    83             output->weight = psImageAlloc(xSize, ySize, PS_TYPE_F32);
    84         }
    85         if (output->weight->numCols < xSize || output->weight->numRows < ySize) {
    86             psImage *newWeight = psImageAlloc(xSize, ySize, PS_TYPE_F32);
    87             psImageInit(newWeight, 0.0);
    88             psImageOverlaySection(newWeight, output->weight, output->col0, output->row0, "=");
    89             psFree(output->weight);
    90             output->weight = newWeight;
    91         }
    92 
    93         if (first) {
    94             psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK,
    95                              "Using input weights to combine images", "");
    96         }
    97 
    98         // Get the correct statistics option for weights
    99         switch (params->combine) {
    100         case PS_STAT_SAMPLE_MEAN:
    101         case PS_STAT_SAMPLE_MEDIAN:
    102             combineStdev = PS_STAT_SAMPLE_STDEV;
    103             break;
    104         case PS_STAT_ROBUST_MEDIAN:
    105             combineStdev = PS_STAT_ROBUST_STDEV;
    106             break;
    107         case PS_STAT_FITTED_MEAN:
    108             combineStdev = PS_STAT_FITTED_STDEV;
    109             break;
    110         case PS_STAT_CLIPPED_MEAN:
    111             combineStdev = PS_STAT_CLIPPED_STDEV;
    112             break;
    113         default:
    114             psAbort("Should never get here --- checked params->combine before.\n");
    115         }
    116         stats->options |= combineStdev;
    117     }
     78    switch (params->combine) {
     79      case PS_STAT_SAMPLE_MEAN:
     80      case PS_STAT_SAMPLE_MEDIAN:
     81        combineStdev = PS_STAT_SAMPLE_STDEV;
     82        break;
     83      case PS_STAT_ROBUST_MEDIAN:
     84        combineStdev = PS_STAT_ROBUST_STDEV;
     85        break;
     86      case PS_STAT_FITTED_MEAN:
     87        combineStdev = PS_STAT_FITTED_STDEV;
     88        break;
     89      case PS_STAT_CLIPPED_MEAN:
     90        combineStdev = PS_STAT_CLIPPED_STDEV;
     91        break;
     92      default:
     93        psAbort("Should never get here --- checked params->combine before.\n");
     94    }
     95    stats->options |= combineStdev;
    11896
    11997    // We loop through each pixel in the output image.  We loop through each input readout.  We determine if
     
    129107    psU8 *maskData = mask->data.U8;     // Dereference mask
    130108
    131     psVector *weights = NULL;           // Stack of weights
    132     psVector *errors = NULL;            // Stack of errors (sqrt of variance/weights), for psVectorStats
    133     psF32 *weightsData = NULL;          // Dereference weights
    134     if (params->weights) {
    135         weights = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of weights
    136         weightsData = weights->data.F32;
    137     }
    138109    psVector *index = NULL;             // The indices to sort the pixels
    139110
     
    172143    psF32 **outputImage  = output->image->data.F32; // Output image
    173144    psU8  **outputMask   = output->mask->data.U8; // Output mask
    174     psF32 **outputWeight = NULL; // Output weight map
    175     if (output->weight) {
    176         outputWeight = output->weight->data.F32;
    177     }
    178145
    179146    psVector *invScale = NULL;          // Inverse scale; pre-calculated for efficiency
Note: See TracChangeset for help on using the changeset viewer.