Changeset 30595 for trunk/psLib/src/imageops
- Timestamp:
- Feb 13, 2011, 10:45:16 AM (15 years ago)
- Location:
- trunk/psLib/src/imageops
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psImageConvolve.c (modified) (6 diffs)
-
psImageConvolve.h (modified) (2 diffs)
-
psImageCovariance.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops
- Property svn:mergeinfo deleted
-
trunk/psLib/src/imageops/psImageConvolve.c
r28405 r30595 67 67 } 68 68 69 psKernel *psKernelAlloc(int xMin, int xMax, int yMin, int yMax) 69 psKernel *p_psKernelAlloc(const char *file, 70 unsigned int lineno, 71 const char *func, 72 int xMin, int xMax, int yMin, int yMax) 70 73 { 71 74 // Check the inputs to make sure max > min; if not, switch. … … 91 94 int numCols = xMax - xMin + 1; // Number of columns for kernel image 92 95 93 psKernel *kernel = p sAlloc(sizeof(psKernel)); // The kernel, to be returned96 psKernel *kernel = p_psAlloc(file, lineno, func, sizeof(psKernel)); // The kernel, to be returned 94 97 psMemSetDeallocator(kernel,(psFreeFunc)kernelFree); 95 98 … … 272 275 float threshold = sumKernel * (1.0 - frac); // Threshold for truncation 273 276 277 int truncateRadius = maxSize; // Truncation radius 278 bool truncate = false; 279 274 280 // Find truncation size 275 int truncate = 0; // Truncation radius 276 for (int radius = 1; truncate == 0 && radius < maxSize; radius++) { 281 for (int radius = 1; !truncate && (radius < maxSize); radius++) { 277 282 int uMin = PS_MAX(-radius, xMin); 278 283 int uMax = PS_MIN(radius, xMax); … … 290 295 } 291 296 } 297 // This is the truncation radius 292 298 if (sum > threshold) { 293 // This is the truncation radius 294 truncate = radius; 295 } 296 } 297 if (truncate == maxSize) { 298 // No truncation possible 299 truncate = true; 300 truncateRadius = radius; 301 } 302 } 303 304 // Do nothing if no truncation is possible 305 if (!truncate) { 299 306 return true; 300 307 } … … 302 309 // Truncate the kernel 303 310 { 304 int uMin = PS_MAX(-truncate , xMin);305 int uMax = PS_MIN(truncate , xMax);306 int vMin = PS_MAX(-truncate , yMin);307 int vMax = PS_MIN(truncate , yMax);308 int r2 = PS_SQR(truncate );311 int uMin = PS_MAX(-truncateRadius, xMin); 312 int uMax = PS_MIN(truncateRadius, xMax); 313 int vMin = PS_MAX(-truncateRadius, yMin); 314 int vMax = PS_MIN(truncateRadius, yMax); 315 int r2 = PS_SQR(truncateRadius); 309 316 for (int v = vMin; v <= vMax; v++) { 310 317 int v2 = PS_SQR(v); … … 317 324 } 318 325 } 319 kernel->xMin = PS_MAX(-truncate , kernel->xMin);320 kernel->xMax = PS_MIN(truncate , kernel->xMax);321 kernel->yMin = PS_MAX(-truncate , kernel->yMin);322 kernel->yMax = PS_MIN(truncate , kernel->yMax);326 kernel->xMin = PS_MAX(-truncateRadius, kernel->xMin); 327 kernel->xMax = PS_MIN(truncateRadius, kernel->xMax); 328 kernel->yMin = PS_MAX(-truncateRadius, kernel->yMin); 329 kernel->yMax = PS_MIN(truncateRadius, kernel->yMax); 323 330 324 331 return true; -
trunk/psLib/src/imageops/psImageConvolve.h
r26892 r30595 84 84 /// @return psKernel* A new kernel object 85 85 /// 86 #ifdef DOXYGEN 86 87 psKernel *psKernelAlloc( 87 88 int xMin, ///< Most negative x index … … 89 90 int yMin, ///< Most negative y index 90 91 int yMax ///< Most positive y index 92 ); 93 #else // ifdef DOXYGEN 94 psKernel *p_psKernelAlloc( 95 const char *file, ///< File of caller 96 unsigned int lineno, ///< Line number of caller 97 const char *func, ///< Function name of caller 98 int xMin, ///< Most negative x index 99 int xMax, ///< Most positive x index 100 int yMin, ///< Most negative y index 101 int yMax ///< Most positive y index 91 102 ) PS_ATTR_MALLOC; 103 #define psKernelAlloc(xMin, xMax, yMin, yMax) \ 104 p_psKernelAlloc(__FILE__, __LINE__, __func__, (xMin), (xMax), (yMin), (yMax)) 105 #endif // ifdef DOXYGEN 92 106 93 107 /// Allocate a convolution kernel from a provided image -
trunk/psLib/src/imageops/psImageCovariance.c
r28667 r30595 30 30 return covar; 31 31 } 32 33 /** 34 35 * changes from 28666 36 ** add scale to imageCovarianceCalculate (& multiply at return) 37 ** add scale to imageCovarianceCalculateThread 38 39 ** accumulate scale (sum kernel^2) in psImageCovarianceCalculate and pass to imageCovarianceCalculate 40 ** accumulate scale (sum kernel^2) in psImageCovarianceCalculateFactor and pass to imageCovarianceCalculate 41 42 **/ 32 43 33 44 /// Calculation of covariance matrix element when convolving
Note:
See TracChangeset
for help on using the changeset viewer.
