IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 6, 2006, 5:26:22 PM (20 years ago)
Author:
Paul Price
Message:

Adding offsets for regions on the image (since readout->image is often a subimage).
No need to move to the extension when writing stats to FITS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmFringeStats.c

    r7828 r7836  
    33 *  @author Eugene Magnier, IfA
    44 *
    5  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-07-06 03:29:28 $
     5 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-07-07 03:26:22 $
    77 *
    88 *  Copyright 2004 IfA
     
    151151    psStats *medianSd = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); // Median and SD
    152152
    153     // Measure the sky over the image
     153    // Measure the sky in each smoothing box
    154154    psImage *sky = psImageAlloc(fringe->nX, fringe->nY, PS_TYPE_F32);
    155155    for (int i = 0; i < fringe->nY; i++) {
    156         int y0 = (float)i * (float)image->numRows / (float)fringe->nY;
    157         int y1 = (float)(i + 1) * (float)image->numRows / (float)fringe->nY;
     156        int y0 = image->row0 + (float)i * (float)image->numRows / (float)fringe->nY;
     157        int y1 = image->row0 + (float)(i + 1) * (float)image->numRows / (float)fringe->nY;
    158158        for (int j = 0; j < fringe->nX; j++) {
    159             int x0 = (float)j * (float)image->numCols / (float)fringe->nX;
    160             int x1 = (float)(j + 1) * (float)image->numCols / (float)fringe->nX;
     159            int x0 = image->col0 + (float)j * (float)image->numCols / (float)fringe->nX;
     160            int x1 = image->col0 + (float)(j + 1) * (float)image->numCols / (float)fringe->nX;
    161161            psRegion region = psRegionSet(x0, x1, y0, y1);
    162162            psImage *subImage = psImageSubset(image, region); // Subimage of the sky region
    163             psImage *subMask = psImageSubset(mask, region); // Subimage of the sky region
     163            psImage *subMask = NULL;
     164            if (mask) {
     165                subMask = psImageSubset(mask, region); // Subimage of the sky region
     166            }
    164167            psImageStats(median, subImage, subMask, maskVal);
    165168            sky->data.F32[i][j] = median->sampleMedian;
     
    168171
    169172    for (int i = 0; i < fringe->x->n; i++) {
    170         psRegion region = psRegionSet(xPt[i] - dX, xPt[i] + dX + 1, yPt[i] - dY, yPt[i] + dY + 1);
    171         region = psRegionForImage(image, region);
     173        psRegion region = psRegionSet(image->col0 + xPt[i] - dX,
     174                                      image->col0 + xPt[i] + dX + 1,
     175                                      image->row0 + yPt[i] - dY,
     176                                      image->row0 + yPt[i] + dY + 1);
    172177        psImage *subImage = psImageSubset(image, region);
    173         psImage *subMask = psImageSubset(mask, region);
     178        psImage *subMask = NULL;
     179        if (mask) {
     180            subMask = psImageSubset(mask, region);
     181        }
    174182        psImageStats(medianSd, subImage, subMask, maskVal);
    175183        psFree(subImage);
     
    220228    PS_ASSERT_VECTOR_SIZE(df, numRows, false);
    221229
    222     if (extname && strlen(extname) > 0) {
    223         if (!psFitsMoveExtName(fits, extname)) {
    224             psError(PS_ERR_IO, false, "Unable to move to extension %s\n", extname);
    225             return false;
    226         }
    227     } else if (!psFitsMoveExtNum(fits, 0, false)) {
    228         psError(PS_ERR_IO, false, "Unable to move to PHU\n");
    229         return false;
    230     }
    231 
    232230    // We need to write:
    233231    // Scalars: dX, dY, nX, nY
Note: See TracChangeset for help on using the changeset viewer.