IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23789


Ignore:
Timestamp:
Apr 9, 2009, 6:00:18 PM (17 years ago)
Author:
Paul Price
Message:

Adding first cut at function to write ds9 region file with stamp positions.

Location:
trunk/psModules/src/imcombine
Files:
2 edited

Legend:

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

    r23688 r23789  
    9595    if (x < footprint || x >= numCols - footprint || y < footprint || y >= numRows - footprint) {
    9696        clean = false;
     97        goto CHECK_STAMP_MASK_DONE;
     98
    9799    }
    98100
     
    116118    // Check the immediate pixel
    117119    if (clean && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & (maskVal | PM_SUBTRACTION_MASK_REJ))) {
     120        goto CHECK_STAMP_MASK_DONE;
    118121        clean = false;
    119122    }
    120123
     124    // Check the footprint
    121125    int xMin = PS_MAX(x - footprint, 0), xMax = PS_MIN(x + footprint, numCols - 1); // Bounds in x
    122126    int yMin = PS_MAX(y - footprint, 0), yMax = PS_MIN(y + footprint, numRows - 1); // Bounds in y
    123 
    124     // Check the footprint
    125127    if (clean) {
    126128        for (int j = yMin; j <= yMax; j++) {
     
    133135        }
    134136    }
    135 CHECK_STAMP_MASK_DONE:
    136 
     137
     138 CHECK_STAMP_MASK_DONE:
    137139    if (!clean) {
    138140        // Mask the footprint, so we don't select something near it again
     
    314316                for (int y = subRegion->y0; y <= subRegion->y1; y++) {
    315317                    for (int x = subRegion->x0; x <= subRegion->x1; x++) {
    316                         if (checkStampMask(x, y, subMask, mode, footprint) &&
    317                             image->data.F32[y][x] > fluxStamp) {
     318                        if (image->data.F32[y][x] > fluxStamp &&
     319                            checkStampMask(x, y, subMask, mode, footprint)) {
    318320                            fluxStamp = image->data.F32[y][x];
    319321                            xStamp = x;
     
    363365}
    364366
     367bool pmSubtractionStampsRegions(pmSubtractionStampList *stamps, const char *filename)
     368{
     369    PM_ASSERT_SUBTRACTION_STAMP_LIST_NON_NULL(stamps, false);
     370    PS_ASSERT_STRING_NON_EMPTY(filename, false);
     371
     372    FILE *outFile = fopen(filename, "w"); // File to write
     373    if (!outFile) {
     374        psError(PS_ERR_IO, false, "Unable to open %s for writing");
     375        return false;
     376    }
     377
     378    for (int i = 0; i < stamps->num; i++) {
     379        // Outline the stamp
     380        psRegion *region = stamps->regions->data[i]; // Region of interest
     381        fprintf(outFile, "image;box(%f,%f,%f,%f,0)\n",
     382                0.5 * (region->x0 + region->x1), 0.5 * (region->y0 + region->y1),
     383                region->x1 - region->x0, region->y1 - region->y0);
     384
     385        psVector *xList = stamps->x->data[i], *yList = stamps->y->data[i]; // Coordinate lists
     386
     387        for (int j = 0; j < xList->n; j++) {
     388            fprintf(outFile, "image;circle(%f,%f,%d)\n",
     389                    xList->data.F32[j], yList->data.F32[j], stamps->footprint);
     390        }
     391    }
     392
     393    fclose(outFile);
     394
     395    return true;
     396}
    365397
    366398pmSubtractionStampList *pmSubtractionStampsSet(const psVector *x, const psVector *y,
  • trunk/psModules/src/imcombine/pmSubtractionStamps.h

    r21363 r23789  
    124124    );
    125125
     126
     127/// Write a ds9 region file with stamp positions
     128///
     129/// Intended for debugging
     130bool pmSubtractionStampsRegions(pmSubtractionStampList *stamps, ///< Stamps
     131                                const char *filename ///< Filename to which to write regions
     132    );
     133
     134
    126135#endif
Note: See TracChangeset for help on using the changeset viewer.