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/pswarpMapGrid.c

    r12505 r12523  
    11# include "pswarp.h"
    22
    3 // construct a grid with superpixel spacing of nXpix, nYpix
    4 // XXX for the moment, ignore readout->cell->chip offsets
     3// pswarpMapGridFromImage builds a set (a grid) of locally-linear maps which convert the source
     4// coordinates (src) to destination coordinates (dest).  we construct a grid with superpixel
     5// spacing of nXpix, nYpix.  The transformation for each grid cell is valid for the superpixel.
     6// The grid over-fills the source image so ever source image pixel is guaranteed to have a map.
    57pswarpMapGrid *pswarpMapGridFromImage (pmReadout *dest, pmReadout *src, int nXpix, int nYpix) {
    68
     
    810    int j, nj;
    911
    10     // XXX I was trying to match the grids too closely
    11     // split the difference of the remainder
    12     // int xMin = 0.5*(src->image->numCols % nXpix);
    13     // int yMin = 0.5*(src->image->numRows % nYpix);
    14     int xMin = 0;
    15     int yMin = 0;
    16 
    17     int nXpts = src->image->numCols / nXpix + 1;
    18     if (src->image->numCols % nXpix) nXpts ++;
    19     int nYpts = src->image->numRows / nYpix + 1;
    20     if (src->image->numRows % nYpix) nYpts ++;
    21 
     12    // start counting from the center of the superpixels
     13    int xMin = 0.5*nXpix;
     14    int yMin = 0.5*nYpix;
     15
     16    // the map is defined for coordinates in the image parent frame.
     17    int Nx = src->image->numCols + src->image->col0;
     18    int Ny = src->image->numRows + src->image->row0;
     19
     20    // allocate an extra superpixel to carry the remainder
     21    int nXpts = Nx / nXpix;
     22    int nYpts = Ny / nYpix;
     23    if (Nx % nXpix) nXpts ++;
     24    if (Ny % nYpix) nYpts ++;
     25
     26    // create the grid of maps
    2227    pswarpMapGrid *grid = pswarpMapGridAlloc (nXpts, nYpts);
    2328
     29    // measure the map for the center of each superpixel
    2430    for (ni = 0, i = xMin; ni < nXpts; i += nXpix, ni++) {
    2531        for (nj = 0, j = yMin; nj < nYpts; j += nYpix, nj++) {
     
    3541}
    3642
     43// set the grid coordinate (gridX,gridY) for the given source image coordinate (ix,iy)
    3744bool pswarpMapGridSetGrid (pswarpMapGrid *grid, int ix, int iy, int *gridX, int *gridY) {
    3845
    39     *gridX = (ix - grid->xMin + 0.5*grid->nXpix) / grid->nXpix;
    40     *gridY = (iy - grid->yMin + 0.5*grid->nYpix) / grid->nYpix;
     46    *gridX = 0.5 + (ix - grid->xMin) / (double) grid->nXpix;
     47    *gridY = 0.5 + (iy - grid->yMin) / (double) grid->nYpix;
    4148    return true;
    4249}
    4350
    44 bool pswarpMapGridNextGrid_X (pswarpMapGrid *grid, int gridX, int *nextX) {
    45 
    46     *nextX = gridX*grid->nXpix + grid->xMin + 0.5*grid->nXpix;
    47     return true;
    48 }
    49 
    50 bool pswarpMapGridNextGrid_Y (pswarpMapGrid *grid, int gridY, int *nextY) {
    51 
    52     *nextY = gridY*grid->nYpix + grid->yMin + 0.5*grid->nYpix;
    53     return true;
    54 }
    55 
    56 // measure the max error accumulated in appling one grid point to its neighbors
     51// given the specified grid coordinate (gridX), return the x-coordinate for the source image
     52// corresponding to the next grid cell
     53int pswarpMapGridNextGrid_X (pswarpMapGrid *grid, int gridX) {
     54
     55    int nextX = (gridX + 0.5)*grid->nXpix + grid->xMin;
     56    return nextX;
     57}
     58
     59// given the specified grid coordinate (gridY), return the y-coordinate for the source image
     60// corresponding to the next grid cell
     61int pswarpMapGridNextGrid_Y (pswarpMapGrid *grid, int gridY) {
     62
     63    int nextY = (gridY + 0.5)*grid->nYpix + grid->yMin;
     64    return nextY;
     65}
     66
     67// measure the max error accumulated in applying one grid point to its neighbors
     68// XXX double-check this
    5769double pswarpMapGridMaxError (pswarpMapGrid *grid) {
    5870
     
    7688}
    7789
     90// given the source coordinate (inX,inY), return the destination coordinate (outX,outY)
    7891bool pswarpMapApply (double *outX, double *outY, pswarpMap *map, double inX, double inY) {
    7992
     
    8497}
    8598
    86 // determine the map for the given pixel from src to dest. pixel is in src coords
     99// determine the (linear) map for the given pixel (ix,iy) from source image (src) to the destination image (dest)
     100// pixel is in src coords. input and output pixel coordinates are in the parent frame of the image (Note that the
     101// astrometric transformations are supplied for the parent image coordinate frame.
    87102bool pswarpMapSetLocalModel (pswarpMap *map, pmReadout *dest, pmReadout *src, int ix, int iy) {
    88103
Note: See TracChangeset for help on using the changeset viewer.