IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 10, 2007, 1:54:26 PM (19 years ago)
Author:
Paul Price
Message:

Adding additional convolution kernels: SPAM (binned pixels around a central single-pixel core) and FRIES (binning changes as a (Fibonacci-like) function of radius).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtractionStamps.c

    r13735 r14106  
    66#include <pslib.h>
    77
    8 #include "pmSubtraction.h"
    98#include "pmSubtractionStamps.h"
    109
     
    4039}
    4140
    42 psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *subMask,
    43                                  float threshold, float spacing)
     41
     42psArray *pmSubtractionFindStamps(psArray *stamps, const psImage *image, const psImage *mask,
     43                                 psMaskType maskVal, psMaskType used, float threshold,
     44                                 float spacing, int border)
    4445{
    4546    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    4647    PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL);
    47     if (subMask) {
    48         PS_ASSERT_IMAGE_NON_NULL(subMask, NULL);
    49         PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL);
    50         PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, NULL);
     48    if (mask) {
     49        PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
     50        PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL);
     51        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     52    }
     53    if (used == 0) {
     54        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "The mask value for used stamps cannot be zero.");
     55        return NULL;
    5156    }
    5257    PS_ASSERT_FLOAT_LARGER_THAN(spacing, 0.0, NULL);
     58    PS_ASSERT_INT_NONNEGATIVE(border, NULL);
     59    PS_ASSERT_INT_LARGER_THAN(image->numCols, 2 * border, NULL);
     60    PS_ASSERT_INT_LARGER_THAN(image->numRows, 2 * border, NULL);
    5361
    54     // Size of image
    55     int numRows = image->numRows;
    56     int numCols = image->numCols;
    57 
    58     // Number of stamps
    59     int xNumStamps = numCols / spacing + 1;
    60     int yNumStamps = numRows / spacing + 1;
     62    maskVal |= used;                    // Make sure we don't get stamps we've already used
     63    int xNumStamps = (image->numCols - 2 * border) / spacing + 1; // Number of stamps in x
     64    int yNumStamps = (image->numRows - 2 * border) / spacing + 1; // Number of stamps in y
    6165
    6266    if (stamps) {
     
    7478        }
    7579    }
     80    // Footprint of image
     81    int numRows = image->numRows;
     82    int numCols = image->numCols;
    7683
    7784    for (int j = 0, index = 0; j < yNumStamps; j++) {
     
    8996
    9097                // Bounds of region to search for stamp
    91                 int yMin = j * numRows / (yNumStamps + 1);
    92                 int yMax = (j + 1) * numRows / (yNumStamps + 1) - 1;
    93                 int xMin = i * numCols / (xNumStamps + 1);
    94                 int xMax = (i + 1) * numCols / (xNumStamps + 1) - 1;
    95                 assert(yMax < image->numRows && xMax < image->numCols &&
    96                        yMin >= 0 && xMin >= 0);
     98                int yMin = border + j * (numRows - border) / (yNumStamps + 1);
     99                int yMax = border + (j + 1) * (numRows - border) / (yNumStamps + 1) - 1;
     100                int xMin = border + i * (numCols - border) / (xNumStamps + 1);
     101                int xMax = border + (i + 1) * (numCols - border) / (xNumStamps + 1) - 1;
     102                assert(yMax < image->numRows - border && xMax < image->numCols - border &&
     103                       yMin >= border && xMin >= border);
    97104
    98105                for (int y = yMin; y <= yMax ; y++) {
    99106                    for (int x = xMin; x <= xMax ; x++) {
    100                         if ((!subMask || !(subMask->data.PS_TYPE_MASK_DATA[y][x] &
    101                                            (PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_FOOTPRINT |
    102                                             PM_SUBTRACTION_MASK_REJ))) &&
    103                             image->data.F32[y][x] > fluxBest) {
    104                             fluxBest = image->data.F32[y][x];
    105                             xBest = x;
    106                             yBest = y;
     107                        if (image->data.F32[y][x] > fluxBest) {
     108                            bool ok = true;
     109                            if (mask) {
     110                                // Check kernel footprint for bad pixels
     111                                if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     112                                    ok = false;
     113                                } else {
     114                                    for (int v = -border; v <= border && ok; v++) {
     115                                        for (int u = -border; u <= border && ok; u++) {
     116                                            if (mask->data.PS_TYPE_MASK_DATA[y + v][x + u] & maskVal) {
     117                                                ok = false;
     118#if 0
     119                                                // Mark it so we don't have to look so hard next time
     120                                                mask->data.PS_TYPE_MASK_DATA[y][x] |= maskVal;
     121#endif
     122                                            }
     123                                        }
     124                                    }
     125                                }
     126                            }
     127
     128                            if (ok) {
     129                                fluxBest = image->data.F32[y][x];
     130                                xBest = x;
     131                                yBest = y;
     132                            }
    107133                        }
    108134                    }
Note: See TracChangeset for help on using the changeset viewer.