IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 22, 2008, 9:50:56 AM (18 years ago)
Author:
Paul Price
Message:

Previous merge didn't have the expected result, probably because of the revert-and-branch I did earlier. I think this is the expected result.

File:
1 edited

Legend:

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

    r16604 r16607  
    44 *  @author GLG, MHPCC
    55 *
     6 *  @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2008-02-22 19:50:56 $
     8 *
    69 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    710 *
     
    4750
    4851    // Take the square of the normal kernel
    49     double sumNormal = 0.0, sumVariance = 0.0; // Sum of the normal and variance kernels
    5052    for (int v = yMin; v <= yMax; v++) {
    5153        for (int u = xMin; u <= xMax; u++) {
    52             float value = normalKernel->kernel[v][u]; // Value of interest
    53             float value2 = PS_SQR(value); // Value squared
    54             sumNormal += value;
    55             sumVariance += value2;
    56             out->kernel[v][u] = value2;
    57         }
    58     }
    59 
    60     // Normalise so that the sum of the variance kernel is the square of the sum of the normal kernel
    61     // This is required to keep the relative scaling between the image and the weight map
    62     psBinaryOp(out->image, out->image, "*", psScalarAlloc(PS_SQR(sumNormal) / sumVariance, PS_TYPE_F32));
     54            out->kernel[v][u] = PS_SQR(normalKernel->kernel[v][u]);
     55        }
     56    }
    6357
    6458    return out;
     
    687681        PS_ASSERT_IMAGE_TYPE(out1->weight, PS_TYPE_F32, false);
    688682    }
    689     if (region) {
    690         if (psRegionIsNaN(*region)) {
    691             psString string = psRegionToString(*region);
    692             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string);
    693             psFree(string);
    694             return false;
    695         }
    696         if (region->x0 < 0 || region->x1 > ro1->image->numCols ||
    697             region->y0 < 0 || region->y1 > ro1->image->numRows) {
    698             psString string = psRegionToString(*region);
    699             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) does not fit in image (%dx%d)",
    700                     string, ro1->image->numCols, ro1->image->numRows);
    701             psFree(string);
    702             return false;
    703         }
     683    if (region && psRegionIsNaN(*region)) {
     684        psString string = psRegionToString(*region);
     685        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string);
     686        psFree(string);
     687        return false;
    704688    }
    705689
     
    776760        yMax = PS_MIN(region->y1, yMax);
    777761    }
     762
     763    // Size to use when calculating normalised coordinates (different from actual size when convolving
     764    // subimage)
     765    int xNormSize = (kernels->numCols > 0 ? kernels->numCols : numCols);
     766    int yNormSize = (kernels->numRows > 0 ? kernels->numRows : numRows);
    778767
    779768    psMaskType maskSource;              // Mask these pixels when convolving
     
    803792    for (int j = yMin; j < yMax; j += fullSize) {
    804793        int ySubMax = PS_MIN(j + fullSize, yMax); // Range for subregion of interest
    805         float yNorm = 2.0 * (float)(j + size + 1 - numRows/2.0) / (float)numRows; // Normalised coordinate
     794        float yNorm = 2.0 * (float)(j + y0 + size + 1 - yNormSize/2.0) /
     795            (float)yNormSize; // Normalised coordinate
    806796        for (int i = xMin; i < xMax; i += fullSize) {
    807797            int xSubMax = PS_MIN(i + fullSize, xMax); // Range for subregion of interest
    808             float xNorm = 2.0 * (float)(i + size + 1 - numCols/2.0) / (float)numCols; // Normalised coordinate
     798            float xNorm = 2.0 * (float)(i + x0 + size + 1 - xNormSize/2.0) /
     799                (float)xNormSize; // Normalised coordinate
    809800
    810801            // Only generate polynomial values every kernel footprint, since we have already assumed
Note: See TracChangeset for help on using the changeset viewer.