IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 25, 2012, 5:33:33 PM (14 years ago)
Author:
watersc1
Message:

Hardcoded version that gets the right solution. I wanted to save this before attempting to clean up the code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20120906/pswarp/src/pswarpMapGrid.c

    r31878 r34470  
    5252    return grid;
    5353}
     54/**
     55 * pswarpMapGridFromImageForBackground builds a set (a grid) of locally-linear maps which convert the source
     56 * coordinates (src) to destination coordinates (dest).  we construct a grid with superpixel
     57 * spacing of nXpix, nYpix.  The transformation for each grid cell is valid for the superpixel.
     58 * The grid over-fills the source image so every source image pixel is guaranteed to have a map.
     59 */
     60pswarpMapGrid *pswarpMapGridFromImageForBackground (pmReadout *dest, pmReadout *src, int nXpix, int nYpix) {
     61
     62    int i, ni;
     63    int j, nj;
     64
     65    // start counting from the center of the superpixels
     66    double xMin = 0.5*nXpix;
     67    double yMin = 0.5*nYpix;
     68
     69    // the map is defined for coordinates in the image parent frame.
     70    int Nx = src->image->numCols + src->image->col0;
     71    int Ny = src->image->numRows + src->image->row0;
     72
     73    // always allocate an extra superpixel to handle spillover
     74    int nXpts = (int)(Nx / nXpix) + 1;
     75    int nYpts = (int)(Ny / nYpix) + 1;
     76
     77    // create the grid of maps
     78    pswarpMapGrid *grid = pswarpMapGridAlloc (nXpts, nYpts);
     79
     80    // measure the map for the center of each superpixel
     81    for (ni = 0, i = xMin; ni < nXpts; i += nXpix, ni++) {
     82        for (nj = 0, j = yMin; nj < nYpts; j += nYpix, nj++) {
     83            pswarpMapSetLocalModel (grid->maps[ni][nj], dest, src, i, j);
     84/*          grid->maps[ni][nj]->Xo += (13.0 * 400.0 - 4846.0) / 2.0; */
     85/*          grid->maps[ni][nj]->Yo += (13.0 * 400.0 - 4868.0) / 2.0; */
     86        }
     87    }
     88
     89    grid->nXpix = nXpix;
     90    grid->nYpix = nYpix;
     91    grid->xMin = xMin;
     92    grid->yMin = yMin;
     93    return grid;
     94}
    5495
    5596/**
Note: See TracChangeset for help on using the changeset viewer.