Changeset 12523 for trunk/pswarp/src/pswarpTransformReadout_Opt.c
- Timestamp:
- Mar 21, 2007, 12:09:22 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/pswarp/src/pswarpTransformReadout_Opt.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpTransformReadout_Opt.c
r12505 r12523 5 5 6 6 int minX, minY, maxX, maxY; 7 int gridXo, gridX, gridY, nextGridX , nextGridY;7 int gridXo, gridX, gridY, nextGridXo, nextGridX, nextGridY; 8 8 pswarpMap *map = NULL; 9 9 … … 18 18 psF32 **outData = output->image->data.F32; 19 19 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 20 27 // we might want to do the rectangular regions outside of the selection independently 21 28 // psImageInit (output->image, NAN); … … 24 31 pswarpMatchRange (&minX, &minY, &maxX, &maxY, input, output); 25 32 33 // pswarpMapGridFromImage builds a set of locally-linear maps which convert the 34 // output coordinates to input coordinates 26 35 pswarpMapGrid *grid = pswarpMapGridFromImage (input, output, 128, 128); 27 36 … … 31 40 32 41 pswarpMapGridSetGrid (grid, minX, minY, &gridX, &gridY); 33 pswarpMapGridNextGrid_Y (grid, gridY, &nextGridY);42 nextGridY = pswarpMapGridNextGrid_Y (grid, gridY); 34 43 map = grid->maps[gridX][gridY]; 35 44 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) 37 54 for (int y = minY; y < maxY; y++) { 38 55 if (y >= nextGridY) { 39 56 gridY ++; 40 pswarpMapGridNextGrid_Y (grid, gridY, &nextGridY);57 nextGridY = pswarpMapGridNextGrid_Y (grid, gridY); 41 58 map = grid->maps[gridX][gridY]; 42 59 } 43 60 44 gridXo = gridX; 61 gridX = gridXo; 62 nextGridX = nextGridXo; 63 map = grid->maps[gridX][gridY]; 45 64 for (int x = minX; x < maxX; x++) { 46 65 if (x >= nextGridX) { 47 66 gridX ++; 48 pswarpMapGridNextGrid_X (grid, gridX, &nextGridX);67 nextGridX = pswarpMapGridNextGrid_X (grid, gridX); 49 68 map = grid->maps[gridX][gridY]; 50 69 } … … 53 72 if (region && region->data.U8[y][x]) continue; 54 73 55 // XXX double check this 1/2 pixel offset56 // 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. 57 76 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; 58 82 59 83 // XXX get interpolation method from the recipe 60 84 // XXX include mask 61 85 // 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); 63 88 } 64 gridX = gridXo;65 pswarpMapGridNextGrid_X (grid, gridX, &nextGridX);66 map = grid->maps[gridX][gridY];67 89 } 68 90 … … 71 93 return true; 72 94 } 73 74 # if (0)75 if (error) {76 // Error is actually the variance77 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 # endif86 87
Note:
See TracChangeset
for help on using the changeset viewer.
