IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 24, 2008, 12:23:14 PM (18 years ago)
Author:
Paul Price
Message:

Fixing psImageConvolveMask --- wasn't masking everything it was supposed to.

File:
1 edited

Legend:

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

    r17726 r17807  
    77/// @author Eugene Magnier, IfA
    88///
    9 /// @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
    10 /// @date $Date: 2008-05-17 01:38:20 $
     9/// @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2008-05-24 22:23:14 $
    1111///
    1212/// Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    795795    int numCols = mask->numCols;        // Number of columns
    796796
    797     if (!out) {
    798         // Propagate the non-masked values
    799         out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_MASK));
    800     }
     797    // Propagate the non-masked values
     798    out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_MASK));
    801799
    802800    if (!setVal) {
     
    804802    }
    805803
     804    psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Temporary convolved image
     805    psImageInit(conv, 0);
     806
    806807    // Dereference mask images
    807808    psMaskType **maskData = mask->data.PS_TYPE_MASK_DATA;
     809    psMaskType **convData = conv->data.PS_TYPE_MASK_DATA;
    808810    psMaskType **outData = out->data.PS_TYPE_MASK_DATA;
    809811
     
    826828                min = PS_MAX(0, min);
    827829                max = PS_MIN(numCols - 1, max);
    828                 for (int i = min; i < max; i++) {
    829                     outData[y][i] |= setVal;
    830                 }
     830                memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
    831831            }
    832832        }
     
    836836        bool masking = false;           // Currently masking?
    837837        for (int y = 0; y < numRows; y++) {
    838             if (maskData[y][x] & maskVal) {
     838            if (convData[y][x]) {
    839839                if (!masking) {
    840840                    masking = true;
     
    849849                min = PS_MAX(0, min);
    850850                max = PS_MIN(numRows - 1, max);
    851                 for (int i = min; i < max; i++) {
     851                for (int i = min; i <= max; i++) {
    852852                    outData[i][x] |= setVal;
    853853                }
     
    856856    }
    857857
     858    psFree(conv);
     859
    858860    return out;
    859861}
Note: See TracChangeset for help on using the changeset viewer.