IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 13, 2011, 10:45:16 AM (15 years ago)
Author:
eugene
Message:

psKernelAlloc now reports file & line; fix bug in psKernelTruncate; limit leak dump to 500 leaks; cleanup log formats (indent by depth, split lines with function name); add test samples for psImageCovariance

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

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops

    • Property svn:mergeinfo deleted
  • trunk/psLib/src/imageops/psImageConvolve.c

    r28405 r30595  
    6767}
    6868
    69 psKernel *psKernelAlloc(int xMin, int xMax, int yMin, int yMax)
     69psKernel *p_psKernelAlloc(const char *file,
     70                          unsigned int lineno,
     71                          const char *func,
     72                          int xMin, int xMax, int yMin, int yMax)
    7073{
    7174    // Check the inputs to make sure max > min; if not, switch.
     
    9194    int numCols = xMax - xMin + 1;      // Number of columns for kernel image
    9295
    93     psKernel *kernel = psAlloc(sizeof(psKernel)); // The kernel, to be returned
     96    psKernel *kernel = p_psAlloc(file, lineno, func, sizeof(psKernel)); // The kernel, to be returned
    9497    psMemSetDeallocator(kernel,(psFreeFunc)kernelFree);
    9598
     
    272275    float threshold = sumKernel * (1.0 - frac); // Threshold for truncation
    273276
     277    int truncateRadius = maxSize;       // Truncation radius
     278    bool truncate = false;
     279
    274280    // 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++) {
    277282        int uMin = PS_MAX(-radius, xMin);
    278283        int uMax = PS_MIN(radius, xMax);
     
    290295            }
    291296        }
     297        // This is the truncation radius
    292298        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) {
    299306        return true;
    300307    }
     
    302309    // Truncate the kernel
    303310    {
    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);
    309316        for (int v = vMin; v <= vMax; v++) {
    310317            int v2 = PS_SQR(v);
     
    317324        }
    318325    }
    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);
    323330
    324331    return true;
Note: See TracChangeset for help on using the changeset viewer.