Changeset 21298
- Timestamp:
- Feb 4, 2009, 2:42:48 PM (17 years ago)
- Location:
- trunk/psLib/src/imageops
- Files:
-
- 2 edited
-
psImageCovariance.c (modified) (4 diffs)
-
psImageCovariance.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageCovariance.c
r21291 r21298 110 110 } 111 111 112 psKernel *psImageCovariance Average(const psArray *array)112 psKernel *psImageCovarianceSum(const psArray *array) 113 113 { 114 114 PS_ASSERT_ARRAY_NON_NULL(array, NULL); … … 116 116 117 117 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 average118 int num = 0; // Number of good matrices to sum 119 119 for (int i = 0; i < array->n; i++) { 120 120 psKernel *covar = array->data[i]; // Covariance matrix … … 129 129 } 130 130 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"); 132 132 return NULL; 133 133 } 134 134 135 psKernel * average = psKernelAlloc(xMin, xMax, yMin, yMax); // Averagecovariance135 psKernel *sum = psKernelAlloc(xMin, xMax, yMin, yMax); // Summed covariance 136 136 for (int i = 0; i < array->n; i++) { 137 137 psKernel *covar = array->data[i]; // Covariance matrix … … 141 141 for (int y = yMin; y <= yMax; y++) { 142 142 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]; 144 144 } 145 145 } 146 146 } 147 psBinaryOp(average->image, average->image, "/", psScalarAlloc(num, PS_TYPE_F32));148 147 149 return average;148 return sum; 150 149 } 150 151 152 psKernel *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 5 5 * @author Paul Price, IfA 6 6 * 7 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2009-02-0 4 02:55:27$7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2009-02-05 00:42:48 $ 9 9 * Copyright 2009 Institute for Astronomy, University of Hawaii 10 10 */ … … 40 40 ); 41 41 42 /// Average many covariance pseudo-matrices 42 /// Sum multiple covariance pseudo-matrices 43 psKernel *psImageCovarianceSum( 44 const psArray *array ///< Array of covariance pseudo-matrices 45 ); 46 47 /// Average multiple covariance pseudo-matrices 43 48 psKernel *psImageCovarianceAverage( 44 49 const psArray *array ///< Array of covariance pseudo-matrices
Note:
See TracChangeset
for help on using the changeset viewer.
