IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 19, 2007, 3:53:41 PM (19 years ago)
Author:
Paul Price
Message:

Not using psPolynomials to do spatial polynomials --- it's awkward,
confusing (x,y or y,x?) and I'm afraid the way it behaves will get
changed underneath me.
Adding function to generate image of each of the components of the
solution kernel.
Ensuring entire image gets convolved.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r14319 r14329  
    44 *  @author GLG, MHPCC
    55 *
    6  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-07-19 21:42:12 $
     6 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-07-20 01:53:41 $
    88 *
    99 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    4141
    4242    psImage *polyValues = psImageAlloc(spatialOrder + 1, spatialOrder + 1, PS_TYPE_F64); // Matrix to return
    43     psPolynomial2D *poly = psPolynomial2DAlloc(PS_POLYNOMIAL_CHEB, spatialOrder, spatialOrder); // Polynomial
    44 
    45     for (int j = 0; j <= spatialOrder; j++) {
    46         for (int i = 0; i <= spatialOrder - j; i++) {
    47             poly->coeff[i][j] = 1.0;
    48             polyValues->data.F64[j][i] = psPolynomial2DEval(poly, x, y);
    49             poly->coeff[i][j] = 0.0;
    50         }
    51     }
    52     psFree(poly);
     43    polyValues->data.F64[0][0] = 1.0;
     44
     45    double value = 1.0;
     46    for (int i = 1; i <= spatialOrder; i++) {
     47        value *= x;
     48        polyValues->data.F64[0][i] = value;
     49    }
     50
     51    value = 1.0;
     52    for (int j = 1; j <= spatialOrder; j++) {
     53        value *= y;
     54        polyValues->data.F64[j][0] = value;
     55    }
     56
     57    for (int j = 1; j <= spatialOrder; j++) {
     58        for (int i = 1; i <= spatialOrder - j; i++) {
     59            polyValues->data.F64[j][i] = polyValues->data.F64[j][0] * polyValues->data.F64[0][i];
     60        }
     61    }
    5362
    5463    return polyValues;
     
    875884}
    876885
     886psArray *pmSubtractionKernelSolutions(const psVector *solution, const pmSubtractionKernels *kernels,
     887                                      float x, float y
     888                                      )
     889{
     890    PS_ASSERT_VECTOR_NON_NULL(solution, NULL);
     891    PS_ASSERT_PTR_NON_NULL(kernels, NULL);
     892    PS_ASSERT_FLOAT_WITHIN_RANGE(x, -1.0, 1.0, NULL);
     893    PS_ASSERT_FLOAT_WITHIN_RANGE(y, -1.0, 1.0, NULL);
     894    PS_ASSERT_VECTOR_SIZE(kernels->u, solution->n - 1, false);
     895    PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->v, NULL);
     896    PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->xOrder, NULL);
     897    PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->yOrder, NULL);
     898    if (kernels->type == PM_SUBTRACTION_KERNEL_ISIS) {
     899        PS_ASSERT_ARRAY_NON_NULL(kernels->preCalc, NULL);
     900        PS_ASSERT_ARRAY_SIZE(kernels->preCalc, solution->n - 1, NULL);
     901    }
     902
     903    psArray *images = psArrayAlloc(solution->n - 1); // Images of each kernel to return
     904    psVector *fakeSolution = psVectorAlloc(solution->n, PS_TYPE_F64); // Fake solution vector
     905    psVectorInit(fakeSolution, 0.0);
     906
     907    for (int i = 0; i < solution->n - 1; i++) {
     908        fakeSolution->data.F64[i] = solution->data.F64[i];
     909        images->data[i] = pmSubtractionKernelImage(fakeSolution, kernels, x, y);
     910        fakeSolution->data.F64[i] = 0.0;
     911    }
     912
     913    psFree(fakeSolution);
     914
     915    return images;
     916}
     917
     918
    877919bool pmSubtractionConvolve(psImage **outImage, psImage **outWeight, psImage **outMask,
    878920                           const psImage *inImage, const psImage *inWeight, const psImage *subMask,
     
    953995    psKernel *kernelWeight = NULL;      // Kernel for the weight map
    954996
    955     for (int j = size; j < inImage->numRows - fullSize - size; j += fullSize) {
    956         for (int i = size; i < inImage->numCols - fullSize - size; i += fullSize) {
     997    for (int j = size; j < inImage->numRows - size; j += fullSize) {
     998        for (int i = size; i < inImage->numCols - size; i += fullSize) {
    957999
    9581000            // Only generate polynomial values every kernel footprint, since we have already assumed
     
    9601002            psFree(polyValues);
    9611003            polyValues = spatialPolyValues(kernels->spatialOrder,
    962                                            2.0 * (float)(i + size - numCols/2.0) / (float)numCols,
    963                                            2.0 * (float)(j + size - numRows/2.0) / (float)numRows);
     1004                                           2.0 * (float)(i + size + 1 - numCols/2.0) / (float)numCols,
     1005                                           2.0 * (float)(j + size + 1 - numRows/2.0) / (float)numRows);
    9641006#ifdef USE_FUNCTIONS_INSTEAD_OF_MACROS
    9651007            kernelImage = solvedKernel(kernelImage, solution, kernels, polyValues, imageWeighting);
     
    9751017#endif
    9761018
    977             for (int y = j; y < j + fullSize; y++) {
    978                 for (int x = i; x < i + fullSize; x++) {
     1019            for (int y = j; y < PS_MIN(j + fullSize, numRows - size); y++) {
     1020                for (int x = i; x < PS_MIN(i + fullSize, numCols - size); x++) {
    9791021                    // Check and propagate the kernel footprint, if required
    9801022                    if (subMask && (subMask->data.PS_TYPE_MASK_DATA[y][x] &
Note: See TracChangeset for help on using the changeset viewer.