IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 14, 2005, 3:23:24 AM (21 years ago)
Author:
eugene
Message:

mask/noise are working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/setup.c

    r4216 r4251  
    1313    psImage *noise = NULL;
    1414    psImage *mask = NULL;
    15 
    16     psRegion  region = {0,0,0,0};       // a region representing the entire array
     15    psRegion region = {0,0,0,0};        // a region representing the entire array
     16    bool status;
    1717
    1818    psTimerStart ("psphot");
     
    2424
    2525    // read header and image data from INPUT
    26     char *input = psMetadataLookupSTR (&status, config, "INPUT");
     26    char *input = psMetadataLookupPtr (&status, config, "INPUT");
    2727    psFits *file = psFitsAlloc (input);
    2828    header = psFitsReadHeader (header, file);
     
    3131
    3232    // grab these values from the approrpiate location (image header if necessary)
    33     bool  status   = false;
    3433    float RDNOISE  = pmConfigLookupF32 (&status, config, header, "RDNOISE");
    3534    float GAIN     = pmConfigLookupF32 (&status, config, header, "GAIN");
     
    3837
    3938    // load the noise image if it is supplied, otherwise build from input
    40     char *noiseName = psMetadataLookupSTR (&status, config, "NOISE");
     39    char *noiseName = psMetadataLookupPtr (&status, config, "NOISE");
    4140    if (status == true) {
    4241      file = psFitsAlloc (noiseName);
     
    4443      psFree (file);
    4544    } else {
    46       psScalar *value = psScalarAlloc (1.0 / GAIN, PS_TYPE_F64);
    47       noise = BinaryOp (NULL, image, '/', value);
     45      psScalar *value;
     46
     47      noise = psImageAlloc (image->numCols, image->numRows, PS_TYPE_F32);
     48      for (int iy = 0; iy < image->numRows; iy++) {
     49        for (int ix = 0; ix < image->numCols; ix++) {
     50          noise->data.F32[iy][ix] = image->data.F32[iy][ix] / GAIN + PS_SQR(RDNOISE/GAIN);
     51        }
     52      }
     53
     54      // XXX EAM it looks like psBinaryOp is broken for (image op scalar)
     55      # if (0)
     56      value = psScalarAlloc (1.0 / GAIN, PS_TYPE_F64);
     57      noise = (psImage *) psBinaryOp (NULL, image, "/", value);
    4858      psFree (value);
    4959
    50       psScalar *value = psScalarAlloc (PS_SQR(RDNOISE/GAIN), PS_TYPE_F64);
    51       noise = BinaryOp (noise, noise, '+', value);
     60      value = psScalarAlloc (PS_SQR(RDNOISE/GAIN), PS_TYPE_F64);
     61      noise = (psImage *) psBinaryOp (noise, noise, "+", value);
    5262      psFree (value);
     63      # endif
    5364    }
    5465
    55     char *maskName = psMetadataLookupSTR (&status, config, "MASK");
     66    char *maskName = psMetadataLookupPtr (&status, config, "MASK");
    5667    if (status == true) {
    5768      file = psFitsAlloc (maskName);
     
    6778    psRegion *keep = psRegionAlloc (XBORDER, -XBORDER, YBORDER, -YBORDER);
    6879    keep           = psRegionForImage (keep, image, keep);
    69     psImageKeepRegion (mask, keep, 0x01);
     80    psImageKeepRegion (mask, keep, OR, 0x01);
    7081
    7182    // mask the saturated pixels
     
    8798    imdata->mask = mask;
    8899
    89     return (true);
     100    return (imdata);
    90101}
Note: See TracChangeset for help on using the changeset viewer.