IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 14, 2012, 6:10:32 PM (14 years ago)
Author:
watersc1
Message:

Still doesn't work correctly. I've simplified and corrected the problems I was having before, but I still have residuals of ~50 pixels in the warped background model relative to the science warp. I'm beginning to think that there's some issue with the interpolated background model, and that it's not quite the correct size? That's pretty much all I can think of at this point.

File:
1 edited

Legend:

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

    r34414 r34442  
    189189    switch (mode) {
    190190      case PS_INTERPOLATE_FLAT:
     191      case PS_INTERPOLATE_BILINEAR_SIMPLE:
    191192        // Nothing to pre-compute
    192193        break;
     
    287288# endif
    288289      case PS_INTERPOLATE_BIQUADRATIC:
     290      case PS_INTERPOLATE_BILINEAR_SIMPLE:
    289291        // 2D kernel, would cost too much memory to pre-calculate
    290292        break;
     293
    291294      default:
    292295        psAbort("Unsupported interpolation mode: %x", mode);
     
    937940
    938941
     942psImageInterpolateStatus interpolateJustWork(double *imageValue, double *varianceValue,
     943                                             psImageMaskType *maskValue, float x, float y,
     944                                             const psImageInterpolation *interp) {
     945  float u1,u2;
     946  int xl,xh;
     947  int yl,yh;
     948  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
     951
     952  xl = floor(x);
     953  if (xl < 0) { xl = 0; }
     954  if (xl >= image->numCols) {xl = image->numCols - 1; }
     955  xh = xl + 1;
     956  if (xh >= image->numCols) {xh = image->numCols - 1; }
     957  yl = floor(y);
     958  if (yl < 0) { yl = 0; }
     959  if (yl >= image->numRows) {yl = image->numRows - 1; }
     960  yh = yl + 1;
     961  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
     976  if (imageValue && image) {
     977    if (image->data.F32[yl][xl] == image->data.F32[yl][xh]) {
     978      u1 = image->data.F32[yl][xh];
     979    }
     980    else {
     981      u1 = (xh - x) * image->data.F32[yl][xl] + (x - xl) * image->data.F32[yl][xh];
     982    }
     983    if (image->data.F32[yh][xl] == image->data.F32[yh][xh]) {
     984      u2 = image->data.F32[yh][xh];
     985    }
     986    else {
     987      u2 = (xh - x) * image->data.F32[yh][xl] + (x - xl) * image->data.F32[yh][xh];
     988    }
     989    if (u1 == u2) {
     990      *imageValue = u1;
     991    }
     992    else {
     993      *imageValue = (yh - y) * u1 + (y - yl) * u2;
     994    }
     995    if ((floor(x) >= image->numCols)||
     996        (floor(y) >= image->numRows)) {
     997      *imageValue = NAN;
     998    }
     999  }
     1000  if (*imageValue == 0.0) {
     1001    fprintf(stderr,"IJK: Zero!: %g %g [%d %d %d %d] %g %g (%g %g %g %g)\n",
     1002            x,y,xl,xh,yl,yh,u1,u2,
     1003            image->data.F32[yl][xl],image->data.F32[yl][xh],image->data.F32[yh][xl],image->data.F32[yh][xh]
     1004            );
     1005  }
     1006  return PS_INTERPOLATE_STATUS_GOOD;
     1007}
     1008 
    9391009
    9401010psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue,
     
    9691039      case PS_INTERPOLATE_BIQUADRATIC:
    9701040        return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp);
     1041      case PS_INTERPOLATE_BILINEAR_SIMPLE:
     1042        return interpolateJustWork(imageValue, varianceValue, maskValue, x, y, interp);
    9711043      case PS_INTERPOLATE_BILINEAR:
    9721044# if (!IS_BILIN_SEPARABLE)
    973         return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp);
     1045        return interpolateKernel(imageValue, varianceValue, maskValue, x, y, interp);
    9741046# endif
    9751047      case PS_INTERPOLATE_GAUSS:
     
    10191091    switch (mode) {
    10201092      case PS_INTERPOLATE_FLAT:
     1093      case PS_INTERPOLATE_BILINEAR_SIMPLE:
    10211094        // No smearing by design
    10221095        return 1.0;
     
    10831156    if (!strcasecmp(name, "FLAT"))     return PS_INTERPOLATE_FLAT;
    10841157    if (!strcasecmp(name, "BILINEAR")) return PS_INTERPOLATE_BILINEAR;
     1158    if (!strcasecmp(name, "SIMPLEBILINEAR")) return PS_INTERPOLATE_BILINEAR_SIMPLE;
    10851159    if (!strcasecmp(name, "BIQUADRATIC")) return PS_INTERPOLATE_BIQUADRATIC;
    10861160    if (!strcasecmp(name, "GAUSS"))    return PS_INTERPOLATE_GAUSS;
Note: See TracChangeset for help on using the changeset viewer.