IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21298


Ignore:
Timestamp:
Feb 4, 2009, 2:42:48 PM (17 years ago)
Author:
Paul Price
Message:

Adding function to sum covariance matrices.

Location:
trunk/psLib/src/imageops
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageCovariance.c

    r21291 r21298  
    110110}
    111111
    112 psKernel *psImageCovarianceAverage(const psArray *array)
     112psKernel *psImageCovarianceSum(const psArray *array)
    113113{
    114114    PS_ASSERT_ARRAY_NON_NULL(array, NULL);
     
    116116
    117117    int xMin = INT_MAX, xMax = INT_MIN, yMin = INT_MAX, yMax = INT_MIN; // Range for covariance
    118     int num = 0;                        // Number of good matrices to average
     118    int num = 0;                        // Number of good matrices to sum
    119119    for (int i = 0; i < array->n; i++) {
    120120        psKernel *covar = array->data[i]; // Covariance matrix
     
    129129    }
    130130    if (num == 0) {
    131         psError(PS_ERR_BAD_PARAMETER_SIZE, true, "No covariance matrices supplied for averaging.");
     131        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "No covariance matrices supplied for summation");
    132132        return NULL;
    133133    }
    134134
    135     psKernel *average = psKernelAlloc(xMin, xMax, yMin, yMax); // Average covariance
     135    psKernel *sum = psKernelAlloc(xMin, xMax, yMin, yMax); // Summed covariance
    136136    for (int i = 0; i < array->n; i++) {
    137137        psKernel *covar = array->data[i]; // Covariance matrix
     
    141141        for (int y = yMin; y <= yMax; y++) {
    142142            for (int x = xMin; x <= xMax; x++) {
    143                 average->kernel[y][x] += covar->kernel[y][x];
     143                sum->kernel[y][x] += covar->kernel[y][x];
    144144            }
    145145        }
    146146    }
    147     psBinaryOp(average->image, average->image, "/", psScalarAlloc(num, PS_TYPE_F32));
    148147
    149     return average;
     148    return sum;
    150149}
     150
     151
     152psKernel *psImageCovarianceAverage(const psArray *array)
     153{
     154    PS_ASSERT_ARRAY_NON_NULL(array, NULL);
     155    PS_ASSERT_ARRAY_NON_EMPTY(array, NULL);
     156
     157    int num = 0;                        // Number of good matrices to average
     158    for (int i = 0; i < array->n; i++) {
     159        psKernel *covar = array->data[i]; // Covariance matrix
     160        if (covar) {
     161            num++;
     162        }
     163    }
     164    if (num == 0) {
     165        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "No covariance matrices supplied for averaging.");
     166        return NULL;
     167    }
     168
     169    psKernel *sum = psImageCovarianceSum(array); // Sum of covariances
     170    psBinaryOp(sum->image, sum->image, "/", psScalarAlloc(num, PS_TYPE_F32));
     171
     172    return sum;
     173}
  • trunk/psLib/src/imageops/psImageCovariance.h

    r21280 r21298  
    55 * @author Paul Price, IfA
    66 *
    7  * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2009-02-04 02:55:27 $
     7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-02-05 00:42:48 $
    99 * Copyright 2009 Institute for Astronomy, University of Hawaii
    1010 */
     
    4040    );
    4141
    42 /// Average many covariance pseudo-matrices
     42/// Sum multiple covariance pseudo-matrices
     43psKernel *psImageCovarianceSum(
     44    const psArray *array                ///< Array of covariance pseudo-matrices
     45    );
     46
     47/// Average multiple covariance pseudo-matrices
    4348psKernel *psImageCovarianceAverage(
    4449    const psArray *array                ///< Array of covariance pseudo-matrices
Note: See TracChangeset for help on using the changeset viewer.