IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6452


Ignore:
Timestamp:
Feb 17, 2006, 5:11:30 PM (20 years ago)
Author:
Paul Price
Message:

Updating to work with pslib rel10 --- needed to fix polynomial allocation and image subregions

Location:
trunk/pois/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/pois/src/poisCalculateDeviations.c

    r5742 r6452  
    4040    psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); // Statistics
    4141
     42    // Pre-allocate for optimisation:
    4243    psImage *subStamp = psImageAlloc(2 * xSize, 2 * ySize, PS_TYPE_F32); // Subtraction of stamp
     44
    4345    for (int s = 0; s < stamps->n; s++) {
    4446        poisStamp *stamp = stamps->data[s]; // The coordinates of the stamp of interest
     
    5557            (void)psBinaryOp(subStamp, subStamp, "*", subStamp);
    5658            (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).
    5764            psRegion stampTrim = { config->xKernel, config->xKernel + 2 * footprint, config->yKernel,
    5865                                   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
    5969            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);
    6972
    7073            deviations->data.F32[s] = sqrtf(stats->sampleMean / 2.0);
  • trunk/pois/src/poisCalculateEquation.c

    r5717 r6452  
    3232    int numKernelParams = kernelParams->n; // Number of kernel parameters
    3333
    34     psPolynomial2D *poly = psPolynomial2DAlloc(config->spatialOrder + 1, config->spatialOrder + 1,
    35                                                PS_POLYNOMIAL_ORD); // Polynomial for evaluation
     34    psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, config->spatialOrder + 1,
     35                                               config->spatialOrder + 1); // Polynomial for evaluation
    3636    for (int j = 0; j < config->spatialOrder + 1; j++) {
    3737        for (int i = 0; i < config->spatialOrder + 1; i++) {
  • trunk/pois/src/poisConvolveImage.c

    r5717 r6452  
    3030    psImage *convolved = psImageAlloc(nx, ny, PS_TYPE_F32); // The convolved image, to be returned
    3131
    32     psPolynomial2D *poly = psPolynomial2DAlloc(config->spatialOrder + 1, config->spatialOrder + 1,
    33                                                PS_POLYNOMIAL_ORD ); // Polynomial
     32    psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, config->spatialOrder + 1,
     33                                               config->spatialOrder + 1); // Polynomial
    3434    for (int i = 0; i < config->spatialOrder + 1; i++) {
    3535        for (int j = 0; j < config->spatialOrder + 1; j++) {
  • trunk/pois/src/poisExtractKernel.c

    r5717 r6452  
    66/* Create a kernel image from the solution vector */
    77psImage *poisExtractKernel(const psVector *solution, // Vector containing the kernel elements
    8                            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
     8                           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
    1212    )
    1313{
     
    1818    assert(y >= -1.0 && y <= 1.0);
    1919
    20     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
     20    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
    2323
    2424    /* Allocate the image */
    2525    psImage *image = psImageAlloc(2*xKernel + 1, 2*yKernel + 1, PS_TYPE_F32); // The kernel image
    2626    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        }
    3030    }
    3131
    32     psPolynomial2D *poly = psPolynomial2DAlloc(config->spatialOrder + 1, config->spatialOrder + 1,
    33                                                PS_POLYNOMIAL_ORD); // Polynomial for evaluation
     32    psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, config->spatialOrder + 1,
     33                                               config->spatialOrder + 1); // Polynomial for evaluation
    3434    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 evaluate
    38         }
     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        }
    3939    }
    4040
     
    4242    /* Iterate over the kernel parameters */
    4343    for (int k = 0; k < kernelParams->n; k++) {
    44         poisKernelBasis *kernel = kernelParams->data[k]; // The kernel basis function
     44        poisKernelBasis *kernel = kernelParams->data[k]; // The kernel basis function
    4545
    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;
    5050
    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;
     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;
    5555
    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;
    5858    }
    5959
Note: See TracChangeset for help on using the changeset viewer.