IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 4, 2007, 12:54:56 PM (19 years ago)
Author:
Paul Price
Message:

Updating following API change to psImagePixelInterpolate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarpTransformReadout.c

    r10958 r12744  
    33bool pswarpTransformReadout (pmReadout *output, pmReadout *input, pmConfig *config) {
    44
    5     // XXX this implementation currently ignores the use of the region 
     5    // XXX this implementation currently ignores the use of the region
    66    psImage *region = NULL;
    77    pmCell *cell = NULL;
     
    1313    int outNy = output->image->numRows;
    1414
    15     psPlane *inPix = psPlaneAlloc();    // Coordinates on the input detector
    16     psPlane *outPix = psPlaneAlloc();   // Coordinates on the output detector
     15    psPlane *inPix = psPlaneAlloc();    // Coordinates on the input detector
     16    psPlane *outPix = psPlaneAlloc();   // Coordinates on the output detector
    1717
    18     psPlane *FP = psPlaneAlloc();       // Coordinates on the focal plane
    19     psPlane *TP = psPlaneAlloc();       // Coordinates on the tangent plane
    20     psSphere *sky = psSphereAlloc();    // Coordinates on the sky
     18    psPlane *FP = psPlaneAlloc();       // Coordinates on the focal plane
     19    psPlane *TP = psPlaneAlloc();       // Coordinates on the tangent plane
     20    psSphere *sky = psSphereAlloc();    // Coordinates on the sky
    2121
    2222    cell = input->parent;
     
    3131    psImage *inImage = input->image;
    3232
     33    psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR, inImage,
     34                                                                       NULL, NULL, 0, NAN, NAN, 0, 0, 0.0);
     35
    3336    // Iterate over the output image pixels
    3437    for (int y = 0; y < outNy; y++) {
    35         for (int x = 0; x < outNx; x++) {
    36             // Only transform those pixels requested
    37             if (region && region->data.U8[y][x]) continue;
     38        for (int x = 0; x < outNx; x++) {
     39            // Only transform those pixels requested
     40            if (region && region->data.U8[y][x]) continue;
    3841
    39             // XXX double check this 1/2 pixel offset
    40             outPix->x = (double)x + 0.5;
    41             outPix->y = (double)y + 0.5;
     42            // XXX double check this 1/2 pixel offset
     43            outPix->x = (double)x + 0.5;
     44            outPix->y = (double)y + 0.5;
    4245
    43             psPlaneTransformApply(FP, chipOutput->toFPA, outPix);
    44             psPlaneTransformApply (TP, fpaOutput->toTPA, FP);
    45             psDeproject (sky, TP, fpaOutput->toSky);
    46                
    47             psProject (TP, sky, fpaInput->toSky);
    48             psPlaneTransformApply (FP, fpaInput->fromTPA, TP);
    49             psPlaneTransformApply (inPix, chipInput->fromFPA, FP);
     46            psPlaneTransformApply(FP, chipOutput->toFPA, outPix);
     47            psPlaneTransformApply (TP, fpaOutput->toTPA, FP);
     48            psDeproject (sky, TP, fpaOutput->toSky);
    5049
    51             // XXX get interpolation method from the recipe
    52             outData[y][x] = (psF32)psImagePixelInterpolate(inImage, inPix->x, inPix->y, NULL, 1, NAN, PS_INTERPOLATE_BILINEAR);
    53             // outData[y][x] = (psF32)psImagePixelInterpolate(inImage, inPix->x, inPix->y, mask, 1, NAN, PS_INTERPOLATE_BILINEAR);
    54             // modify zero and scale?
    55         }
     50            psProject (TP, sky, fpaInput->toSky);
     51            psPlaneTransformApply (FP, fpaInput->fromTPA, TP);
     52            psPlaneTransformApply (inPix, chipInput->fromFPA, FP);
     53
     54            // XXX get interpolation method from the recipe
     55            double value;
     56            if (!psImageInterpolate(&value, NULL, NULL, inPix->x, inPix->y, interp)) {
     57                psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
     58                psFree(interp);
     59                psFree(inPix);
     60                psFree(outPix);
     61                psFree(FP);
     62                psFree(TP);
     63                psFree(sky);
     64                return false;
     65            }
     66
     67            outData[y][x] = value;
     68            // modify zero and scale?
     69        }
    5670    }
    57 
    58     psFree (inPix);
    59     psFree (outPix);
    60     psFree (FP);
    61     psFree (TP);
    62     psFree (sky);
     71    psFree(interp);
     72    psFree(inPix);
     73    psFree(outPix);
     74    psFree(FP);
     75    psFree(TP);
     76    psFree(sky);
    6377
    6478    return true;
    6579}
    66 
    67 # if (0)
    68             if (error) {
    69                 // Error is actually the variance
    70                 outError->data.F32[y][x] = (psF32)p_psImageErrorInterpolateBILINEAR_F32(error,
    71                                                                                         detector->x,
    72                                                                                         detector->y,
    73                                                                                         mask, 1, NAN);
    74             }
    75             if (error) {
    76                 outError->data.F32[y][x] = outError->data.F32[y][x] / SQUARE(scale);
    77             }
    78 # endif
Note: See TracChangeset for help on using the changeset viewer.