IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15865


Ignore:
Timestamp:
Dec 16, 2007, 12:22:06 PM (18 years ago)
Author:
eugene
Message:

added pmMaskIdentifyMode functions

Location:
trunk/psModules/src/detrend
Files:
2 edited

Legend:

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

    r14935 r15865  
    55#include <stdio.h>
    66#include <math.h>
     7#include <strings.h>
    78#include <pslib.h>
    89
     
    125126    psFree(stats);
    126127
     128    psTrace ("psModules.detrend", 3, "suspect: %f +/- %f\n", median, stdev);
     129
    127130    if (!out) {
    128131        out = psImageAlloc(image->numCols, image->numRows, PS_TYPE_S32);
     
    142145}
    143146
    144 
    145 psImage *pmMaskIdentifyBadPixels(const psImage *suspects, float thresh, psMaskType maskVal)
     147psImage *pmMaskIdentifyBadPixels(const psImage *suspects, psMaskType maskVal, int nTotal, float thresh, pmMaskIdentifyMode mode)
    146148{
    147149    PS_ASSERT_IMAGE_NON_NULL(suspects, NULL);
     
    150152
    151153    float limit = NAN;                  // Limit for masking
    152     if (thresh > 0) {
     154
     155    switch (mode) {
     156      case PM_MASK_ID_VALUE:
     157        limit = thresh;
     158        break;
     159
     160      case PM_MASK_ID_FRACTION:
     161        limit = thresh * nTotal;
     162        break;
     163
     164      case PM_MASK_ID_SIGMA: {
    153165        psStats *stats = psStatsAlloc(PS_STAT_CLIPPED_STDEV); // Statistics
    154166        stats->clipSigma = 5.0;
     
    160172        }
    161173        limit = thresh * stats->clippedStdev;
    162         psFree(stats);
    163     } else if (thresh < 0) {
     174        psTrace ("psModules.detrend", 3, "bad: %f -> %f\n", stats->clippedStdev, limit);
     175        psFree(stats);
     176        break;
     177      }
     178
     179      case PM_MASK_ID_POISSON: {
    164180        psStats *stats = psStatsAlloc(PS_STAT_MAX); // Statistics
    165181        if (!psImageStats(stats, suspects, NULL, 0)) {
     
    189205        limit = max + 1.0 - thresh * sqrtf((float)max + 1.0);
    190206
    191     } else {
    192         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    193                 "Threshold (%f) must be a positive or negative real number.\n", thresh);
     207        psTrace ("psModules.detrend", 3, "bad: mode: %d, stdev: %f, limit: %f\n", max, sqrtf((float)max + 1.0), limit);
     208        break;
     209      }
     210      default:
     211        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Invalid mask identify mode");
    194212        return NULL;
    195213    }
     
    212230    }
    213231
     232    psTrace ("psModules.detrend", 3, "bad pixel threshold: %f", limit);
     233
    214234    for (int y = 0; y < suspects->numRows; y++) {
    215235        for (int x = 0; x < suspects->numCols; x++) {
     
    222242    return badpix;
    223243}
     244
     245pmMaskIdentifyMode pmMaskIdentifyModeFromString (const char *string) {
     246
     247    if (!strcasecmp (string, "VALUE")) {
     248      return PM_MASK_ID_VALUE;
     249    }
     250    if (!strcasecmp (string, "FRACTION")) {
     251      return PM_MASK_ID_FRACTION;
     252    }
     253    if (!strcasecmp (string, "SIGMA")) {
     254      return PM_MASK_ID_SIGMA;
     255    }
     256    if (!strcasecmp (string, "POISSON")) {
     257      return PM_MASK_ID_POISSON;
     258    }
     259    return PM_MASK_ID_NONE;
     260}
  • trunk/psModules/src/detrend/pmMaskBadPixels.h

    r12696 r15865  
    55 * @author Eugene Magnier, IfA
    66 *
    7  * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-03-30 21:12:56 $
     7 * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2007-12-16 22:22:06 $
    99 * Copyright 2004 Institute for Astronomy, University of Hawaii
    1010 */
     
    1515/// @addtogroup detrend Detrend Creation and Application
    1616/// @{
     17
     18typedef enum {
     19  PM_MASK_ID_NONE,
     20  PM_MASK_ID_VALUE,
     21  PM_MASK_ID_FRACTION,
     22  PM_MASK_ID_SIGMA,
     23  PM_MASK_ID_POISSON,
     24} pmMaskIdentifyMode;
     25
     26pmMaskIdentifyMode pmMaskIdentifyModeFromString (const char *string);
    1727
    1828/// Applies the bad pixel mask to the input
     
    4959/// pixels (output image).  If "thresh" is negative, a Poisson is assumed.
    5060psImage *pmMaskIdentifyBadPixels(const psImage *suspects, ///< Accumulated suspect pixels image
     61                                 psMaskType maskVal, ///< Value to set for bad pixels
     62                                 int nTotal,
    5163                                 float thresh, ///< Threshold for bad pixel (standard deviations)
    52                                  psMaskType maskVal ///< Value to set for bad pixels
     64                                 pmMaskIdentifyMode mode
    5365                                );
    5466/// @}
Note: See TracChangeset for help on using the changeset viewer.