Changeset 10957 for trunk/pswarp/src/pswarpTransformReadout_Opt.c
- Timestamp:
- Jan 7, 2007, 3:28:00 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/pswarp/src/pswarpTransformReadout_Opt.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpTransformReadout_Opt.c
r10954 r10957 1 1 # include "pswarp.h" 2 2 3 bool pswarpTransformReadout (pmReadout *output, pmReadout *input, pmConfig *config) { 3 // NOTE: in this function, the coordinates are transformed from the OUTPUT to the INPUT 4 bool pswarpTransformReadout_Opt (pmReadout *output, pmReadout *input, pmConfig *config) { 5 6 int minX, minY, maxX, maxY; 7 int gridX, gridY, nextGridX, nextGridY; 8 pswarpMap *map = NULL; 4 9 5 10 // XXX this implementation currently ignores the use of the region 6 11 psImage *region = NULL; 7 pmCell *cell = NULL;8 12 9 13 // select the current recipe 10 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE); 11 12 int outNx = output->image->numCols; 13 int outNy = output->image->numRows; 14 // psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE); 14 15 15 16 psPlane *inPix = psPlaneAlloc(); // Coordinates on the input detector 16 psPlane *outPix = psPlaneAlloc(); // Coordinates on the output detector 17 18 psPlane *FP = psPlaneAlloc(); // Coordinates on the focal plane 19 psPlane *TP = psPlaneAlloc(); // Coordinates on the tangent plane 20 psSphere *sky = psSphereAlloc(); // Coordinates on the sky 21 22 cell = input->parent; 23 pmChip *chipInput = cell->parent; 24 pmFPA *fpaInput = chipInput->parent; 25 26 cell = output->parent; 27 pmChip *chipOutput = cell->parent; 28 pmFPA *fpaOutput = chipOutput->parent; 29 17 psImage *inImage = input->image; 30 18 psF32 **outData = output->image->data.F32; 31 psImage *inImage = input->image;32 19 33 20 // we might want to do the rectangular regions outside of the selection independently … … 37 24 pswarpMatchRange (&minX, &minY, &maxX, &maxY, input, output); 38 25 26 pswarpMapGrid *grid = pswarpMapGridFromImage (input, output, 128, 128); 27 28 // XXX need to modify the grid based on this result and force the maxError < XXX 29 double maxError = pswarpMapGridMaxError (grid); 30 fprintf (stderr, "maximum error using this grid sampling: %f\n", maxError); 31 32 pswarpMapGridSetGrid (grid, minX, minY, &gridX, &gridY); 33 pswarpMapGridNextGrid (grid, gridX, gridY, &nextGridX, &nextGridY); 34 map = grid->maps[gridX][gridY]; 35 39 36 // Iterate over the output image pixels 40 for (int y = 0; y < outNy; y++) { 41 for (int x = 0; x < outNx; x++) { 37 for (int y = minY; y < maxY; y++) { 38 if (y >= nextGridY) { 39 gridY ++; 40 pswarpMapGridNextGrid (grid, gridX, gridY, &nextGridX, &nextGridY); 41 map = grid->maps[gridX][gridY]; 42 } 43 for (int x = minX; x < maxX; x++) { 44 if (x >= nextGridX) { 45 gridX ++; 46 pswarpMapGridNextGrid (grid, gridX, gridY, &nextGridX, &nextGridY); 47 map = grid->maps[gridX][gridY]; 48 } 49 42 50 // Only transform those pixels requested 43 if (!region || (region && region->data.U8[y][x])) { 44 // Transform! 51 if (region && region->data.U8[y][x]) continue; 45 52 46 // XXX double check this 1/2 pixel offset47 outPix->x = (double)x + 0.5;48 outPix->y = (double)y + 0.5;53 // XXX double check this 1/2 pixel offset 54 // XXX subtract 0.5,0.5 from result? 55 pswarpMapApply (&inPix->x, &inPix->y, map, x + 0.5, y + 0.5); 49 56 50 psPlaneTransformApply(FP, chipOutput->toFPA, outPix); 51 psPlaneTransformApply (TP, fpaOutput->toTPA, FP); 52 psDeproject (sky, TP, fpaOutput->toSky); 53 54 psProject (TP, sky, fpaInput->toSky); 55 psPlaneTransformApply (FP, fpaInput->fromTPA, TP); 56 psPlaneTransformApply (inPix, chipInput->fromFPA, FP); 57 58 // XXX get interpolation method from the recipe 59 outImage->data.F32[y][x] = (psF32)psImagePixelInterpolate(image, inPix->x, inPix->y, mask, 1, NAN, PS_INTERPOLATE_BILINEAR); 60 61 # if (0) 62 if (error) { 63 // Error is actually the variance 64 outError->data.F32[y][x] = (psF32)p_psImageErrorInterpolateBILINEAR_F32(error, 65 detector->x, 66 detector->y, 67 mask, 1, NAN); 68 } 69 # endif 70 71 outImage->data.F32[y][x] = (outImage->data.F32[y][x] - offset) / scale; 72 # if (0) 73 if (error) { 74 outError->data.F32[y][x] = outError->data.F32[y][x] / SQUARE(scale); 75 } 76 # endif 77 78 } // Pixels of interest 79 57 // XXX get interpolation method from the recipe 58 // XXX include mask 59 // XXX apply scale and offset? 60 outData[y][x] = (psF32)psImagePixelInterpolate(inImage, inPix->x, inPix->y, NULL, 1, NAN, PS_INTERPOLATE_BILINEAR); 80 61 } 81 } // Iterating over output pixels 82 62 } 83 63 return true; 84 64 } 85 65 66 # if (0) 67 if (error) { 68 // Error is actually the variance 69 outError->data.F32[y][x] = (psF32)p_psImageErrorInterpolateBILINEAR_F32(error, 70 detector->x, 71 detector->y, 72 mask, 1, NAN); 73 } 74 if (error) { 75 outError->data.F32[y][x] = outError->data.F32[y][x] / SQUARE(scale); 76 } 77 # endif 78 86 79
Note:
See TracChangeset
for help on using the changeset viewer.
