IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 21, 2007, 2:16:47 PM (19 years ago)
Author:
eugene
Message:

adding header load, timing code

File:
1 edited

Legend:

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

    r12526 r12528  
    11# include "pswarp.h"
     2psImageInterpolateMode psImageInterpolateModeFromString (char *name);
    23
    34// NOTE: in this function, the coordinates are transformed from the OUTPUT to the INPUT
    45bool pswarpTransformReadout_Opt (pmReadout *output, pmReadout *input, pmConfig *config) {
    56
     7    bool status;
    68    int minX, minY, maxX, maxY;
    79    int gridXo, gridX, gridY, nextGridXo, nextGridX, nextGridY;
    810    pswarpMap *map = NULL;
     11    psImageInterpolateMode interpolationMode = PS_INTERPOLATE_NONE;
    912
    1013    // XXX this implementation currently ignores the use of the region
    1114    psImage *region = NULL;
    1215
     16    psTimerStart ("warp");
     17
    1318    // select the current recipe
    14     // psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
     19    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE);
     20    if (!recipe) {
     21        psError(PSWARP_ERR_CONFIG, true, "Can't find PSWARP recipe!\n");
     22        return false;
     23    }
     24   
     25    int nGridX = psMetadataLookupS32 (&status, recipe, "GRID.NX");
     26    if (!status) nGridX = 128;
     27    int nGridY = psMetadataLookupS32 (&status, recipe, "GRID.NY");
     28    if (!status) nGridY = 128;
     29
     30    char *name = psMetadataLookupStr (&status, recipe, "INTERPOLATION.MODE");
     31    if (!name) {
     32        interpolationMode = PS_INTERPOLATE_BILINEAR;
     33        psLogMsg ("pswarp", 3, "defaulting to bilinear interpolation\n");
     34    } else {
     35        interpolationMode = psImageInterpolateModeFromString (name);
     36        if (interpolationMode == PS_INTERPOLATE_NONE) {
     37            interpolationMode = PS_INTERPOLATE_BILINEAR;
     38            psLogMsg ("pswarp", 3, "unknown interpolation mode %s, defaulting to bilinear interpolation\n", name);
     39        }
     40    }
    1541
    1642    psPlane *inPix = psPlaneAlloc();    // Coordinates on the input detector
     
    3359    // pswarpMapGridFromImage builds a set of locally-linear maps which convert the
    3460    // output coordinates to input coordinates
    35     pswarpMapGrid *grid = pswarpMapGridFromImage (input, output, 128, 128);
     61    pswarpMapGrid *grid = pswarpMapGridFromImage (input, output, nGridX, nGridY);
    3662
    3763    // XXX need to modify the grid based on this result and force the maxError < XXX
     
    81107            if (inPix->y - inRow0 >= inImage->numRows) continue;
    82108
    83             // XXX get interpolation method from the recipe
    84109            // XXX include mask
    85110            // XXX apply scale and offset?
    86111            // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates
    87             outData[y-outRow0][x-outCol0] = (psF32)psImagePixelInterpolate(inImage, inPix->x - inCol0, inPix->y - inRow0, NULL, 1, NAN, PS_INTERPOLATE_BILINEAR);
     112            outData[y-outRow0][x-outCol0] = (psF32)psImagePixelInterpolate(inImage, inPix->x - inCol0, inPix->y - inRow0, NULL, 1, NAN, interpolationMode);
    88113        }
    89114    }
     
    91116    psFree (inPix);
    92117    psFree (grid);
     118    psLogMsg ("pswarp", 3, "warping analysis: %f sec\n", psTimerMark ("warp"));
     119
    93120    return true;
    94121}
Note: See TracChangeset for help on using the changeset viewer.