IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 5, 2007, 5:09:58 PM (19 years ago)
Author:
magnier
Message:

added special case for division to handle div-by-zero; added different bad values for different types

File:
1 edited

Legend:

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

    r10999 r12256  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2007-01-09 22:38:52 $
     12 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2007-03-06 03:09:58 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    261261    }
    262262
     263    #define psImageOverlayLoopDivide(DATATYPE,BADVALUE) { \
     264        for (int row=y0;row<imageRowLimit;row++) { \
     265            ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \
     266            ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-y0]; \
     267            for (int col=x0;col<imageColLimit;col++) { \
     268                if (overlayRow[col-x0] == 0) { \
     269                    imageRow[col] = BADVALUE; \
     270                    continue; \
     271                } \
     272                imageRow[col] /= overlayRow[col-x0]; \
     273            } \
     274        } \
     275        pixelsOverlaid += (imageRowLimit - y0) * (imageColLimit - x0); \
     276    }
     277
    263278    // Use memcpy to perform the '=' operation.  Depending on the particular application, it can be about 20%
    264279    // faster than using a 'for' loop.  Josh Hoblitt says it has an additional advantage that it doesn't blow
     
    279294    }
    280295
    281     #define psImageOverlayCase(DATATYPE) \
     296    #define psImageOverlayCase(DATATYPE,BADVALUE) \
    282297case PS_TYPE_##DATATYPE: \
    283298    switch (*op) { \
     
    292307        break; \
    293308    case '/': \
    294         psImageOverlayLoop(DATATYPE,/=); \
     309        psImageOverlayLoopDivide(DATATYPE,BADVALUE); \
    295310        break; \
    296311    case '=': \
     
    306321
    307322    switch (type) {
    308         psImageOverlayCase(U8);
    309         psImageOverlayCase(U16);
    310         psImageOverlayCase(U32);       // Not a requirement
    311         psImageOverlayCase(U64);       // Not a requirement
    312         psImageOverlayCase(S8);
    313         psImageOverlayCase(S16);
    314         psImageOverlayCase(S32);       // Not a requirement
    315         psImageOverlayCase(S64);       // Not a requirement
    316         psImageOverlayCase(F32);
    317         psImageOverlayCase(F64);
    318         psImageOverlayCase(C32);
    319         psImageOverlayCase(C64);
     323        psImageOverlayCase(U8, 0);
     324        psImageOverlayCase(U16,0);
     325        psImageOverlayCase(U32,0);       // Not a requirement
     326        psImageOverlayCase(U64,0);       // Not a requirement
     327        psImageOverlayCase(S8, 0);
     328        psImageOverlayCase(S16,0);
     329        psImageOverlayCase(S32,0);       // Not a requirement
     330        psImageOverlayCase(S64,0);       // Not a requirement
     331        psImageOverlayCase(F32,NAN);
     332        psImageOverlayCase(F64,NAN);
     333        psImageOverlayCase(C32,NAN);
     334        psImageOverlayCase(C64,NAN);
    320335
    321336    default: {
Note: See TracChangeset for help on using the changeset viewer.