IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 27, 2008, 8:00:23 AM (18 years ago)
Author:
eugene
Message:

threaded and unthreaded equivalent versions now compile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080719/pswarp/src/pswarpTransformTile.c

    r18666 r18752  
     1# include "pswarp.h"
    12
    2 // XXX need to determine all of the needed inputs and put them in a structure
     3void pswarpTransformTileArgsFree (pswarpTransformTileArgs *args) {
     4    if (!args) return;
     5    return;
     6}
    37
    4 typedef struct {
    5     int gridX;
    6     int gridY;
    7 } pswarpTransformTileOpts;
     8pswarpTransformTileArgs *pswarpTransformTileArgsAlloc() {
    89
    9 pswarpTransformTile (int gridX, int gridY) {
     10    pswarpTransformTileArgs *args = (pswarpTransformTileArgs *)psAlloc(sizeof(pswarpTransformTileArgs));
     11    psMemSetDeallocator(args, (psFreeFunc)pswarpTransformTileArgsFree);
    1012
    11     minX = pswarpMapGridNextGrid_Y (grid, gridY);
    12     minY = pswarpMapGridNextGrid_X (grid, gridX);
     13    args->input = NULL;
     14    args->output = NULL;
     15    args->grid = NULL;
     16    args->interp = NULL;
     17    args->region = NULL;
    1318
    14     maxX = pswarpMapGridNextGrid_Y (grid, gridY);
    15     maxY = pswarpMapGridNextGrid_X (grid, gridX);
     19    args->gridX = 0;
     20    args->gridY = 0;
    1621
    17     map = grid->maps[gridX][gridY];
     22    args->goodPixels = 0;
    1823
    19     psPlane *inPix = psPlaneAlloc();    // Coordinates on the input detector
     24    return args;
     25}
     26
     27bool pswarpTransformTile (pswarpTransformTileArgs *args) {
     28
     29    // int inCol0 = args->input->image->col0;
     30    // int inRow0 = args->input->image->row0;
     31    int inNcol = args->input->image->numCols;
     32    int inNrow = args->input->image->numRows;
     33
     34    int outCol0 = args->output->image->col0;
     35    int outRow0 = args->output->image->row0;
     36    // int outNcol = args->output->image->numCols;
     37    // int outNrow = args->output->image->numRows;
     38
     39    // XXX these are wrong (min or max is wrong)
     40    int minX = pswarpMapGridNextGrid_Y (args->grid, args->gridY);
     41    int minY = pswarpMapGridNextGrid_X (args->grid, args->gridX);
     42    int maxX = pswarpMapGridNextGrid_Y (args->grid, args->gridY);
     43    int maxY = pswarpMapGridNextGrid_X (args->grid, args->gridX);
     44
     45    psF32 **outImageData     = args->output->image->data.F32;
     46    psF32 **outVarData       = args->output->weight->data.F32;
     47    psMaskType **outMaskData = args->output->mask->data.U8;
     48
     49    pswarpMap *map = args->grid->maps[args->gridX][args->gridY];
     50
     51    psImage *region = args->region;
     52
     53    double xInRaw, yInRaw;
     54
     55    // output values for this pixel
     56    double imageValue;
     57    double varValue;
     58    psMaskType maskValue;
    2059
    2160    // Iterate over the output image pixels (parent frame)
    2261    long goodPixels = 0;                // Number of input pixels landing on the output image
    2362    for (int y = minY; y < maxY; y++) {
    24         int yOut = y - outRow0;         // Position on image
    2563        for (int x = minX; x < maxX; x++) {
    2664
     
    3068            // pswarpMapApply converts the output coordinate (x,y) to the input coordinate.
    3169            // both are in the parent frames of the input and output images.
    32             pswarpMapApply (&inPix->x, &inPix->y, map, x + 0.5, y + 0.5);
     70            pswarpMapApply (&xInRaw, &yInRaw, map, x + 0.5, y + 0.5);
    3371
    34             if (inPix->x - inCol0 < 0) continue;
    35             if (inPix->x - inCol0 >= inImage->numCols) continue;
    36             if (inPix->y - inRow0 < 0) continue;
    37             if (inPix->y - inRow0 >= inImage->numRows) continue;
     72            double xIn = xInRaw - outCol0;      // Position on input image
     73            double yIn = yInRaw - outRow0;      // Position on input image
     74
     75            if (xIn < 0) continue;
     76            if (yIn >= inNcol) continue;
     77            if (yIn < 0) continue;
     78            if (yIn >= inNrow) continue;
    3879
    3980            goodPixels++;
    4081
    41             // XXX include mask
    42             // XXX apply scale and offset?
    4382            // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates
    44             double imageValue, varValue;
    45             psMaskType maskValue;
    46             if (!psImageInterpolate(&imageValue, &varValue, &maskValue,
    47                                     inPix->x - inCol0, inPix->y - inRow0, interp)) {
     83            if (!psImageInterpolate(&imageValue, &varValue, &maskValue, xIn, yIn, args->interp)) {
    4884                psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
    49                 psFree(interp);
    50                 psFree(inPix);
    51                 psFree(grid);
    5285                return false;
    5386            }
    54             int xOut = x - outCol0;     // Position on image
    55             outImageData[yOut][xOut] = imageValue;
    56             if (inVar) {
     87
     88            int xOut = x - outCol0;     // Position on output image
     89            int yOut = y - outRow0;     // Position on output image
     90
     91            // not all images need be transformed
     92            if (outImageData) {
     93                outImageData[yOut][xOut] = imageValue;
     94            }
     95            if (outVarData) {
    5796                outVarData[yOut][xOut] = varValue;
    5897            }
     
    62101        }
    63102    }
    64 
    65     psFree(inPix);
     103    args->goodPixels = goodPixels;
     104    return true;
    66105}
Note: See TracChangeset for help on using the changeset viewer.