IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14723


Ignore:
Timestamp:
Sep 1, 2007, 4:03:58 PM (19 years ago)
Author:
magnier
Message:

updates to the image map tools

Location:
branches/eam_branch_20070830/psLib/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20070830/psLib/src/imageops/psImageMap.c

    r14721 r14723  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-09-01 00:41:01 $
     9 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-09-02 02:03:58 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    2222#include "psAssert.h"
    2323#include "psRegion.h"
     24#include "psVector.h"
    2425#include "psImage.h"
     26#include "psStats.h"
    2527#include "psImageBinning.h"
    2628#include "psImageMap.h"
     29#include "psImagePixelInterpolate.h"
    2730
    2831static void psImageMapFree(psImageMap *map) {
     
    5760
    5861// generate a psImageMap (or NULL) with the given number of superpixels in X and Y
    59 psImageMap *psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac) {
    60 
    61     int nBad;
    62     int nPoor;
     62bool psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac) {
    6363
    6464    psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_MASK);
     
    8484    }
    8585
    86     for (int iy = 0; iy < map->map->numRows; iy++) {
    87         for (int ix = 0; ix < map->map->numCols; ix++) {
     86    int Nx = map->map->numCols;
     87    int Ny = map->map->numRows;
     88    for (int iy = 0; iy < Ny; iy++) {
     89        for (int ix = 0; ix < Nx; ix++) {
    8890   
    8991            // select the vector
    9092            psVector *vector = vectors->data[ix + iy*Nx];
    91            
     93
     94            // reset the stats to avoid contamination from the previous loop
     95            psStatsInit (map->stats);
     96
    9297            // get the value
    93             if (psVectorStats (stats, vector, NULL, NULL, 0)) {
     98            if (psVectorStats (map->stats, vector, NULL, NULL, 0)) {
    9499                mask->data.U8[iy][ix] = 0;
    95                 map->map->data.F32[iy][ix] = stats->robustMedian; // XXX select correct stats
     100                // XXX ensure only one option is selected, or save both position and width
     101                map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options);
    96102            } else {
    97103                mask->data.U8[iy][ix] = 1;
     
    102108    psImage *state = psImagePixelInterpolateState (&map->nBad, &map->nPoor, mask, 0xff);
    103109    map->nGood = mask->numCols * mask->numRows - map->nBad - map->nPoor;
    104     if (nBad > badFrac * mask->numCols * mask->numRows) {
    105         return false:
     110    if (map->nBad > badFrac * mask->numCols * mask->numRows) {
     111        return false;
    106112    }
    107113
  • branches/eam_branch_20070830/psLib/src/imageops/psImageMap.h

    r14721 r14723  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-09-01 00:41:01 $
     9 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-09-02 02:03:58 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    2727    psImage *map;
    2828    psImage *field;
    29     psImageMap *binning;
     29    psImageBinning *binning;
    3030    int nBad;
    3131    int nPoor;
     
    3636
    3737// generate a psImageMap (or NULL) with the given number of superpixels in X and Y
    38 psImageMap *psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac);
     38bool psImageMapGenerate (psImageMap *map, psVector *x, psVector *y, psVector *f, float badFrac);
    3939
    4040/// @}
  • branches/eam_branch_20070830/psLib/src/imageops/psImagePixelInterpolate.c

    r14721 r14723  
    1111 *  @author Eugene Magnier, IfA
    1212 *
    13  *  @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2007-09-01 00:41:01 $
     13 *  @version $Revision: 1.1.2.2 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2007-09-02 02:03:58 $
    1515 *
    1616 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    3232#include "psAssert.h"
    3333#include "psString.h"
     34#include "psPolynomial.h"
     35#include "psPolynomialUtils.h"
    3436#include "psImage.h"
    3537#include "psImageInterpolate.h"
     38#include "psImagePixelInterpolate.h"
    3639
    3740# define PS_IMAGE_ITER_STATE(XS,XE,YS,YE,N_MIN,TYPE) \
    3841            nGood = 0; \
    39             for (jy = YS; jy <= YE; jy++) { \
    40                 // stick to pixels in image grid \
     42            for (int jy = YS; jy <= YE; jy++) { \
     43                /* stick to pixels in image grid */ \
    4144                if (jy + iy < 0) { continue; } \
    4245                if (jy + iy >= mask->numRows) { continue; } \
    43                 for (jx = XS; jx <= XE; jx++) { \
    44                     // stick to pixels in image grid \
     46                for (int jx = XS; jx <= XE; jx++) { \
     47                    /* stick to pixels in image grid */ \
    4548                    if (jx + ix < 0) { continue; } \
    4649                    if (jx + ix >= mask->numCols) { continue; } \
    47                     // do not test self \
     50                    /* do not test self */ \
    4851                    if (!jx && jy) { continue; } \
    4952                    if (mask->data.PS_TYPE_MASK_DATA[iy][ix] & maskVal) { continue; } \
     
    6669    psImageInit (result, 0);
    6770   
    68     int nPoor = 0;
    69     int nBad = 0;
     71    *nPoor = 0;
     72    *nBad = 0;
    7073
    7174    for (int iy = 0; iy < mask->numRows; iy++) {
     
    103106              case PS_IMAGE_INTERPOLATE_GOOD:
    104107                // skip the good pixels
    105                 continue;
     108                break;
    106109
    107110              case PS_IMAGE_INTERPOLATE_BAD:
    108111                // skip the bad pixels
    109                 continue;
     112                break;
    110113
    111               case PS_IMAGE_INTERPOLATE_CENTER:
    112                 // fit a quadratic to the valid neighbor pixels
    113                 // apply the quadratic to get the poor pixel value
    114                 psPolynomial2D *poly = psImageBicubeFit (image, mask, maskVal, ix, iy);
    115                 image->data.F32[iy][ix] = poly->coeff[0][0];
    116                 continue;
     114              case PS_IMAGE_INTERPOLATE_CENTER: {
     115                  // fit a quadratic to the valid neighbor pixels
     116                  // apply the quadratic to get the poor pixel value
     117                  psPolynomial2D *poly = psImageBicubeFit (image, mask, maskVal, ix, iy);
     118                  image->data.F32[iy][ix] = poly->coeff[0][0];
     119                  break; }
    117120
    118               case PS_IMAGE_INTERPOLATE_LL:
    119                 // fit a plane to the valid neighbor pixels
    120                 // apply the plane to get the poor pixel value
    121                 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 1);
    122                 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0] + poly->coeff[0][1];
    123                 continue;
    124               case PS_IMAGE_INTERPOLATE_LR:
    125                 // fit a plane to the valid neighbor pixels
    126                 // apply the plane to get the poor pixel value
    127                 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 1);
    128                 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[0][1];
    129                 continue;
    130               case PS_IMAGE_INTERPOLATE_UL:
    131                 // fit a plane to the valid neighbor pixels
    132                 // apply the plane to get the poor pixel value
    133                 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 0);
    134                 image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0];
    135                 continue;
    136               case PS_IMAGE_INTERPOLATE_UR:
    137                 // fit a plane to the valid neighbor pixels
    138                 // apply the plane to get the poor pixel value
    139                 psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 0);
    140                 image->data.F32[iy][ix] = poly->coeff[0][0];
    141                 continue;
     121              case PS_IMAGE_INTERPOLATE_LL: {
     122                  // fit a plane to the valid neighbor pixels
     123                  // apply the plane to get the poor pixel value
     124                  psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 1);
     125                  image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0] + poly->coeff[0][1];
     126                  break; }
     127
     128              case PS_IMAGE_INTERPOLATE_LR: {
     129                  // fit a plane to the valid neighbor pixels
     130                  // apply the plane to get the poor pixel value
     131                  psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 1);
     132                  image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[0][1];
     133                  break; }
     134
     135              case PS_IMAGE_INTERPOLATE_UL: {
     136                  // fit a plane to the valid neighbor pixels
     137                  // apply the plane to get the poor pixel value
     138                  psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 1, iy - 0);
     139                  image->data.F32[iy][ix] = poly->coeff[0][0] + poly->coeff[1][0];
     140                  break; }
     141
     142              case PS_IMAGE_INTERPOLATE_UR: {
     143                  // fit a plane to the valid neighbor pixels
     144                  // apply the plane to get the poor pixel value
     145                  psPolynomial2D *poly = psImageBilinearFit (image, mask, maskVal, ix - 0, iy - 0);
     146                  image->data.F32[iy][ix] = poly->coeff[0][0];
     147                  break; }
     148
     149              default:
     150                psAbort("impossible case in __func__");
    142151            }
    143152        }           
    144153    }
    145     return result;
     154    return true;
    146155}
    147156
     157   
  • branches/eam_branch_20070830/psLib/src/math/psStats.c

    r14440 r14723  
    1313 * use ->min and ->max (PS_STAT_USE_RANGE)
    1414 *
    15  *  @version $Revision: 1.215 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2007-08-08 21:31:42 $
     15 *  @version $Revision: 1.215.2.1 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2007-09-02 02:03:58 $
    1717 *
    1818 *  Copyright 2006 IfA, University of Hawaii
     
    17481748    psStats *stats = p_psAlloc(file, lineno, func, sizeof(psStats));
    17491749    psMemSetDeallocator(stats, (psFreeFunc)statsFree);
     1750
     1751    // set initial, default values
     1752    psStatsInit (stats);
     1753
     1754    // these values are can be set as desired by the user.  they are not affected by
     1755    // psStatsInit
     1756    stats->clipSigma = 3.0;
     1757    stats->clipIter = 3;
     1758    stats->nSubsample = 100000;
     1759    stats->options = options;
     1760
     1761    psTrace(TRACE, 3, "---- %s() end  ----\n", __func__);
     1762    return stats;
     1763}
     1764
     1765// reset the values which are output, and which may be used from one psStats stage to the next
     1766void psStatsInit(psStats *stats)
     1767{
    17501768    stats->sampleMean = NAN;
    17511769    stats->sampleMedian = NAN;
     
    17661784    stats->clippedStdev = NAN;
    17671785    stats->clippedNvalues = -1;     // XXX: This is never used
    1768     stats->clipSigma = 3.0;
    1769     stats->clipIter = 3;
    17701786    stats->min = NAN;
    17711787    stats->max = NAN;
    17721788    stats->binsize = NAN;
    1773     stats->nSubsample = 100000;
    1774     stats->options = options;
    1775 
    1776     psTrace(TRACE, 3, "---- %s() end  ----\n", __func__);
    1777     return stats;
     1789    return;
    17781790}
    17791791
  • branches/eam_branch_20070830/psLib/src/math/psStats.h

    r14452 r14723  
    88 * @author GLG, MHPCC
    99 *
    10  * @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
    11  * @date $Date: 2007-08-09 01:40:07 $
     10 * @version $Revision: 1.62.2.1 $ $Name: not supported by cvs2svn $
     11 * @date $Date: 2007-09-02 02:03:58 $
    1212 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1313 */
     
    131131);
    132132
     133// reset the values which are output, and which may be used from one psStats stage to the next
     134void psStatsInit(psStats *stats);
     135
    133136// Get the statistics option from a string
    134137psStatsOptions psStatsOptionFromString(const char *string);
Note: See TracChangeset for help on using the changeset viewer.