IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20572


Ignore:
Timestamp:
Nov 6, 2008, 6:12:10 PM (18 years ago)
Author:
bills
Message:

fixed a couple of bugs in warped pixels computation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src/warpedpixels.c

    r20520 r20572  
    11#include "streaks.h"
    22#include "pmAstrometryWCS.h"
     3
     4// #define DEBUG_PRINT 1
    35
    46static void addTouchedPixels(streakFiles *sf, psString fileName);
     
    3133    }
    3234
    33     psFits *fits = psFitsOpen("warpedpixels.fits", "w");
    34     psFitsWriteImage(fits, NULL, sf->warpedPixels, 0, NULL);
    35     psFitsClose(fits);
    36 
    37     exit (0);
     35    bool writeTouchedPixels = false;
     36    if (writeTouchedPixels) {
     37        // write out the warped pixels
     38        psMetadata * header = psMetadataAlloc();
     39        pmAstromWriteWCS(header, sf->inAstrom->fpa, sf->chip, 0.001);
     40        psFits *fits = psFitsOpen("warpedpixels.fits", "w");
     41
     42        psFitsWriteImage(fits, header, sf->warpedPixels, 0, NULL);
     43        psFitsClose(fits);
     44    }
    3845}
    3946
     
    6269
    6370    /* now set up our wrapper to the chip astrometry to apply to the whole chip */
    64     sf->astrom = streakSetAstrometry(sf->astrom, sf->inAstrom->fpa, sf->chip, false, NULL,
     71    sf->astrom = streakSetAstrometry(sf->astrom, sf->stage, sf->inAstrom->fpa, sf->chip, false, NULL,
    6572        sf->warpedPixels->numCols, sf->warpedPixels->numRows);
    6673   
     
    108115        type = "2";
    109116    }
     117#ifdef DEBUG_PRINT
    110118    printf("\nSKYCELL %s Type: %s\n", fileName, type);
    111119    for (int i=0; i<4; i++) {
    112120        printf("%f %f\n", pt[i].x, pt[i].y);
    113121    }
    114 
     122#endif
    115123    // Now set the touched pixels
    116124    int ymin = fmax(0, pt[1].y);
    117125    int ymax = fmin(pt[3].y, sf->warpedPixels->numRows);
     126#ifdef DEBUG_PRINT
    118127    printf("\nymin: %d ymax: %d\n", ymin, ymax);
     128#endif
    119129    for (int y = ymin ; y < ymax; y++) {
    120130        int xleft  = xLeft(pt, y);
     
    125135        }
    126136        if (xleft > sf->warpedPixels->numCols) {
    127             xleft = sf->warpedPixels->numCols - 1;
     137            continue;
    128138        }
    129139        if (xright < 0) {
    130             xright = 0;
     140            continue;
    131141        }
    132142        if (xright >= sf->warpedPixels->numCols) {
    133143            xright = sf->warpedPixels->numCols - 1;
    134144        }
     145#ifdef DEBUG_PRINT
    135146        printf("  y: %d xleft: %d xright: %d\n", y, xleft, xright);
    136 
    137         psU8 *scanline = sf->warpedPixels->data.U8[y];
    138 
    139         for (int x = xleft ; x <= xright; x++) {
    140             scanline[x] = 1;
     147#endif
     148
     149        psU8 *rowPixels = sf->warpedPixels->data.U8[y];
     150
     151        int n = xright - xleft + 1;
     152        if (n > 0) {
     153            memset(&rowPixels[xleft], 255, n);
    141154        }
    142155    }
Note: See TracChangeset for help on using the changeset viewer.