IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 21, 2007, 12:09:22 PM (19 years ago)
Author:
eugene
Message:

fpa field is now determined by the header and/or the chip regions; pixel scale is not needed for readBilevelMosaic, etc; fixed trimsec errors on input/output; fixed errors on map boundaries

File:
1 edited

Legend:

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

    r12505 r12523  
    55
    66    int minX, minY, maxX, maxY;
    7     int gridXo, gridX, gridY, nextGridX, nextGridY;
     7    int gridXo, gridX, gridY, nextGridXo, nextGridX, nextGridY;
    88    pswarpMap *map = NULL;
    99
     
    1818    psF32 **outData = output->image->data.F32;
    1919
     20    // we need to apply the offset to convert parent coordinates to child coordinates for
     21    // psImagePixelInterpolate below
     22    int inCol0 = input->image->col0;
     23    int inRow0 = input->image->row0;
     24    int outCol0 = output->image->col0;
     25    int outRow0 = output->image->row0;
     26
    2027    // we might want to do the rectangular regions outside of the selection independently
    2128    // psImageInit (output->image, NAN);
     
    2431    pswarpMatchRange (&minX, &minY, &maxX, &maxY, input, output);
    2532
     33    // pswarpMapGridFromImage builds a set of locally-linear maps which convert the
     34    // output coordinates to input coordinates
    2635    pswarpMapGrid *grid = pswarpMapGridFromImage (input, output, 128, 128);
    2736
     
    3140
    3241    pswarpMapGridSetGrid (grid, minX, minY, &gridX, &gridY);
    33     pswarpMapGridNextGrid_Y (grid, gridY, &nextGridY);
     42    nextGridY = pswarpMapGridNextGrid_Y (grid, gridY);
    3443    map = grid->maps[gridX][gridY];
    3544
    36     // Iterate over the output image pixels
     45    assert ((int)(minX - outCol0) >= 0);
     46    assert ((int)(maxX - outCol0) <= output->image->numCols);
     47    assert ((int)(minY - outRow0) >= 0);
     48    assert ((int)(maxY - outRow0) <= output->image->numRows);
     49
     50    gridXo = gridX;
     51    nextGridXo = pswarpMapGridNextGrid_X (grid, gridX);
     52
     53    // Iterate over the output image pixels (parent frame)
    3754    for (int y = minY; y < maxY; y++) {
    3855        if (y >= nextGridY) {
    3956            gridY ++;
    40             pswarpMapGridNextGrid_Y (grid, gridY, &nextGridY);
     57            nextGridY = pswarpMapGridNextGrid_Y (grid, gridY);
    4158            map = grid->maps[gridX][gridY];
    4259        }
    4360
    44         gridXo = gridX;
     61        gridX = gridXo;
     62        nextGridX = nextGridXo;
     63        map = grid->maps[gridX][gridY];
    4564        for (int x = minX; x < maxX; x++) {
    4665            if (x >= nextGridX) {
    4766                gridX ++;
    48                 pswarpMapGridNextGrid_X (grid, gridX, &nextGridX);
     67                nextGridX = pswarpMapGridNextGrid_X (grid, gridX);
    4968                map = grid->maps[gridX][gridY];
    5069            }
     
    5372            if (region && region->data.U8[y][x]) continue;
    5473
    55             // XXX double check this 1/2 pixel offset
    56             // XXX subtract 0.5,0.5 from result?
     74            // pswarpMapApply converts the output coordinate (x,y) to the input coordinate.
     75            // both are in the parent frames of the input and output images.
    5776            pswarpMapApply (&inPix->x, &inPix->y, map, x + 0.5, y + 0.5);
     77
     78            if (inPix->x - inCol0 < 0) continue;
     79            if (inPix->x - inCol0 >= inImage->numCols) continue;
     80            if (inPix->y - inRow0 < 0) continue;
     81            if (inPix->y - inRow0 >= inImage->numRows) continue;
    5882
    5983            // XXX get interpolation method from the recipe
    6084            // XXX include mask
    6185            // XXX apply scale and offset?
    62             outData[y][x] = (psF32)psImagePixelInterpolate(inImage, inPix->x, inPix->y, NULL, 1, NAN, PS_INTERPOLATE_BILINEAR);
     86            // 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);
    6388        }
    64         gridX = gridXo;
    65         pswarpMapGridNextGrid_X (grid, gridX, &nextGridX);
    66         map = grid->maps[gridX][gridY];
    6789    }
    6890
     
    7193    return true;
    7294}
    73 
    74 # if (0)
    75     if (error) {
    76         // Error is actually the variance
    77         outError->data.F32[y][x] = (psF32)p_psImageErrorInterpolateBILINEAR_F32(error,
    78                                                                                 detector->x,
    79                                                                                 detector->y,
    80                                                                                 mask, 1, NAN);
    81     }
    82     if (error) {
    83         outError->data.F32[y][x] = outError->data.F32[y][x] / SQUARE(scale);
    84     }
    85 # endif
    86 
    87    
Note: See TracChangeset for help on using the changeset viewer.