IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 5, 2008, 1:04:13 PM (17 years ago)
Author:
Paul Price
Message:

Adding mode to allow creation of large holes (attempting to simulate e.g., dead cells in GPC1).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSimBadPixels.c

    r15602 r20910  
    99
    1010#include "ppSim.h"
     11
     12// Mode for bad pixels
     13typedef enum {
     14    BADPIX_ERROR,                       // Error: mode not set
     15    BADPIX_RANDOM,                      // Random values for bad pixels
     16    BADPIX_NAN,                         // NAN values for bad pixels
     17} badpixMode;
    1118
    1219
     
    4653    }
    4754
     55    int size = psMetadataLookupS32(&mdok, recipe, "BADPIX.SIZE"); // (Half-)size of bad pixels
     56    if (!mdok) {
     57        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "BADPIX.SIZE not set.");
     58        return false;
     59    }
     60
     61    psString modeString = psMetadataLookupStr(&mdok, recipe, "BADPIX.MODE"); // Mode for bad pixels
     62    if (!mdok) {
     63        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "BADPIX.MODE not set.");
     64        return false;
     65    }
     66    badpixMode mode = BADPIX_ERROR;
     67    if (strcmp(modeString, "RANDOM") == 0) {
     68        mode = BADPIX_RANDOM;
     69    } else if (strcmp(modeString, "NAN") == 0) {
     70        mode = BADPIX_NAN;
     71    } else {
     72        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "BADPIX.MODE not recognised.");
     73        return false;
     74    }
     75
    4876    psRandom *pseudoRNG = psRandomAlloc(PS_RANDOM_TAUS, seed); // Pseudo-random number generator
    4977
     
    5280
    5381    for (int y = 0; y < numRows; y++) {
     82        int vMin = PS_MAX(y - size, 0), vMax = PS_MIN(y + size, numRows - 1); // Extent of CR
    5483        for (int x = 0; x < numCols; x++) {
    5584            if (psRandomUniform(pseudoRNG) < frac) {
    56                 image->data.F32[y][x] *= psRandomGaussian(rng);
     85                int uMin = PS_MAX(x - size, 0), uMax = PS_MIN(x + size, numCols - 1); // Extent of CR
     86                for (int v = vMin; v <= vMax; v++) {
     87                    for (int u = uMin; u <= uMax; u++) {
     88                        switch (mode) {
     89                          case BADPIX_RANDOM:
     90                            image->data.F32[v][u] *= psRandomGaussian(rng);
     91                            break;
     92                          case BADPIX_NAN:
     93                            image->data.F32[v][u] = NAN;
     94                            break;
     95                          default:
     96                            psAbort("Unrecognised mode: %x", mode);
     97                        }
     98                    }
     99                }
    57100            }
    58101        }
Note: See TracChangeset for help on using the changeset viewer.