IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 26, 2009, 8:40:07 PM (17 years ago)
Author:
eugene
Message:

incorporating changes from 16bit mask upgrades (eam_branch_20081230)

Location:
trunk/psLib/src/imageops
Files:
19 edited

Legend:

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

    r20216 r21183  
    1818// XXX allow the user to choose the stats method?
    1919// (SAMPLE_MEAN, CLIPPED_MEAN, ROBUST_MEDIAN, FITTED_MEAN)
    20 bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, psMaskType maskValue, psRandom *rng)
     20bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, psImageMaskType maskValue, psRandom *rng)
    2121{
    2222    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    2323    if (mask) {
    2424        PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    25         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, NULL);
     25        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    2626        PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, NULL);
    2727    }
     
    6363        int iy = pixel / nx;
    6464
    65         if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.U8[iy][ix] & maskValue)) {
     65        if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskValue)) {
    6666            continue;
    6767        }
  • trunk/psLib/src/imageops/psImageBackground.h

    r16115 r21183  
    55 *  @author EAM, IfA
    66 *
    7  *  $Revision: 1.6 $ $Name: not supported by cvs2svn $
    8  *  $Date: 2008-01-17 22:07:33 $
     7 *  $Revision: 1.7 $ $Name: not supported by cvs2svn $
     8 *  $Date: 2009-01-27 06:39:37 $
    99 *  Copyright 2004-2005 IfA, University of Hawaii
    1010 */
     
    2727                       const psImage *image, // Image for which to get the background
    2828                       const psImage *mask, // Mask image
    29                        psMaskType maskValue, // Mask pixels which this mask value
     29                       psImageMaskType maskValue, // Mask pixels which this mask value
    3030                       psRandom *rng // Random number generator (for pixel selection)
    3131                      );
  • trunk/psLib/src/imageops/psImageConvolve.c

    r20830 r21183  
    77/// @author Eugene Magnier, IfA
    88///
    9 /// @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
    10 /// @date $Date: 2008-11-26 00:43:12 $
     9/// @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2009-01-27 06:39:37 $
    1111///
    1212/// Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    319319}
    320320
    321 psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, psMaskType maskVal,
    322                                    psMaskType setVal, int xMin, int xMax, int yMin, int yMax)
     321psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, psImageMaskType maskVal,
     322                                   psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax)
    323323{
    324324    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    325     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     325    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    326326    if (out == mask && ((maskVal & setVal) || !setVal)) {
    327327        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     
    352352    if (!out) {
    353353        // Propagate the non-masked values
    354         out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_MASK));
     354        out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_IMAGE_MASK));
    355355    }
    356356
    357357    // Dereference mask images
    358     psMaskType **maskData = mask->data.PS_TYPE_MASK_DATA;
    359     psMaskType **outData = out->data.PS_TYPE_MASK_DATA;
     358    psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA;
     359    psImageMaskType **outData = out->data.PS_TYPE_IMAGE_MASK_DATA;
    360360
    361361    if (setVal) {
     
    376376        for (int row = 0; row < numRows; row++) {
    377377            for (int col = 0; col < numCols; col++) {
    378                 psMaskType pixel = outData[row][col]; // Pixel value to set
     378                psImageMaskType pixel = outData[row][col]; // Pixel value to set
    379379                if (pixel & maskVal) {
    380380                    // Already done this one
     
    395395
    396396
    397 psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, psMaskType maskVal,
    398                                 psMaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh)
     397psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, psImageMaskType maskVal,
     398                                psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh)
    399399{
    400400    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    401     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     401    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    402402    PS_ASSERT_FLOAT_LARGER_THAN(thresh, 0.0, NULL);
    403403    PS_ASSERT_FLOAT_LESS_THAN(thresh, 1.0, NULL);
     
    431431    for (int y = 0; y < numRows; y++) {
    432432        for (int x = 0; x < numCols; x++) {
    433             if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     433            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    434434                onoff->data.F32[y][x] = 1.0;
    435435            }
     
    452452
    453453    if (!out) {
    454         out = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     454        out = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    455455    }
    456456    for (int y = 0; y < numRows; y++) {
    457457        for (int x = 0; x < numCols; x++) {
    458             out->data.PS_TYPE_MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ?
    459                 (mask->data.PS_TYPE_MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_MASK_DATA[y][x];
     458            out->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ?
     459                (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
    460460        }
    461461    }
     
    651651case PS_TYPE_##TYPE: { \
    652652    psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_##TYPE); /* Calculation image; BW */ \
    653     psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_MASK); /* Mask for calculation image; BW */ \
     653    psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */ \
    654654    \
    655655    /** Smooth in X direction **/ \
     
    658658            int xMin = PS_MAX(i - size, 0); \
    659659            int xMax = PS_MIN(i + size, xLast); \
    660             const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin]; \
     660            const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin]; \
    661661            const ps##TYPE *imageData = &image->data.TYPE[j][xMin]; \
    662662            int uMin = - PS_MIN(i, size); /* Minimum kernel index */ \
     
    673673                /* BW */ \
    674674                calculation->data.TYPE[i][j] = sumIG / sumG; \
    675                 calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0; \
     675                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0; \
    676676            } else { \
    677677                /* BW */ \
    678                 calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0xFF; \
     678                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF; \
    679679            } \
    680680        } \
     
    688688            int yMin = PS_MAX(j - size, 0); \
    689689            int yMax = PS_MIN(j + size, yLast); \
    690             const psMaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */ \
     690            const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */ \
    691691            const ps##TYPE *imageData = &calculation->data.TYPE[i][yMin]; /* BW */ \
    692692            int vMin = - PS_MIN(j, size); /* Minimum kernel index */ \
     
    714714                           const psImage *image,
    715715                           const psImage *mask,
    716                            psMaskType maskVal,
     716                           psImageMaskType maskVal,
    717717                           float sigma,
    718718                           float numSigma,
     
    721721    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    722722    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    723     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     723    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    724724    PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL);
    725725
     
    751751      case PS_TYPE_F32: {
    752752          psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */
    753           psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_MASK); /* Mask for calculation image; BW */
     753          psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */
    754754
    755755          /** Smooth in X direction **/
     
    758758                  int xMin = PS_MAX(i - size, 0);
    759759                  int xMax = PS_MIN(i + size, xLast);
    760                   const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];
     760                  const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin];
    761761                  const psF32 *imageData = &image->data.F32[j][xMin];
    762762                  int uMin = - PS_MIN(i, size); /* Minimum kernel index */
     
    776776                      /* BW */
    777777                      calculation->data.F32[i][j] = sumIG / sumG;
    778                       calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0;
     778                      calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0;
    779779                  } else {
    780780                      /* BW */
    781                       calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0xFF;
     781                      calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF;
    782782                  }
    783783              }
     
    791791                  int yMin = PS_MAX(j - size, 0);
    792792                  int yMax = PS_MIN(j + size, yLast);
    793                   const psMaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */
     793                  const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */
    794794                  const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */
    795795                  int vMin = - PS_MIN(j, size); /* Minimum kernel index */
     
    832832                                     const psImage *image,
    833833                                     const psImage *mask,
    834                                      psMaskType maskVal,
     834                                     psImageMaskType maskVal,
    835835                                     psVector *gaussNorm,
    836836                                     float minGauss,
     
    848848            int xMin = PS_MAX(i - size, 0);
    849849            int xMax = PS_MIN(i + size, xLast);
    850             const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];
     850            const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin];
    851851            const psF32 *imageData = &image->data.F32[j][xMin];
    852852            int uMin = - PS_MIN(i, size); /* Minimum kernel index */
     
    863863                /* BW */
    864864                calculation->data.F32[i][j] = sumIG / sumG;
    865                 calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0;
     865                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0;
    866866            } else {
    867867                /* BW */
    868                 calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0xFF;
     868                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF;
    869869            }
    870870        }
     
    876876                                     psImage *calculation,
    877877                                     psImage *calcMask,
    878                                      psMaskType maskVal,
     878                                     psImageMaskType maskVal,
    879879                                     psVector *gaussNorm,
    880880                                     float minGauss,
     
    892892            int yMin = PS_MAX(j - size, 0);
    893893            int yMax = PS_MIN(j + size, yLast);
    894             const psMaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */
     894            const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */
    895895            const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */
    896896            int vMin = - PS_MIN(j, size); /* Minimum kernel index */
     
    921921    const psImage *mask   = job->args->data[3]; // input mask
    922922
    923     psMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[4],U8);
     923    psImageMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
    924924    psVector *gaussNorm   = job->args->data[5]; // gauss kernel
    925925    float minGauss        = PS_SCALAR_VALUE(job->args->data[6],F32);
     
    941941    psImage *calculation  = job->args->data[1]; // calculation image
    942942    psImage *calcMask     = job->args->data[2]; // calculation mask
    943     psMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[3],U8);
     943    psImageMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA);
    944944
    945945    psVector *gaussNorm   = job->args->data[4]; // gauss kernel
     
    956956                                    const psImage *image,
    957957                                    const psImage *mask,
    958                                     psMaskType maskVal,
     958                                    psImageMaskType maskVal,
    959959                                    float sigma,
    960960                                    float numSigma,
     
    963963    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    964964    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    965     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     965    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    966966    PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL);
    967967
     
    999999      case PS_TYPE_F32: {
    10001000          psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */
    1001           psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_MASK); /* Mask for calculation image; BW */
     1001          psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */
    10021002
    10031003          /** Smooth in X direction **/
     
    10111011              psArrayAdd(job->args, 1, (psImage *) image); // cast away const
    10121012              psArrayAdd(job->args, 1, (psImage *) mask); // cast away const
    1013               PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_U8);
     1013              PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
    10141014              psArrayAdd(job->args, 1, gaussNorm);
    10151015              PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
     
    10461046              psArrayAdd(job->args, 1, calculation);
    10471047              psArrayAdd(job->args, 1, calcMask);
    1048               PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_U8);
     1048              PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
    10491049              psArrayAdd(job->args, 1, gaussNorm);
    10501050              PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
     
    10911091bool psImageSmoothMaskF32 (psImage *image,
    10921092                           psImage *mask,
    1093                            psMaskType maskVal,
     1093                           psImageMaskType maskVal,
    10941094                           double  sigma,
    10951095                           double  Nsigma)
     
    11221122    psVector *calculation = psVectorAlloc(Nx, PS_TYPE_F32);
    11231123    for (int j = 0; j < Ny; j++) {
    1124         psU8  *vm = mask->data.U8[j];
     1124        psImageMaskType  *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[j];
    11251125        psF32 *vi = image->data.F32[j];
    11261126        psF32 *vo = calculation->data.F32;
     
    11281128        for (int i = 0; i < Nx; i++, vi++, vo++, vm++) {
    11291129            int offset = PS_MIN (i, Nrange);
    1130             psU8  *sm = vm - offset;
     1130            psImageMaskType  *sm = vm - offset;
    11311131            psF32 *si = vi - offset;
    11321132            psF32 *sg = gauss - offset;
     
    11711171        int yMax = PS_MIN (j + Nrange + 1, Ny);
    11721172        for (int n = yMin; n < yMax; n++) {
    1173             psU8  *vm = mask->data.U8[n];
     1173            psImageMaskType  *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[n];
    11741174            psF32 *vi = image->data.F32[n];
    11751175            psF32 *vo = output->data.F32;
     
    12141214                                     const psImage *input, // Input image
    12151215                                     int start, int stop, // Range of rows
    1216                                      psMaskType maskVal, // Value to mask; NOTE subtle difference!
     1216                                     psImageMaskType maskVal, // Value to mask; NOTE subtle difference!
    12171217                                     int xMin, int xMax // Range in x for kernel
    12181218                                     )
    12191219{
    12201220    // Dereference mask images
    1221     psMaskType **inputData = input->data.PS_TYPE_MASK_DATA;
    1222     psMaskType **targetData = target->data.PS_TYPE_MASK_DATA;
     1221    psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA;
     1222    psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA;
    12231223
    12241224    int numCols = input->numCols;       // Number of columns
     
    12411241                min = PS_MAX(0, min);
    12421242                max = PS_MIN(numCols - 1, max);
    1243                 memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
     1243                memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
    12441244            }
    12451245        }
     
    12471247            // Mask from the minimum to the end of the row
    12481248            min = PS_MAX(0, min);
    1249             memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
     1249            memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
    12501250        }
    12511251    }
     
    12561256                                     const psImage *input, // Input image
    12571257                                     int start, int stop, // Range of rows
    1258                                      psMaskType setVal, // Value to set; NOTE subtle difference!
     1258                                     psImageMaskType setVal, // Value to set; NOTE subtle difference!
    12591259                                     int yMin, int yMax // Range in y for kernel
    12601260                                     )
    12611261{
    12621262    // Dereference mask images
    1263     psMaskType **inputData = input->data.PS_TYPE_MASK_DATA;
    1264     psMaskType **targetData = target->data.PS_TYPE_MASK_DATA;
     1263    psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA;
     1264    psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA;
    12651265
    12661266    int numRows = input->numRows;       // Number of rows
     
    13081308    int start = PS_SCALAR_VALUE(args->data[2], S32); // Row/col to start at
    13091309    int stop = PS_SCALAR_VALUE(args->data[3], S32); // Row/col to stop at
    1310     psMaskType maskVal = PS_SCALAR_VALUE(args->data[4], U8); // Value to mask/set
     1310    psImageMaskType maskVal = PS_SCALAR_VALUE(args->data[4], PS_TYPE_IMAGE_MASK_DATA); // Value to mask/set
    13111311    int kernelMin = PS_SCALAR_VALUE(args->data[5], S32); // Minimum range for kernel
    13121312    int kernelMax = PS_SCALAR_VALUE(args->data[6], S32); // Maximum range for kernel
     
    13171317}
    13181318
    1319 psImage *psImageConvolveMask(psImage *out, const psImage *mask, psMaskType maskVal,
    1320                              psMaskType setVal, int xMin, int xMax, int yMin, int yMax)
     1319psImage *psImageConvolveMask(psImage *out, const psImage *mask, psImageMaskType maskVal,
     1320                             psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax)
    13211321{
    13221322    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    1323     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     1323    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    13241324    if (out) {
    13251325        PS_ASSERT_IMAGE_NON_NULL(out, NULL);
    1326         PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_MASK, NULL);
     1326        PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_IMAGE_MASK, NULL);
    13271327        PS_ASSERT_IMAGES_SIZE_EQUAL(out, mask, NULL);
    13281328        if (out == mask && ((maskVal & setVal) || !setVal)) {
     
    13541354
    13551355    // Propagate the non-masked values
    1356     out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_MASK));
     1356    out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_IMAGE_MASK));
    13571357
    13581358    if (!setVal) {
     
    13601360    }
    13611361
    1362     psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Temporary convolved image
     1362    psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Temporary convolved image
    13631363    psImageInit(conv, 0);
    13641364
     
    13771377            PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32);
    13781378            PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32);
    1379             PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_MASK);
     1379            PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);
    13801380            PS_ARRAY_ADD_SCALAR(job->args, xMin, PS_TYPE_S32);
    13811381            PS_ARRAY_ADD_SCALAR(job->args, xMax, PS_TYPE_S32);
     
    14151415            PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32);
    14161416            PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32);
    1417             PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_MASK);
     1417            PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_IMAGE_MASK);
    14181418            PS_ARRAY_ADD_SCALAR(job->args, yMin, PS_TYPE_S32);
    14191419            PS_ARRAY_ADD_SCALAR(job->args, yMax, PS_TYPE_S32);
     
    14601460                min = PS_MAX(0, min);
    14611461                max = PS_MIN(numCols - 1, max);
    1462                 memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
     1462                memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
    14631463            }
    14641464        }
     
    14661466            // Mask from the minimum to the end of the row
    14671467            min = PS_MAX(0, min);
    1468             memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
     1468            memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
    14691469        }
    14701470    }
  • trunk/psLib/src/imageops/psImageConvolve.h

    r20830 r21183  
    55 * @author Robert DeSonia, MHPCC
    66 *
    7  * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-11-26 00:43:12 $
     7 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:37 $
    99 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1010 */
     
    148148psImage *psImageConvolveMask(psImage *out, ///< Output image, or NULL
    149149                             const psImage *mask, ///< Mask to convolve
    150                              psMaskType maskVal, ///< Mask value to convolve
    151                              psMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
     150                             psImageMaskType maskVal, ///< Mask value to convolve
     151                             psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
    152152                             int xMin, int xMax, int yMin, int yMax ///< Convolution bounds
    153153    );
     
    160160psImage *psImageConvolveMaskDirect(psImage *out, ///< Output image, or NULL
    161161                                   const psImage *mask, ///< Mask to convolve
    162                                    psMaskType maskVal, ///< Mask value to convolve
    163                                    psMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
     162                                   psImageMaskType maskVal, ///< Mask value to convolve
     163                                   psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
    164164                                   int xMin, int xMax, int yMin, int yMax ///< Convolution bounds
    165165    );
     
    174174psImage *psImageConvolveMaskFFT(psImage *out, ///< Output image, or NULL
    175175                                const psImage *mask, ///< Mask to convolve
    176                                 psMaskType maskVal, ///< Mask value to convolve
    177                                 psMaskType setVal, ///< Mask value to set; 0 to use maskVal
     176                                psImageMaskType maskVal, ///< Mask value to convolve
     177                                psImageMaskType setVal, ///< Mask value to set; 0 to use maskVal
    178178                                int xMin, int xMax, int yMin, int yMax, ///< Convolution bounds
    179179                                float thresh ///< Threshold (0..1) for convolved floating-point image
     
    201201    const psImage *image,               ///< Input image (F32 or F64)
    202202    const psImage *mask,                ///< Mask image
    203     psMaskType maskVal,                 ///< Mask value
     203    psImageMaskType maskVal,            ///< Mask value
    204204    float sigma,                        ///< Width of the smoothing kernel (pixels)
    205205    float numSigma,                     ///< Size of the smoothing box (sigma)
     
    211211                                    const psImage *image,
    212212                                    const psImage *mask,
    213                                     psMaskType maskVal,
     213                                    psImageMaskType maskVal,
    214214                                    float sigma,
    215215                                    float numSigma,
     
    219219    psImage *image,                    ///< the image to be smoothed
    220220    psImage *mask,                     ///< optional mask
    221     psMaskType maskVal,
     221    psImageMaskType maskVal,            ///< masked bits
    222222    double  sigma,                     ///< the width of the smoothing kernel in pixels
    223223    double  Nsigma                     ///< the size of the smoothing box in sigmas
  • trunk/psLib/src/imageops/psImageGeomManip.c

    r20299 r21183  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2008-10-21 22:10:53 $
     12 *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2009-01-27 06:39:37 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3939                      const psImage* in,
    4040                      const psImage* mask,
    41                       psMaskType maskVal,
     41                      psImageMaskType maskVal,
    4242                      int scale,
    4343                      const psStats* stats)
     
    4747    psS32 outRows;
    4848    psS32 outCols;
    49     psVector* vec;                     // vector to hold the values of a single bin.
    50     psVector* maskVec = NULL;          // vector to hold the mask of a single bin.
    51     psMaskType* maskData = NULL;
    52     psStats* myStats;
     49    psVector *vec;                     // vector to hold the values of a single bin.
     50    psVector *maskVec = NULL;          // vector to hold the mask of a single bin.
     51    psVectorMaskType *maskData = NULL;
     52    psStats *myStats;
    5353
    5454    if (in == NULL) {
     
    8686
    8787    if (mask != NULL) {
    88         if (mask->type.type != PS_TYPE_MASK) {
     88        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
    8989            char* typeStr;
    9090            PS_TYPE_NAME(typeStr,mask->type.type);
    9191            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    9292                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    93                     typeStr, PS_TYPE_MASK_NAME);
     93                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    9494            psFree(out);
    9595            psFree(vec);
    9696            return NULL;
    9797        }
    98         maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_MASK);
    99         maskData = maskVec->data.PS_TYPE_MASK_DATA;
     98        maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_VECTOR_MASK);
     99        maskData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA;
    100100    }
    101101
     
    114114        ps##TYPE *outRowData; \
    115115        ps##TYPE *vecData = vec->data.TYPE; \
    116         psMaskType *inRowMask = NULL; \
     116        psImageMaskType *inRowMask = NULL; \
    117117        for (psS32 row = 0; row < outRows; row++) { \
    118118            outRowData = out->data.TYPE[row]; \
     
    126126                    ps##TYPE* inRowData = in->data.TYPE[inRow]; \
    127127                    if (mask != NULL) { \
    128                         inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \
     128                        inRowMask = mask->data.PS_TYPE_IMAGE_MASK_DATA[inRow]; \
    129129                    } \
    130130                    for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \
    131131                        if (maskData != NULL) { \
    132                             maskData[n] = inRowMask[inCol]; \
     132                            maskData[n] = (inRowMask[inCol] & maskVal); \
    133133                        } \
    134134                        vecData[n++] = inRowData[inCol]; \
     
    139139                    maskVec->n = n; \
    140140                } \
    141                 psVectorStats(myStats, vec, NULL, maskVec, maskVal); \
     141                 psVectorStats(myStats, vec, NULL, maskVec, 0xff); /* the mask vector has only 0 or 1 */ \
    142142                outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
    143143            } \
     
    659659
    660660bool psImageShiftMask(psImage **out, psImage **outMask, const psImage* in, const psImage *inMask,
    661                       psMaskType maskVal, float dx, float dy, double exposed, psMaskType blank,
     661                      psImageMaskType maskVal, float dx, float dy, double exposed, psImageMaskType blank,
    662662                      psImageInterpolateMode mode)
    663663{
     
    667667        PS_ASSERT_IMAGE_NON_NULL(inMask, false);
    668668        PS_ASSERT_IMAGES_SIZE_EQUAL(in, inMask, false);
    669         PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_MASK, false);
     669        PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_IMAGE_MASK, false);
    670670    }
    671671
     
    675675    *out = psImageRecycle(*out, numCols, numRows, type);
    676676    if (outMask) {
    677         *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_MASK);
     677        *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_IMAGE_MASK);
    678678    }
    679679
     
    702702    for (int row = 0; row < numRows; row++) { \
    703703        ps##TYPE* outRow = (*out)->data.TYPE[row]; \
    704         psMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_MASK_DATA[row] : NULL); \
     704        psImageMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_IMAGE_MASK_DATA[row] : NULL); \
    705705        float y = row + 0.5 - dy; \
    706706        for (int col = 0; col < numCols; col++) { \
    707707            float x = col + 0.5 - dx; \
    708708            double value; \
    709             psMaskType valueMask = 0; \
     709            psImageMaskType valueMask = 0; \
    710710            if (!psImageInterpolate(&value, NULL, &valueMask, x, y, interp)) { \
    711711                psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); \
     
    750750                          const psImage *input,
    751751                          const psImage *inputMask,
    752                           psMaskType inputMaskVal,
     752                          psImageMaskType inputMaskVal,
    753753                          const psPlaneTransform *outToIn,
    754754                          psRegion region,
     
    778778            return NULL;
    779779        }
    780         if (inputMask->type.type != PS_TYPE_MASK) {
     780        if (inputMask->type.type != PS_TYPE_IMAGE_MASK) {
    781781            char* typeStr;
    782782            PS_TYPE_NAME(typeStr,inputMask->type.type);
    783783            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    784784                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    785                     typeStr, PS_TYPE_MASK_NAME);
     785                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    786786            psFree(output);
    787787            return NULL;
  • trunk/psLib/src/imageops/psImageGeomManip.h

    r16910 r21183  
    66 * @author Robert DeSonia, MHPCC
    77 *
    8  * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2008-03-11 00:41:30 $
     8 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2009-01-27 06:39:37 $
    1010 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    3636    const psImage* in,                 ///< input image
    3737    const psImage* mask,               ///< mask for input image.  If NULL, no masking is done.
    38     psMaskType maskVal,                ///< the bits to check in mask.
     38    psImageMaskType maskVal,            ///< the bits to check in mask.
    3939    int scale,                         ///< the scale to rebin for each dimension
    4040    const psStats* stats
     
    106106    const psImage* in,                  ///< Input image
    107107    const psImage *inMask,              ///< Input mask, or NULL
    108     psMaskType maskVal,                 ///< Value to mask
     108    psImageMaskType maskVal,            ///< Value to mask
    109109    float dx, float dy,                 ///< Shift to apply
    110110    double exposed,                     ///< Value to give exposed pixels
    111     psMaskType blank,                   ///< Mask value for exposed pixels
     111    psImageMaskType blank,              ///< Mask value for exposed pixels
    112112    psImageInterpolateMode mode         ///< Interpolation mode
    113113    );
     
    159159    const psImage *input,              ///< psImage to apply transform to
    160160    const psImage *inputMask,          ///< if not NULL, mask of input psImage
    161     psMaskType inputMaskVal,           ///< masking value for inputMask
     161    psImageMaskType inputMaskVal,       ///< masking value for inputMask
    162162    const psPlaneTransform *outToIn,   ///< the transform to apply
    163163    psRegion region,                   ///< the size of the transformed image
  • trunk/psLib/src/imageops/psImageInterpolate.c

    r20758 r21183  
    77 *  @author Paul Price, IfA
    88 *
    9  *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-11-15 03:09:34 $
     9 *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:37 $
    1111 *
    1212 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    205205psImageInterpolation *psImageInterpolationAlloc(psImageInterpolateMode mode,
    206206                                                const psImage *image, const psImage *variance,
    207                                                 const psImage *mask, psMaskType maskVal,
     207                                                const psImage *mask, psImageMaskType maskVal,
    208208                                                double badImage, double badVariance,
    209                                                 psMaskType badMask, psMaskType poorMask,
     209                                                psImageMaskType badMask, psImageMaskType poorMask,
    210210                                                float poorFrac, int numKernels)
    211211{
     
    274274// Interpolation engine for flat mode (nearest pixel)
    275275static inline psImageInterpolateStatus interpolateFlat(double *imageValue, double *varianceValue,
    276                                                        psMaskType *maskValue, float x, float y,
     276                                                       psImageMaskType *maskValue, float x, float y,
    277277                                                       const psImageInterpolation *interp)
    278278{
     
    331331        if (maskValue) {
    332332            if (interp->mask) {
    333                 *maskValue = interp->mask->data.PS_TYPE_MASK_DATA[yInt][xInt];
     333                *maskValue = interp->mask->data.PS_TYPE_IMAGE_MASK_DATA[yInt][xInt];
    334334            } else {
    335335                *maskValue = 0;
     
    456456// Interpolation engine for separable interpolation kernels
    457457static psImageInterpolateStatus interpolateSeparable(double *imageValue, double *varianceValue,
    458                                                      psMaskType *maskValue, float x, float y,
     458                                                     psImageMaskType *maskValue, float x, float y,
    459459                                                     const psImageInterpolation *interp)
    460460{
     
    465465    const psImage *mask = interp->mask; // Image mask
    466466    const psImage *variance = interp->variance; // Image variance
    467     psMaskType maskVal = interp->maskVal; // Value to mask
     467    psImageMaskType maskVal = interp->maskVal; // Value to mask
    468468    bool wantVariance = variance && varianceValue; // Does the user want the variance value?
    469469    bool haveMask = mask && maskVal; // Does the user want the variance value?
     
    582582                  const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \
    583583                  const ps##TYPE *varianceData = &variance->data.TYPE[yPix][xMin]; \
    584                   const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \
     584                  const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \
    585585                  const psF32 *xKernelData = xKernel; \
    586586                  const psF32 *xKernel2Data = xKernel2; \
     
    642642              /* Dereferenced versions of inputs */ \
    643643              const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \
    644               const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \
     644              const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \
    645645              const psF32 *xKernelData = xKernel; \
    646646              const psF32 *xKernel2Data = xKernel2; \
     
    713713// Interpolation engine for (separable) interpolation kernels
    714714static psImageInterpolateStatus interpolateKernel(double *imageValue, double *varianceValue,
    715                                                   psMaskType *maskValue, float x, float y,
     715                                                  psImageMaskType *maskValue, float x, float y,
    716716                                                  const psImageInterpolation *interp)
    717717{
     
    722722    const psImage *mask = interp->mask; // Image mask
    723723    const psImage *variance = interp->variance; // Image variance
    724     psMaskType maskVal = interp->maskVal; // Value to mask
     724    psImageMaskType maskVal = interp->maskVal; // Value to mask
    725725    bool wantVariance = variance && varianceValue; // Does the user want the variance value?
    726726    bool haveMask = mask && maskVal; // Does the user want the variance value?
     
    790790                      float kernelValue = kernel[j][i]; /* Value of kernel */ \
    791791                      float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \
    792                       if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) { \
     792                      if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \
    793793                          sumBad += kernelValue2; \
    794794                      } else { \
     
    820820                  float kernelValue = kernel[j][i]; /* Value of kernel */ \
    821821                  float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \
    822                   if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) { \
     822                  if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \
    823823                      sumBad += kernelValue2; \
    824824                  } else { \
     
    866866
    867867
    868 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psMaskType *maskValue,
     868psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psImageMaskType *maskValue,
    869869                                            float x, float y, const psImageInterpolation *interp)
    870870{
     
    885885    if (maskValue && mask) {
    886886        PS_ASSERT_IMAGE_NON_NULL(mask, PS_INTERPOLATE_STATUS_ERROR);
    887         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, PS_INTERPOLATE_STATUS_ERROR);
     887        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, PS_INTERPOLATE_STATUS_ERROR);
    888888        psAssert(image->numCols == mask->numCols && image->numRows == mask->numRows, "Image and mask sizes");
    889889    }
  • trunk/psLib/src/imageops/psImageInterpolate.h

    r20327 r21183  
    77 * @author Paul Price, Institute for Astronomy
    88 *
    9  * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    10  * @date $Date: 2008-10-22 19:21:06 $
     9 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     10 * @date $Date: 2009-01-27 06:39:37 $
    1111 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1212 */
     
    5050    const psImage *variance;            ///< Variance image for interpolation
    5151    const psImage *mask;                ///< Mask image for interpolation
    52     psMaskType maskVal;                 ///< Value to mask
     52    psImageMaskType maskVal;            ///< Value to mask
    5353    double badImage;                    ///< Image value if x,y location is not good
    5454    double badVariance;                 ///< Variance value if x,y location is not good
    55     psMaskType badMask;                 ///< Mask value to give bad pixels
    56     psMaskType poorMask;                ///< Mask value to give poor pixels
     55    psImageMaskType badMask;            ///< Mask value to give bad pixels
     56    psImageMaskType poorMask;           ///< Mask value to give poor pixels
    5757    float poorFrac;                     ///< Fraction of flux in bad pixels before output is marked bad
    5858    bool shifting;                      ///< Shifting images? Don't interpolate if the shift is exact.
     
    6969    const psImage *variance,            // Variance image
    7070    const psImage *mask,                // Mask image
    71     psMaskType maskVal,                 // Value to mask
     71    psImageMaskType maskVal,                 // Value to mask
    7272    double badImage,                    // Value for image if bad
    7373    double badVariance,                 // Value for variance if bad
    74     psMaskType badMask,                 // Mask value for bad pixels
    75     psMaskType poorMask,                // Mask value for poor pixels
     74    psImageMaskType badMask,                 // Mask value for bad pixels
     75    psImageMaskType poorMask,                // Mask value for poor pixels
    7676    float poorFrac,                     // Fraction of flux for question
    7777    int numKernels                      // Number of interpolation kernels to pre-calculate
     
    8383    double *imageValue,                 ///< Return value for image
    8484    double *varianceValue,              ///< Return value for variance
    85     psMaskType *maskValue,              ///< Return value for mask
     85    psImageMaskType *maskValue,              ///< Return value for mask
    8686    float x, float y,                   ///< Location to which to interpolate
    8787    const psImageInterpolation *options ///< Options
  • trunk/psLib/src/imageops/psImageMap.c

    r21172 r21183  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2009-01-27 00:00:21 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:37 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    145145    }
    146146
    147     psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_MASK);
     147    psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_IMAGE_MASK);
    148148    psImage *xCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32);
    149149    psImage *yCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32);
     
    212212            // this will not in general be properly weighted...
    213213            if (psVectorStats (map->stats, fCell, dfCell, NULL, 0)) {
    214                 mask->data.U8[iy][ix] = 0;
     214                mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 0;
    215215                // XXX ensure only one option is selected, or save both position and width
    216216                map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options);
     
    224224                yCoord->data.F32[iy][ix] = psStatsGetValue (meanStat, meanStat->options);
    225225            } else {
    226                 mask->data.U8[iy][ix] = 1;
     226                mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 1;
    227227            }
    228228
     
    353353}
    354354
    355 psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, psMaskType maskValue, const psVector *x, const psVector *y)
     355psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, psVectorMaskType maskValue, const psVector *x, const psVector *y)
    356356{
    357357    PS_ASSERT_IMAGE_MAP_NON_NULL(map, NULL);
     
    365365
    366366    for (int i = 0; i < x->n; i++) {
    367       if (mask && (mask->data.U8[i] & maskValue)) {
     367      if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
    368368        result->data.F32[i] = 0.0;
    369369      } else { 
  • trunk/psLib/src/imageops/psImageMapFit.c

    r21172 r21183  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2009-01-27 00:00:21 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:37 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    4747
    4848// map defines the output image dimensions and scaling.
    49 bool psImageMapFit(psImageMap *map, const psVector *mask, psMaskType maskValue,
     49bool psImageMapFit(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    5050                   const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    5151{
     
    145145            for (int i = 0; i < x->n; i++) {
    146146
    147                 if (mask && (mask->data.U8[i] & maskValue)) continue;
     147                if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue;
    148148
    149149                // base coordinate offset for this point (x,y) relative to this map element (n,m)
     
    338338
    339339// measure residuals on each pass and clip outliers based on stats
    340 bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psMaskType maskValue,
     340bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,
    341341                       const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    342342{
     
    377377    psVector *mask = inMask;
    378378    if (!inMask) {
    379         mask = psVectorAlloc (x->n, PS_TYPE_U8);
     379        mask = psVectorAlloc (x->n, PS_TYPE_VECTOR_MASK);
    380380        psVectorInit (mask, 0);
    381381    }
     
    429429        for (psS32 i = 0; i < resid->n; i++) {
    430430            // XXX this prevents recovery of previously masked values
    431             if (mask->data.U8[i] & maskValue) {
     431            if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue) {
    432432                continue;
    433433            }
     
    435435            if ((resid->data.F32[i] - meanValue > maxClipValue) || (resid->data.F32[i] - meanValue < minClipValue)) {
    436436                psTrace("psLib.imageops", 6, "Masking element %d  : %f vs %f : resid is %f\n", i, f->data.F32[i], fit->data.F32[i], resid->data.F32[i]);
    437                 mask->data.U8[i] |= 0x01;
     437                mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
    438438                continue;
    439439            }
     
    455455
    456456// map defines the output image dimensions and scaling.
    457 bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psMaskType maskValue,
     457bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    458458                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    459459{
     
    490490        for (int i = 0; i < y->n; i++) {
    491491
    492             if (mask && (mask->data.U8[i] & maskValue)) continue;
     492            if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue;
    493493
    494494            float dy = psImageBinningGetRuffY (map->binning, y->data.F32[i]) - (m + 0.5);
     
    603603
    604604// map defines the output image dimensions and scaling.
    605 bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psMaskType maskValue,
     605bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    606606                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    607607{
     
    638638        for (int i = 0; i < x->n; i++) {
    639639
    640             if (mask && (mask->data.U8[i] & maskValue)) continue;
     640            if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue;
    641641
    642642            float dx = psImageBinningGetRuffX (map->binning, x->data.F32[i]) - (m + 0.5);
  • trunk/psLib/src/imageops/psImageMapFit.h

    r15841 r21183  
    1010bool psImageMapFit(psImageMap *map,
    1111                   const psVector *mask,
    12                    psMaskType maskValue,
     12                   psVectorMaskType maskValue, //
    1313                   const psVector *x,
    1414                   const psVector *y,
     
    2121                       psStats *stats,
    2222                       psVector *mask,  // WARNING: Mask is modified!
    23                        psMaskType maskValue,
     23                       psVectorMaskType maskValue,
    2424                       const psVector *x,
    2525                       const psVector *y,
     
    3030bool psImageMapFit1DinY(psImageMap *map,
    3131                        const psVector *mask,
    32                         psMaskType maskValue,
     32                        psVectorMaskType maskValue,
    3333                        const psVector *x,
    3434                        const psVector *y,
     
    3939bool psImageMapFit1DinX(psImageMap *map,
    4040                        const psVector *mask,
    41                         psMaskType maskValue,
     41                        psVectorMaskType maskValue,
    4242                        const psVector *x,
    4343                        const psVector *y,
  • trunk/psLib/src/imageops/psImageMaskOps.c

    r18494 r21183  
    88 *  @author David Robbins, MHPCC
    99 *
    10  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2008-07-12 21:08:33 $
     10 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2009-01-27 06:39:37 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3737                       psRegion region,
    3838                       const char *op,
    39                        psMaskType maskValue)
     39                       psImageMaskType maskValue)
    4040{
    4141    if (image == NULL) {
     
    5353          if ((i + image->col0) < region.x0) continue; \
    5454          if ((i + image->col0) > region.x1) continue; /* is this correct (not >= ?) */ \
    55           image->data.PS_TYPE_MASK_DATA[j][i] OP maskValue; \
     55          image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \
    5656        } \
    5757      }
     
    8484                       psRegion region,
    8585                       const char *op,
    86                        psMaskType maskValue)
     86                       psImageMaskType maskValue)
    8787{
    8888    if (image == NULL) {
     
    100100            (i + image->col0) < region.x0 || \
    101101            (i + image->col0) > region.x1 ) { \
    102           image->data.PS_TYPE_MASK_DATA[j][i] OP maskValue; \
     102          image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \
    103103        } } }
    104104
     
    131131                       double radius,
    132132                       const char *op,
    133                        psMaskType maskValue)
     133                       psImageMaskType maskValue)
    134134{
    135135    if (image == NULL) {
     
    150150            r2 = PS_SQR(dx) + PS_SQR(dy); \
    151151            if (r2 <= R2) { \
    152               image->data.PS_TYPE_MASK_DATA[iy][ix] OP maskValue; \
     152              image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \
    153153            } } }
    154154
     
    182182                       double radius,
    183183                       const char *op,
    184                        psMaskType maskValue)
     184                       psImageMaskType maskValue)
    185185{
    186186
     
    201201            r2 = PS_SQR(dx) + PS_SQR(dy); \
    202202            if (r2 > R2) { \
    203               image->data.PS_TYPE_MASK_DATA[iy][ix] OP maskValue; \
     203              image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \
    204204            } } }
    205205
     
    228228psImage *psImageGrowMask(psImage *out,
    229229                         const psImage *in,
    230                          psMaskType maskVal,
     230                         psImageMaskType maskVal,
    231231                         unsigned int growSize,
    232                          psMaskType growVal)
     232                         psImageMaskType growVal)
    233233{
    234234    if (in == NULL) {
     
    237237        return NULL;
    238238    }
    239     if (in->type.type != PS_TYPE_MASK) {
     239    if (in->type.type != PS_TYPE_IMAGE_MASK) {
    240240        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    241                 "Invalid input image.  Input image type must match psMaskType.\n");
     241                "Invalid input image.  Input image type must match psImageMaskType.\n");
    242242        return NULL;
    243243    }
     
    261261    for (k = 0; k < in->numRows; k++) {
    262262        for (l = 0; l < in->numCols; l++) {
    263             out->data.PS_TYPE_MASK_DATA[k][l] = in->data.PS_TYPE_MASK_DATA[k][l];
    264             changed->data.PS_TYPE_MASK_DATA[k][l] = 0;
     263            out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = in->data.PS_TYPE_IMAGE_MASK_DATA[k][l];
     264            changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 0;
    265265        }
    266266    }
     
    268268    for (int i = 0; i < in->numRows; i++) {
    269269        for (int j = 0; j < in->numCols; j++) {
    270             if ( (in->data.PS_TYPE_MASK_DATA[i][j] & maskVal) != 0 &&
    271                     changed->data.PS_TYPE_MASK_DATA[i][j] == 0) {
     270            if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) != 0 &&
     271                    changed->data.PS_TYPE_IMAGE_MASK_DATA[i][j] == 0) {
    272272                m = i - growSize;
    273273                if (m < 0) {
     
    281281                    for (l = n; l <= (j + growSize) && l < in->numCols; l++) {
    282282                        if (((k-i)*(k-i) + (l-j)*(l-j)) <= (growSize*growSize)) {
    283                             out->data.PS_TYPE_MASK_DATA[k][l] |= growVal;
    284                             if ( (in->data.PS_TYPE_MASK_DATA[i][j] & maskVal) == 0 ) {
    285                                 changed->data.PS_TYPE_MASK_DATA[k][l] = 1;
     283                            out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] |= growVal;
     284                            if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) == 0 ) {
     285                                changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 1;
    286286                            }
    287287                        }
  • trunk/psLib/src/imageops/psImageMaskOps.h

    r11248 r21183  
    66 * @author David Robbins, MHPCC
    77 *
    8  * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-01-23 22:47:23 $
     8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2009-01-27 06:39:37 $
    1010 *
    1111 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3232    psRegion region,                   ///< the specified region
    3333    const char *op,                    ///< the logical operation
    34     psMaskType maskValue               ///< the specified bits
     34    psImageMaskType maskValue           ///< the specified bits
    3535);
    3636
     
    4444    psRegion region,                   ///< the specified region
    4545    const char *op,                    ///< the logical operation
    46     psMaskType maskValue               ///< the specified bits
     46    psImageMaskType maskValue           ///< the specified bits
    4747);
    4848
     
    5858    double radius,                     ///< the radius of the specified circle
    5959    const char *op,                    ///< the logical operation
    60     psMaskType maskValue               ///< the specified bits
     60    psImageMaskType maskValue           ///< the specified bits
    6161);
    6262
     
    7272    double radius,                     ///< the radius of the specified circle
    7373    const char *op,                    ///< the logical operation
    74     psMaskType maskValue               ///< the specified bits
     74    psImageMaskType maskValue           ///< the specified bits
    7575);
    7676
     
    8989    psImage *out,                      ///< the image to set and return
    9090    const psImage *in,                 ///< the input to image
    91     psMaskType maskVal,                ///< the specified mask value
     91    psImageMaskType maskVal,            ///< the specified mask value
    9292    unsigned int growSize,             ///< the range of values from maskVal
    93     psMaskType growVal                 ///< the output value to set
     93    psImageMaskType growVal             ///< the output value to set
    9494);
    9595
  • trunk/psLib/src/imageops/psImagePixelExtract.c

    r20306 r21183  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2008-10-22 02:10:37 $
     10 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2009-01-27 06:39:37 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    206206                       const psImage* input,
    207207                       const psImage* mask,
    208                        psMaskType maskVal,
     208                       psImageMaskType maskVal,
    209209                       psRegion region,
    210210                       psImageCutDirection direction,
     
    357357            return NULL;
    358358        }
    359         if (mask->type.type != PS_TYPE_MASK) {
     359        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
    360360            char* typeStr;
    361361            PS_TYPE_NAME(typeStr,mask->type.type);
    362362            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    363363                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    364                     typeStr, PS_TYPE_MASK_NAME);
     364                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    365365            psFree(out);
    366366            return NULL;
     
    394394        psVector* imgVec = psVectorAlloc(numRows, type);
    395395        psVector* maskVec = NULL;
    396         psMaskType* maskData = NULL;
     396        psImageMaskType* maskData = NULL;
    397397        psPixelCoord* outPosition = NULL;
    398398
     
    416416
    417417        if (mask != NULL) {
    418             maskVec = psVectorAlloc(numRows, mask->type.type);
    419         }
    420         #define PSIMAGE_CUT_VERTICAL(TYPE) \
     418            maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK);
     419        }
     420
     421#define PSIMAGE_CUT_VERTICAL(TYPE) \
    421422    case PS_TYPE_##TYPE: { \
    422             psMaskType* maskVecData = NULL; \
    423             for (psS32 c=col0;c<col1;c++) { \
     423            psVectorMaskType* maskVecData = NULL; \
     424            for (psS32 c = col0; c < col1; c++) { \
    424425                ps##TYPE *imgData = input->data.TYPE[row0] + c; \
    425426                ps##TYPE *imgVecData = imgVec->data.TYPE; \
    426427                if (maskVec != NULL) { \
    427                     maskVecData = maskVec->data.U8; \
    428                     maskData = (psMaskType* )(mask->data.U8[row0]) + c; \
     428                    maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; \
     429                    maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[row0][c]; /* XXX double check this... */ \
     430                    /** old entry: maskData = (psMaskType* )(mask->data.PS_TYPE_IMAGE_MASK_DATA[row0]) + c; */ \
    429431                } \
    430                 for (psS32 r=row0;r<row1;r++) { \
    431                     *(imgVecData++) = *imgData; \
     432                for (psS32 r = row0; r < row1; r++) { \
     433                   *imgVecData = *imgData; \
     434                    imgVecData ++; \
    432435                    imgData += inCols; \
    433436                    if (maskVecData != NULL) { \
    434                         *(maskVecData++) = *maskData; \
     437                        *maskVecData = (*maskData & maskVal); \
     438                        maskVecData ++; \
    435439                        maskData += inCols; \
    436440                    } \
    437441                } \
    438                 psVectorStats(myStats,imgVec,NULL,maskVec,maskVal); \
     442                psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); \
    439443                *outData = psStatsGetValue(myStats, statistic); \
    440444                if (outPosition != NULL) { \
     
    471475        psFree(imgVec);
    472476        psFree(maskVec);
     477
    473478    } else if (direction == PS_CUT_Y_POS || direction == PS_CUT_Y_NEG) {
    474479        // Cut in Y direction
     480        // XXX use this if we drop the hackish stuff below: psVector* imgVec = psVectorAlloc(numCols, type);
    475481        psVector* imgVec = NULL;
    476482        psVector* maskVec = NULL;
     
    479485
    480486        // fill in psVector to fake out the statistics functions.
     487        // XXX EAM : this seems rather hackish: just use the needed psVectorAlloc (like above)?
    481488        imgVec = psAlloc(sizeof(psVector));
    482489        imgVec->type = input->type;
    483490        P_PSVECTOR_SET_NALLOC(imgVec,numCols);
    484         if (mask != NULL) {
    485             maskVec = psAlloc(sizeof(psVector));
    486             maskVec->type = mask->type;
    487             P_PSVECTOR_SET_NALLOC(maskVec,numCols);
    488         }
     491        imgVec->n = imgVec->nalloc;
     492
    489493        // recycle output to make a proper sized/type output structure
    490494        // n.b. type is double as that is the type given for all stats in
     
    492496        out = psVectorRecycle(out, numRows, PS_TYPE_F64);
    493497        out->n = numRows;
    494         imgVec->n = imgVec->nalloc;
    495         maskVec->n = maskVec->nalloc;
    496498        if (coords != NULL) {
    497499            coords = psPixelsRealloc(coords, numRows);
     
    507509        }
    508510
     511        if (mask != NULL) {
     512            maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK);
     513            // XXX the old code (below) faked out the mask vector
     514            // maskVec = psAlloc(sizeof(psVector));
     515            // maskVec->type = mask->type;
     516            // P_PSVECTOR_SET_NALLOC(maskVec,numCols);
     517            // maskVec->n = maskVec->nalloc;
     518        }
     519
    509520        for (psS32 r = row0; r < row1; r++) {
    510521            // point the vector struct to the
    511522            // data to calculate the stats
    512523            imgVec->data.U8 = (psPtr )(input->data.U8[r] + col0 * elementSize);
     524
     525            // set the vector mask pixels based on the image pixels
    513526            if (maskVec != NULL) {
    514                 maskVec->data.U8 = (psPtr )(mask->data.U8[r] + col0 * sizeof(psMaskType));
    515             }
    516             psVectorStats(myStats, imgVec, NULL, maskVec, maskVal);
     527                psVectorMaskType *maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA;
     528                psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[r][col0];
     529                for (psS32 c = col0; c < col1; c++) {
     530                    *maskVecData = (*maskData & maskVal);
     531                    maskVecData ++;
     532                    maskData ++;
     533                }
     534            }
     535
     536            psVectorStats(myStats, imgVec, NULL, maskVec, 0xff);
    517537            *outData = psStatsGetValue(myStats, statistic);
    518538            if (outPosition != NULL) {
     
    544564                     const psImage* input,
    545565                     const psImage* mask,
    546                      psMaskType maskVal,
     566                     psImageMaskType maskVal,
    547567                     psRegion region,
    548568                     unsigned int nSamples,
     
    651671            return NULL;
    652672        }
    653         if (mask->type.type != PS_TYPE_MASK) {
     673        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
    654674            char* typeStr;
    655675            PS_TYPE_NAME(typeStr,mask->type.type);
    656676            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    657677                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    658                     typeStr, PS_TYPE_MASK_NAME);
     678                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    659679            psFree(out);
    660680            return NULL;
     
    739759                           const psImage* input,
    740760                           const psImage* mask,
    741                            psMaskType maskVal,
     761                           psImageMaskType maskVal,
    742762                           float x,
    743763                           float y,
     
    765785            return NULL;
    766786        }
    767         if (mask->type.type != PS_TYPE_MASK) {
     787        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
    768788            char* typeStr;
    769789            PS_TYPE_NAME(typeStr,mask->type.type);
    770790            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    771791                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    772                     typeStr, PS_TYPE_MASK_NAME);
     792                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    773793            psFree(out);
    774794            return NULL;
     
    868888        if (mask != NULL) {
    869889            bufferMask[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]),
    870                                                  PS_TYPE_MASK);
     890                                                 PS_TYPE_VECTOR_MASK);
    871891        }
    872892    }
     
    877897    for (psS32 row=startRow; row <= endRow; row++) {
    878898        psF32* inRow = input->data.F32[row];
    879         psMaskType* maskRow = NULL;
     899        psImageMaskType* maskRow = NULL;
    880900        if (mask != NULL) {
    881             maskRow = mask->data.PS_TYPE_MASK_DATA[row];
     901            maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[row];
    882902        }
    883903        for (psS32 col=startCol; col <= endCol; col++) {
     
    899919
    900920                    if (maskRow != NULL) {
    901                         bufferMask[r]->data.PS_TYPE_MASK_DATA[n] = maskRow[col];
     921                        bufferMask[r]->data.PS_TYPE_VECTOR_MASK_DATA[n] = (maskRow[col] & maskVal);
    902922                        bufferMask[r]->n = n+1;
    903923                    }
     
    913933
    914934    for (psS32 r = 0; r < numOut; r++) {
    915         psVectorStats(myStats,buffer[r], NULL, bufferMask[r],maskVal);
     935        psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff);
    916936        outData[r] = psStatsGetValue(myStats, statistic);
    917937    }
  • trunk/psLib/src/imageops/psImagePixelExtract.h

    r11248 r21183  
    55 * @author Robert DeSonia, MHPCC
    66 *
    7  * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-01-23 22:47:23 $
     7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:37 $
    99 *
    1010 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    8484    const psImage* input,              ///< the input image in which to perform the slice
    8585    const psImage* mask,               ///< the mask for the input image.
    86     psMaskType maskVal,                ///< the mask value to apply to the mask
     86    psImageMaskType maskVal,            ///< the mask value to apply to the mask
    8787    psRegion region,                   ///< the slice region
    8888    psImageCutDirection direction,     ///< the slice dimension and direction
     
    112112    const psImage* input,              ///< the input image in which to perform the cut
    113113    const psImage* mask,               ///< the mask for the input image.
    114     psMaskType maskVal,                ///< the mask value to apply to the mask
     114    psImageMaskType maskVal,            ///< the mask value to apply to the mask
    115115    psRegion region,                   ///< the start and end points to cut along
    116116    unsigned int nSamples,             ///< the number of samples along the cut
     
    135135    const psImage* input,              ///< the input image in which to perform the cut
    136136    const psImage* mask,               ///< the mask for the input image.
    137     psMaskType maskVal,                ///< the mask value to apply to the mask
     137    psImageMaskType maskVal,            ///< the mask value to apply to the mask
    138138    float x,                           ///< the column of the center of the cut circle
    139139    float y,                           ///< the row of the center of the cut circle
  • trunk/psLib/src/imageops/psImagePixelInterpolate.c

    r15254 r21183  
    1111 *  @author Eugene Magnier, IfA
    1212 *
    13  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2007-10-09 19:25:44 $
     13 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2009-01-27 06:39:37 $
    1515 *
    1616 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    5454                    /* do not test self */ \
    5555                    if (!jx && !jy) { continue; } \
    56                     if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \
     56                    if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \
    5757                    nGood ++; \
    5858                } \
     
    6767// just the mask, the output image contains enum values which define the type of interpolation which
    6868// can be performed
    69 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal) {
     69psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal) {
    7070
    7171    psImage *result = psImageAlloc (mask->numCols, mask->numRows, PS_TYPE_S32);
     
    7979
    8080            // state of the good pixels (unmasked)
    81             if (!(mask->data.PS_TYPE_MASK_DATA[iy][ix] & maskVal)) {
     81            if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal)) {
    8282                // count good neighbor pixels (+ self)
    8383                int nGood = 0;
     
    9494                        if (jx + ix < 0) { continue; }
    9595                        if (jx + ix >= mask->numCols) { continue; }
    96                         if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
     96                        if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
    9797                        nGood ++;
    9898                        minX = PS_MIN (minX, jx);
     
    137137
    138138// interpolate the poor pixels using the available options
    139 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal) {
     139bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal) {
    140140
    141141    assert (image->numCols == state->numCols);
     
    185185                          if (!jx && !jy) { continue; }
    186186                          // skip masked pixels
    187                           if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
     187                          if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
    188188                          x->data.F32[n] = jx;
    189189                          y->data.F32[n] = jy;
     
    241241   
    242242// interpolate the good pixels to their true centers
    243 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psMaskType maskVal) {
     243bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal) {
    244244
    245245    assert (value->numCols == state->numCols);
     
    299299                          if (jx + ix >= value->numCols) { continue; }
    300300                          // skip masked pixels
    301                           if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
     301                          if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
    302302                          x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx];
    303303                          y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx];
     
    331331                          if (jx + ix >= value->numCols) { continue; }
    332332                          // skip masked pixels
    333                           if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
     333                          if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
    334334                          x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx];
    335335                          y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx];
     
    363363    for (int iy = 0; iy < value->numRows; iy++) {
    364364        for (int ix = 0; ix < value->numCols; ix++) {
    365           if (mask->data.PS_TYPE_MASK_DATA[iy][ix] & maskVal) { continue; }
     365          if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) { continue; }
    366366          value->data.F32[iy][ix] = output->data.F32[iy][ix];
    367367        }
  • trunk/psLib/src/imageops/psImagePixelInterpolate.h

    r14924 r21183  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-09-20 23:54:25 $
     9 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:37 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    3434} psImagePixelInterpolateType;
    3535
    36 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal);
    37 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal);
    38 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psMaskType maskVal);
     36psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal);
     37bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal);
     38bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal);
    3939
    4040/// @}
  • trunk/psLib/src/imageops/psImageStats.c

    r12431 r21183  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2007-03-14 00:39:50 $
     11 *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2009-01-27 06:39:37 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5353                      const psImage* in,
    5454                      const psImage* mask,
    55                       psMaskType maskVal)
     55                      psImageMaskType maskVal)
    5656{
    5757    psVector *junkData = NULL;
     
    6262    PS_ASSERT_IMAGE_NON_NULL(in, false)
    6363    if (mask != NULL) {
    64         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, false);
     64        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
    6565        PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false);
    6666    }
     67
     68    if (in->parent == NULL) {
     69        // stuff the image data into a psVector struct.
     70        // XXX this is a bit hackish: does it save much time? (avoids a Nx*Ny alloc)
     71        junkData = (psVector *) psAlloc(sizeof(psVector));
     72        junkData->type = in->type;
     73        P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols);
     74        junkData->n = junkData->nalloc;
     75        junkData->data.U8 = in->data.V[0];      // since psImage data is contiguous...
     76    } else {
     77        // image not necessarily contiguous
     78        int numRows = in->numRows;
     79        int numCols = in->numCols;
     80        int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
     81
     82        junkData = psVectorAlloc(numRows*numCols, in->type.type);
     83
     84        psU8* data = junkData->data.U8;
     85        for (int row = 0; row < numRows; row++) {
     86            memcpy(data, in->data.V[row], rowSize);
     87            data += rowSize;
     88        }
     89    }
     90
     91    if (mask != NULL) {
     92        // image not necessarily contiguous, generate a temp vector to hold the full image
     93        int numRows = mask->numRows;
     94        int numCols = mask->numCols;
     95
     96        junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK);
     97
     98        psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA;
     99        for (int row = 0, nVect = 0; row < numRows; row++) {
     100            for (int col = 0; col < numCols; col++, nVect++) {
     101                data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal);
     102            }
     103        }
     104    }
     105
     106    psVectorStats(stats, junkData, NULL, junkMask, 0xff);
     107
     108    psFree(junkMask);
     109    psFree(junkData);
     110    return true;
     111}
     112
     113/*****************************************************************************
     114NOTE: We assume that the psHistogram structure out has already been allocated
     115and initialized.
     116 *****************************************************************************/
     117bool psImageHistogram(psHistogram* out,
     118                              const psImage* in,
     119                              const psImage* mask,
     120                              psImageMaskType maskVal)
     121{
     122    PS_ASSERT_PTR_NON_NULL(out, false);
     123    PS_ASSERT_PTR_NON_NULL(in, false);
     124    if (mask != NULL) {
     125        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
     126        PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false);
     127    }
     128    psVector* junkData = NULL;
     129    psVector* junkMask = NULL;
    67130
    68131    if (in->parent == NULL) {
     
    89152
    90153    if (mask != NULL) {
    91         if (mask->parent == NULL) {
    92             // stuff the mask data into a psVector struct.
    93             junkMask = psAlloc(sizeof(psVector));
    94             junkMask->type = mask->type;
    95             P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols);
    96             junkMask->n = junkMask->nalloc;
    97             junkMask->data.U8 = mask->data.V[0];
    98         } else {
    99             // image not necessarily contiguous
    100             int numRows = mask->numRows;
    101             int numCols = mask->numCols;
    102             int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
    103 
    104             junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
    105 
    106             psU8* data = junkMask->data.U8;
    107             for (int row = 0; row < numRows; row++) {
    108                 memcpy(data, mask->data.V[row], rowSize);
    109                 data += rowSize;
    110             }
    111         }
    112     }
    113 
    114     psVectorStats(stats, junkData, NULL, junkMask, maskVal);
    115 
    116     psFree(junkMask);
    117     psFree(junkData);
    118     return true;
    119 }
    120 
    121 /*****************************************************************************
    122 NOTE: We assume that the psHistogram structure out has already been allocated
    123 and initialized.
    124  *****************************************************************************/
    125 bool psImageHistogram(psHistogram* out,
    126                               const psImage* in,
    127                               const psImage* mask,
    128                               psMaskType maskVal)
    129 {
    130     PS_ASSERT_PTR_NON_NULL(out, false);
    131     PS_ASSERT_PTR_NON_NULL(in, false);
    132     if (mask != NULL) {
    133         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, false);
    134         PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false);
    135     }
    136     psVector* junkData = NULL;
    137     psVector* junkMask = NULL;
    138 
    139     if (in->parent == NULL) {
    140         // stuff the image data into a psVector struct.
    141         junkData = (psVector *) psAlloc(sizeof(psVector));
    142         junkData->type = in->type;
    143         P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols);
    144         junkData->n = junkData->nalloc;
    145         junkData->data.U8 = in->data.V[0];      // since psImage data is contiguous...
    146     } else {
    147         // image not necessarily contiguous
    148         int numRows = in->numRows;
    149         int numCols = in->numCols;
    150         int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
    151 
    152         junkData = psVectorAlloc(numRows*numCols, in->type.type);
    153 
    154         psU8* data = junkData->data.U8;
    155         for (int row = 0; row < numRows; row++) {
    156             memcpy(data, in->data.V[row], rowSize);
    157             data += rowSize;
    158         }
    159     }
    160 
    161     if (mask != NULL) {
    162         if (mask->parent == NULL) {
    163             // stuff the mask data into a psVector struct.
    164             junkMask = psAlloc(sizeof(psVector));
    165             junkMask->type = mask->type;
    166             P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols);
    167             junkMask->n = junkMask->nalloc;
    168             junkMask->data.U8 = mask->data.V[0];
    169         } else {
    170             // image not necessarily contiguous
    171             int numRows = mask->numRows;
    172             int numCols = mask->numCols;
    173             int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
    174 
    175             junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
    176 
    177             psU8* data = junkMask->data.U8;
    178             for (int row = 0; row < numRows; row++) {
    179                 memcpy(data, mask->data.V[row], rowSize);
    180                 data += rowSize;
    181             }
    182         }
     154        // image not necessarily contiguous; vector & image mask types do not match
     155        int numRows = mask->numRows;
     156        int numCols = mask->numCols;
     157
     158        junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK);
     159
     160        psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA;
     161        for (int row = 0, nVect = 0; row < numRows; row++) {
     162            for (int col = 0; col < numCols; col++, nVect++) {
     163                data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal);
     164            }
     165        }
    183166    }
    184167
     
    472455long psImageCountPixelMask (psImage *mask,
    473456                            psRegion region,
    474                             psMaskType value)
     457                            psImageMaskType value)
    475458{
    476459    long Npixels = 0;
     
    479462    int x1 = 0;
    480463    int y1 = 0;
    481     psElemType type;
    482464
    483465    // this is not a valid error: a psRegion with ranges outside the valid pixels
     
    608590    y1 = row1;
    609591
    610     type = mask->type.type;
    611     if (type != PS_TYPE_MASK) {
    612         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    613                 "psImage type does not match the specified psMaskType!\n");
    614         return -1;
    615     }
    616 
     592# define PS_IMAGE_COUNT_PIXEL_MASK(NAME,TYPE) \
     593    case PS_TYPE_##NAME: \
     594        for (long j = y0; j < y1; j++) { \
     595            for (long i = x0; i < x1; i++) { \
     596                if (mask->data.TYPE[j][i] & value) { \
     597                    Npixels ++; \
     598                } \
     599            } \
     600        } \
     601        break;
     602
     603    psElemType type = mask->type.type;
    617604    switch (type) {
    618     case PS_TYPE_U8:
    619     case PS_TYPE_U16:
    620         for (long j = y0; j < y1; j++) {
    621             for (long i = x0; i < x1; i++) {
    622                 if (mask->data.PS_TYPE_MASK_DATA[j][i] & value) {
    623                     Npixels ++;
    624                 }
    625             }
    626         }
    627         break;
    628     case PS_TYPE_S8:
    629     case PS_TYPE_S16:
    630     case PS_TYPE_S32:
    631     case PS_TYPE_S64:
    632     case PS_TYPE_U32:
    633     case PS_TYPE_U64:
    634     case PS_TYPE_F32:
    635     case PS_TYPE_F64:
     605        PS_IMAGE_COUNT_PIXEL_MASK(U8, U8);
     606        PS_IMAGE_COUNT_PIXEL_MASK(U16,U16);
     607        PS_IMAGE_COUNT_PIXEL_MASK(U32,U32);
     608        PS_IMAGE_COUNT_PIXEL_MASK(U64,U64);
     609        PS_IMAGE_COUNT_PIXEL_MASK(S8, S8);
     610        PS_IMAGE_COUNT_PIXEL_MASK(S16,S16);
     611        PS_IMAGE_COUNT_PIXEL_MASK(S32,S32);
     612        PS_IMAGE_COUNT_PIXEL_MASK(S64,S64);
     613
    636614    default:
    637615        // XXX this should include the mask type (as a string)
    638616        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    639                 _("Input psImage mask type is not a supported mask datatype"));
     617                _("Input psImage is an unsupported datatype"));
    640618
    641619        return -1;
  • trunk/psLib/src/imageops/psImageStats.h

    r11759 r21183  
    99 * @author GLG, MHPCC
    1010 *
    11  * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    12  * @date $Date: 2007-02-13 03:01:23 $
     11 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     12 * @date $Date: 2009-01-27 06:39:37 $
    1313 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1414 */
     
    4242    const psImage* in,                 ///< image (or subimage) to calculate stats
    4343    const psImage* mask,               ///< mask data for image (NULL ok)
    44     psMaskType maskVal                 ///< mask value for mask
     44    psImageMaskType maskVal             ///< mask value for mask
    4545);
    4646
     
    5757    const psImage* in,                 ///< Image data to be histogramed.
    5858    const psImage* mask,               ///< mask data for image (NULL ok)
    59     psMaskType maskVal                 ///< mask Mask for mask
     59    psImageMaskType maskVal             ///< mask Mask for mask
    6060);
    6161
     
    9797    psImage *mask,                     ///< input image to count
    9898    psRegion region,                   ///< input region of image
    99     psMaskType value                   ///< the mask value to satisfy
     99    psImageMaskType value               ///< the mask value to satisfy
    100100);
    101101
Note: See TracChangeset for help on using the changeset viewer.