IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34470


Ignore:
Timestamp:
Sep 25, 2012, 5:33:33 PM (14 years ago)
Author:
watersc1
Message:

Hardcoded version that gets the right solution. I wanted to save this before attempting to clean up the code.

Location:
branches/czw_branch/20120906
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20120906/psLib/src/imageops/psImageInterpolate.c

    r34442 r34470  
    947947  int yl,yh;
    948948  const psImage *image = interp->image; // Image to interpolate
    949   // const psImage *mask = interp->mask; // Mask to interpolate
    950   const psImage *variance = interp->variance; // Variance to interpolate
    951949
    952950  xl = floor(x);
    953951  if (xl < 0) { xl = 0; }
    954952  if (xl >= image->numCols) {xl = image->numCols - 1; }
     953    //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; }
    955954  xh = xl + 1;
    956955  if (xh >= image->numCols) {xh = image->numCols - 1; }
     956    //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; }
     957    //
    957958  yl = floor(y);
    958959  if (yl < 0) { yl = 0; }
    959960  if (yl >= image->numRows) {yl = image->numRows - 1; }
     961    //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; }
     962  //
    960963  yh = yl + 1;
    961964  if (yh >= image->numRows) {yh = image->numRows - 1; }
    962   if (varianceValue && variance) {
    963     u1 = (xh - x) * variance->data.F32[yl][xl] + (x - xl) * variance->data.F32[yl][xh];
    964     u2 = (xh - x) * variance->data.F32[yh][xl] + (x - xl) * variance->data.F32[yh][xh];
    965 
    966     *varianceValue = (yh - y) * u1 + (y - yl) * u2;
    967   }
    968 #if 0
    969   if (maskValue && mask) {
    970     u1 = (xh - x) * mask->data.F32[yl][xl] + (x - xl) * mask->data.F32[yl][xh];
    971     u2 = (xh - x) * mask->data.F32[yh][xl] + (x - xl) * mask->data.F32[yh][xh];
    972 
    973     maskValue = (yh - y) * u1 + (y - yl) * u2;
    974   }
    975 #endif
     965    //{ *imageValue = NAN; return PS_INTERPOLATE_STATUS_GOOD; }
     966  //
    976967  if (imageValue && image) {
    977968    if (image->data.F32[yl][xl] == image->data.F32[yl][xh]) {
  • branches/czw_branch/20120906/pswarp/src/pswarp.h

    r34411 r34470  
    9494
    9595pswarpMapGrid *pswarpMapGridFromImage (pmReadout *dest, pmReadout *src, int nXpix, int nYpix);
     96pswarpMapGrid *pswarpMapGridFromImageForBackground (pmReadout *dest, pmReadout *src, int nXpix, int nYpix);
    9697bool pswarpMapGridSetGrid (pswarpMapGrid *grid, int ix, int iy, int *gridX, int *gridY);
    9798bool pswarpMapGridCoordRange (pswarpMapGrid *grid, int gridX, int gridY, psPlane *min, psPlane *max);
  • branches/czw_branch/20120906/pswarp/src/pswarpLoop.c

    r34449 r34470  
    804804
    805805                fprintf(stderr,"Transforming Readout!\n");
     806
     807                psMetadataAddBool(config->arguments,PS_LIST_TAIL, "BACKGROUND_WARPING", PS_META_REPLACE, "", true);
    806808                pswarpTransformReadout(output, readout, config);
     809                psMetadataAddBool(config->arguments,PS_LIST_TAIL, "BACKGROUND_WARPING", PS_META_REPLACE, "", false);
    807810               
    808811                if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
  • branches/czw_branch/20120906/pswarp/src/pswarpMapGrid.c

    r31878 r34470  
    5252    return grid;
    5353}
     54/**
     55 * pswarpMapGridFromImageForBackground builds a set (a grid) of locally-linear maps which convert the source
     56 * coordinates (src) to destination coordinates (dest).  we construct a grid with superpixel
     57 * spacing of nXpix, nYpix.  The transformation for each grid cell is valid for the superpixel.
     58 * The grid over-fills the source image so every source image pixel is guaranteed to have a map.
     59 */
     60pswarpMapGrid *pswarpMapGridFromImageForBackground (pmReadout *dest, pmReadout *src, int nXpix, int nYpix) {
     61
     62    int i, ni;
     63    int j, nj;
     64
     65    // start counting from the center of the superpixels
     66    double xMin = 0.5*nXpix;
     67    double yMin = 0.5*nYpix;
     68
     69    // the map is defined for coordinates in the image parent frame.
     70    int Nx = src->image->numCols + src->image->col0;
     71    int Ny = src->image->numRows + src->image->row0;
     72
     73    // always allocate an extra superpixel to handle spillover
     74    int nXpts = (int)(Nx / nXpix) + 1;
     75    int nYpts = (int)(Ny / nYpix) + 1;
     76
     77    // create the grid of maps
     78    pswarpMapGrid *grid = pswarpMapGridAlloc (nXpts, nYpts);
     79
     80    // measure the map for the center of each superpixel
     81    for (ni = 0, i = xMin; ni < nXpts; i += nXpix, ni++) {
     82        for (nj = 0, j = yMin; nj < nYpts; j += nYpix, nj++) {
     83            pswarpMapSetLocalModel (grid->maps[ni][nj], dest, src, i, j);
     84/*          grid->maps[ni][nj]->Xo += (13.0 * 400.0 - 4846.0) / 2.0; */
     85/*          grid->maps[ni][nj]->Yo += (13.0 * 400.0 - 4868.0) / 2.0; */
     86        }
     87    }
     88
     89    grid->nXpix = nXpix;
     90    grid->nYpix = nYpix;
     91    grid->xMin = xMin;
     92    grid->yMin = yMin;
     93    return grid;
     94}
    5495
    5596/**
  • branches/czw_branch/20120906/pswarp/src/pswarpTransformReadout.c

    r34442 r34470  
    6060    // pswarpMapGridFromImage builds a set of locally-linear maps which convert the
    6161    // output coordinates to input coordinates
    62     pswarpMapGrid *grid = pswarpMapGridFromImage(input, output, nGridX, nGridY);
    63 
     62    pswarpMapGrid *grid;
     63    if (psMetadataLookupBool(NULL,config->arguments,"BACKGROUND_WARPING")) {
     64      grid = pswarpMapGridFromImageForBackground(input, output, nGridX, nGridY);
     65    }
     66    else {
     67      grid = pswarpMapGridFromImage(input, output, nGridX, nGridY);
     68    }
    6469    // XXX optionally modify the grid based on this result and force the maxError < XXX
    6570    double maxError = pswarpMapGridMaxError(grid); // Maximum (positional) error from using grid
  • branches/czw_branch/20120906/pswarp/src/pswarpTransformTile.c

    r34442 r34470  
    8686    for (int y = yMin; y < yMax; y++) {
    8787        for (int x = xMin; x < xMax; x++) {
    88 /*        if ((x == 931)||(x == 717)||(x == 924)) { */
    89 /* /\*      if ((y == 1348)||(y == 1249)||(y == 1081)) { *\/ */
    90 /* /\*        fprintf(stderr,"BEcause: %d %d [%d %d %d %d]\n",x,y,yMin,yMax,xMin,xMax); *\/ */
    91 /* /\*      } *\/ */
    92 /*        } */
    93             if (((x == 931)&&(y == 1348))||
    94                 ((x == 717)&&(y == 1249))||
    95                 ((x == 924)&&(y == 1081))) {
    96               psTrace("pswarp",3,"TT: A\n");
    97               psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);
    98 
    99             }
    100 
    10188            // Only transform those pixels requested
    10289            if (region && region->data.PS_TYPE_IMAGE_MASK_DATA[y][x]) {
    10390                continue;
    10491            }
    105             if (((x == 931)&&(y == 1348))||
    106                 ((x == 717)&&(y == 1249))||
    107                 ((x == 924)&&(y == 1081))) {
    108               psTrace("pswarp",3,"TT: B\n");
    109               psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);
    110 
    111             }
    112 
    11392            // pswarpMapApply converts the output coordinate (x,y) to the input coordinate.
    11493            // both are in the parent frames of the input and output images.
    11594            double xIn, yIn;            // Input pixel coordinates
    11695            pswarpMapApply(&xIn, &yIn, map, x + 0.5, y + 0.5);
    117             if (((x == 931)&&(y == 1348))||
    118                 ((x == 717)&&(y == 1249))||
    119                 ((x == 924)&&(y == 1081))) {
    120               psTrace("pswarp",3,"TT: Ct\n");
    121               psTrace("pswarp",3,"TT: %d %d %d %d %g %g %d %d\n",xMin,xMax,yMin,yMax,xIn,yIn,inNumCols,inNumRows);
    12296
    123             }
     97            if (args->interp->mode == 8) {
     98              xIn += 177.0 / 400.0;
     99              yIn += 166.0 / 400.0;
    124100
     101              if ((xIn > inNumCols - 177.0/ 400.0)||
     102                  (yIn > inNumRows - 166.0/ 400.0)||
     103                  (xIn < 177.0/ 400.0)||
     104                  (yIn < 166.0/ 400.0)
     105                 
     106                  ) {
     107                fprintf(stderr,"\n");
     108                continue;
     109              }
     110            }           
     111           
    125112            if (xIn < 0 || xIn >= inNumCols || yIn < 0 || yIn >= inNumRows) {
    126113                continue;
    127114            }
    128             if (((x == 931)&&(y == 1348))||
    129                 ((x == 717)&&(y == 1249))||
    130                 ((x == 924)&&(y == 1081))) {
    131               psTrace("pswarp",3,"TT: C\n");
    132               psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);
    133 
    134             }
    135115
    136116            // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates
     
    144124            int xOut = x - outCol0, yOut = y - outRow0; ///< Position on output image
    145125
    146             if ((xIn >= args->interp->image->numCols - 1)||
    147                 (yIn >= args->interp->image->numRows - 1)) {
    148               imageValue = NAN;
     126            if (((xOut % 500) == 0)&&((yOut % 500) == 0)) {
     127              fprintf(stderr,"%d %d %g %g %d %d (%d %d %d %d) %g %g %g\n",
     128                      x,y,xIn,yIn,xOut,yOut,xMin,xMax,yMin,yMax,imageValue,
     129                      (4846 - 400 * (12)) / 2.0,
     130                      (4868 - 400 * (12)) / 2.0
     131                     
     132                      );
    149133            }
     134           
     135/*          if ((xIn >= args->interp->image->numCols - 1)|| */
     136/*              (yIn >= args->interp->image->numRows - 1)) { */
     137/*            imageValue = NAN; */
     138/*          } */
    150139            if (outImageData) {
    151140                outImageData[yOut][xOut] = imageValue * jacobian;
     
    159148
    160149            goodPixels++;
    161 
    162             if ((x == 931)||(x == 717)||(x == 924)) {
    163               if ((y == 1348)||(y == 1249)||(y == 1081)) {
    164               psTrace("pswarp",3,"TT: %d %d %g %g %d %d %g %g (%g) %ld %g %g %g %g\n",x,y,xIn,yIn,xOut,yOut,imageValue,jacobian,
    165                       args->input->image->data.F32[(int) yIn][(int) xIn],(long) args->interp,
    166                       0.0,0.0,0.0,0.0);
    167 /*                    inImage->data.F32[(int) yIn][(int) xIn], */
    168 /*                    inImage->data.F32[(int) yIn+1][(int) xIn], */
    169 /*                    inImage->data.F32[(int) yIn+1][(int) xIn+1], */
    170 /*                    inImage->data.F32[(int) yIn][(int) xIn+1]); */
    171               psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);
    172               }
    173             }
    174            
    175             if (((xOut == 931)&&(yOut == 1348))||
    176                 ((xOut == 717)&&(yOut == 1249))||
    177                 ((xOut == 924)&&(yOut == 1081))) {
    178               psTrace("pswarp",3,"TT: %d %d %g %g %d %d %g %g (%g) %ld %g %g %g %g\n",x,y,xIn,yIn,xOut,yOut,imageValue,jacobian,
    179                       args->input->image->data.F32[(int) yIn][(int) xIn],(long) args->interp,
    180                                       0.0,0.0,0.0,0.0);
    181 /*                    inImage->data.F32[(int) yIn][(int) xIn], */
    182 /*                    inImage->data.F32[(int) yIn+1][(int) xIn], */
    183 /*                    inImage->data.F32[(int) yIn+1][(int) xIn+1], */
    184 /*                    inImage->data.F32[(int) yIn][(int) xIn+1]); */
    185               psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);
    186 
    187             }
    188             if ((xOut ==  443)&&(yOut == 659)) {
    189               psTrace("pswarp",3,"TT: %d %d %g %g %d %d %g %g (%g) %ld\n",x,y,xIn,yIn,xOut,yOut,imageValue,jacobian,
    190                       args->input->image->data.F32[(int) yIn][(int) xIn],(long) args->interp);
    191               psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);
    192 
    193             }
    194             if ((xOut ==  524)&&(yOut == 576)) {
    195               psTrace("pswarp",3,"TT: %d %d %g %g %d %d %g %g (%g) %ld\n",x,y,xIn,yIn,xOut,yOut,imageValue,jacobian,
    196                       args->input->image->data.F32[(int) yIn][(int) xIn],(long) args->interp);
    197               psTrace("pswarp",3,"TT: %d %d %d %d\n",xMin,xMax,yMin,yMax);
    198              
    199             }
    200150        }
    201151    }
Note: See TracChangeset for help on using the changeset viewer.