Changeset 12744
- Timestamp:
- Apr 4, 2007, 12:54:56 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
pswarp/src/pswarpTransformReadout.c (modified) (3 diffs)
-
pswarp/src/pswarpTransformReadout_Opt.c (modified) (6 diffs)
-
stac/src/stacRejection.c (modified) (2 diffs)
-
stac/src/stacTransform.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpTransformReadout.c
r10958 r12744 3 3 bool pswarpTransformReadout (pmReadout *output, pmReadout *input, pmConfig *config) { 4 4 5 // XXX this implementation currently ignores the use of the region 5 // XXX this implementation currently ignores the use of the region 6 6 psImage *region = NULL; 7 7 pmCell *cell = NULL; … … 13 13 int outNy = output->image->numRows; 14 14 15 psPlane *inPix = psPlaneAlloc(); // Coordinates on the input detector16 psPlane *outPix = psPlaneAlloc(); // Coordinates on the output detector15 psPlane *inPix = psPlaneAlloc(); // Coordinates on the input detector 16 psPlane *outPix = psPlaneAlloc(); // Coordinates on the output detector 17 17 18 psPlane *FP = psPlaneAlloc(); // Coordinates on the focal plane19 psPlane *TP = psPlaneAlloc(); // Coordinates on the tangent plane20 psSphere *sky = psSphereAlloc(); // Coordinates on the sky18 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 21 22 22 cell = input->parent; … … 31 31 psImage *inImage = input->image; 32 32 33 psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR, inImage, 34 NULL, NULL, 0, NAN, NAN, 0, 0, 0.0); 35 33 36 // Iterate over the output image pixels 34 37 for (int y = 0; y < outNy; y++) { 35 for (int x = 0; x < outNx; x++) {36 // Only transform those pixels requested37 if (region && region->data.U8[y][x]) continue;38 for (int x = 0; x < outNx; x++) { 39 // Only transform those pixels requested 40 if (region && region->data.U8[y][x]) continue; 38 41 39 // XXX double check this 1/2 pixel offset40 outPix->x = (double)x + 0.5;41 outPix->y = (double)y + 0.5;42 // XXX double check this 1/2 pixel offset 43 outPix->x = (double)x + 0.5; 44 outPix->y = (double)y + 0.5; 42 45 43 psPlaneTransformApply(FP, chipOutput->toFPA, outPix); 44 psPlaneTransformApply (TP, fpaOutput->toTPA, FP); 45 psDeproject (sky, TP, fpaOutput->toSky); 46 47 psProject (TP, sky, fpaInput->toSky); 48 psPlaneTransformApply (FP, fpaInput->fromTPA, TP); 49 psPlaneTransformApply (inPix, chipInput->fromFPA, FP); 46 psPlaneTransformApply(FP, chipOutput->toFPA, outPix); 47 psPlaneTransformApply (TP, fpaOutput->toTPA, FP); 48 psDeproject (sky, TP, fpaOutput->toSky); 50 49 51 // XXX get interpolation method from the recipe 52 outData[y][x] = (psF32)psImagePixelInterpolate(inImage, inPix->x, inPix->y, NULL, 1, NAN, PS_INTERPOLATE_BILINEAR); 53 // outData[y][x] = (psF32)psImagePixelInterpolate(inImage, inPix->x, inPix->y, mask, 1, NAN, PS_INTERPOLATE_BILINEAR); 54 // modify zero and scale? 55 } 50 psProject (TP, sky, fpaInput->toSky); 51 psPlaneTransformApply (FP, fpaInput->fromTPA, TP); 52 psPlaneTransformApply (inPix, chipInput->fromFPA, FP); 53 54 // XXX get interpolation method from the recipe 55 double value; 56 if (!psImageInterpolate(&value, NULL, NULL, inPix->x, inPix->y, interp)) { 57 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 58 psFree(interp); 59 psFree(inPix); 60 psFree(outPix); 61 psFree(FP); 62 psFree(TP); 63 psFree(sky); 64 return false; 65 } 66 67 outData[y][x] = value; 68 // modify zero and scale? 69 } 56 70 } 57 58 psFree (inPix);59 psFree (outPix);60 psFree (FP);61 psFree (TP);62 psFree (sky);71 psFree(interp); 72 psFree(inPix); 73 psFree(outPix); 74 psFree(FP); 75 psFree(TP); 76 psFree(sky); 63 77 64 78 return true; 65 79 } 66 67 # if (0)68 if (error) {69 // Error is actually the variance70 outError->data.F32[y][x] = (psF32)p_psImageErrorInterpolateBILINEAR_F32(error,71 detector->x,72 detector->y,73 mask, 1, NAN);74 }75 if (error) {76 outError->data.F32[y][x] = outError->data.F32[y][x] / SQUARE(scale);77 }78 # endif -
trunk/pswarp/src/pswarpTransformReadout_Opt.c
r12528 r12744 1 1 # include "pswarp.h" 2 psImageInterpolateMode psImageInterpolateModeFromString (char *name);3 2 4 3 // NOTE: in this function, the coordinates are transformed from the OUTPUT to the INPUT … … 11 10 psImageInterpolateMode interpolationMode = PS_INTERPOLATE_NONE; 12 11 13 // XXX this implementation currently ignores the use of the region 12 // XXX this implementation currently ignores the use of the region 14 13 psImage *region = NULL; 15 14 … … 19 18 psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE); 20 19 if (!recipe) { 21 psError(PSWARP_ERR_CONFIG, true, "Can't find PSWARP recipe!\n");22 return false;20 psError(PSWARP_ERR_CONFIG, true, "Can't find PSWARP recipe!\n"); 21 return false; 23 22 } 24 23 25 24 int nGridX = psMetadataLookupS32 (&status, recipe, "GRID.NX"); 26 25 if (!status) nGridX = 128; … … 30 29 char *name = psMetadataLookupStr (&status, recipe, "INTERPOLATION.MODE"); 31 30 if (!name) { 32 interpolationMode = PS_INTERPOLATE_BILINEAR;33 psLogMsg ("pswarp", 3, "defaulting to bilinear interpolation\n");31 interpolationMode = PS_INTERPOLATE_BILINEAR; 32 psLogMsg ("pswarp", 3, "defaulting to bilinear interpolation\n"); 34 33 } else { 35 interpolationMode = psImageInterpolateModeFromString (name);36 if (interpolationMode == PS_INTERPOLATE_NONE) {37 interpolationMode = PS_INTERPOLATE_BILINEAR;38 psLogMsg ("pswarp", 3, "unknown interpolation mode %s, defaulting to bilinear interpolation\n", name);39 }34 interpolationMode = psImageInterpolateModeFromString (name); 35 if (interpolationMode == PS_INTERPOLATE_NONE) { 36 interpolationMode = PS_INTERPOLATE_BILINEAR; 37 psLogMsg ("pswarp", 3, "unknown interpolation mode %s, defaulting to bilinear interpolation\n", name); 38 } 40 39 } 41 40 42 psPlane *inPix = psPlaneAlloc(); // Coordinates on the input detector41 psPlane *inPix = psPlaneAlloc(); // Coordinates on the input detector 43 42 psImage *inImage = input->image; 44 43 psF32 **outData = output->image->data.F32; … … 65 64 psLogMsg ("pswarp", 3, "maximum error using this grid sampling: %f\n", maxError); 66 65 67 pswarpMapGridSetGrid (grid, minX, minY, &gridX, &gridY); 66 pswarpMapGridSetGrid (grid, minX, minY, &gridX, &gridY); 68 67 nextGridY = pswarpMapGridNextGrid_Y (grid, gridY); 69 68 map = grid->maps[gridX][gridY]; … … 77 76 nextGridXo = pswarpMapGridNextGrid_X (grid, gridX); 78 77 78 psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR, inImage, 79 NULL, NULL, 0, NAN, NAN, 0, 0, 0.0); 80 79 81 // Iterate over the output image pixels (parent frame) 80 82 for (int y = minY; y < maxY; y++) { 81 if (y >= nextGridY) {82 gridY ++;83 nextGridY = pswarpMapGridNextGrid_Y (grid, gridY);84 map = grid->maps[gridX][gridY];85 }83 if (y >= nextGridY) { 84 gridY ++; 85 nextGridY = pswarpMapGridNextGrid_Y (grid, gridY); 86 map = grid->maps[gridX][gridY]; 87 } 86 88 87 gridX = gridXo;88 nextGridX = nextGridXo;89 map = grid->maps[gridX][gridY];90 for (int x = minX; x < maxX; x++) {91 if (x >= nextGridX) {92 gridX ++;93 nextGridX = pswarpMapGridNextGrid_X (grid, gridX);94 map = grid->maps[gridX][gridY];95 }89 gridX = gridXo; 90 nextGridX = nextGridXo; 91 map = grid->maps[gridX][gridY]; 92 for (int x = minX; x < maxX; x++) { 93 if (x >= nextGridX) { 94 gridX ++; 95 nextGridX = pswarpMapGridNextGrid_X (grid, gridX); 96 map = grid->maps[gridX][gridY]; 97 } 96 98 97 // Only transform those pixels requested98 if (region && region->data.U8[y][x]) continue;99 // Only transform those pixels requested 100 if (region && region->data.U8[y][x]) continue; 99 101 100 // pswarpMapApply converts the output coordinate (x,y) to the input coordinate.101 // both are in the parent frames of the input and output images.102 pswarpMapApply (&inPix->x, &inPix->y, map, x + 0.5, y + 0.5);102 // pswarpMapApply converts the output coordinate (x,y) to the input coordinate. 103 // both are in the parent frames of the input and output images. 104 pswarpMapApply (&inPix->x, &inPix->y, map, x + 0.5, y + 0.5); 103 105 104 if (inPix->x - inCol0 < 0) continue;105 if (inPix->x - inCol0 >= inImage->numCols) continue;106 if (inPix->y - inRow0 < 0) continue;107 if (inPix->y - inRow0 >= inImage->numRows) continue;106 if (inPix->x - inCol0 < 0) continue; 107 if (inPix->x - inCol0 >= inImage->numCols) continue; 108 if (inPix->y - inRow0 < 0) continue; 109 if (inPix->y - inRow0 >= inImage->numRows) continue; 108 110 109 // XXX include mask 110 // XXX apply scale and offset? 111 // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates 112 outData[y-outRow0][x-outCol0] = (psF32)psImagePixelInterpolate(inImage, inPix->x - inCol0, inPix->y - inRow0, NULL, 1, NAN, interpolationMode); 113 } 111 // XXX include mask 112 // XXX apply scale and offset? 113 // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates 114 double value; 115 if (!psImageInterpolate(&value, NULL, NULL, inPix->x - inCol0, inPix->y - inRow0, interp)) { 116 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 117 psFree(interp); 118 psFree (inPix); 119 psFree (grid); 120 return false; 121 } 122 outData[y-outRow0][x-outCol0] = value; 123 } 114 124 } 115 125 126 psFree(interp); 116 127 psFree (inPix); 117 128 psFree (grid); -
trunk/stac/src/stacRejection.c
r9740 r12744 111 111 #endif 112 112 113 psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR, 114 reject, NULL, NULL, 0, 0.0, 0.0, 115 0, 0, 0.0); 116 113 117 // Transform the mask 114 118 // Optimisation option is to only transform the pixels that have been rejected in the output, … … 125 129 inCoords->y = (double)y + 0.5; 126 130 (void)psPlaneTransformApply(outCoords, map, inCoords); 127 float maskVal = (float)psImagePixelInterpolate(reject, outCoords->x, outCoords->y, 128 NULL, 0, 0.0, PS_INTERPOLATE_BILINEAR); 131 double maskVal; 132 if (!psImageInterpolate(&maskVal, NULL, NULL, outCoords->x, outCoords->y, interp)) { 133 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 134 psFree(grads); 135 psFree(gradsMask); 136 psFree(inCoords); 137 psFree(outCoords); 138 return NULL; 139 } 140 129 141 #ifdef TESTING 130 142 rejmap->data.F32[y][x] = maskVal; -
trunk/stac/src/stacTransform.c
r9740 r12744 193 193 } 194 194 195 psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR, 196 image, error, mask, 1, NAN, NAN, 197 1, 0, 0.0); 198 195 199 // Iterate over the output image pixels 196 200 for (int y = 0; y < outny; y++) { … … 204 208 205 209 // Change PS_INTERPOLATE_BILINEAR to best available technique. 206 outImage->data.F32[y][x] = (psF32)psImagePixelInterpolate(image, detector->x, 207 detector->y, mask, 1, NAN, 208 PS_INTERPOLATE_BILINEAR); 210 double imageValue, varianceValue; 211 if (!psImageInterpolate(&imageValue, &varianceValue, NULL, 212 detector->x, detector->y, interp)) { 213 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 214 psFree(interp); 215 psFree(detector); 216 psFree(sky); 217 return false; 218 } 219 outImage->data.F32[y][x] = imageValue; 220 209 221 if (error) { 210 222 // Error is actually the variance 211 outError->data.F32[y][x] = (psF32)p_psImageErrorInterpolateBILINEAR_F32(error, 212 detector->x, 213 detector->y, 214 mask, 1, NAN); 223 outError->data.F32[y][x] = varianceValue; 215 224 } 216 225 … … 224 233 } 225 234 } // Iterating over output pixels 235 psFree(interp); 226 236 227 237 } // Iterating over images
Note:
See TracChangeset
for help on using the changeset viewer.
