IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 7, 2009, 6:43:53 PM (18 years ago)
Author:
eugene
Message:

mask modifications for Image and Vector mask types (ppSim, ppStack, ppSub, pswarp, psphot)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20081230/psphot/src/psphotMakeResiduals.c

    r21087 r21090  
    11# include "psphotInternal.h"
    22
    3 XXX this function is probably broken: fmasks is confused between Image and Vector.  it is used by psVectorStats, so it must be Vector, but
    4   is populated by mflux, which seems to be Image..
    53bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal) {
    64
     
    7169    // - set output pixel, weight, and mask
    7270
    73     XXX need to set these correctly based on the RECIPE values
    74     const int badMask = 1;              // mask bits
    75     const int poorMask = 2;             //       from psImageInterpolate
    76     const int clippedMask = 4;          // mask bit set for clipped values
     71    // these mask values do not correspond to the recipe values: they
     72    // are not propagated to images: they just need to fit in an 8-bit
     73    // value.  they are supplied to psImageInterpolate, which takes a
     74    // psImageMaskType; the mask portion of the result from
     75    // psImageInterpolate is supplied to fmasks, which is then used by
     76    // psVectorStats
     77
     78    const psImageMaskType badMask     = 0x01;   // mask bits
     79    const psImageMaskType poorMask    = 0x02;   // from psImageInterpolate
     80    const psImageMaskType clippedMask = 0x04;   // mask bit set for clipped values
     81    const psVectorMaskType fmaskVal = badMask | poorMask | clippedMask;
    7782
    7883    // determine the maximum image size from the input sources
     
    105110        psBinaryOp (weight, weight, "/", psScalarAlloc(Io*Io, PS_TYPE_F32));
    106111
    107         // we will interpolate the image and weight - include the mask or not?
    108         // XXX consider better values for the mask bits
    109         psImageInterpolation *interp =
    110             psImageInterpolationAlloc(mode, image, weight, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0);
    111         psArrayAdd (input,  100, interp);
     112        // we interpolate the image and weight - include the mask or not?
     113        // XXX why not the mask?
     114        // psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, weight, mask, maskVal, 0.0, 0.0, badMask, poorMask, 0.0, 0);
     115        psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, weight, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0);
     116        psArrayAdd (input, 100, interp);
    112117
    113118        // save the X,Y position for future reference
     
    166171                bool offImage = false;
    167172                if (psImageInterpolate (&flux, &dflux, &mflux, ix, iy, interp) == PS_INTERPOLATE_STATUS_OFF) {
     173                    // fprintf (stderr, "off image: %f %f : %f %f\n", ix, iy, flux, dflux);
    168174                    // This pixel is off the image
    169175                    offImage = true;
    170                     fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
    171                     // fprintf (stderr, "off image: %f %f : %f %f\n", ix, iy, flux, dflux);
    172                 }
    173                 fluxes->data.F32[i] = flux;
    174                 dfluxes->data.F32[i] = dflux;
    175                 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = mflux; // XXX is mflux IMAGE or VECTOR type?
     176                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask;
     177                } else {
     178                  fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = mflux; // XXX is mflux IMAGE or VECTOR type?
     179                }
     180                fluxes->data.F32[i] = flux;
     181                dfluxes->data.F32[i] = dflux;
    176182                if (isnan(flux)) {
    177                     fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
     183                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask;
    178184                }
    179185                if (fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
     
    182188            }
    183189
    184             // skip pixels which are off the image...
     190            // skip pixels with insufficient data
    185191            bool validPixel = (SPATIAL_ORDER == 0) ? (nGoodPixel > 1) : (nGoodPixel > 3);
    186192            if (!validPixel) {
     
    188194                resid->Rx->data.F32[oy][ox] = 0.0;
    189195                resid->Ry->data.F32[oy][ox] = 0.0;
    190                 resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox] = 1;
     196                resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox] = badMask;
    191197                continue;
    192198            }
     
    194200            // measure the robust median to determine a baseline reference value
    195201            *fluxClip = *fluxClipDef;
    196             psVectorStats (fluxClip, fluxes, NULL, fmasks, 0xff);
     202            psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal);
    197203            psErrorClear();             // clear (ignore) any outstanding errors
    198204
     
    204210                float swing = fabs(delta) / sigma;
    205211
    206                 // make this a user option
     212                // mask pixels which are out of range
    207213                if (swing > nSigma) {
    208214                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = clippedMask;
     
    214220                // measure the desired statistic on the unclipped pixels
    215221                *fluxStats = *fluxStatsDef;
    216                 psVectorStats (fluxStats, fluxes, NULL, fmasks, 0xff);
     222                psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal);
    217223                psErrorClear();         // clear (ignore) any outstanding errors
    218224
Note: See TracChangeset for help on using the changeset viewer.