IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14725


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

fix compile bugs in psImageMap, psImagePixelInterpolate

Location:
branches/eam_branch_20070830/psLib
Files:
5 edited

Legend:

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

    r14723 r14725  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-09-02 02:03:58 $
     9 *  @version $Revision: 1.1.2.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-09-02 20:29:50 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    112112    }
    113113
    114     psImagePixelInterpolatePoor (map->map, mask, 0xff, state);
     114    psImagePixelInterpolatePoor (map->map, state, mask, 0xff);
    115115    return true;
    116116}
  • 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}
  • branches/eam_branch_20070830/psLib/src/imageops/psImagePixelInterpolate.h

    r14721 r14725  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-09-01 00:41:01 $
     9 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-09-02 20:29:50 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    3232
    3333psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal);
    34 bool psImagePixelInterpolatePoor (psImage *image, psImage *mask, psMaskType maskVal, psImage *state);
     34bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal);
    3535
    3636/// @}
  • branches/eam_branch_20070830/psLib/src/pslib_strict.h

    r12741 r14725  
    99*  @author Eric Van Alst, MHPCC
    1010*
    11 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2007-04-04 22:42:02 $
     11*  @version $Revision: 1.29.8.1 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2007-09-02 20:29:50 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4949#include "psImagePixelExtract.h"
    5050#include "psImagePixelManip.h"
     51#include "psImagePixelInterpolate.h"
    5152#include "psImageStats.h"
    5253#include "psImageStructManip.h"
     
    5455#include "psImageBinning.h"
    5556#include "psImageUnbin.h"
     57#include "psImageMap.h"
    5658
    5759#include "psImageJpeg.h"
  • branches/eam_branch_20070830/psLib/test/imageops/tap_psImageMap.c

    r14721 r14725  
    1313    return (TRUE);
    1414}
     15
     16# define C00 +0.5
     17# define C01 +0.1
     18# define C10 -0.2
    1519
    1620int main (void)
     
    3539        psVector *f = psVectorAllocEmpty (100, PS_TYPE_F32);
    3640
    37         for (int ix = 0; ix < 1000; ix += 25) {
    38             for (int iy = 0; iy < 1000; iy += 25) {
     41        for (int ix = 0; ix < 1000; ix += 10) {
     42            for (int iy = 0; iy < 1000; iy += 10) {
    3943                x->data.F32[x->n] = ix;
    4044                y->data.F32[y->n] = iy;
     
    5256
    5357        // allocate a map, but we have no field image to supply
    54         bool status = psImageMapGenerate (map, x, y, f, 0.1);
     58        // XXX this function needs to correct for the mean superpixel position
     59        // which is sampled...
     60        psImageMapGenerate (map, x, y, f, 0.1);
    5561        psFree (binning);
    5662
    57         fprint  (stderr, "nGood: %d\n", map->nGood);
    58         fprint  (stderr, "nPoor: %d\n", map->nPoor);
    59         fprint  (stderr, "nBad:  %d\n", map->nBad);
     63        fprintf (stderr, "nGood: %d\n", map->nGood);
     64        fprintf (stderr, "nPoor: %d\n", map->nPoor);
     65        fprintf (stderr, "nBad:  %d\n", map->nBad);
    6066       
    6167        SaveImage (NULL, map->map, "map.fits");
     
    7177        // measure difference between model (map) and data (field)
    7278        for (int ix = 0; ix < map->map->numCols; ix++) {
    73             for (int iy = 0; iy < map->map->num; iy++) {
    74                 int xo = ix*map->binning->nXbin;
    75                 int yo = iy*map->binning->nYbin;
    76                 df = field->data.F32[yo][xo] - map->map->data.F32[iy][ix];
    77                 fprintf (stderr, "%d %d   %f = %f - %f\n", ix, iy, df, field->data.F32[yo][xo], map->map->data.F32[iy][ix]);
     79            for (int iy = 0; iy < map->map->numRows; iy++) {
     80             
     81                int xo = (ix + 0.5)*map->binning->nXbin;
     82                int yo = (iy + 0.5)*map->binning->nYbin;
     83                float df = field->data.F32[yo][xo] - map->map->data.F32[iy][ix];
     84                fprintf (stderr, "%d %d -> %d %d  :  %f = %f - %f\n", ix, iy, xo, yo, df, field->data.F32[yo][xo], map->map->data.F32[iy][ix]);
    7885            }
    7986        }
Note: See TracChangeset for help on using the changeset viewer.