IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2008, 1:33:09 PM (18 years ago)
Author:
Paul Price
Message:

Rewinding state of psModules/src/imcombine to the last merge (pap_merge_080122), so that ppStack on the mainline will build (I had branched ppStack but made changes to psModules/src/imcombine on the mainline; this check in is restoring to the state of the mainline while the development proceeds on branch pap_branch_080214)

File:
1 edited

Legend:

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

    r16476 r16479  
    44 *  @author GLG, MHPCC
    55 *
    6  *  @version $Revision: 1.79 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2008-02-14 23:18:34 $
     6 *  @version $Revision: 1.80 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2008-02-14 23:33:09 $
    88 *
    99 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    5050
    5151    // Take the square of the normal kernel
     52    double sumNormal = 0.0, sumVariance = 0.0; // Sum of the normal and variance kernels
    5253    for (int v = yMin; v <= yMax; v++) {
    5354        for (int u = xMin; u <= xMax; u++) {
    54             out->kernel[v][u] = PS_SQR(normalKernel->kernel[v][u]);
    55         }
    56     }
     55            float value = normalKernel->kernel[v][u]; // Value of interest
     56            float value2 = PS_SQR(value); // Value squared
     57            sumNormal += value;
     58            sumVariance += value2;
     59            out->kernel[v][u] = value2;
     60        }
     61    }
     62
     63    // Normalise so that the sum of the variance kernel is the square of the sum of the normal kernel
     64    // This is required to keep the relative scaling between the image and the weight map
     65    psBinaryOp(out->image, out->image, "*", psScalarAlloc(PS_SQR(sumNormal) / sumVariance, PS_TYPE_F32));
    5766
    5867    return out;
     
    681690        PS_ASSERT_IMAGE_TYPE(out1->weight, PS_TYPE_F32, false);
    682691    }
    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;
     692    if (region) {
     693        if (psRegionIsNaN(*region)) {
     694            psString string = psRegionToString(*region);
     695            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) contains NAN values", string);
     696            psFree(string);
     697            return false;
     698        }
     699        if (region->x0 < 0 || region->x1 > ro1->image->numCols ||
     700            region->y0 < 0 || region->y1 > ro1->image->numRows) {
     701            psString string = psRegionToString(*region);
     702            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Input region (%s) does not fit in image (%dx%d)",
     703                    string, ro1->image->numCols, ro1->image->numRows);
     704            psFree(string);
     705            return false;
     706        }
    688707    }
    689708
     
    705724
    706725    int numCols = ro1->image->numCols, numRows = ro1->image->numRows; // Image dimensions
    707     int x0 = ro1->col0, y0 = ro1->row0; // Image offset
    708726
    709727    psImage *convImage1 = out1->image;   // Convolved image
     
    762780        yMax = PS_MIN(region->y1, yMax);
    763781    }
    764 
    765     // Size to use when calculating normalised coordinates (different from actual size when convolving
    766     // subimage)
    767     int xNormSize = (kernels->numCols > 0 ? kernels->numCols : numCols);
    768     int yNormSize = (kernels->numRows > 0 ? kernels->numRows : numRows);
    769782
    770783    psMaskType maskSource;              // Mask these pixels when convolving
     
    794807    for (int j = yMin; j < yMax; j += fullSize) {
    795808        int ySubMax = PS_MIN(j + fullSize, yMax); // Range for subregion of interest
    796         float yNorm = 2.0 * (float)(j + y0 + size + 1 - yNormSize/2.0) /
    797             (float)yNormSize; // Normalised coordinate
     809        float yNorm = 2.0 * (float)(j + size + 1 - numRows/2.0) / (float)numRows; // Normalised coordinate
    798810        for (int i = xMin; i < xMax; i += fullSize) {
    799811            int xSubMax = PS_MIN(i + fullSize, xMax); // Range for subregion of interest
    800             float xNorm = 2.0 * (float)(i + x0 + size + 1 - xNormSize/2.0) /
    801                 (float)xNormSize; // Normalised coordinate
     812            float xNorm = 2.0 * (float)(i + size + 1 - numCols/2.0) / (float)numCols; // Normalised coordinate
    802813
    803814            // Only generate polynomial values every kernel footprint, since we have already assumed
Note: See TracChangeset for help on using the changeset viewer.