IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 22, 2011, 10:17:13 AM (15 years ago)
Author:
eugene
Message:

fix counting error in psImageSmooth (for real this time!)

File:
1 edited

Legend:

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

    r32729 r32745  
    626626                /* Smooth first Nrange pixels, with renorm */ \
    627627                for (int i = 0; i < xMax; i++, vi++, vo++) { \
    628                     int convRange = PS_MIN(Nrange + 1, Nx - xMax + 1);  \
     628                    int convRange = PS_MIN(Nrange + 1, Nx - i);  \
    629629                    ps##TYPE *vr = vi - i; \
    630630                    ps##TYPE *vg = gauss - i; \
     
    650650                    } \
    651651                    /* Smooth last Nrange pixels, with renorm */ \
    652                     /* XXX does this miss the last column? */ \
    653                     for (int i = Nx - Nrange; i < Nx; i++, vi++, vo++) { \
     652                    /* if Nx < 2*Nrange, this pass starts at i == Nrange */ \
     653                    int xMin = PS_MAX(Nx - Nrange, Nrange); \
     654                    for (int i = xMin; i < Nx; i++, vi++, vo++) { \
    654655                        ps##TYPE *vr = vi - Nrange; \
    655656                        ps##TYPE *vg = gauss - Nrange; \
     
    717718                calculation = save; \
    718719            } \
    719             /* Smooth last Nrange pixels, with renorm */ \
    720             for (int j = Ny - Nrange; j < Ny; j++) { \
     720            /* Smooth last Nrange pixels, with renorm */                \
     721            /* if Ny < 2*Nrange, this pass starts at j == Nrange */ \
     722            int yMin = PS_MAX(Ny - Nrange, Nrange); \
     723            for (int j = yMin; j < Ny; j++) { \
    721724                /* save the Nrange-offset output row, then zero */ \
    722725                memset(calculation->data.TYPE, 0, Nx*sizeof(ps##TYPE)); \
     
    834837                double s = 0.0;
    835838                for (int n = -i; n < convRange; n++, vr++, vg++) {
    836                     psAssert (vr - image->data.F32[j] < image->numCols, "counting error");
    837839                    s += *vg * *vr;
    838840                    g += *vg;
     
    848850                    double s = 0;
    849851                    for (int n = -Nrange; n < Nrange + 1; n++, vr++, vg++) {
    850                         psAssert (vr - image->data.F32[j] < image->numCols, "counting error");
    851852                        s += *vg * *vr;
    852853                    }
     
    862863                    double s = 0.0;
    863864                    for (int n = -Nrange; n < Nx - i; n++, vr++, vg++) {
    864                         psAssert (vr - image->data.F32[j] < image->numCols, "counting error");
    865865                        s += *vg * *vr;
    866866                        g += *vg;
     
    904904                }
    905905                /* Smooth last Nrange pixels, with renorm */
    906                 for (int j = Ny - Nrange; j < Ny; j++) {
     906                // if Ny < 2*Nrange, this pass starts at j == Nrange
     907                int yMin = PS_MAX(Ny - Nrange, Nrange);
     908                for (int j = yMin; j < Ny; j++) {
    907909                    psF32 *vg = gauss - Nrange;
    908910                    double g = 0.0;
Note: See TracChangeset for help on using the changeset viewer.