IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 19, 2004, 4:48:38 PM (22 years ago)
Author:
desonia
Message:

added mask support for psImageRebin, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImageManip.c

    r1520 r1604  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-08-13 00:02:03 $
     13 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2004-08-20 02:48:38 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3131#include "psImageExtraction.h"
    3232
    33 int psImageClip(psImage* input, psF64 min, psF64 vmin, psF64 max, psF64 vmax)
     33int psImageClip(psImage* input,
     34                psF64 min,
     35                psF64 vmin,
     36                psF64 max,
     37                psF64 vmax)
    3438{
    3539    int numClipped = 0;
     
    125129}
    126130
    127 int psImageClipNaN(psImage* input, psF64 value)
     131int psImageClipNaN(psImage* input,
     132                   psF64 value)
    128133{
    129134    int numClipped = 0;
     
    164169}
    165170
    166 int psImageOverlaySection(psImage* image, const psImage* overlay, int col0, int row0, const char *op)
     171int psImageOverlaySection(psImage* image,
     172                          const psImage* overlay,
     173                          int col0,
     174                          int row0,
     175                          const char *op)
    167176{
    168177    unsigned int imageNumRows;
     
    267276}
    268277
    269 int psImageClipComplexRegion(psImage* input, psC64 min, psC64 vmin, psC64 max, psC64 vmax)
     278int psImageClipComplexRegion(psImage* input,
     279                             psC64 min,
     280                             psC64 vmin,
     281                             psC64 max,
     282                             psC64 vmax)
    270283{
    271284    int numClipped = 0;
     
    340353}
    341354
    342 psImage* psImageRebin(psImage* out, const psImage* in, unsigned int scale, const psStats* stats)
     355psImage* psImageRebin(psImage* out,
     356                      const psImage* in,
     357                      const psImage* restrict mask,
     358                      unsigned int maskVal,
     359                      unsigned int scale,
     360                      const psStats* stats)
    343361{
    344362    int inRows;
     
    346364    int outRows;
    347365    int outCols;
    348     psVector* vec;              // vector to hold
    349 
    350     // the values of
    351     // a single bin.
     366    psVector* vec;                     // vector to hold the values of a single bin.
     367    psVector* maskVec = NULL;          // vector to hold the mask of a single bin.
     368    psMaskType* maskData = NULL;
    352369    psStats* myStats;
    353370    double statVal;
     
    377394    }
    378395
     396    vec = psVectorAlloc(scale * scale, in->type.type);
     397
     398    if (mask != NULL) {
     399        if (mask->type.type != PS_TYPE_MASK) {
     400            psError(__func__, "The mask datatype must be %s (%d).",
     401                    PS_TYPE_MASK_NAME,
     402                    mask->type.type);
     403            psFree(out);
     404            psFree(vec);
     405            return NULL;
     406        }
     407        maskVec = psVectorAlloc(scale * scale, PS_TYPE_MASK);
     408        maskData = maskVec->data.PS_TYPE_MASK_DATA;
     409    }
     410
    379411    myStats = psAlloc(sizeof(psStats));
    380412    *myStats = *stats;
    381 
    382     vec = psVectorAlloc(scale * scale, in->type.type);
    383413
    384414    // create output image.
    385415    inRows = in->numRows;
    386416    inCols = in->numCols;
    387     outRows = (inRows + scale - 1) / scale;     // round-up
    388     // for
    389     // remainders
    390     outCols = (inCols + scale - 1) / scale;     // round-up
    391     // for
    392     // remainders
     417    outRows = (inRows + scale - 1) / scale;     // round-up for remainders
     418    outCols = (inCols + scale - 1) / scale;     // round-up for remainders
    393419    out = psImageRecycle(out, outCols, outRows, in->type.type);
    394420
    395421    #define PS_IMAGE_REBIN_CASE(type) \
    396422case PS_TYPE_##type: { \
     423        ps##type* outRowData; \
    397424        ps##type* vecData = vec->data.type; \
     425        psMaskType* inRowMask = NULL; \
    398426        for (int row = 0; row < outRows; row++) { \
    399             ps##type* outRowData = out->data.type[row]; \
     427            outRowData = out->data.type[row]; \
    400428            int inCurrentRow = row*scale; \
    401429            int inNextRow = (row+1)*scale; \
     
    406434                for (int inRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \
    407435                    ps##type* inRowData = in->data.type[inRow]; \
     436                    if (mask != NULL) { \
     437                        inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \
     438                    } \
    408439                    for (int inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \
     440                        if (maskData != NULL) { \
     441                            maskData[n] = inRowMask[inCol]; \
     442                        } \
    409443                        vecData[n++] = inRowData[inCol]; \
    410444                    } \
    411445                } \
    412446                vec->n = n; \
    413                 myStats = psVectorStats(myStats,vec,NULL,0); \
     447                myStats = psVectorStats(myStats,vec,maskVec,maskVal); \
    414448                p_psGetStatValue(myStats,&statVal); \
    415449                outRowData[col] = (ps##type)statVal; \
     
    444478}
    445479
    446 psImage* psImageResample(psImage* out, const psImage* in, int scale, psImageInterpolateMode mode)
     480psImage* psImageResample(psImage* out,
     481                         const psImage* in,
     482                         int scale,
     483                         psImageInterpolateMode mode)
    447484{
    448485    int outRows;
     
    496533}
    497534
    498 psImage* psImageRoll(psImage* out, const psImage* in, int dx, int dy)
     535psImage* psImageRoll(psImage* out,
     536                     const psImage* in,
     537                     int dx,
     538                     int dy)
    499539{
    500540    int outRows;
     
    808848psImage* psImageShift(psImage* out,
    809849                      const psImage* in,
    810                       float dx, float dy, psF64 unexposedValue, psImageInterpolateMode mode)
     850                      float dx,
     851                      float dy,
     852                      psF64 unexposedValue,
     853                      psImageInterpolateMode mode)
    811854{
    812855    int outRows;
Note: See TracChangeset for help on using the changeset viewer.