Changeset 3375 for trunk/stac/src/stacInvertMaps.c
- Timestamp:
- Mar 4, 2005, 11:37:01 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacInvertMaps.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacInvertMaps.c
r2897 r3375 1 1 #include <stdio.h> 2 #include <assert.h> 2 3 #include "pslib.h" 3 4 #include "stac.h" … … 24 25 psPlaneTransform *oldMap = (psPlaneTransform*)maps->data[mapNum]; // Uninverted map 25 26 // Check input 26 if (oldMap->x->nX != oldMap->x->nY) { 27 psError("stac.invertMaps", "Polynomial order in x and y don't match for map %d\n", mapNum); 28 return NULL; 29 } 30 if (oldMap->y->nX != oldMap->y->nY) { 31 psError("stac.invertMaps", "Polynomial order in x and y don't match for map %d\n", mapNum); 32 return NULL; 33 } 34 if (oldMap->x->nX != oldMap->y->nX) { 35 psError("stac.invertMaps", "Polynomial order in x and y don't match for map %d\n", mapNum); 36 return NULL; 37 } 27 assert(oldMap->x->nX == oldMap->x->nY && oldMap->y->nX == oldMap->y->nY && 28 oldMap->x->nX == oldMap->y->nX); 38 29 int order = oldMap->x->nX; // Polynomial order 39 30 psTrace("stac.invertMaps", 4, "Generating order %d polynomial inverse transformation.\n", order); … … 91 82 92 83 fakePoly->mask[i][j] = 0; 93 double ijPoly = psDPolynomial2DEval( xIn->data.F32[g], yIn->data.F32[g], fakePoly);84 double ijPoly = psDPolynomial2DEval(fakePoly, xIn->data.F32[g], yIn->data.F32[g]); 94 85 fakePoly->mask[i][j] = 1; 95 86 … … 98 89 99 90 fakePoly->mask[m][n] = 0; 100 double mnPoly = psDPolynomial2DEval( xIn->data.F32[g], yIn->data.F32[g], fakePoly);91 double mnPoly = psDPolynomial2DEval(fakePoly, xIn->data.F32[g], yIn->data.F32[g]); 101 92 fakePoly->mask[m][n] = 1; 102 93 … … 113 104 // Solution via LU Decomposition 114 105 psVector *permutation = psVectorAlloc(nCoeff, PS_TYPE_F64); // Permutation vector for LU Decomposition 115 psImage *luMatrix = psMatrixLUD(NULL, permutation, matrix); // LU decomposed matrix106 psImage *luMatrix = psMatrixLUD(NULL, &permutation, matrix); // LU decomposed matrix 116 107 psVector *xSolution = psMatrixLUSolve(NULL, luMatrix, xVector, permutation); // Solution in x 117 108 psVector *ySolution = psMatrixLUSolve(NULL, luMatrix, yVector, permutation); // Solution in y … … 178 169 #if 0 179 170 // Can't handle higher order than linear yet 180 if (((psPlaneTransform*)maps->data[i])->x->nX != 2 || 181 ((psPlaneTransform*)maps->data[i])->x->nY != 2 || 182 ((psPlaneTransform*)maps->data[i])->y->nX != 2 || 183 ((psPlaneTransform*)maps->data[i])->y->nY != 2) { 184 psError("stac.invertMaps", 185 "STAC cannot currently support orders other than linear.\n"); 186 psFree(inverted); 187 return NULL; 188 } 189 171 assert(((psPlaneTransform*)maps->data[i])->x->nX == 2 && 172 ((psPlaneTransform*)maps->data[i])->x->nY == 2 && 173 ((psPlaneTransform*)maps->data[i])->y->nX == 2 && 174 ((psPlaneTransform*)maps->data[i])->y->nY == 2); 190 175 psPlaneTransform *newMap = psPlaneTransformAlloc(2, 2); // Inverted map 191 176 psPlaneTransform *oldMap = (psPlaneTransform*)maps->data[i]; // Uninverted map
Note:
See TracChangeset
for help on using the changeset viewer.
