Changeset 6891
- Timestamp:
- Apr 18, 2006, 12:42:12 PM (20 years ago)
- Location:
- trunk/pois/src
- Files:
-
- 7 edited
-
poisCalculateDeviations.c (modified) (2 diffs)
-
poisCalculateEquation.c (modified) (1 diff)
-
poisCheckKernel.c (modified) (3 diffs)
-
poisFindStamps.c (modified) (1 diff)
-
poisKernelBasisFunctions.c (modified) (1 diff)
-
poisReadStamps.c (modified) (1 diff)
-
poisSolveEquation.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pois/src/poisCalculateDeviations.c
r6772 r6891 33 33 if (!deviations) { 34 34 deviations = psVectorAlloc(stamps->n, PS_TYPE_F32); 35 deviations->n = stamps->n; 35 36 } 36 37 … … 64 65 psRegion stampTrim = { config->xKernel, config->xKernel + 2 * footprint, config->yKernel, 65 66 config->yKernel + 2 * footprint }; 67 #if 0 66 68 psRegion maskTrim = { x - xSize + config->xKernel, x + xSize - config->xKernel, 67 69 y - ySize + config->yKernel, y + ySize - config->yKernel }; 68 70 psImage *maskStampTrim = psImageSubset(maskStamp, maskTrim); 71 #else 72 psImage *maskStampTrim = psImageSubset(maskStamp, stampTrim); 73 #endif 69 74 psImage *subStampTrim = psImageSubset(subStamp, stampTrim); 70 psImage *maskStampTrim = psImageSubset(maskStamp, maskTrim);71 75 (void)psImageStats(stats, subStampTrim, maskStampTrim, POIS_MASK_BAD | POIS_MASK_NEAR_BAD); 72 76 -
trunk/pois/src/poisCalculateEquation.c
r6452 r6891 60 60 psTrace("pois.calculateEquation", 3, "Allocating vector: %d\n", numSolveParams); 61 61 stamp->vector = psVectorAlloc(numSolveParams, PS_TYPE_F64); 62 stamp->vector->n = numSolveParams; 62 63 } 63 64 -
trunk/pois/src/poisCheckKernel.c
r4700 r6891 4 4 5 5 bool poisCheckKernel(const psVector *solution,// Kernel solution 6 const psArray *kernels, // Kernel basis functions7 const poisConfig *config // Configuration6 const psArray *kernels, // Kernel basis functions 7 const poisConfig *config // Configuration 8 8 ) 9 9 { … … 13 13 psVector *radKernel = psVectorAlloc((2*config->xKernel + 1) * (2*config->yKernel + 1), PS_TYPE_F32); 14 14 psVector *radii = psVectorAlloc((2*config->xKernel + 1) * (2*config->yKernel + 1), PS_TYPE_F32); // Radius 15 radKernel->n = radii->n = (2*config->xKernel + 1) * (2*config->yKernel + 1); 15 16 for (int i = 0; i < solution->n - 1; i++) { 16 poisKernelBasis *kernel = kernels->data[i]; // The kernel basis function17 if (kernel->xOrder == 0 && kernel->yOrder == 0) {18 int u = kernel->u;// x offset19 int v = kernel->v;// y offset20 float distance = sqrtf((float)(u*u) + (float)(v*v)); // Distance from the centre21 radKernel->data.F32[i] = solution->data.F64[i];22 radii->data.F32[i] = distance;23 }17 poisKernelBasis *kernel = kernels->data[i]; // The kernel basis function 18 if (kernel->xOrder == 0 && kernel->yOrder == 0) { 19 int u = kernel->u; // x offset 20 int v = kernel->v; // y offset 21 float distance = sqrtf((float)(u*u) + (float)(v*v)); // Distance from the centre 22 radKernel->data.F32[i] = solution->data.F64[i]; 23 radii->data.F32[i] = distance; 24 } 24 25 } 25 26 26 27 psVector *sortIndex = psVectorSortIndex(NULL, radii); // Indices from sort 27 float distance = 0.0; // Distance from the centre that's being examined28 float sum = 0.0; // Sum of kernel for that distance29 int num = 0; // Number of pixels at that distance28 float distance = 0.0; // Distance from the centre that's being examined 29 float sum = 0.0; // Sum of kernel for that distance 30 int num = 0; // Number of pixels at that distance 30 31 int centreIndex = sortIndex->data.U32[0]; // Index of the centre pixel 31 int numSuspect = 0; // Number of radii considered suspect32 int numSuspect = 0; // Number of radii considered suspect 32 33 for (int i = 0; i < (2*config->xKernel + 1) * (2*config->yKernel + 1); i++) { 33 unsigned int index = sortIndex->data.U32[i];34 if (radii->data.F32[index] != distance) {35 psTrace("pois.checkKernel", 7, "Radius: %f\tMean: %f\n", distance, sum/(float)num);36 if (fabs(distance*sum/(float)num) > radKernel->data.F32[centreIndex]) {37 numSuspect++;38 }39 sum = 0.0;40 num = 0;41 distance = radii->data.F32[index];42 }43 sum += radKernel->data.F32[index];44 num++;34 unsigned int index = sortIndex->data.U32[i]; 35 if (radii->data.F32[index] != distance) { 36 psTrace("pois.checkKernel", 7, "Radius: %f\tMean: %f\n", distance, sum/(float)num); 37 if (fabs(distance*sum/(float)num) > radKernel->data.F32[centreIndex]) { 38 numSuspect++; 39 } 40 sum = 0.0; 41 num = 0; 42 distance = radii->data.F32[index]; 43 } 44 sum += radKernel->data.F32[index]; 45 num++; 45 46 } 46 47 psTrace("pois.checkKernel", 7, "Radius: %f\tMean: %f\n", distance, sum/(float)num); 47 48 if (fabs(distance*sum/(float)num) > radKernel->data.F32[centreIndex]) { 48 numSuspect++;49 numSuspect++; 49 50 } 50 51 … … 56 57 57 58 if (numSuspect > 0) { 58 psWarning("There is significant power at large radii. The kernel may be bad.\n");59 return false;59 psWarning("There is significant power at large radii. The kernel may be bad.\n"); 60 return false; 60 61 } 61 62 -
trunk/pois/src/poisFindStamps.c
r5717 r6891 31 31 if (stamps == NULL) { 32 32 stamps = psArrayAlloc(nsx * nsy); 33 stamps->n = nsx * nsy; 33 34 // Initialise 34 35 for (int i = 0; i < nsx * nsy; i++) { -
trunk/pois/src/poisKernelBasisFunctions.c
r5717 r6891 14 14 int yKernelHalfSize = config->yKernel; // Half size of kernel in y 15 15 int spatialOrder = config->spatialOrder; // Order of spatial variations 16 16 17 17 // Number of basis functions 18 18 int nBF = (2 * xKernelHalfSize + 1) * (2 * yKernelHalfSize + 1) * (spatialOrder + 1) * 19 (spatialOrder + 2) / 2;19 (spatialOrder + 2) / 2; 20 20 21 psArray *array = psArrayAlloc(nBF); // Array to hold the basis functions 21 psArray *array = psArrayAlloc(nBF); // Array to hold the basis functions 22 array->n = nBF; 22 23 23 int num = 0; // Kernel parameter number24 int num = 0; // Kernel parameter number 24 25 25 26 // Put the (u,v) = (0,0) component right at the start of the list for convenience 26 27 for (int order = 0; order <= spatialOrder; order++) { 27 for (int i = 0; i <= order; i++) {28 int j = order - i;29 poisKernelBasis *kernel = psAlloc(sizeof(poisKernelBasis));30 kernel->u = 0;31 kernel->v = 0;32 kernel->xOrder = i;33 kernel->yOrder = j;28 for (int i = 0; i <= order; i++) { 29 int j = order - i; 30 poisKernelBasis *kernel = psAlloc(sizeof(poisKernelBasis)); 31 kernel->u = 0; 32 kernel->v = 0; 33 kernel->xOrder = i; 34 kernel->yOrder = j; 34 35 35 // Stuff into the array36 array->data[num] = kernel;36 // Stuff into the array 37 array->data[num] = kernel; 37 38 38 psTrace("pois.kernelBasisFunctions", 3, "--> %d: (%d,%d) x^%d y^%d\n", i, kernel->u,39 kernel->v, kernel->xOrder, kernel->yOrder);40 num++;41 }39 psTrace("pois.kernelBasisFunctions", 3, "--> %d: (%d,%d) x^%d y^%d\n", i, kernel->u, 40 kernel->v, kernel->xOrder, kernel->yOrder); 41 num++; 42 } 42 43 } 43 44 44 45 // Iterate over (u,v) 45 46 for (int u = -xKernelHalfSize; u <= xKernelHalfSize; u++) { 46 for (int v = -yKernelHalfSize; v <= yKernelHalfSize; v++) {47 for (int v = -yKernelHalfSize; v <= yKernelHalfSize; v++) { 47 48 48 // Already did (u,v) = (0,0): it's at the start, so skip it now.49 if ((u != 0) || (v != 0)) {49 // Already did (u,v) = (0,0): it's at the start, so skip it now. 50 if ((u != 0) || (v != 0)) { 50 51 51 // Iterate over spatial order52 for (int order = 0; order <= spatialOrder; order++) {52 // Iterate over spatial order 53 for (int order = 0; order <= spatialOrder; order++) { 53 54 54 for (int i = 0; i <= order; i++) {55 int j = order - i;56 poisKernelBasis *kernel = psAlloc(sizeof(poisKernelBasis));55 for (int i = 0; i <= order; i++) { 56 int j = order - i; 57 poisKernelBasis *kernel = psAlloc(sizeof(poisKernelBasis)); 57 58 58 kernel->u = u;59 kernel->v = v;60 kernel->xOrder = i;61 kernel->yOrder = j;59 kernel->u = u; 60 kernel->v = v; 61 kernel->xOrder = i; 62 kernel->yOrder = j; 62 63 63 // Stuff into the array64 array->data[num] = kernel;64 // Stuff into the array 65 array->data[num] = kernel; 65 66 66 psTrace("pois.kernelBasisFunctions", 3, "--> %d: (%d,%d) x^%d y^%d\n", num,67 kernel->u, kernel->v, kernel->xOrder, kernel->yOrder);68 num++;69 }70 } // Iterating over spatial order71 } // Except (u,v) = (0,0)72 }67 psTrace("pois.kernelBasisFunctions", 3, "--> %d: (%d,%d) x^%d y^%d\n", num, 68 kernel->u, kernel->v, kernel->xOrder, kernel->yOrder); 69 num++; 70 } 71 } // Iterating over spatial order 72 } // Except (u,v) = (0,0) 73 } 73 74 } // Iterating over (u,v) 74 75 -
trunk/pois/src/poisReadStamps.c
r5717 r6891 17 17 if (stamps == NULL) { 18 18 stamps = psArrayAlloc(config->nsx); 19 stamps->n = config->nsx; 19 20 // Initialise 20 21 for (int i = 0; i < config->nsx; i++) { -
trunk/pois/src/poisSolveEquation.c
r5717 r6891 4 4 #include "pois.h" 5 5 6 psVector *poisSolveEquation(psVector *solution, // Solution vector, or NULL7 const psArray *stamps, // Array of stamps8 const poisConfig *config6 psVector *poisSolveEquation(psVector *solution, // Solution vector, or NULL 7 const psArray *stamps, // Array of stamps 8 const poisConfig *config 9 9 ) 10 10 { … … 14 14 15 15 int size = (2 * config->xKernel + 1) * (2 * config->yKernel + 1) * (config->spatialOrder + 1) * 16 (config->spatialOrder + 2) / 2 + 1; // Size of matrix and vector16 (config->spatialOrder + 2) / 2 + 1; // Size of matrix and vector 17 17 18 18 assert(!solution || solution->n == size); … … 20 20 psImage *matrix = psImageAlloc(size, size, PS_TYPE_F64); 21 21 psVector *vector = psVectorAlloc(size, PS_TYPE_F64); 22 vector->n = size; 22 23 for (int j = 0; j < size; j++) { 23 for (int i = 0; i < size; i++) {24 matrix->data.F64[j][i] = 0.0;25 }26 vector->data.F64[j] = 0.0;24 for (int i = 0; i < size; i++) { 25 matrix->data.F64[j][i] = 0.0; 26 } 27 vector->data.F64[j] = 0.0; 27 28 } 28 29 29 30 for (int s = 0; s < stamps->n; s++) { 30 poisStamp *stamp = stamps->data[s]; // Stamp of interest31 psImage *stampMatrix = stamp->matrix; // Corresponding matrix32 psVector *stampVector = stamp->vector; // Corresponding vector31 poisStamp *stamp = stamps->data[s]; // Stamp of interest 32 psImage *stampMatrix = stamp->matrix; // Corresponding matrix 33 psVector *stampVector = stamp->vector; // Corresponding vector 33 34 34 // Check inputs35 assert(matrix->type.type == PS_TYPE_F64);36 assert(vector->type.type == PS_TYPE_F64);37 assert(matrix->numCols == size && matrix->numRows == size);38 assert(vector->n == size);35 // Check inputs 36 assert(matrix->type.type == PS_TYPE_F64); 37 assert(vector->type.type == PS_TYPE_F64); 38 assert(matrix->numCols == size && matrix->numRows == size); 39 assert(vector->n == size); 39 40 40 if (stamp->status == POIS_STAMP_USED) {41 (void)psBinaryOp(matrix, matrix, "+", stampMatrix);42 (void)psBinaryOp(vector, vector, "+", stampVector);43 }41 if (stamp->status == POIS_STAMP_USED) { 42 (void)psBinaryOp(matrix, matrix, "+", stampMatrix); 43 (void)psBinaryOp(vector, vector, "+", stampVector); 44 } 44 45 } 45 46 … … 53 54 printf("Matrix:\n"); 54 55 for (int i = 0; i < matrix->numCols; i++) { 55 for (int j = 0; j < matrix->numRows; j++) {56 printf("%f ", matrix->data.F64[i][j]);57 }58 printf("\n");56 for (int j = 0; j < matrix->numRows; j++) { 57 printf("%f ", matrix->data.F64[i][j]); 58 } 59 printf("\n"); 59 60 } 60 61 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
