Changeset 6452
- Timestamp:
- Feb 17, 2006, 5:11:30 PM (20 years ago)
- Location:
- trunk/pois/src
- Files:
-
- 4 edited
-
poisCalculateDeviations.c (modified) (2 diffs)
-
poisCalculateEquation.c (modified) (1 diff)
-
poisConvolveImage.c (modified) (1 diff)
-
poisExtractKernel.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pois/src/poisCalculateDeviations.c
r5742 r6452 40 40 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); // Statistics 41 41 42 // Pre-allocate for optimisation: 42 43 psImage *subStamp = psImageAlloc(2 * xSize, 2 * ySize, PS_TYPE_F32); // Subtraction of stamp 44 43 45 for (int s = 0; s < stamps->n; s++) { 44 46 poisStamp *stamp = stamps->data[s]; // The coordinates of the stamp of interest … … 55 57 (void)psBinaryOp(subStamp, subStamp, "*", subStamp); 56 58 (void)psBinaryOp(subStamp, subStamp, "/", inStamp); 59 60 // Trim regions. Need separate regions for the subtraction and the mask, since the subtraction 61 // isn't a child image (it's the subtraction of two child images, but placed in a pre-allocated 62 // image which isn't a child image), but the mask *is* a child image. Therefore the regions are 63 // different, since they refer to the region on the parent image (if it exists). 57 64 psRegion stampTrim = { config->xKernel, config->xKernel + 2 * footprint, config->yKernel, 58 65 config->yKernel + 2 * footprint }; 66 psRegion maskTrim = { x - xSize + config->xKernel, x + xSize - config->xKernel, 67 y - ySize + config->yKernel, y + ySize - config->yKernel }; 68 59 69 psImage *subStampTrim = psImageSubset(subStamp, stampTrim); 60 psImage *maskStampTrim = psImageSubset(maskStamp, stampTrim); 61 // Copy image to workaround bug 305 62 psImage *tempImage = psImageCopy(NULL, subStampTrim, PS_TYPE_F32); 63 psImage *tempMask = psImageCopy(NULL, maskStampTrim, PS_TYPE_U8); 64 65 (void)psImageStats(stats, tempImage, tempMask, POIS_MASK_BAD | POIS_MASK_NEAR_BAD); 66 67 psFree(tempImage); 68 psFree(tempMask); 70 psImage *maskStampTrim = psImageSubset(maskStamp, maskTrim); 71 (void)psImageStats(stats, subStampTrim, maskStampTrim, POIS_MASK_BAD | POIS_MASK_NEAR_BAD); 69 72 70 73 deviations->data.F32[s] = sqrtf(stats->sampleMean / 2.0); -
trunk/pois/src/poisCalculateEquation.c
r5717 r6452 32 32 int numKernelParams = kernelParams->n; // Number of kernel parameters 33 33 34 psPolynomial2D *poly = psPolynomial2DAlloc( config->spatialOrder + 1, config->spatialOrder + 1,35 PS_POLYNOMIAL_ORD); // Polynomial for evaluation34 psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, config->spatialOrder + 1, 35 config->spatialOrder + 1); // Polynomial for evaluation 36 36 for (int j = 0; j < config->spatialOrder + 1; j++) { 37 37 for (int i = 0; i < config->spatialOrder + 1; i++) { -
trunk/pois/src/poisConvolveImage.c
r5717 r6452 30 30 psImage *convolved = psImageAlloc(nx, ny, PS_TYPE_F32); // The convolved image, to be returned 31 31 32 psPolynomial2D *poly = psPolynomial2DAlloc( config->spatialOrder + 1, config->spatialOrder + 1,33 PS_POLYNOMIAL_ORD); // Polynomial32 psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, config->spatialOrder + 1, 33 config->spatialOrder + 1); // Polynomial 34 34 for (int i = 0; i < config->spatialOrder + 1; i++) { 35 35 for (int j = 0; j < config->spatialOrder + 1; j++) { -
trunk/pois/src/poisExtractKernel.c
r5717 r6452 6 6 /* Create a kernel image from the solution vector */ 7 7 psImage *poisExtractKernel(const psVector *solution, // Vector containing the kernel elements 8 const psArray *kernelParams, // The kernel parameters9 float x,// The relative (-1 to 1) x position for which to get the kernel10 float y,// The relative (-1 to 1) y position for which to get the kernel11 const poisConfig *config // Configuration8 const psArray *kernelParams, // The kernel parameters 9 float x, // The relative (-1 to 1) x position for which to get the kernel 10 float y, // The relative (-1 to 1) y position for which to get the kernel 11 const poisConfig *config // Configuration 12 12 ) 13 13 { … … 18 18 assert(y >= -1.0 && y <= 1.0); 19 19 20 int xKernel = config->xKernel; // Half-size of kernel in x21 int yKernel = config->yKernel; // Half-size of kernel in y22 float kernelSum = 0.0; // Sum of the kernel20 int xKernel = config->xKernel; // Half-size of kernel in x 21 int yKernel = config->yKernel; // Half-size of kernel in y 22 float kernelSum = 0.0; // Sum of the kernel 23 23 24 24 /* Allocate the image */ 25 25 psImage *image = psImageAlloc(2*xKernel + 1, 2*yKernel + 1, PS_TYPE_F32); // The kernel image 26 26 for (int j = 0; j < (2*yKernel + 1); j++) { 27 for (int i = 0; i < (2*xKernel + 1); i++) {28 image->data.F32[j][i] = 0.0;29 }27 for (int i = 0; i < (2*xKernel + 1); i++) { 28 image->data.F32[j][i] = 0.0; 29 } 30 30 } 31 31 32 psPolynomial2D *poly = psPolynomial2DAlloc( config->spatialOrder + 1, config->spatialOrder + 1,33 PS_POLYNOMIAL_ORD); // Polynomial for evaluation32 psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, config->spatialOrder + 1, 33 config->spatialOrder + 1); // Polynomial for evaluation 34 34 for (int j = 0; j < config->spatialOrder + 1; j++) { 35 for (int i = 0; i < config->spatialOrder + 1; i++) {36 poly->coeff[j][i] = 1.0;37 poly->mask[j][i] = 1;// Mask all coefficients; unmask to evaluate38 }35 for (int i = 0; i < config->spatialOrder + 1; i++) { 36 poly->coeff[j][i] = 1.0; 37 poly->mask[j][i] = 1; // Mask all coefficients; unmask to evaluate 38 } 39 39 } 40 40 … … 42 42 /* Iterate over the kernel parameters */ 43 43 for (int k = 0; k < kernelParams->n; k++) { 44 poisKernelBasis *kernel = kernelParams->data[k]; // The kernel basis function44 poisKernelBasis *kernel = kernelParams->data[k]; // The kernel basis function 45 45 46 int u = kernel->u;47 int v = kernel->v;48 int xOrder = kernel->xOrder;49 int yOrder = kernel->yOrder;46 int u = kernel->u; 47 int v = kernel->v; 48 int xOrder = kernel->xOrder; 49 int yOrder = kernel->yOrder; 50 50 51 // Evaluate polynomial52 poly->mask[xOrder][yOrder] = 0;53 double evaluation = solution->data.F64[k] * psPolynomial2DEval(poly, x, y);54 poly->mask[xOrder][yOrder] = 1;51 // Evaluate polynomial 52 poly->mask[xOrder][yOrder] = 0; 53 double evaluation = solution->data.F64[k] * psPolynomial2DEval(poly, x, y); 54 poly->mask[xOrder][yOrder] = 1; 55 55 56 image->data.F32[v + yKernel][u + xKernel] += (float)evaluation;57 kernelSum += (float)evaluation;56 image->data.F32[v + yKernel][u + xKernel] += (float)evaluation; 57 kernelSum += (float)evaluation; 58 58 } 59 59
Note:
See TracChangeset
for help on using the changeset viewer.
