IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41523


Ignore:
Timestamp:
Apr 2, 2021, 2:44:18 PM (5 years ago)
Author:
eugene
Message:

assign pixel vector manually rather than using psVectorAppend (trying to find memory corruption problem)

File:
1 edited

Legend:

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

    r37050 r41523  
    104104    float min = +PS_MAX_F32;
    105105    float max = -PS_MAX_F32;
    106 
     106   
    107107    if ((nSubset < 0.01*nGoodPixels) && (nGoodPixels >= 0.1*nPixels)) {
    108108        psTrace ("psLib.imageops", 4, "case 3: nSubset < 0.01*nGoodPixels && nGoodPixels > 0.1*nPixels (%d x %d : %d : %d : %d)\n", (int) nx, (int) ny, (int) nSubset, (int) nGoodPixels, (int) nPixels);
     
    144144        // generate a vector of all pixels which may in theory be selected
    145145        psVector *pixelVector = psVectorAllocEmpty(nGoodPixels, PS_TYPE_F32);
     146        int ipix = 0;
    146147        for (long iy = 0; iy < ny; iy++) {
    147148            for (long ix = 0; ix < nx; ix++) {
    148149                if (!isfinite(image->data.F32[iy][ix])) continue;
    149150                if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskValue) continue;
    150                 psVectorAppend(pixelVector, image->data.F32[iy][ix]);
     151                psAssert (ipix < pixelVector->nalloc, "we must have mis-counted above");
     152                pixelVector->data.F32[ipix] = image->data.F32[iy][ix];
     153                ipix ++;
    151154            }
    152155        }
     156        pixelVector->n = ipix;
     157        psAssert (ipix <= pixelVector->nalloc, "we must have mis-counted above");
    153158        psAssert (nGoodPixels == pixelVector->n, "we must have mis-counted above");
    154        
     159
    155160        // generate the unique random subset
    156161        for (int i = 0; i < nSubset; i++) {
Note: See TracChangeset for help on using the changeset viewer.