Changeset 5745 for trunk/stac/src/stacWrite.c
- Timestamp:
- Dec 7, 2005, 4:04:22 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacWrite.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacWrite.c
r5743 r5745 4 4 #include "stac.h" 5 5 6 bool stacWriteMap(const char *mapName, // Filename to write to7 psPlaneTransform *map// Map to write6 bool stacWriteMap(const char *mapName, // Filename to write to 7 psPlaneTransform *map // Map to write 8 8 ) 9 9 { … … 12 12 FILE *mapFile = fopen(mapName, "w"); 13 13 if (!mapFile) { 14 fprintf(stderr, "Unable to open map file: %s\n", mapName);15 return false;14 fprintf(stderr, "Unable to open map file: %s\n", mapName); 15 return false; 16 16 } 17 17 18 psPolynomial2D *xMap = map->x; // x transform19 psPolynomial2D *yMap = map->y; // y transform18 psPolynomial2D *xMap = map->x; // x transform 19 psPolynomial2D *yMap = map->y; // y transform 20 20 21 21 // A crucial limitation of the current system --- the order of each polynomial must be the same 22 22 assert(xMap->nX == xMap->nY && yMap->nX == yMap->nY && xMap->nX == yMap->nX); 23 int order = xMap->nX; // The polynomial order23 int order = xMap->nX; // The polynomial order 24 24 fprintf(mapFile, "%d\n", order); 25 25 26 26 // x coefficients 27 for (int k = 0; k < order + 1; k++) {28 for (int j = 0; j < k + 1; j++) {29 int i = k - j;30 if (xMap->mask[i][j]) {31 fprintf(mapFile, "0.0 ");32 } else {33 fprintf(mapFile, "%g ", xMap->coeff[i][j]);34 }35 }27 for (int k = 0; k <= order; k++) { 28 for (int j = 0; j <= k; j++) { 29 int i = k - j; 30 if (xMap->mask[i][j]) { 31 fprintf(mapFile, "0.0 "); 32 } else { 33 fprintf(mapFile, "%g ", xMap->coeff[i][j]); 34 } 35 } 36 36 } 37 37 fprintf(mapFile, "\n"); 38 38 39 39 // y coefficients 40 for (int k = 0; k < order + 1; k++) {41 for (int j = 0; j < k + 1; j++) {42 int i = k - j;43 if (yMap->mask[i][j]) {44 fprintf(mapFile, "0.0 ");45 } else {46 fprintf(mapFile, "%g ", yMap->coeff[i][j]);47 }48 }40 for (int k = 0; k <= order; k++) { 41 for (int j = 0; j <= k; j++) { 42 int i = k - j; 43 if (yMap->mask[i][j]) { 44 fprintf(mapFile, "0.0 "); 45 } else { 46 fprintf(mapFile, "%g ", yMap->coeff[i][j]); 47 } 48 } 49 49 } 50 50 fprintf(mapFile, "\n"); 51 51 52 52 fclose(mapFile); 53 53 … … 57 57 58 58 bool stacWriteMaps(const psArray *names, // Filenames of the input images (will add ".map") 59 const psArray *maps// Maps to write59 const psArray *maps // Maps to write 60 60 ) 61 61 { … … 65 65 66 66 for (int i = 0; i < names->n; i++) { 67 char mapName[MAXCHAR];// Filename of error image68 sprintf(mapName, "%s.map",names->data[i]);69 if (!stacWriteMap(mapName, maps->data[i])) {70 return false;71 }67 char mapName[MAXCHAR]; // Filename of error image 68 sprintf(mapName, "%s.map", (const char*)names->data[i]); 69 if (!stacWriteMap(mapName, maps->data[i])) { 70 return false; 71 } 72 72 } 73 73
Note:
See TracChangeset
for help on using the changeset viewer.
