IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 5, 2007, 12:04:28 PM (19 years ago)
Author:
Paul Price
Message:

Even if no mask is supplied, a mask value may be desired (either good or bad --- no poor is possible).

File:
1 edited

Legend:

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

    r13483 r13651  
    77 *  @author Paul Price, IfA
    88 *
    9  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-05-23 02:55:01 $
     9 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-06-05 22:04:28 $
    1111 *
    1212 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    121121        }
    122122
    123         if (maskValue && options->mask) {
    124             *maskValue = options->mask->data.PS_TYPE_MASK_DATA[yInt][xInt];
     123        if (maskValue) {
     124            if (options->mask) {
     125                *maskValue = options->mask->data.PS_TYPE_MASK_DATA[yInt][xInt];
     126            } else {
     127                *maskValue = 0;
     128            }
    125129        }
    126130    }
     
    270274    const psImage *mask = options->mask; // Image mask
    271275    psImageInterpolateStatus status = PS_INTERPOLATE_STATUS_GOOD; // Status of interpolation
    272     if (maskValue && mask) {
     276    if (maskValue) {
    273277        *maskValue = 0;
    274         psMaskType maskVal = options->maskVal; // Mask value
    275         double badContrib = 0.0;        // Amount of kernel on bad pixels
    276         double totContrib = 0.0;        // Total amount of kernel
    277         bool badPix = false;            // Is there a bad pixel?
    278         for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) {
    279             for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) {
    280                 if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) {
    281                     badContrib += fabs(kernel[j][i]);
    282                     badPix = true;
     278        if (mask) {
     279            psMaskType maskVal = options->maskVal; // Mask value
     280            double badContrib = 0.0;        // Amount of kernel on bad pixels
     281            double totContrib = 0.0;        // Total amount of kernel
     282            bool badPix = false;            // Is there a bad pixel?
     283            for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) {
     284                for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) {
     285                    if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) {
     286                        badContrib += fabs(kernel[j][i]);
     287                        badPix = true;
     288                    }
     289                    *maskValue |= mask->data.PS_TYPE_MASK_DATA[yPix][xPix];
     290                    totContrib += fabs(kernel[j][i]);
    283291                }
    284                 *maskValue |= mask->data.PS_TYPE_MASK_DATA[yPix][xPix];
    285                 totContrib += fabs(kernel[j][i]);
    286292            }
    287         }
    288 
    289         if (badPix) {
    290             if (badContrib / totContrib >= options->poorFrac) {
    291                 *maskValue |= options->badMask;
    292                 status = PS_INTERPOLATE_STATUS_BAD;
    293             } else {
    294                 *maskValue |= options->poorMask;
    295             status = PS_INTERPOLATE_STATUS_POOR;
     293
     294            if (badPix) {
     295                if (badContrib / totContrib >= options->poorFrac) {
     296                    *maskValue |= options->badMask;
     297                    status = PS_INTERPOLATE_STATUS_BAD;
     298                } else {
     299                    *maskValue |= options->poorMask;
     300                    status = PS_INTERPOLATE_STATUS_POOR;
     301                }
    296302            }
    297303        }
     
    492498    const psImage *mask = options->mask; // Image mask
    493499    psImageInterpolateStatus status = PS_INTERPOLATE_STATUS_GOOD; // Status of interpolation
    494     if (maskValue && mask) {
    495         psMaskType maskVal = options->maskVal; // Mask value
    496         double badContrib = 0.0;        // Amount of kernel on bad pixels
    497         double totContrib = 0.0;        // Total amount of kernel
    498         bool badPix = false;            // Number of bad pixels
     500    if (maskValue) {
    499501        *maskValue = 0;
    500         for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) {
    501             // Interpolation in x
    502             double xBadContrib = 0.0;   // Amount of x kernel on bad pixels
    503             double xTotContrib = 0.0;   // Total amount of x kernel
    504             for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) {
    505                 if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) {
    506                     xBadContrib += fabs(xKernel[i]);
    507                     badPix = true;
     502        if (mask) {
     503            psMaskType maskVal = options->maskVal; // Mask value
     504            double badContrib = 0.0;        // Amount of kernel on bad pixels
     505            double totContrib = 0.0;        // Total amount of kernel
     506            bool badPix = false;            // Number of bad pixels
     507            for (int j = 0, yPix = yCentral - (yNum - 1) / 2; j < yNum; j++, yPix++) {
     508                // Interpolation in x
     509                double xBadContrib = 0.0;   // Amount of x kernel on bad pixels
     510                double xTotContrib = 0.0;   // Total amount of x kernel
     511                for (int i = 0, xPix = xCentral - (xNum - 1) / 2; i < xNum; i++, xPix++) {
     512                    if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) {
     513                        xBadContrib += fabs(xKernel[i]);
     514                        badPix = true;
     515                    }
     516                    *maskValue |= mask->data.PS_TYPE_MASK_DATA[yPix][xPix];
     517                    xTotContrib += fabs(xKernel[i]);
    508518                }
    509                 *maskValue |= mask->data.PS_TYPE_MASK_DATA[yPix][xPix];
    510                 xTotContrib += fabs(xKernel[i]);
     519                // Interpolating in y
     520                badContrib += fabs(yKernel[j]) * xBadContrib;
     521                totContrib += fabs(yKernel[j]) * xTotContrib;
    511522            }
    512             // Interpolating in y
    513             badContrib += fabs(yKernel[j]) * xBadContrib;
    514             totContrib += fabs(yKernel[j]) * xTotContrib;
    515         }
    516 
    517         if (badPix) {
    518             if (badContrib / totContrib >= options->poorFrac) {
    519                 *maskValue |= options->badMask;
    520                 status = PS_INTERPOLATE_STATUS_BAD;
    521             } else {
    522                 *maskValue |= options->poorMask;
    523                 status = PS_INTERPOLATE_STATUS_POOR;
     523
     524            if (badPix) {
     525                if (badContrib / totContrib >= options->poorFrac) {
     526                    *maskValue |= options->badMask;
     527                    status = PS_INTERPOLATE_STATUS_BAD;
     528                } else {
     529                    *maskValue |= options->poorMask;
     530                    status = PS_INTERPOLATE_STATUS_POOR;
     531                }
    524532            }
    525533        }
Note: See TracChangeset for help on using the changeset viewer.