IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 2, 2007, 10:29:50 AM (19 years ago)
Author:
magnier
Message:

fix compile bugs in psImageMap, psImagePixelInterpolate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20070830/psLib/src/imageops/psImagePixelInterpolate.c

    r14724 r14725  
    1111 *  @author Eugene Magnier, IfA
    1212 *
    13  *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2007-09-02 02:42:55 $
     13 *  @version $Revision: 1.1.2.4 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2007-09-02 20:29:50 $
    1515 *
    1616 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    6262
    6363// count and mark pixels based on their potential for being interpolated.  the input image is
    64 // just the mask, the output image is the mask image in which the good, bad, and poor pixels
    65 // are marked.
    66 // XXX return in the image the state (2nd, which of 4 corners, etc)?
     64// just the mask, the output image contains enum values which define the type of interpolation which
     65// can be performed
    6766psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal) {
    6867
     
    9998
    10099// interpolate the poor pixels using the available options
    101 bool psImagePixelInterpolatePoor (psImage *image, psImage *mask, psMaskType maskVal, psImage *state) {
     100bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal) {
     101
     102    assert (image->numCols == state->numCols);
     103    assert (image->numRows == state->numRows);
     104    assert (image->numCols == mask->numCols);
     105    assert (image->numRows == mask->numRows);
     106
     107    // allocate the vectors for the 2nd order fit below
     108    psVector *f  = psVectorAlloc (9, PS_TYPE_F32);
     109    // XXX if we add the weight above, include df
     110    // psVector *df = psVectorAlloc (9, PS_TYPE_F32);
     111    psVector *x  = psVectorAlloc (9, PS_TYPE_F32);
     112    psVector *y  = psVectorAlloc (9, PS_TYPE_F32);
     113
     114    // allocate a 2D polynomial to fit a quadratic to the valid neighbor pixels.
     115    psPolynomial2D *poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, 2, 2);
     116    poly->mask[2][2] = 1;
     117    poly->mask[2][1] = 1;
     118    poly->mask[1][2] = 1;
    102119
    103120    for (int iy = 0; iy < state->numRows; iy++) {
     
    114131
    115132              case PS_IMAGE_INTERPOLATE_CENTER: {
    116                   // fit a quadratic to the valid neighbor pixels
    117                   // apply the quadratic to get the poor pixel value
    118                   psPolynomial2D *poly = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, 2, 2);
    119                   poly->mask[2][2] = 1;
    120                   poly->mask[2][1] = 1;
    121                   poly->mask[1][2] = 1;
    122                   psVector *f = psVectorAlloc (9, PS_TYPE_F32);
    123                   psVector *df = psVectorAlloc (9, PS_TYPE_F32);
    124                   psVector *x = psVectorAlloc (9, PS_TYPE_F32);
    125                   psVector *y = psVectorAlloc (9, PS_TYPE_F32);
    126 
     133                  // XXX is there a fit-image-region function?
    127134                  int n = 0;
    128135                  for (int jy = -1; jy <= +1; jy++) {
    129                       // skip invalid pixels (jx < 0, >= Nx), etc
     136                      // skip invalid pixels
    130137                      if (jy + iy < 0) { continue; }
    131138                      if (jy + iy >= image->numRows) { continue; }
    132139                      for (int jx = -1; jx <= +1; jx++) {
    133                           // skip invalid pixels (jx < 0, >= Nx), etc
     140                          // skip invalid pixels
    134141                          if (jx + ix < 0) { continue; }
    135                           if (jx + ix >= mask->numCols) { continue; }
    136                           /* skip self */
     142                          if (jx + ix >= image->numCols) { continue; }
     143                          // skip self
    137144                          if (!jx && !jy) { continue; }
    138145                          // skip masked pixels
    139                           if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \
    140                           f->data.F32[n] = image->data.F32[iy+jy][ix+jx];
    141                           // df->data.F32[n] = weight->data.F32[jy][jx];
     146                          if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
    142147                          x->data.F32[n] = jx;
    143148                          y->data.F32[n] = jy;
     149                          f->data.F32[n] = image->data.F32[iy+jy][ix+jx];
     150                          // df->data.F32[n] = weight->data.F32[iy+jy][ix+jx];
    144151                          n++;
    145152                      }
    146153                  }
    147                   // XXX set vector lengths here
     154                  // set vector lengths here
    148155                  x->n = n;
    149156                  y->n = n;
    150157                  f->n = n;
    151158                  // df->n = n;
    152                   psVectorFitPolynomial2D (poly, mask, maskValue, f, df, x, y);
     159                  // psVectorFitPolynomial2D (poly, NULL, 0xff, f, df, x, y);
     160                  psVectorFitPolynomial2D (poly, NULL, 0xff, f, NULL, x, y);
     161                  // apply the fitted quadratic to get the poor pixel value
    153162                  image->data.F32[iy][ix] = poly->coeff[0][0];
    154163                  break; }
     
    179188        }           
    180189    }
     190
     191    psFree (x);
     192    psFree (y);
     193    psFree (f);
     194
     195    psFree (poly);
    181196    return true;
    182197}
Note: See TracChangeset for help on using the changeset viewer.