IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 18, 2009, 3:51:38 PM (17 years ago)
Author:
eugene
Message:

generate images of consistent size with selected star always at center

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/eam_branch_20090312/psastro/src/psastroExtractAnalysis.c

    r23335 r23407  
    1313# include "psastroInternal.h"
    1414
    15 # define ESCAPE { \
    16   psError(PS_ERR_UNKNOWN, false, "I/O failure in psastroMaskUpdate"); \
    17   psFree (view); \
    18   return false; \
    19 }
     15# define ESCAPE {                                                       \
     16        psError(PS_ERR_UNKNOWN, false, "I/O failure in psastroMaskUpdate"); \
     17        psFree (view);                                                  \
     18        return false;                                                   \
     19    }
    2020
    2121# define TEST_OUTPUT 1
     
    106106    char *filename = psMetadataLookupStr (&status, config->arguments, "OUTPUT");
    107107    if (!filename) {
    108       psLogMsg ("psastro", PS_LOG_INFO, "output filename not supplieda");
    109       return false;
     108        psLogMsg ("psastro", PS_LOG_INFO, "output filename not supplieda");
     109        return false;
    110110    }
    111111    psFits *outStars = psFitsOpen (filename, "w");
    112112    if (!outStars) {
    113       psError(PS_ERR_IO, false, "error opening file %s\n", filename);
    114       return false;
     113        psError(PS_ERR_IO, false, "error opening file %s\n", filename);
     114        return false;
    115115    }
    116116
     
    131131        FILE *f = NULL;
    132132        if (TEST_OUTPUT) {
    133           char *filename = NULL;
    134           char *chipname = psMetadataLookupStr (&status, chip->concepts, "CHIP.NAME");
    135           psStringAppend (&filename, "bright.%s.dat", chipname);
    136           f = fopen (filename, "w");
    137           if (!f) {
    138             psWarning ("cannot create test output file %s\n", filename);
    139             continue;
    140           }
    141           psFree (filename);
     133            char *filename = NULL;
     134            char *chipname = psMetadataLookupStr (&status, chip->concepts, "CHIP.NAME");
     135            psStringAppend (&filename, "bright.%s.dat", chipname);
     136            f = fopen (filename, "w");
     137            if (!f) {
     138                psWarning ("cannot create test output file %s\n", filename);
     139                continue;
     140            }
     141            psFree (filename);
    142142        }
    143143
     
    160160
    161161                    if (TEST_OUTPUT) {
    162                       fprintf (f, "stars %f %f  %f %f   %f\n", ref->chip->x, ref->chip->y, ref->FP->x, ref->FP->y, ref->Mag);
     162                        fprintf (f, "stars %f %f  %f %f   %f\n", ref->chip->x, ref->chip->y, ref->FP->x, ref->FP->y, ref->Mag);
    163163                    }
    164164
     
    190190psImage *psastroExtractStar (psImage *input, float x, float y, float dX, float dY) {
    191191
    192   // skip if no pixels are on the image
    193   // skip if center is not on the image
    194   // if bounds fall off image, paste into a full-size image.
    195 
    196   if (x < 0) return NULL;
    197   if (y < 0) return NULL;
    198   if (x >= input->numCols) return NULL;
    199   if (y >= input->numRows) return NULL;
    200 
    201   psRegion fullRegion = psRegionSet (x - dX, x + dX, y - dY, y + dY);
    202   psRegion realRegion = psRegionForImage (input, fullRegion);
    203   psImage *subset = psImageSubset (input, realRegion);
    204 
    205   // if ((subset->numCols < dX) || (subset->numRows < dY)) {
    206   //   psImage *fullsize = psImageAlloc (dX, dY, PS_TYPE_F32);
    207   //   // fill in the fullsize image with the values from the subset
    208   //   // I must already have done this elsewhere...
    209   // }
    210   return subset;
     192    // skip if no pixels are on the image
     193    // skip if center is not on the image
     194    // if bounds fall off image, paste into a full-size image.
     195
     196    if (x < 0) return NULL;
     197    if (y < 0) return NULL;
     198    if (x >= input->numCols) return NULL;
     199    if (y >= input->numRows) return NULL;
     200
     201    int xo = x; // index of center pixel (eg, 6.00 to 6.99 -> 6)
     202    int yo = y;
     203
     204    // build an output image of size 2dX + 1, 2dY + 1
     205    // psRegion fullRegion = psRegionSet (xo - dX, x + dX + 1, y - dY, y + dY + 1);
     206    // psRegion realRegion = psRegionForImage (input, fullRegion);
     207    // psImage *subset = psImageSubset (input, realRegion);
     208
     209    psImage *subset = psImageAlloc (2*dX+1, 2*dY+1, PS_TYPE_F32);
     210    psImageInit (subset, 0.0);
     211
     212    // fill in the subset image with the values from the subset
     213    // I must already have done this elsewhere...
     214
     215    for (int iy = yo - dY; iy < yo + dY + 1; iy++) {
     216        for (int ix = xo - dX; ix < xo + dX + 1; ix++) {
     217
     218            if (ix < input->col0) continue;
     219            if (iy < input->row0) continue;
     220            if (ix >= input->numCols) continue;
     221            if (iy >= input->numRows) continue;
     222       
     223            int jx = ix + dX - xo; // runs from 0 to 2dX
     224            int jy = iy + dY - yo;
     225            subset->data.F32[jy][jx] = input->data.F32[iy][ix];
     226        }
     227    }
     228    return subset;
    211229}
Note: See TracChangeset for help on using the changeset viewer.