IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25585


Ignore:
Timestamp:
Sep 27, 2009, 10:21:09 AM (17 years ago)
Author:
eugene
Message:

add a function to apply mask operations to the full image array

Location:
branches/eam_branches/20090715/psLib/src/imageops
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/psLib/src/imageops/psImageMaskOps.c

    r21183 r25585  
    223223    psError(PS_ERR_BAD_PARAMETER_VALUE,true,
    224224            "The logical operation specified is incorrect\n");
     225    return;
     226}
     227
     228// perform the mask operation on the image pixels
     229void psImageMaskPixels(psImage *image,
     230                       const char *op,
     231                       psImageMaskType maskValue)
     232{
     233    if (image == NULL) {
     234        psError(PS_ERR_BAD_PARAMETER_NULL, true, "Invalid image input.  Image is NULL.\n");
     235        return;
     236    }
     237
     238# define MASK_IT_IMAGE(OP) \
     239    for (int iy = 0; iy < image->numRows; iy++) { \
     240        for (int ix = 0; ix < image->numCols; ix++) { \
     241            image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \
     242        } }
     243
     244    if ( !strncmp(op, "&", 2) || !strncmp(op, "AND", 5) ) {
     245      MASK_IT_IMAGE (&=);
     246      return;
     247    }
     248    if ( !strncmp(op, "|", 2) || !strncmp(op, "OR", 5) ) {
     249      MASK_IT_IMAGE (|=);
     250      return;
     251    }
     252    if ( !strncmp(op, "=", 2) || !strncmp(op, "EQUAL", 5) ) {
     253      MASK_IT_IMAGE (=);
     254      return;
     255    }
     256    if ( !strncmp(op, "^", 2) || !strncmp(op, "XOR", 5) ) {
     257      MASK_IT_IMAGE (^=);
     258      return;
     259    }
     260
     261    psError(PS_ERR_BAD_PARAMETER_VALUE, true, "The logical operation specified is incorrect\n");
    225262    return;
    226263}
  • branches/eam_branches/20090715/psLib/src/imageops/psImageMaskOps.h

    r21183 r25585  
    2222#include "psStats.h"
    2323#include "psPixels.h"
     24
     25/** Perform the mask opertion on all image pixels
     26 *
     27 *  The pixels are set by combining the existing pixel value and the given maskValue
     28 *  with a logical operation.  The allowed operations are =, AND, OR, and XOR.
     29 */
     30void psImageMaskPixels(psImage *image,
     31                       const char *op,
     32                       psImageMaskType maskValue);
    2433
    2534/** Sets the bits inside the region, ignoring pixels outside.
Note: See TracChangeset for help on using the changeset viewer.