Changeset 12523 for trunk/pswarp/src/pswarpMapGrid.c
- Timestamp:
- Mar 21, 2007, 12:09:22 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/pswarp/src/pswarpMapGrid.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpMapGrid.c
r12505 r12523 1 1 # include "pswarp.h" 2 2 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. 5 7 pswarpMapGrid *pswarpMapGridFromImage (pmReadout *dest, pmReadout *src, int nXpix, int nYpix) { 6 8 … … 8 10 int j, nj; 9 11 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 22 27 pswarpMapGrid *grid = pswarpMapGridAlloc (nXpts, nYpts); 23 28 29 // measure the map for the center of each superpixel 24 30 for (ni = 0, i = xMin; ni < nXpts; i += nXpix, ni++) { 25 31 for (nj = 0, j = yMin; nj < nYpts; j += nYpix, nj++) { … … 35 41 } 36 42 43 // set the grid coordinate (gridX,gridY) for the given source image coordinate (ix,iy) 37 44 bool pswarpMapGridSetGrid (pswarpMapGrid *grid, int ix, int iy, int *gridX, int *gridY) { 38 45 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; 41 48 return true; 42 49 } 43 50 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 53 int 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 61 int 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 57 69 double pswarpMapGridMaxError (pswarpMapGrid *grid) { 58 70 … … 76 88 } 77 89 90 // given the source coordinate (inX,inY), return the destination coordinate (outX,outY) 78 91 bool pswarpMapApply (double *outX, double *outY, pswarpMap *map, double inX, double inY) { 79 92 … … 84 97 } 85 98 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. 87 102 bool pswarpMapSetLocalModel (pswarpMap *map, pmReadout *dest, pmReadout *src, int ix, int iy) { 88 103
Note:
See TracChangeset
for help on using the changeset viewer.
