Changeset 34471 for branches/czw_branch/20120906/pswarp/src/pswarpMapGrid.c
- Timestamp:
- Sep 25, 2012, 6:08:46 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20120906/pswarp/src/pswarpMapGrid.c
r34470 r34471 52 52 return grid; 53 53 } 54 /**55 * pswarpMapGridFromImageForBackground builds a set (a grid) of locally-linear maps which convert the source56 * coordinates (src) to destination coordinates (dest). we construct a grid with superpixel57 * 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 */60 pswarpMapGrid *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 superpixels66 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 spillover74 int nXpts = (int)(Nx / nXpix) + 1;75 int nYpts = (int)(Ny / nYpix) + 1;76 77 // create the grid of maps78 pswarpMapGrid *grid = pswarpMapGridAlloc (nXpts, nYpts);79 80 // measure the map for the center of each superpixel81 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 }95 54 96 55 /**
Note:
See TracChangeset
for help on using the changeset viewer.
