IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30595


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
Files:
8 edited
6 copied

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;
  • trunk/psLib/src/imageops/psImageConvolve.h

    r26892 r30595  
    8484/// @return psKernel*          A new kernel object
    8585///
     86#ifdef DOXYGEN
    8687psKernel *psKernelAlloc(
    8788    int xMin,                          ///< Most negative x index
     
    8990    int yMin,                          ///< Most negative y index
    9091    int yMax                           ///< Most positive y index
     92);
     93#else // ifdef DOXYGEN
     94psKernel *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
    91102) PS_ATTR_MALLOC;
     103#define psKernelAlloc(xMin, xMax, yMin, yMax)                           \
     104    p_psKernelAlloc(__FILE__, __LINE__, __func__, (xMin), (xMax), (yMin), (yMax))
     105#endif // ifdef DOXYGEN
    92106
    93107/// Allocate a convolution kernel from a provided image
  • trunk/psLib/src/imageops/psImageCovariance.c

    r28667 r30595  
    3030    return covar;
    3131}
     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 **/
    3243
    3344/// Calculation of covariance matrix element when convolving
  • trunk/psLib/src/sys/psLogMsg.c

    r28404 r30595  
    291291        head_ptr += strlen(head_ptr);
    292292    }
    293     // Hostname should be 20 characters.
     293
     294    // Hostname should be 10 characters.
    294295    if (logHost) {
    295296        if (head_ptr > head) {
    296297            *head_ptr++ = '|';
    297298        }
    298         maxLength -= snprintf(head_ptr, maxLength, "%-20s", hostname);
     299        maxLength -= snprintf(head_ptr, maxLength, " %s ", hostname);
    299300        head_ptr += strlen(head_ptr);
    300301    }
     
    310311            *head_ptr++ = '|';
    311312        }
    312         maxLength -= snprintf(head_ptr, maxLength, "%s", name);
     313        maxLength -= snprintf(head_ptr, maxLength, "%s|\n", name);
    313314
    314315        head_ptr += strlen(head_ptr);
    315     }
    316 
    317     if (head_ptr > head) {
    318         *head_ptr++ = '\n';
    319     } else if (!logMsg) {                  // no output desired
     316    } else {
     317      if (head_ptr > head) {
     318        *head_ptr++ = '|';
     319      }
     320    }
     321
     322    // rather than putting in a return for the message, let's only put in the return if we asked for the function name
     323    if ((head_ptr == head) && !logMsg) { // no output desired
    320324        return;
    321325    }
     
    332336        char *line = strtok_r(msg, "\n", &msgPtr);
    333337        while (line) {
    334             if(write(logFD, "    ", 4)) {;} // ignore return value
     338            if(write(logFD, "          ", PS_MIN(2*level, 10))) {;} // ignore return value
    335339            if(write(logFD, line, strlen(line))) {;} // ignore return value
    336340            if(write(logFD, "\n", 1)) {;} // ignore return value
  • trunk/psLib/src/sys/psMemory.c

    r28401 r30595  
    626626            nleak++;
    627627
    628             if (fd != NULL) {
     628            // only print a max of 500 leaks (make this an argument)
     629            if ((nleak < 500) && (fd != NULL)) {
    629630                if (nleak == 1) {
    630631                    fprintf(fd, "# func at (file:line)  ID: X  Ref: X\n");
  • trunk/psLib/test/imageops/Makefile.am

    r29929 r30595  
    2626        tap_psImageMapFit \
    2727        tap_psImageMapFit2 \
    28         tap_psImageMaskOps
     28        tap_psImageMaskOps \
     29        tap_psImageCovariance
    2930
    3031#       tap_psImageShiftKernel
  • trunk/psLib/test/math

    • Property svn:mergeinfo deleted
Note: See TracChangeset for help on using the changeset viewer.